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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:47:05+00:00 2026-06-13T08:47:05+00:00

I’m working on a fairly standard Django app and lately I’ve been tweaking the

  • 0

I’m working on a fairly standard Django app and lately I’ve been tweaking the admin. While the list views load at reasonable rates, the detail and add views take some ~10 seconds to load.

I’m not exactly sure why it is so– I suspected it had something to do with the database being over queried, and in fact it is. After turning on logging I discovered that the controller is querying for every id in the table:

...
[Mon Oct 22 18:32:52 2012] [error] (0.001) SELECT `courses_course`.`id`, `courses_course`.`semester`,
 `courses_course`.`name`, `courses_course`.`credits`, `courses_course`.`description`, `courses_course
`.`history_id`, `courses_course`.`oldpcr_id`, `courses_course`.`primary_alias_id` FROM `courses_cours
e` WHERE `courses_course`.`id` = 2077 ; args=(2077,)
[Mon Oct 22 18:32:52 2012] [error] (0.000) SELECT `courses_course`.`id`, `courses_course`.`semester`,
 `courses_course`.`name`, `courses_course`.`credits`, `courses_course`.`description`, `courses_course
`.`history_id`, `courses_course`.`oldpcr_id`, `courses_course`.`primary_alias_id` FROM `courses_cours
e` WHERE `courses_course`.`id` = 2078 ; args=(2078,)
[Mon Oct 22 18:32:52 2012] [error] (0.001) SELECT `courses_course`.`id`, `courses_course`.`semester`,
 `courses_course`.`name`, `courses_course`.`credits`, `courses_course`.`description`, `courses_course
`.`history_id`, `courses_course`.`oldpcr_id`, `courses_course`.`primary_alias_id` FROM `courses_cours
e` WHERE `courses_course`.`id` = 2079 ; args=(2079,)
...

Can somebody explain why this is happening? I can’t think of anything at all that might explain it.

  • 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-13T08:47:06+00:00Added an answer on June 13, 2026 at 8:47 am

    I discovered the answer here: Improving Performance of Django ForeignKey Fields in Admin

    Because Django lists foreign keys as a select list, it has to query every one. it looks like several solutions are possible, but the simplest is just to set the field to a raw_id field. (And in fact, doing so fixed my problem.)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I have a reasonable size flat file database of text documents mostly saved in
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.