#29445: Compute defaults values with using of objects manager
-------------------------------------+-------------------------------------
               Reporter:  Yurii      |          Owner:  nobody
  Shtrikker                          |
                   Type:  New        |         Status:  new
  feature                            |
              Component:             |        Version:  2.0
  contrib.admin                      |       Keywords:  compute, defaults,
               Severity:  Normal     |  fields, admin site, form
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  1          |
-------------------------------------+-------------------------------------
 Background:
 I have an issue for add a field used for ordering records to few models .
 Problem is pre-defined value, that should calculate as currently max value
 plus ten. For example:
 Add first record. Field should be a 10 by default.
 Add second record. Field should be a 20 by default.
 Add third record. Field should be a 30 by default, but we change it to 15
 for placing between first two records.
 Add fourth record. Field should be a 30 by default.

 For implement this logic I need access to class object when default method
 is called (I mean method specifying as value for default argument for
 field).
 But at method call I don't get any arguments. In case when I need
 implement this field for single model - I can use model name as his
 objects argument for this logic. But for many models I thinks it's will be
 bad. Abstract model also not a choice, because it doesn't have a objects
 manager.

 So I remember about prepopulated fields in BaseModelAdmin (this all need
 inly for admin site), and I use formfield_for_dbfield for implementing
 this logic.

 Now I want to ask about add new feature to add compute_defaults dict to
 BaseModelAdmin. Key used as field name selector and value as computing
 function (information about model and current field we can get from
 db_field variable). I can create PL with this feature by myself, but
 should I do it? Is it need to somebody else? And what you all thinking
 about this idea?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29445>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.4236b9fae50d474ab66a2e69bd1c9fa1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to