Can't get ModelForm to show in template - Django -
i have been trying form show 8hours no luck. have read every question on site , others , didn't resolve problem.
models.py
class quote(models.model): first_name = models.charfield(verbose_name=('first name'), max_length=35, null=true,blank=true) last_name = models.charfield(verbose_name=_('last name'), max_length=35,null=true,blank=true)
forms.py
class quoteform(forms.modelform): class meta: model = quote fields = '__all__'
views.py
def get_quote(request): if request.method == 'post': form = quoteform(request.post or none) if form.is_valid(): #form.save() # process data in form.cleaned_data required # ... # redirect new url: return httpresponseredirect('/testing/thank-you/') else: form = quoteform() return render(request, 'request-for-quote.html', {'form': form})
urls.py
urlpatterns = patterns ('', url(r'^testing/request-for-quote/','lsr.views.get_quote', name='get_quote'),)
request-for-quote.html
{% extends "base.html" %} {% load cms_tags staticfiles sekizai_tags menu_tags %} {% load i18n %} {% block content %} <form method="post" action=""> {% csrf_token %} {{ form }} <button type="submit">{% trans "request quote" %}</button></form> {% endblock content %}
when use shell commands display form shows me html , renders in console. wont display in html template. doing wrong? (edit) forgot mention if change action "get_quote" , click on button redirect thank page above. won't show form fields.
shell commands
>>>from lsr.forms import quoteform >>>from lsr.models import quote >>>form = quoteform() >>>form.as_p()
help resolving appreciated. yes i'm new django & python.
update: believe views.py not getting called. other 2 defs have 404 , 500 view turned debug off in settings , got bad request instead of custom 404 pages. i'm looking @ how django-cms , django forms work together. i'm going try this , let know if worked.
Comments
Post a Comment