문제

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