Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Django uses ORM (Object Relational Mapper). What that means is that you do not directly deal with database tables for querying things however you deal with certain classes which then deal with the database. This is very useful and much more user-friendly then doing manually SQL. Consider the following example:</p> <pre><code>SELECT * FROM foo WHERE field="value" </code></pre> <p>vs</p> <pre><code>Foo.objects.filter(field='value') </code></pre> <p>In ORM, you describe the tables you have by making certain classes (in Django we call them models) and those models correspond to tables in the db, and their fields correspond to the columns in the db table. The following are very similar:</p> <pre><code>CREATE TABLE foo ( title varchar(50), description text, likes integer ); </code></pre> <p>and</p> <pre><code>class Foo(models.Model): title = models.CharField(max_length=50) description = models.TextField() likes = models.IntegerField() </code></pre> <p>However it is waste of time for you as a developer to construct the SQL statements for creating tables, and describing those tables in Python as models. Not to do that, Django allows you once you define all your models, to create db tables for you. That is the purpose of the <code>syncdb</code> command. It takes all the installed apps and models within them and creates tables within your database for them. However as you already mentioned in your question, databases have roles and those roles have permissions. For example, one of the permissions is <code>CREATE</code> as described <a href="http://www.postgresql.org/docs/9.0/static/sql-grant.html" rel="nofollow">here</a>. So what Django documentation is saying is for you to grand all necessary permission to a role which Django will use to interact with the db for Django to be able to create necessary db tables it needs as well as possibly modify them later. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload