Reputation: 125
What I am trying to achieve is:
My Problem is when the User clicks on Preview I can pass a Modelform with the data and show it to him. But since there are no fields in the he can just click on Accept to publish his Content. I need a form which is like a Deny/Accept Dialog but still related to the Model because i have to make changes before saving it to the database.
I tried to exclude all fields and also fields=None
I read this but the solution looks a little hacky. FormPreview is not what i want because it is a too different approach.
Is there any way to create a form that consists of just a button? I am also able to pass the data from view to view, so in worst case it hasnt to be a ModelForm.
Upvotes: 1
Views: 3930
Reputation: 125
I found a solution which fits my needs:
Just take any_field
and make it a hidden field:
from django.forms import HiddenInput
class MyModelForm(ModelForm):
class Meta:
model = MyModel
widgets = {'any_field': HiddenInput(),}
Dont forget to exclude all the other fields.
Upvotes: 2