Hey folks, I was about to submit a ticket but i thought it might be better 
to ask everybody for opinions on the matter first. I am running a couple of 
medium (not even large) Django websites (around +20K users) and we rely on 
the admin heavily. We have multiple models pointing to Users (or other 
derived models) and every time we create a new model, we MUST remember to 
include User in `raw_id_fields` for that model. If we forget to do so, the 
whole testing site crashes when the whole `SELECT * FROM User` query is run.

To add to the problem, some derived models (for example Customer) include 
in their `__str__` both the User + something else. Think about the model 
Customer in this way:

class Customer(models.Model):
    user = models.ForeignKey(User)
    plan = models.ForeignKey(Plan)


    def __str__(self):
        return f"{self.user} - {self.plan}"


(Not a real example, but to make the point)

Imagine any other model with an FK to Customer, an `Inquiry`, for example. 
If you open the `Inquiry` add/change page on the admin, the whole thing 
will blow up.

I know the related select field is an amazing feature, and looks slick on 
the admin when starting a new Django projects (specially for beginners), 
but it just doesn't scale for large websites.

*My proposal*

I think just a project-wide setting `settings.ADMIN_DEFAULT_FK_WIDGET = 
[raw|select]` would work and help us (running a medium/large site) a lot.

What do you think? 

Thanks for all the support, this community rocks 🤘!

PS: I can create a ticket if that's a better medium of discussion, just let 
me know?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5dae8b31-356c-45f3-b707-83b5ef33f396%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to