Merge pull request #117 from chrislawlor/feature/model-create-page-title

Adds page title to model create page
This commit is contained in:
Daniel Greenfeld 2013-05-20 10:37:47 -07:00
commit 2b4449a769
2 changed files with 6 additions and 0 deletions

View file

@ -2,6 +2,7 @@
{% block content %}
<h3>Add {{ model|capfirst }}</h3>
<form method="post">
{% csrf_token %}
{{ form.as_p }}

View file

@ -125,6 +125,11 @@ class ModelAddFormView(AdminModel2Mixin, generic.CreateView):
default_template_name = "model_add_form.html"
permission_type = 'add'
def get_context_data(self, **kwargs):
context = super(ModelAddFormView, self).get_context_data(**kwargs)
context['model'] = self.get_model()._meta.verbose_name
return context
def get_success_url(self):
view_name = 'admin2:{}_{}_detail'.format(self.app_label, self.model_name)
return reverse(view_name, kwargs={'pk': self.object.pk})