- [Show page]
- [Old revisions]
- [[unknown link type]]
- []
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
python:django [2014/10/23 12:26] vondra |
python:django [2015/01/28 13:12] vondra [Database settings] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====Installation==== | ||
as root: | as root: | ||
<code> | <code> | ||
Line 12: | Line 13: | ||
$ source bin/activate | $ source bin/activate | ||
(projectname):$ pip freeze | (projectname):$ pip freeze | ||
- | (projectname):$ pip install django==1.6.1 | + | (projectname):$ pip install django==1.6.7 |
+ | (projectname):$ pip install south django-registration stripe | ||
(projectname):$ django-admin.py startproject djlogin | (projectname):$ django-admin.py startproject djlogin | ||
</code> | </code> | ||
Line 18: | Line 20: | ||
Just a bunch of code i will probably **not** remeber | Just a bunch of code i will probably **not** remeber | ||
<code bash> | <code bash> | ||
- | python manage.py runserver | + | python manage.py startapp myapp |
- | pip install south django-registration stripe | + | |
python manage.py syncdb | python manage.py syncdb | ||
- | python manage.py startapp users | + | python manage.py runserver |
</code> | </code> | ||
+ | First command creates app myapp, second creates tables in database according to models.py, and the third one starts the server at port 8000. | ||
+ | |||
+ | In case you want to access the server from outside: | ||
+ | <code> | ||
+ | python manage.py runserver 0.0.0.0:8000 | ||
+ | </code> | ||
+ | |||
+ | Best editor for django/python development | ||
+ | * http://komodoide.com/download/edit-linux64/ | ||
====South==== | ====South==== | ||
Line 29: | Line 39: | ||
To start using south... | To start using south... | ||
- | - Make sure your django tables match your current database tables exactly - if you planned to add or remove columns, comment those out. | + | Make sure your django tables match your current database tables exactly - if you planned to add or remove columns, comment those out and run: |
- | - Run python manage.py schemamigration myapp --initial | + | <code> |
- | - Run python manage.py migrate myapp --fake | + | ./manage.py schemamigration myapp --initial name_of_migration |
- | - Make changes to your django model | + | ./manage.py migrate myapp --fake |
- | - Run python manage.py schemamigration myapp --auto | + | </code> |
- | - Run python manage.py migrate myapp | + | Make changes to your django model and then run: |
+ | <code> | ||
+ | ./manage.py schemamigration myapp --auto | ||
+ | ./manage.py migrate myapp | ||
+ | </code> | ||
+ | ====Vim python autocomplete==== | ||
+ | * https://github.com/davidhalter/jedi-vim | ||
+ | * in debian following packages needed to be installed: vim-athena vim-nox | ||
+ | * also pathogen addon has to be installed: https://github.com/tpope/vim-pathogen | ||
- | Best editor for django/python development | + | ====Python source code encodings==== |
- | * http://komodoide.com/download/edit-linux64/ | + | If UTF-8 source file encoding is needed ... |
+ | <code> | ||
+ | # -*- coding: UTF-8 -*- | ||
+ | </code> | ||
+ | ...put this on the beginning of the source file. | ||
- | ====Vim python autocomplete==== | + | |
+ | ====Database settings==== | ||
+ | MyISAM storage: | ||
+ | <code> | ||
+ | mysql>>> ALTER TABLE search_ftext ENGINE = MyISAM; | ||
+ | </code> | ||
+ | |||
+ | Create fulltext index | ||
+ | |||
+ | <code> | ||
+ | mysql>>> ALTER TABLE search_ftext ADD FULLTEXT (text); | ||
+ | </code> | ||
+ | |||
+ | if Django keeps falling after editing in admin - convert table DjangoAdminLog to the same collation as other tables: | ||
+ | <code> | ||
+ | alter table auth_user_user_permissions convert to character set utf8 collate utf8_unicode_ci; | ||
+ | </code> |
python/django.txt · Last modified: 2015/01/28 13:12 by vondra