Django for Designers/CRUD: Difference between revisions

Content added Content deleted
imported>Aldeka
imported>Aldeka
Line 374: Line 374:
Reload your development server and your web page, and try creating a bookmark. It should appear right away on the page now!
Reload your development server and your web page, and try creating a bookmark. It should appear right away on the page now!


Try submitting the form with a tag but no URL. <div class="instructor">Nothing happens, right?</div> If you check the server log in your terminal window, you'll see an error message:
Try submitting the form with a tag but no URL. <div class="instructor">Eek.</div> We see the browser try to render the entire page inside the page--because we're redirecting back to the normal index view!


Our index view doesn't properly handle the case where the request is a POST, but the form doesn't validate, and Django noticed this and returned an error. Let's fix this by editing the ''index'' function in ''views.py'' again:
<source lang="bash">
ValueError: The view bookmarks.views.index didn't return an HttpResponse object.
</source>

Eek. Our index view doesn't handle the case where the request is a POST, but the form doesn't validate, and Django noticed this and returned an error. Let's fix this by editing the ''index'' function in ''views.py'' again:


<source lang="python">
<source lang="python">