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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:53:42+00:00 2026-05-24T05:53:42+00:00

I have a problem when trying to run syncdb. My models: class TeachSubject(models.Model): teacher

  • 0

I have a problem when trying to run syncdb. My models:

class TeachSubject(models.Model):
    teacher = models.ForeignKey(User)
    taught_class  = models.ForeignKey(SchoolClass)
    subject = models.ForeignKey(Subject)
    year = models.IntegerField(default=datetime.date.today().year)
    semester = models.IntegerField()

    #class Meta:
        #db_table = 'subject_teachers'

another file:

from customUsers.models import TeachSubject

class SubjectPeriod(models.Model):
    days = ((1, 'Mon'),
            (2, 'Tues'),
            (3, 'Wed'),
            (4,'Thurs'),
            (5,'Friday'))
    tsc = models.ForeignKey(TeachSubject)
    day = models.IntegerField(choices = days)
    period = models.IntegerField()

    class Meta:
        db_table = 'subject_period'
        unique_together = ('day', 'period', 'tsc')

Tried running syncdb, the table subject_period is created alright. The thing is, after checking the database itself, strangely no foreign key constraint is created for the line tsc = models.ForeignKey(TeachSubject).

Anyone can shed some light? Using django 1.2.4 (ps. I spent some time checking before posting here. So I beg your forgiveness if it was a careless mistake)

EDIT:

ok I deleted the tables and retried creating the tables using south instead. Works fine now, but it would be still good to know what went wrong with the former method.

  • 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-24T05:53:42+00:00Added an answer on May 24, 2026 at 5:53 am

    I assume your two models are from different apps.

    The docs says:

    To refer to models defined in another application, you can explicitly specify a model with the full application label. For example, if the Manufacturer model above is defined in another application called production, you’d need to use:

    so your foreignkeyfield will look like:

    tsc = models.ForeignKey('customUsers.TeachSubject')
    

    This also means you don’t have to import the models from the other application (also solving problems of circular imports.

    It seems strange that you dont get an error – just nothing at all – but try that, it might just work.

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

Sidebar

Related Questions

I have run into a problem trying to modify a form I myself have
I have run into a problem... I'm trying to use QTKit in an application
Hello I have a problem while trying to run a makefile. I change the
I have run into a very interesting problem trying to debug my custom PHP
I'm trying to get familiar with CI and I have run into a problem
I have a weird, annoying problem with Python 2.6. I'm trying to run this
I have a problem with java applet and graphics. I'm trying to run it
I've just started using Fluent NHibernate and have run into the following problem trying
I have a problem with the code I am currently trying to run -
I'm new to java and i have a problem while trying to run my

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.