Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:41:07+00:00 2026-05-30T21:41:07+00:00

I’m using OneToOneField connected with User to do form submitting tasks. But I’m getting

  • 0

I’m using OneToOneField connected with User to do form submitting tasks. But I’m getting OperationalError. This is one app I’m using for providing form after login. The login process are done using another app successfully.

Models.py:

from django.db import models
from django.forms import ModelForm
from sorl.thumbnail import ImageField
from django.contrib.auth.models import User

class BasicModel(models.Model):
    user = models.OneToOneField(User, unique=True, related_name='profile')
    name = models.CharField(max_length=200)
    dob = models.DateField()
    photo = ImageField(upload_to='sample')

class BasicModelForm(ModelForm):
    class Meta:
            model = BasicModel
            exclude = ('user',)

Views.py:

@login_required
def BasicView(request):
    if request.method == 'POST':
            form = BasicModelForm(request.POST, request.FILES, instance=request.user.profile)
            if form.is_valid():
                    data = form.save()
                    im = get_thumbnail(data.photo, '100x100', crop='center', quality=99)
                    return preview(request, data.id, im)
    else:
            form = BasicModelForm()
    return render_to_response("unnamed.html", {'form': form}, context_instance=RequestContext(request))

def preview(request, id, im):
    obj = get_object_or_404(BasicModel, pk=id)
    return render_to_response("preview.html", {'obj': obj, 'im': im})

Errors:

Exception Type: OperationalError
Exception Value:    (1054, "Unknown column 'unnamed_basicmodel.user_id' in 'field list'")
Exception Location: /usr/lib/pymodules/python2.7/MySQLdb/connections.py in defaulterrorhandler, line 36
Traceback: form = BasicModelForm(request.POST, request.FILES, instance=request.user.profile) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:41:09+00:00Added an answer on May 30, 2026 at 9:41 pm

    It looks like you have added the user field to your model, but not added the column to the database.

    The syncdb command will create new tables for you, but it does not add or modify columns in tables that already exist. You have a few options:

    If you’re still developing your app, and don’t have any important data yet, the easiest thing to do is to drop the table then run syncdb again to recreate it.

    If you can’t drop the table, then you need to manually run the SQL command to add the column.

    You may also want to investigate south, a schema migration tool for Django.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.