pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.79k stars 1.57k forks source link

Unable to use theme from Bootswatch #1286

Closed scottydelta closed 8 years ago

scottydelta commented 8 years ago

As per suggestion from comment: https://github.com/flask-admin/flask-admin/pull/1016#issuecomment-134437376, I made the changes but the theme doesnt get applied properly:

{% extends 'admin/base.html' %}

{% block head_tail %}
  {{ super() }}
    {% set bootswatch_theme = 'cyborg' %}
    {% set bootswatch_version = '3.3.6' %}
    <link href="//netdna.bootstrapcdn.com/bootswatch/{{ bootswatch_version }}/{{ bootswatch_theme }}/bootstrap.min.css" rel="stylesheet" >
{% endblock %}

admin = Admin(name='Tweet Tracker',base_template='custom_admin.html', template_mode='bootstrap3' ,url='/', index_view=ProjectView(Project, db.session, url='/admin'))

image

Deleting this line admin/base.html solves the issue.

image

mrjoes commented 8 years ago

You can always override head_css block and get rid of the base CSS file.

scottydelta commented 8 years ago
{% extends 'admin/base.html' %}

{% block head_css %}
  {{ super() }}
    {% set bootswatch_theme = 'lumen' %}
    {% set bootswatch_version = '3.3.6' %}
    <link href="//bootswatch.com/{{ bootswatch_theme }}/bootstrap.min.css" rel="stylesheet" >
{% endblock %}

^ doesnt solve the issue, is there any thing that I need to use explicitly to override the block?

mrjoes commented 8 years ago

Remove super() statement- it makes your block inherit contents of original head_css.

    {% block head_css %}
        {% set bootswatch_theme = 'lumen' %}
        {% set bootswatch_version = '3.3.6' %}
        <link href="//bootswatch.com/{{ bootswatch_theme }}/bootstrap.min.css" rel="stylesheet" >
        <link href="{{ admin_static.url(filename='admin/css/bootstrap3/admin.css', v='1.1.1') }}" rel="stylesheet">
        <style>
        body {
            padding-top: 4px;
        }
        </style>
    {% endblock %}
scottydelta commented 8 years ago

It worked nicely, thank you @mrjoes