ModelForms
Hello,
when using ModelForms, which is the correct way to implement the "edit item" pattern?
Suppose I've a table with many rows, each representing a record in a database.
I choose one and wish to display/let the user edit the details.
I'm trying to use a ModelForm and fill some fields with specific data coming froma query.
The problem is I'm unable to initialize the fields and have the page served.
The arguments taken for a form do not work in a modelform.
class Quotation(models.Model):
#...
filename = models.CharField("Filename", max_length=60)
#...
class QuotationForm(ModelForm):
class Meta:
model = Quotation
#...
def manage_quotations(request, quote_id):
# retrieve quotation here
# ...
# just try to fill a form and have the page served
qd = { 'filename' : '123' }
form = QuotationForm() # cannot pass qd here as initializer
if request.method == "POST":
pass # manage posted data
return render_to_response("quotes/manage_quotation.html", {
"form": form,
})
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/523244aa-f4ad-4f90-9abf-ec06b41ff113%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home