Вопрос

Using Django 1.5, I need a Default values button with my form.

The form is a forms.ModelForm and the model is populated using Django fixtures when the application is deployed. Basically, the reset button would fetch the fixture content and update the form content with it.

Do I have to open the fixture file with os and stuff ?

Это было полезно?

Решение

IMHO you need to create a record (e.g. the first record in the table) with the fixture content and load that when needed. You'd need to get the record ID (which you can set in the fixture) and use it (either hardcoded or with other method) in your view.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top