Search This Website

Wednesday, 30 September 2009

Django (Python Framework) Useful Tips

Using the Command line:
  1. Django Installation look at Installation Guide 
  2. Creating Project:  python django-admin.py startproject MYSITE
  3. Creating Module(Class): python manage.py startapp CLASSNAME
  4. Update DB: python manage.py syncdb
  5. Run Django Server: python manage.py runserver
  6. View Models in SQL: python manage.py sql MODELNAME
  7. Validate SQL Models: python manage.py validate
  8. Create tables in DB:run No.6 then No.4
  9. Shell Access: python manage.py shell
Django Debug Toolbar:
The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response.  It is a small toolbar that, when activated, situates itself in the top-right location of the browser window. When particular panels are clicked, more details about that panel's content are displayed. For Installation follow the steps below:
  1. Download the package from here
  2. Install python-profile from the Synaptic Package Manager
  3. Add the debug_toolbar directory to your Django python project directory.
  4. Add the following middleware to your project's settings.py file:
  5.             'debug_toolbar.middleware.DebugToolbarMiddleware',
  6. Add debug_toolbar to your INSTALLED_APPS setting so Django can find the template files associated with the Debug Toolbar.
  7. Run Django server 
  8. Open your Django project URL e.g. http://localhost:8000/admin if your admin page is activated
Django-Piston:
A mini-framework for Django for creating RESTful APIs. Piston is a relatively small Django application that lets you create application programming interfaces (API) for your sites. For usage follow the steps:
  1. Install it from here
  2. For full documentation click here
Django Python Comment Code:
  • # for one line comment
  • """ code """ for whole set

No comments:

Post a Comment