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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:09:54+00:00 2026-05-13T19:09:54+00:00

Currently, I have 3 models, A, B and C C has foreign key to

  • 0

Currently, I have 3 models, A, B and C

C has foreign key to B
B has foreign key to A

class C(models.Model):
    name = models.CharField(max_length=50, db_index=True, unique=True)
    b = models.ForeignKey(B)
class B:
...similar to C
class A
...similar to C except for the FK

However, the SQL generated by manage.py sqlindexes app doesn’t create indexes for C.name, B.name, and A.name. Anyone know why this happens?

  • 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-13T19:09:54+00:00Added an answer on May 13, 2026 at 7:09 pm

    That looks to me like it’ll be because the fields also have unique = True, so I wouldn’t worry too much about it. If you’ve got unique = True, then you’ll get a unique index (which may or may not be implemented as a database index), so I guess Django just ignores the db_index = True bit.

    I get very similar behaviour for one of my models that is similarly specified. What output do you get when run manage.py sql app? Do you see the name fields being created with UNIQUE?

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

Sidebar

Related Questions

I have two models: class Studio(models.Model): name = models.CharField(Studio, max_length=30, unique=True) class Film(models.Model): studio
I have a model like this: class database(models.Model): db_name = models.CharField('Name', max_length=20) server =
I have the following models: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, related_name='profile') starred_authors =
Currently I have a database of Courses, and it has 6 columns: class Course(models.Model):
I currently have two different models: User and Project . The User model has
Say I have the following in my models.py : class Company(models.Model): name = ...
I am currently using Django and my model is like this. class City(models.Model): name
I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include
I want to turn Model.attribute into Attribute.models. e.g. I currently have Model.first.attribute => string
I currently have a model set up like so: I have a Test class

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.