Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango (Python) : DatabaseError : x Table has No Column named y
    primarykey
    data
    text
    <p>hi i am working on a django python application using sqlite3 database. I have a an extention to django's user model defined in my models.py as follows:</p> <pre><code>#Account Model class Account(models.Model): user = models.OneToOneField(User) avatar_url = models.CharField(max_length=200) profile_url = models.CharField(max_length=200) account_type = models.CharField(max_length=60, choices=choices.ACCOUNT_TYPE) </code></pre> <p>i also have a method to create the <code>Account object</code> and a <code>post_save</code> handler defined like this:</p> <pre><code>#Function to Create user Account/Profile def create_user_account(sender, instance, created, **kwargs): if created: models.Account.objects.create(user=instance) #Create User / User Registration def UserRegistration(request): if request.method == 'POST': username = request.POST['fn'].capitalize() + ' ' + request.POST['ln'].capitalize() # CREATE USER newuser = User.objects.create_user(username=username, email=request.POST['email'], password=request.POST['pw']) newuser.save() return HttpResponse(username) #Post Save handler to create user Account/Profile post_save.connect(create_user_account, sender=User) </code></pre> <p>Now, whenever i try to register a new user i get the following database error:</p> <pre><code>DatabaseError at /register/ table engine_account has no column named user_id Request Method: POST Request URL: http://localhost:8000/register/ Django Version: 1.4 Exception Type: DatabaseError Exception Value: table engine_account has no column named user_id Exception Location: /usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/db/backends/sqlite3/base.py in execute, line 337 Python Executable: /usr/bin/python Python Version: 2.7.3 </code></pre> <p>and i have no idea where that <code>"user_id"</code> field is coming from .. any ideas ?</p> <p>PS:</p> <p>table engine_account is basically the <code>Account</code> class in the application named <code>Engine</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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