Tuesday, June 10, 2014

Helpful Django Commands

# Django Basic Helpful Commands
#!/bin/bash
# Sync Database
python manage.py syncdb

# Run Debug Server
python manage.py runserver

# Validating The Database
python manage.py validate

# See the SQL statments used to generate the database tables.
python manage.py sqlall app_name

# Creates a new app. Be sure to add it to the settings.py file and also to the urls.py file.
python manage.py startapp appname

# Debug Django Page Location
http://localhost:8000/

# Install Django
sudo python setup.py install

sudo apt-get install python-django

# Django Verison
django-admin.py --version

# Create A New Django Project
django-admin.py startproject project_name

# Create A New Django App
django-admin.py startapp app_name

# urls.py patterns
.    # Any character
^    # Start of a string
$    # End of a string
*    # 0 or more repetitions
+    # 1 or more repetitions
?    # 0 or 1 repetitions
|    # A | B means A or B
[a-z]    # Any lowercase character
\w    # Any alphanumeric character or _
\d    # Any digit

# Display SQL Statements Out Of Django
python manage.py sql folder_name_that_conatins_model.py

# Django Python Interactive Shell
python manage.py shell

# Django Python Sphinx Search Configuration File Generate
python manage.py generate_sphinx_config MyApp >> sphinx.conf

# Installing easy_install for python Django Apps.
sudo apt-get install python-setuptools

No comments:

Post a Comment