0

Suppose that in a django project:

  1. ModelAdmin class "FooModelAdmin" is defined in module <app1.admin.py> for model "Foo".
  2. Model "Foo" has a field named "F1", which is of type CharField.
  3. A list of choices is defined for field "F1" by the attributes of class "Choices1".
  4. Class "Choices1" is a child class of DjangoChoices.

In such a case, django creates the choices for field "F1" in class "FooModelAdmin" already when class "FooModelAdmin" is defined, that is, when the software is loaded. Is there a way for the project's code to dynamically override the choices for field "F1" of class "FooModelAdmin" at any desired time later on?

Alternatively, is there a way for the project's code to reload module <app1.admin.py> at any desired time later on, so that the new class definition (in which class "Choices1" defines a new set of choices) will take over the old one?

Ofer
  • 423
  • 6
  • 11

0 Answers0