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

Hello,
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 'manage.py 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/base.py", 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/base.py", 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/manager.py", line 203, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", 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/compiler.py", line 912, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 40, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", 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 'manage.py syncdb' does not generate the expected output (creating tables..)
But it does not show any errors either.
How do I fix the problem?
Thanx
ole111
 
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:

https://docs.djangoproject.com/en/1.6/intro/tutorial01/

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

http://killtheyak.com/use-postgresql-with-django-flask/

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 'manage.py 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?
7stud
 
Posts: 99
Joined: Wed Apr 02, 2014 2:36 am


Return to General Coding Help

Who is online

Users browsing this forum: bill z and 4 guests