Hello, would like to ask, using Django Smart Selects for dynamic filtering dropdows in Admin: https://github.com/digi604/django-smart-selects My model looks like this:
My problem is when I am in Admin and filled out the data when I am clicking on each Table:
Basically you should see: image? So when you clicking on all above all works except PAGE it takes like 5 minutes to load no sure why, I dont think the model is so that complicated to make heavy SQL or jquery processing. Can anyone help or even maybe suggest better solution how to do Dynamic Admin filtering? I can also open a ticket if possible to look fully at the code, thanks a lot |
We can not tell you why the app would be going slow from the code alone. You will have to log your SQL queries and possibly attach a debugger to get statistics about the app and try to determine what it is actually processing. With that info you will either have to rewrite the view to be more efficient or possibly write the author of the 'Django Smart Selects' application with your findings. answered 23 Sep '12, 23:59 johns I removed Smart Select plugin and did regular Foreign Keys: and when I add data and PRESS "TYPE" in admin it takes like 4 seconds to process SQL: screenshot: http://cl.ly/image/3w3D3g0h3h1A When I add PAGE model the last one it basically time out and when I look WF mysql server with TOP function in terminal its running on 300%, why that model is so bad? How should I make this entire model better that last PAGE has all prepopulated attributes from others? class Client(models.Model): title = models.CharField(max_length=100, unique=True) def unicode(self): return self.title class Category(models.Model): client = models.ForeignKey(Client, to_field='title') title = models.CharField(max_length=200, unique=True) def unicode(self): return self.title class Subcategory(models.Model): client = models.ForeignKey(Client, to_field='title') category = models.ForeignKey(Category, to_field='title') title = models.CharField(max_length=200, unique=True) def unicode(self): return self.title class Project(models.Model): client = models.ForeignKey(Client, to_field='title') category = models.ForeignKey(Category, to_field='title') subcategory = models.ForeignKey(Subcategory, to_field='title') title = models.CharField(max_length=200, unique=True) def unicode(self): return self.title class Type(models.Model): client = models.ForeignKey(Client, to_field='title') category = models.ForeignKey(Category, to_field='title') subcategory = models.ForeignKey(Subcategory, to_field='title') project = models.ForeignKey(Project, to_field='title') title = models.CharField(max_length=200, unique=True) def unicode(self): return self.title class Page(models.Model): client = models.ForeignKey(Client, to_field='title') category = models.ForeignKey(Category, to_field='title') subcategory = models.ForeignKey(Subcategory, to_field='title') project = models.ForeignKey(Project, to_field='title') type = models.ForeignKey(Type, to_field='title') pageurl = models.CharField(max_length=200)
(24 Sep '12, 16:20)
rentgeeen
I can open a ticket you will see how your sql server will go on 200-300% because of clicking in admin on type or page and that model is not huge
(24 Sep '12, 16:23)
rentgeeen
We will want the SQL that is being generated, as stated above enable logging to get that. Also, we will not debug the application itself(to change what SQL it generates), you will have to contact the developer for that.
(24 Sep '12, 17:08)
johns
This is the SQL:
(24 Sep '12, 17:14)
rentgeeen
here is also mysql query in PHPmyadmin: http://cl.ly/image/2S320h3d0P0J 17 seconds
(24 Sep '12, 17:18)
rentgeeen
Also just found out when I remove Foreign Keys from admin.py from "list_display", it works blazing fast:
FOREIGN KEYS cannot be in list_display? How to optimize them?
(24 Sep '12, 18:29)
rentgeeen
Now that you know the SQL You can profile it to get more info about why it is going slow. The way to optimize it is by rewriting the Django code to be more efficient, there is no simple answer for doing that, that is the core of what development work is.
(24 Sep '12, 19:39)
johns
Did a mysql profiling, curious what is statistics that took so long: Results: Query: http://cl.ly/image/0311392u0Z0S CPU Profile: http://cl.ly/image/2D210h0f1L06
(26 Sep '12, 09:17)
rentgeeen
All of the various thread states are documented here: General Thread States
(26 Sep '12, 12:15)
seanf
showing 5 of 9
show 4 more comments
|