Django admin add related object doesn't open popup window?

后端 未结 2 1434
暖寄归人
暖寄归人 2021-01-05 16:47

The django-admin app is supposed to open a popup window when I try to create a related object. For example, clicking the green plus button here:

Should brin

相关标签:
2条回答
  • 2021-01-05 17:00

    I wasn't able to produce a minimal example of what was going on, but it is fixed now. Essentially, I did the following:

    1. Upgraded to Django 1.8.6 .
    2. Ran python manage.py collectstatic (as suggested in https://community.webfaction.com/questions/18544/there-is-not-popup-window-for-one-to-many-relationship-with-djangos-admin-v18)

    So in the end I'm not sure what the issue was. I hope this is useful to someone else.

    If someone else comes up with a more complete answer, which involves a minimal example and with an explanation of what was going on, I'll be glad to change the accepter answer.

    0 讨论(0)
  • 2021-01-05 17:01

    This appears to be a reproducible error in 1.9.3. Testing it myself I setup a new project using the latest Django (1.9.3) and ran into the same error. Below is the fix. It seems to also work with 1.9.1 I will report to Django team now.

    +++ b/contrib/admin/templates/admin/related_widget_wrapper.html
    @@ -10,7 +10,7 @@
             </a>
             {% endif %}
             {% if can_add_related %}
    -        <a class="related-widget-wrapper-link add-related" id="add_id_{{ name }}"
    +        <a class="related-widget-wrapper-link add-another" id="add_id_{{ name }}"
                 href="{{ add_related_url }}?{{ url_params }}"
                 title="{% blocktrans %}Add another {{ model }}{% endblocktrans %}">
                 <img src="{% static 'admin/img/icon-addlink.svg' %}" alt="{% trans 'Add' %}"/>
    
    0 讨论(0)
提交回复
热议问题