Django. Customize action for model
<p>I need to edit the "Add Object" action in the admin. It needs to redirect the user to a custom cause the logic required for adding objects is too complex to be managed in the admin. So, how do I make this possible? i.e:</p>

<p><a href="http://i.stack.imgur.com/ChoP7.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/ChoP7.jpg" alt="enter image description here"></a></p>

<p>The picture shows a django-suit admin, but the question is the same. How can I make that button redirect to a custom url? Or, how can I create a similar button that redirects to a custom url (I could disable the default create and leave only the custom button).</p>

<p>Override <code>change_list_template</code> html, the block <code>object-tools-items</code>. It's where add button is placed.</p>

<pre><code>class MyModelAdmin(admin.ModelAdmin):
    change_list_template = 'change_list.html'
</code></pre>

<p>In your <code>change_list.html</code></p>

<pre><code>{% extends "admin/change_list.html" %}
{% load i18n admin_static admin_list %}

{% block object-tools-items %}
        {% if has_add_permission %}
        &lt;li&gt;
          &lt;a href="your/custom/url" class="addlink"&gt;
            {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
              &lt;/a&gt;
        &lt;/li&gt;
        {% endif %}
{% endblock %}
</code></pre>

<p>You need to add your new html in any dir that is included on <code>TEMPLATE_DIRS</code> options. But, you should do it inside your model's app. </p>

<pre><code>-app
    -templates
         -admin
              change_list.html
</code></pre>

<p>Add above dir in TEMPLATE DIRS paths.</p>

python django django-admin