1👍
✅
Probably you’re right and you were passing request
instead of request.POST
, reqest.GET
or request.REQUEST
to the constructor of your form. See the doc on how to use forms:
def contact(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
form = ContactForm() # An unbound form
return render_to_response('contact.html', {
'form': form,
})
1👍
Two problems that I can see. The easy one being that you can simply replace this line:
context['form'] = createNewStoryForm(self.request)
with
context['form'] = StoryForm(request.POST, request.FILES)
Finally shouldn’t this:
class StoryShowView(ListView):
model = StoryForm
Be:
class StoryShowView(ListView):
model = Story
- [Answered ]-Zinnia Templates for List and detail view
- [Answered ]-DRF Custom Permission not blocking the view
- [Answered ]-Can you put static folder in project root, rather than app root?
- [Answered ]-How to setup a VPS with Django, Nginx, Gunicorn, Postgres and then properly deploy a Django application to it?
- [Answered ]-Python Django populate() isn't reentrant
Source:stackexchange.com