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 6089041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:03:17+00:00 2026-05-23T12:03:17+00:00

How does Django handle changes to my Model? Or, what help does it offer

  • 0

How does Django handle changes to my Model? Or, what help does it offer me to do this?

I am thinking of a situation where I have already have published data to my DB which I don’t want to lose, but I need to make changes to my data model – for example, adding extra fields to a particular class, changing the types of fields, etc. My understanding is that syncdb won’t ever alter tables that already exist in the DB.

For example, let’s say I have the following model:

class Person(models.Model):
    name = models.CharField(max_length=200)
    phone_number=models.CharField(max_length=200)
    hair_colour=CharField(max_length=50)

Things I might want to do to Person off the top of my head:

  1. I wish to add an ‘age’ field.
  2. I realise I want to use IntegerField instead of CharField for phone_number (whether this is a good idea or not, is out of scope…) – assuming it’s possible.
  3. I realise that I no longer wish to define hair_colour ‘inline’ within Person, because several people share the same hair colour – I wish instead to change this to be a foreign key to some other model.

Whilst I can imagine some of these are tough/impossible for the framework to ‘guess’ exactly what needs to be done to my data if all I do is update the models.py, I can imagine that there might still be some tooling to help enable it – does it exist?

In particular I imagine there must be some good patterns for option 1.

I’m very new to Django and have no experience with any other ORM-type stuff, which I think this is – I’ve always been a bit suspicious of ORMs, mainly for the reasons above 🙂

  • 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-23T12:03:17+00:00Added an answer on May 23, 2026 at 12:03 pm

    Django itself will not attempt to modify an already created database table. What you are trying to do is typically called “Migration” and there are a couple of different Database Migration tools available for Django.

    South

    • Schema Migrations
    • Data Migrations
    • Backwards Migrations

    Nash Vegas

    • Schema Migrations
    • Data Migrations

    Django Evolution

    • Schema Migrations
    • Data Migrations (Unknown)
    • Backwards Migrations (Unknown)

    Of the three South is probably the most widely used but they each have different ways of dealing with migrations. You can see more details on the comparison on Django Packages.

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

Sidebar

Related Questions

I have a Python program (with Django - does this matter?) that I want
Does Django have any template tags to generate common HTML markup? For example, I
This question is related to (but perhaps not quite the same as): Does Django
It looks like Django does not update last_login field in auth_user model when a
The debug screen says that django does not have write access to the db.
I am doing geolocation, and Django does not have a PointField. So, I am
Why does Django give me this exception [(7, u'Acura'), (18, u'Alfa Romeo'), ...] is
I'm working on a django project that has a large fixture which does not
I have done everything said on the following page. https://help.ubuntu.com/community/Django but it gives me
Does anyone know of a Django 1.0 + postgresql + apache + mod_python VMware

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.