Can I edit the Django administration screen to display my html?

前端 未结 1 1433
夕颜
夕颜 2020-12-20 05:39

Is there a way to display html data on a specific page in the django administrator feature?

For example, let\'s say I have a programming-language Model, and for each

相关标签:
1条回答
  • 2020-12-20 05:47

    Override admin change_form.html for your model with

    {% extends "admin/change_form.html" %}
    
    {% block after_related_objects %}
        {# put your html here #}
    {% endblock %}
    

    (Django 1.8 note) Make sure you have specified 'DIRS' key in TEMPLATES dict (settings.py)

    'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
        ],
    

    templates/

    ----admin/

    --------app_name/

    ------------modelname/

    ----------------change_form.html

    0 讨论(0)
提交回复
热议问题