#15125: UpdateView should introspect form_class instead of requiring you to pass
the model
-----------------------------------------+----------------------------------
Reporter: sontek | Owner: nobody
Status: closed | Milestone: 1.3
Component: Generic views | Version: SVN
Resolution: wontfix | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 |
-----------------------------------------+----------------------------------
Changes (by russellm):
* status: new => closed
* resolution: => wontfix
Comment:
Looking at this more closely, I'm not sure this can be achieved:
* UpdateView calls get_object() to find the object to edit
* get_object() calls get_queryset()
* If a queryset hasn't been specified, get_queryset() then calls
get_model()
* get_model() calls get_form_class()
* If a form_class hasn't been specified, get_form_class() calls
get_queryset().
This means that get_model depends on get_queryset, and get_queryset
depends on get_model. This dependency chain can be resolved in certain
circumstances -- the provided test case is one such case. However, in the
general case, it's a minefield. Any of these functions can be overridden
-- get_object, get_model, or get_queryset -- which means that there needs
to be a clear dependency of information, or else you could easily get
stuck in a recursive loop of calls. The simplest way to break it is to not
specify a form_class OR a queryset, but the complex dependency chain
combined with extensibility strikes me as an accident waiting to happen.
Closing wontfix, but only because I can't see a way to build this (and
then explain it clearly) in the general case. Feel free to reopen if you
can find a cleaner way to put the pieces together.
--
Ticket URL: <http://code.djangoproject.com/ticket/15125#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.