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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:31:02+00:00 2026-06-12T13:31:02+00:00

I have models in Django set up as below. class Pupil(models.Model): forename = models.CharField(max_length=30)

  • 0

I have models in Django set up as below.

class Pupil(models.Model):
    forename = models.CharField(max_length=30)
    surname = models.CharField(max_length=30)
    dateofbirth = models.DateField()
    year = models.IntegerField()
    class_group = models.CharField(max_length=30)
    email = models.EmailField(blank=True)
    assignments = models.ManyToManyField('Assignment', verbose_name='related assignments')

    def __unicode__(self):
        return u'%s %s' % (self.forename, self.surname)

class Subject(models.Model):
    name = models.CharField(max_length=30)
    level = models.CharField(max_length=30)
    teachers = models.ManyToManyField('Teacher', verbose_name='related teachers')

    def __unicode__(self):
        return self.name

class Teacher(models.Model):
    forename = models.CharField(max_length=30)
    surname = models.CharField(max_length=30)
    email = models.EmailField(blank=True)

    def __unicode__(self):
        return u'%s %s' % (self.forename, self.surname)

class Assignment(models.Model):
    assignment_name = models.CharField(max_length=30)
    date_assigned = models.DateField()
    date_submitted = models.DateField()

    def __unicode__(self):
        return self.assignment_name

When I attempt to add a pupil and attach an assignment to the pupil in the admin, I get a database error –

no such table: homework_pupil_assignments

after reading this I realised this could be due to django not updating changes to my models as when I do manage.py sqlall homework

I see the following:

BEGIN;
CREATE TABLE "homework_pupil_assignments" (
    "id" integer NOT NULL PRIMARY KEY,
    "pupil_id" integer NOT NULL,
    "assignment_id" integer NOT NULL,
    UNIQUE ("pupil_id", "assignment_id")
)
;
CREATE TABLE "homework_pupil" (
    "id" integer NOT NULL PRIMARY KEY,
    "forename" varchar(30) NOT NULL,
    "surname" varchar(30) NOT NULL,
    "dateofbirth" date NOT NULL,
    "year" integer NOT NULL,
    "class_group" varchar(30) NOT NULL,
    "email" varchar(75) NOT NULL
)
;
CREATE TABLE "homework_subject_teachers" (
    "id" integer NOT NULL PRIMARY KEY,
    "subject_id" integer NOT NULL,
    "teacher_id" integer NOT NULL,
    UNIQUE ("subject_id", "teacher_id")
)
;
CREATE TABLE "homework_subject" (
    "id" integer NOT NULL PRIMARY KEY,
    "name" varchar(30) NOT NULL,
    "level" varchar(30) NOT NULL
)
;
CREATE TABLE "homework_teacher" (
    "id" integer NOT NULL PRIMARY KEY,
    "forename" varchar(30) NOT NULL,
    "surname" varchar(30) NOT NULL,
    "email" varchar(75) NOT NULL
)
;
CREATE TABLE "homework_assignment" (
    "id" integer NOT NULL PRIMARY KEY,
    "assignment_name" varchar(30) NOT NULL,
    "date_assigned" date NOT NULL,
    "date_submitted" date NOT NULL
)
;
COMMIT;

I then installed South, following the directions to get up and running with an existing app, in the hope of successfully syncing these tables. No joy.

Can anyone suggest how I can get the database (sqlite3) to reflect the models or point out what I’m doing 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-12T13:31:03+00:00Added an answer on June 12, 2026 at 1:31 pm

    Updated answer for Django migrations without south plugin:

    Like T.T suggested in his answer, my previous answer was for south migration plugin, when Django hasn’t any schema migration features.
    Now (works in Django 1.9+):

    T.T wrote:

    You can try this!

    python manage.py makemigrations
    
    python manage.py migrate --run-syncdb
    

    Outdated for south migrations plugin

    As I can see you done it all in wrong order, to fix it up your should
    complete this checklist (I assume you can’t delete sqlite3 database
    file to start over):

    1. Grab any SQLite GUI tool (i.e. http://sqliteadmin.orbmu2k.de/)
    2. Change your model definition to match database definition (best approach is to comment new fields)
    3. Delete migrations folder in your model
    4. Delete rows in south_migrationhistory table where app_name match your application name (probably homework)
    5. Invoke: ./manage.py schemamigration <app_name> --initial
    6. Create tables by ./manage.py migrate <app_name> --fake (--fake will skip SQL execute because table already exists in your database)
    7. Make changes to your app’s model
    8. Invoke ./manage.py schemamigration <app_name> --auto
    9. Then apply changes to database: ./manage.py migrate <app_name>

    Steps 7,8,9 repeat whenever your model needs any changes.

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

Sidebar

Related Questions

Let's say I have a set of Django Models: class Article(models.Model): title = models.CharField(max_length=100,
I have these models set up in Django: class SourceBusiness(models.Model): source = models.CharField(max_length=100) ...(other
I have the following abstract Django models: class Food(models.Model): name = models.CharField(max_length=100) class Meta:
I have these Django models: class Group(models.Model): name = models.CharField(max_length=100) parent_group = models.ManyToManyField("self", blank=True)
If I have two models in Django: class Blog(models.Model): author = models.CharField() class Post(models.Model):
I have a couple of Django models set up like this: class Group(models.model): name
I have two models: call them questions and answers: class FacetQuestion(models.Model): the_question = models.CharField(max_length=50)
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I have two models in my Django 1.1.1 application: class UserRequest(models.Model): # blah blah
Let's assume we have following models: from django.db import models class Foo(models.Model): name =

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.