On Fri, Aug 24, 2012 at 9:37 AM, Barry Morrison <[email protected]> wrote: > Code: http://dpaste.org/az8Nb/ > Video http://www.youtube.com/watch?v=XFSb044UkPs&feature=youtu.be > > so first action, I click + which adds new, hitting cancel, takes me back to > the view displaying all the news events > next action, I hit + again, adds new news event...this time I browse for an > image, again, I click cancel, takes me back to the view of all news events, > but you see now an empty news event has been created > next action, I hit + again, add a new image, hit submit. success_url takes > me go the view of all events, this time it created the form I submitted and > created another empty one > > The function in views.py "add_news_item" is not set up in the URL, but it > does support the cancel on the form action. The video posted is using that > view for the URL. With the 'CreateView' in the URL, canceling the form will > create an empty field in the database. > > Any help/guidance would be greatly appreciated!! > > Thanks!
I've not watched your video. I also have no idea what crispy forms are, or what django form attributes are created using that syntax. However… Your model definition allows an empty form to be valid - none of those fields are required AFAICT. Therefore, submitting an empty form using the cancel button is being allowed to proceed. Therefore your check on whether "cancel" was submitted is not working. Put some debug here: http://dpaste.org/az8Nb/#l28 Output what "submit" is, and all values in request.POST. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

