Django for Designers: Difference between revisions

Content added Content deleted
imported>Aldeka
imported>Aldeka
Line 159: Line 159:
Now that we have a the scaffolding for our project in place, we can get to work! First, it needs to be configured.
Now that we have a the scaffolding for our project in place, we can get to work! First, it needs to be configured.


Open myproject/settings.py in your editor. settings.py is a Python script that only contains variable definitions. Django looks at the values of these variables when it runs your project.
Open myproject/myproject/settings.py in your editor. settings.py is a Python script that only contains variable definitions. Django looks at the values of these variables when it runs your project.


In settings.py, let's find DATABASES. The DATABASES variable is a dictionary (note the ‘{}’ characters) with one key: default.
In settings.py, let's find DATABASES. The DATABASES variable is a dictionary (note the ‘{}’ characters) with one key: default.
Line 190: Line 190:


<source lang="bash">
<source lang="bash">
git add myproject/ # this is a shortcut that will add all changes inside the named folder
git add settings.py
git commit -m "set up the database for Django to use"
git commit -m "set up the database for Django to use"
</source>
</source>
Line 215: Line 215:
Each of our applications makes use of at least one database table, so we need to create the tables in the database before we can use them. To do that, run the following command in your terminal window:
Each of our applications makes use of at least one database table, so we need to create the tables in the database before we can use them. To do that, run the following command in your terminal window:


<source lang="bash">python manage.py syncdb</source>
<source lang="bash">
$ cd myproject
$ python manage.py syncdb</source>


The syncdb command looks at the INSTALLED_APPS setting and creates any necessary database tables according to the database settings in your settings.py file. You’ll see a message for each database table it creates.
The syncdb command looks at the INSTALLED_APPS setting and creates any necessary database tables according to the database settings in your settings.py file. You’ll see a message for each database table it creates.