Working With Django Projects, The Basics: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
(Created page with "category:Django category:Python category:Web Development == Creating a new project == <syntaxhighlight lang="bash"> $ django-admin.py startproject mysite </syntax...")
 
Line 36: Line 36:
$ python manage.py migrate
$ python manage.py migrate
</syntaxhighlight>
</syntaxhighlight>
The `makemigrations` and `migrate` commands are run anytime there is a change to the models.

Revision as of 15:45, 22 March 2015

Creating a new project

$ django-admin.py startproject mysite

Define a database connection

Enter database properties in myproject/settings.py, then from the project root:

$ python manage.py migrate

Run the server

$ python manage.py runserver

The server address will be reported in the output of that command, typically http://127.0.0.1:8000/

Add an app

$ python manage.py startapp myapp
  • Define some models in myapp/models.py.
  • Add the app name to INSTALLED_APPS in mysiet/settings.py.
  • Then:
$ python manage.py makemigrations myapp
$ python manage.py migrate


The makemigrations and migrate commands are run anytime there is a change to the models.