Error with syncdb on django?

This is the place for queries that don't fit in any of the other categories.

Error with syncdb on django?

Postby ole111 » Tue Apr 22, 2014 1:34 pm

I have a problem connecting to the data base (Postgresql) from my django web site (the app is called 'consumer')
Here is the traceback when using ' shell':
Code: Select all
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/", line 463, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/", line 551, in save_base
    result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/", line 203, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/", line 1593, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/", line 912, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/", line 40, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/", line 52, in execute
    return self.cursor.execute(query, args)
DatabaseError: relation "consumer_test" does not exist

This is the model:
Code: Select all
class Test(models.Model):
        fieldone = models.CharField(max_length=40)
        fieldtwo = models.CharField(max_length=40)

Using ' syncdb' does not generate the expected output (creating tables..)
But it does not show any errors either.
How do I fix the problem?
Posts: 7
Joined: Thu Mar 27, 2014 11:23 pm

Re: Error with syncdb on django?

Postby 7stud » Wed Apr 23, 2014 6:54 pm

I successfully used syncdb to create your table in postgres by following the Django Tutorial, part 1 here:

And in place of the "Database Setup" section, I followed these postgres instructions:

I tried leaving some steps out to duplicate your error, but I was unsuccessful. I suggest you create a new project, and follow the instructions above to see if you can get syncdb to create your table.

Here is the traceback when using ' shell':

So you tried to launch the shell, and you immediately got that error? Or did you issue some commands in the shell....then you got that error? If so, what commands?
Posts: 106
Joined: Wed Apr 02, 2014 2:36 am

Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 4 guests