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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:56:52+00:00 2026-06-05T04:56:52+00:00

I have a models folder that has a few models in files that are

  • 0

I have a models folder that has a few models in files that are already in the DB. I have just added another file/model but it is not being added to the DB when I run syncdb. I’ve tried manage.py validate and it is running fine. I have also run the code and it only fails when it tries to save with “table does not exist”.

the original structure was like this:
/models
— __init__.py
— file1.py
— file2.py

and __init__.py looked like:

from file1 import File1Model
from file2 import File2Model

I added file3.py
/models
— __init__.py
— file1.py
— file2.py
— file3.py

and modified __init__.py

from file1 import File1Model
from file2 import File2Model
from file3 import File3Model

And the contents of file3 (names may have been changed to protect the innocent, but besides that its the exact file):
UPDATE: just tried adding a primary key since the id field may have been messing with the automatically added integer primary key id. Also tried a few variations but no dice.

from django.db import models
from django.contrib.auth.models import User


class File3Model(models.Model):
    user = models.OneToOneField(User)
    token = models.CharField(max_length=255, blank=False, null=False)
    id = models.CharField(primary_key=True, max_length=255)

    class Admin:
        pass

    class Meta:
        app_label = 'coolabel'

    def __unicode__(self):
        return self.user.username

    @staticmethod
    def getinstance(user, token, id):
        try:
            instance = File3Model.objects.get(pk=id)
            if instance.token != token:
                instance.token = token
                instance.save()
            return instance
        except:
            pass
        instance = File3Model()
        instance.user = user
        instance.token = token
        instance.id = id
        instance.save()
        return instance

So in this example, File1Model and File2Model are already in the DB and remain in the DB after syncdb. However, File3Model is not added even after rerunning syncdb. Is there any way to figure out why the new model isn’t being added??

  • 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-05T04:56:53+00:00Added an answer on June 5, 2026 at 4:56 am

    BOOM!

    I was using a different app_label for the new model but it has to be the same across the model group.

    The other models labels were “mediocrelabel” and my new model had the label “coolabel”. I changed the new model’s label to “mediocrelabel” and now they are being added to the DB correctly.

    Thanks for your help, folks!

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

Sidebar

Related Questions

I have that situation: I have models Item, Region and Country. class Item(models.Model): name
I have the following models: class Application(models.Model): users = models.ManyToManyField(User, through='Permission') folder = models.ForeignKey(Folder)
We have already built a rails app that has several users and an image
I have a Maven project that has always worked fine in Netbeans, but upgrading
I have models like this: class IdfPracownicy(models.Model): nazwa = models.CharField(max_length=100) class IdfPracaOpinie(models.Model): nazwa =
I use flask with flask-peewee and wtfpeewee. So, I have models like that: class
By default, rails is looking for images to public/images folder. But it is not
I have a question about password protecting an Excel file. The situation is that,
In my site I have a folder called module . It has two sub-folders
I have table 'pages' in my database. I have noticed that cakePHp has a

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.