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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:37:19+00:00 2026-05-26T15:37:19+00:00

I have tested to inspectdb but I think my schema is to complex, for

  • 0

I have tested to “inspectdb” but I think my schema is to complex, for
example… for the table “tdir_files_context” (djangoinspectdb.JPG
“image in attachment”) I got this model:

class TdirFilesContext(models.Model):
   id_category = models.ForeignKey(TdirCategories, db_column='id_category')
   id_file_context = models.CharField(max_length=20)
   n_file_context = models.CharField(max_length=150)
   coment = models.CharField(max_length=2000)
   id_user_db_ins = models.CharField(max_length=45)
   id_user_db_upd = models.CharField(max_length=45)
   id_user_sys_ins = models.CharField(max_length=45)
   id_user_sys_upd = models.CharField(max_length=45)
   date_ins = models.DateTimeField()
   date_last_upd = models.DateTimeField()
   class Meta:
       db_table = u'tdir_files_context'

This database table have Two primary keys and One foreign key. The
Django Model handle this kind of database tables?

enter image description here

  • 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-26T15:37:19+00:00Added an answer on May 26, 2026 at 3:37 pm

    First, no table can have two primary keys. That’s just not possible. I’ll just assume yours has a primary key composed of two columns, id_category and id_file_context.

    Unfortunately, Django doesn’t currently support models with composite primary keys, it can only handle tables with exactly one columns as their primary key.

    <plug type="shameless">There is work underway on making this possible with Django, see https://code.djangoproject.com/ticket/373 and my work on this from last Google Summer of Code: https://github.com/koniiiik/django </plug>

    Other than that though, ForeignKeys are perfectly fine with Django and I see no other problems with your table.

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

Sidebar

Related Questions

I have tested this on my development computer, but now I have uploaded everything
i have tested following code which might print 0 and 2 but it print
I have tested PHP's IMAP lib. to fetch emails from a GMAIL account, but
I have tested optcomplete working with the optparse module. Its example is a simple
I wish I could have tested it myself, but unfortunately it's impossible to do
I have tested the following query in LINQPad and it runs fine, but VS2010
Ciao, I have tested in several ways, but I'm still unable to test and
I have tested this on Android and it works great but on iPhone it
I have tested and done quite some research online, but still no luck. Did
I have tested out hundreds of different codes, either they work and screw something

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.