Skip to content

Instantly share code, notes, and snippets.

@jacobian
Created February 25, 2010 16:46
Show Gist options
  • Save jacobian/314712 to your computer and use it in GitHub Desktop.
Save jacobian/314712 to your computer and use it in GitHub Desktop.
#### yabl/authors/views.py --- create view
def create(request):
if request.method == 'POST':
form = AuthorForm(request.POST)
if form.is_valid():
author = form.save()
return redirect("author_detail", author.id)
else:
form = AuthorForm()
return render_to_response("authors/form.html", {
'form': form,
})
#### yabl/templates/authors/form.html, v2
{% extends "base.html" %}
{% block title %}
{% if author %}
Edit {{ author.name }}
{% else %}
Create new author
{% endif %}
{% endblock %}
{% block content %}
<form action="" method="post">
<table>{{ form.as_table }}</table>
<input type=submit>
</form>
{% endblock content %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment