Re: Django admin runs out of memory with ForeignKeys to large tables
On 9/5/12 6:00 AM, Mattias Linnap wrote: I've found two solutions: setting "editable=False" in the model's field definition (which removes the field completely from admin), or adding it to readonly_fields list in the ModelAdmin (which keeps the data visible). Perhaps it will be possible to subclass ModelAdmin, and make all editable=False fields show up as readonly: after all, their data is still interesting to look at, just should not be editable. Looking at millions of read-only entries should lead to hours of enjoyment ;) What good is that volume of data displayed to a user or admin? How about showing a rollup of the number of values and then allowing a click-through to a detailed display if necessary? - Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django admin runs out of memory with ForeignKeys to large tables
what about raw_id_fields ? On Wed, Sep 5, 2012 at 9:00 AM, Mattias Linnap wrote: > I've found two solutions: setting "editable=False" in the model's > field definition (which removes the field completely from admin), or > adding it to readonly_fields list in the ModelAdmin (which keeps the > data visible). > > Perhaps it will be possible to subclass ModelAdmin, and make all > editable=False fields show up as readonly: after all, their data is > still interesting to look at, just should not be editable. > > Mattias > > On Wed, Sep 5, 2012 at 1:37 PM, Mattias Linnap wrote: > > Hi all, > > > > I have a model X that references another model Y with a ForeignKey. > > There are very few Xs, but close to a million Ys in the database (and > > it will grow considerably in the future). > > This causes MemoryErrors in the Django built-in admin pages: the > > ForeignKey is rendered as a select box field, and the admin attempts > > to populate it with all million possible Ys. > > > > What would be the recommended solution? The ForeignKey relationship > > does not need to be actually editable in the admin, it's a simple > > uniqueness constraint that should never change after an X is created. > > I'm using the admin as more of a data browsing UI rather than a > > management UI. > > > > Thanks, > > > > Mattias > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django admin runs out of memory with ForeignKeys to large tables
I've found two solutions: setting "editable=False" in the model's field definition (which removes the field completely from admin), or adding it to readonly_fields list in the ModelAdmin (which keeps the data visible). Perhaps it will be possible to subclass ModelAdmin, and make all editable=False fields show up as readonly: after all, their data is still interesting to look at, just should not be editable. Mattias On Wed, Sep 5, 2012 at 1:37 PM, Mattias Linnap wrote: > Hi all, > > I have a model X that references another model Y with a ForeignKey. > There are very few Xs, but close to a million Ys in the database (and > it will grow considerably in the future). > This causes MemoryErrors in the Django built-in admin pages: the > ForeignKey is rendered as a select box field, and the admin attempts > to populate it with all million possible Ys. > > What would be the recommended solution? The ForeignKey relationship > does not need to be actually editable in the admin, it's a simple > uniqueness constraint that should never change after an X is created. > I'm using the admin as more of a data browsing UI rather than a > management UI. > > Thanks, > > Mattias -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django admin runs out of memory with ForeignKeys to large tables
Hi all, I have a model X that references another model Y with a ForeignKey. There are very few Xs, but close to a million Ys in the database (and it will grow considerably in the future). This causes MemoryErrors in the Django built-in admin pages: the ForeignKey is rendered as a select box field, and the admin attempts to populate it with all million possible Ys. What would be the recommended solution? The ForeignKey relationship does not need to be actually editable in the admin, it's a simple uniqueness constraint that should never change after an X is created. I'm using the admin as more of a data browsing UI rather than a management UI. Thanks, Mattias -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.