Задать вопрос

Тел: +7 965 3737 888

584

Просмотров

0

Ответов

Readonly Select Widget Replacement

This is for situations where a ModelForm is needed on an existing object, but we want to disable ForeignKey widgets, and only use them as a display.

Usage: save the code in teh top half of the example above into a file somewhere in your django project, in this example we will call it customwidget.py

The second half shows an example usage, but setting the widget and queryset in the init method of the form. If the queryset returned by the ForeignKey model (Example.objects.all() ) is small, you can omit the init code.

Вопрос полезен? Да0/Нет0
file_4789.py(1.6Кб)
None