Hello,
I've done a bit of reading but still think I'm missing
something
fundamental . Could someone lend a hand? I'm trying to
display a form
based on my Project model, using the latest dev version of
Django. I
don't get any errors with the view below, but the template
refuses to
dump the form.as_p(), or as_table(), etc - it just leaves a
blank line.
Looking at the code for newforms, or the unit tests didn't
seem to
suggest what I'm doing incorrectly. Any tips would be
appreciated.
Thanks!
Bill.
views.py
from company.crm.models import Project
from django.shortcuts import render_to_response,
get_object_or_404
from django import newforms as forms
def addproject(request):
if request.method == "GET":
#f = ProjectForm()
f = forms.form_for_model(Project)
return render_to_response('crm/addproject.html',
{'theform':
f})
elif request.method == "POST":
pass
else:
pass
addproject.html
<html xmlns="http://www.w3.org/
1999/xhtml" xml:lang="en"
lang="en">
<head>
<title> CRM</title>
<link href="http://localhost/sty
le.css" rel="stylesheet"
type="text/css" />
</head>
<body>
<h1>CRM</h1>
<h2>Add Projects</h2>
{% if theform %}
<form action = "addproject/" method =
"post">
{{ theform.as_p }}
<input type = "submit" />
</form>
{% endif %}
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|