Adds page title to model create page

This commit is contained in:
Chris Lawlor 2013-05-20 09:06:28 -04:00
parent b0abe58121
commit 32f5e4802f
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})