Django: Unterschied zwischen den Versionen

Aus Open Source Ecology - Germany
Zur Navigation springen Zur Suche springen
 
(35 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
[https://www.djangoproject.com/ Django] - a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
+
[https://www.djangoproject.com/ Django] - a high-level [[Python]] Web framework that encourages rapid development and clean, pragmatic design.
  
 
==Aptana Configuration==
 
==Aptana Configuration==
 
* Win-Preferences->PyDev->Editor->Code Completeion: Apply completion on '.' and '('
 
* Win-Preferences->PyDev->Editor->Code Completeion: Apply completion on '.' and '('
 +
 +
==Install Packages==
 +
* Find version: https://pypi.python.org/pypi/
 +
 +
==Django CMS==
 +
Best Practices:
 +
* Test web pages always with "Preview". When the page is ready see it with "Publish".
 +
 +
==Virtualenv==
 +
Activate:
 +
* source <your_environment>/bin/activate
 +
* . ~/.environments/<your_environment>/bin/activate
 +
 +
See:
 +
[http://pad.sinnwerkstatt.com/p/backend-guidelines Backend Guidelines of Sinnwerkstatt]
 +
 +
===Virtualenv Wrapper===
 +
* [http://virtualenvwrapper.readthedocs.org Virtualenv Wrapper Docs]
 +
** sudo pip install virtualenvwrapper
 +
** Add to your .bashrc:
 +
*** export WORKON_HOME=~/path/to/your/virtualenvironments
 +
*** export PROJECT_HOME=~/path/to/your/workspace
 +
*** source /usr/local/bin/virtualenvwrapper.sh
 +
** Restart your bash
 +
** To add a project to the wrapper:
 +
*** Cd to your project and activate its virtualenv
 +
*** <pre>setvirtualenvproject $VIRTUAL_ENV $(pwd)</pre>
 +
*** Then you can use "workon <project_folder_name>" to active and cd to the project.
 +
 +
===PIP===
 +
* sudo pip install <package_name> - installs the package globally
 +
* pip install <package_name> - installs the package in the current python context (often in the virtualenv)
  
 
==Tutorials==
 
==Tutorials==
Zeile 13: Zeile 45:
 
* [http://www.python.org/dev/peps/pep-0008/ PEP 8 -- Style Guide for Python Code]
 
* [http://www.python.org/dev/peps/pep-0008/ PEP 8 -- Style Guide for Python Code]
  
==Collaborative==
+
==Images==
 +
* http://www.sandersnewmedia.com/why/2012/04/16/installing-pil-virtualenv-ubuntu-1204-precise-pangolin/ - fix image showing problem.
 +
 
 +
==Configure with PyCharm==
 +
* [http://stackoverflow.com/a/14428951/2510374 DJANGO_SETTINGS_MODULE]
 +
 
 +
==Databases==
 +
* Install Databases
 +
~/.environments/<PROJEKT>env/bin/pip install -r requirements.txt
 +
 
 +
==Requirements.txt==
 +
On change of the requirements.txt:
 +
* pip install -r requirements.txt
 +
* <ENV> manage.py '''syncdb'''
 +
* <ENV> manage.py '''migrate'''
 +
 
 +
==Migrations==
 
* Migrate on change of requirements.txt, e.g. new tables are added.
 
* Migrate on change of requirements.txt, e.g. new tables are added.
 +
** <ENV> manage.py '''syncdb'''
 
** <ENV> manage.py '''migrate'''
 
** <ENV> manage.py '''migrate'''
 +
* Migrate on model change:
 +
** manage.py schemamigration app_name --auto
 +
** manage.py migrate app_name
 +
* [http://www.djangopro.com/2011/01/django-database-migration-tool-south-explained/ Django database migration tool: south, explained]
 +
* Delete migration
 +
** manage.py migrate <app_name> <number_of_migration_to_rollback_to>
 +
** delete file
 +
 +
==Internationalization==
 +
* [https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#how-django-discovers-translations How Django discovers translations]
 +
* Create or update message files:
 +
** manage.py makemessages -l de
 +
* Compile:
 +
** manage.py compilemessages -v 2 -l de
 +
* Compile all:
 +
** bash compilemessages.sh
 +
 +
 +
If you have problems with translating strings:
 +
* read How Django discovers translation https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#how-django-discovers-translations
 +
* Define in your settings.py to make sure that strings are first read from the directory defined by you:
 +
** BASEPATH = realpath(join(dirname(_file), '..'))
 +
** LOCALE_PATHS = (
 +
**    join(BASE_PATH, 'locale'),
 +
** )
 +
** Stackoverflow: http://stackoverflow.com/questions/1832709/django-how-to-make-translation-work?rq=1
 +
 +
==AJAX==
 +
* http://www.dajaxproject.com/
 +
 +
==REST==
 +
* [http://django-rest-framework.org/ Django REST Framework]
 +
 +
==AngularJS==
 +
* [https://www.youtube.com/watch?v=Q8FRBGTJ020 django-rest-framework and angularjs]
 +
 +
==Best Practices==
 +
* [http://de.slideshare.net/DZPM/12-tips-on-django-best-practices 12 tips on Django Best Practices]
  
 
==Hosting==
 
==Hosting==
 
* https://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
 
* https://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
 
** http://locum.ru/public/hosting
 
** http://locum.ru/public/hosting
 +
 +
==Sites in Django==
 +
* [http://marakana.com/s/post/1505/learn_how_disqus_does_it_when_it_is_not_django_python_video Disqus]
 +
* [http://pinterest.com/ Pinterest]
 +
* http://www.djangosites.org/
  
 
[[Category: Software]]
 
[[Category: Software]]

Aktuelle Version vom 30. August 2013, 09:44 Uhr

Django - a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Aptana Configuration

  • Win-Preferences->PyDev->Editor->Code Completeion: Apply completion on '.' and '('

Install Packages

Django CMS

Best Practices:

  • Test web pages always with "Preview". When the page is ready see it with "Publish".

Virtualenv

Activate:

  • source <your_environment>/bin/activate
  • . ~/.environments/<your_environment>/bin/activate

See: Backend Guidelines of Sinnwerkstatt

Virtualenv Wrapper

  • Virtualenv Wrapper Docs
    • sudo pip install virtualenvwrapper
    • Add to your .bashrc:
      • export WORKON_HOME=~/path/to/your/virtualenvironments
      • export PROJECT_HOME=~/path/to/your/workspace
      • source /usr/local/bin/virtualenvwrapper.sh
    • Restart your bash
    • To add a project to the wrapper:
      • Cd to your project and activate its virtualenv
      • setvirtualenvproject $VIRTUAL_ENV $(pwd)
      • Then you can use "workon <project_folder_name>" to active and cd to the project.

PIP

  • sudo pip install <package_name> - installs the package globally
  • pip install <package_name> - installs the package in the current python context (often in the virtualenv)

Tutorials

Style Guides

Images

Configure with PyCharm

Databases

  • Install Databases
~/.environments/<PROJEKT>env/bin/pip install -r requirements.txt

Requirements.txt

On change of the requirements.txt:

  • pip install -r requirements.txt
  • <ENV> manage.py syncdb
  • <ENV> manage.py migrate

Migrations

  • Migrate on change of requirements.txt, e.g. new tables are added.
    • <ENV> manage.py syncdb
    • <ENV> manage.py migrate
  • Migrate on model change:
    • manage.py schemamigration app_name --auto
    • manage.py migrate app_name
  • Django database migration tool: south, explained
  • Delete migration
    • manage.py migrate <app_name> <number_of_migration_to_rollback_to>
    • delete file

Internationalization

  • How Django discovers translations
  • Create or update message files:
    • manage.py makemessages -l de
  • Compile:
    • manage.py compilemessages -v 2 -l de
  • Compile all:
    • bash compilemessages.sh


If you have problems with translating strings:

AJAX

REST

AngularJS

Best Practices

Hosting

Sites in Django