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

  • Home
  • SEARCH
  • 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 7849145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:26:25+00:00 2026-06-02T18:26:25+00:00

As I am working through https://docs.djangoproject.com/en/1.4/topics/db/models/ , in django, I have started a new

  • 0

As I am working through https://docs.djangoproject.com/en/1.4/topics/db/models/ , in django, I have started a new app called myapp and edited the the models.py file as the walkthrough defines:

class Person(models.Model):
  GENDER_CHOICES = (
    (u'M', u'Male'),
    (u'F', u'Female')
  )
  name = models.CharField(max_length=60)
  gender = models.CharField(max_length=2, choices=GENDER_CHOICES)

Then I ran manage.py syncdb and tried to run the next few lines in the manage.py shell interactive prompt

>>> p = Person(name="Fred Flintstone", gender="M")
>>> p.save()
Traceback (most recent call last):
  .…[I removed a few lines]...
  DatabaseError: table myapp_person has no column named name
>>> p.gender
u'M'
>>> p.get_gender_display()
u'Male'

…so then I checked to see if sqlite3 had an object in the database called Person with the name column

C:\Users\djangoSite>python manage.py sql myapp
BEGIN;
CREATE TABLE "myapp_person" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(60) NOT NULL,
"gender" varchar(2) NOT NULL

);

And of course it does! So the Person model exists, however it doesn’t get the fields that I designed it with in models.py? I did a dir(Person) calls and it confirms that the name and gender fields aren’t in there… secondly, I did dir(p) and it does have them. I suppose that is because we just added them in with that tuple, so that’s not a surprise.

The big questions then are:

  1. Why can’t I ‘p.save()’?
  2. Why doesn’t the import call bring in objects with the fields that I designed in models.py?
  3. Is this by design?
  4. Am I just doing it wrong?
  • 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-06-02T18:26:26+00:00Added an answer on June 2, 2026 at 6:26 pm

    Why can’t I p.save()?

    There is no column named name in your person table. manage.py sql myapp just shows the sql that django generates based on your model. Not the actual table in sqlite. (of course it should match up) It is important that you enter your sqlite database and verfiy the table and its schema. I find that when developing I syncdb and make a change to the model later. Re-syncing db doesn’t modify the table. You have to delete the table then resync, or alter table.

    Why doesn’t the import call bring in objects with the fields that I designed in models.py?

    Please modify your question to reflect this issue, it doens’t look like you have any issues accessing or instantiating a person object.

    Is this by design?

    No i don’t think this is by design, I believe these are common issues that arise as a new user is learning a new framework. I ran into all sorts of problems like these for weeks and months as I was learning, they will get farther and farther apart. Just make sure you are verifying things work correctly. Checking manage.py sql myapp isn’t that relevant. Checking your database to view the schem is more relevant. Django is a mature platform and when it gives you an error like missing colum 99.9% of the time it means exactly that it is transparent.

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

Sidebar

Related Questions

I have read the Django documentation (For reference, https://docs.djangoproject.com/en/1.3/intro/tutorial01/ ), but I'm still having
I am working through this tutorial https://developers.google.com/cloud-print/docs/android for google cloud print. I am trying
A quickie, and hopefully an easy one. I'm following the docs at http://docs.djangoproject.com/en/dev/topics/auth/ to
I went through a document at Adobe Livedocs that describes working with pdf: http://livedocs.adobe.com/flex/3/html/help.html?content=PDF_1.html
I was working with background threads and orientation changes. i have gone through the
Given the following URL (working, try it!) https://select-test.wp3.rbsworldpay.com/wcc/purchase?instId=151711&cartId=28524&currency=GBP&amount=1401.49&testMode=100&name=Tom%20Gul&address=24%20House%20Road \nSome Place\nCounty&postcode=TR33%20999&email=email@mail.com&country=GB If you click on
How to write joins in django,i have gone through below django documentation ,but joins
I am working on an app through my developer test account and all I
I'm working on a site that exposes endpoints over HTTP and HTTPS through Azure
I am working through the SDL tutorials over at http://lazyfoo.net/SDL_tutorials/index.php and I'm stuck on

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.