-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved templates to make easier to customize them for integration w… #478
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to super seems unnecessary as the block in base is empty so won't pull anything in?
@marksweb it's done so that customization can be done in one place - the explorer/base.html. Otherwise, you would have to override all 4 templates: query_list.html, query.html, play.html and qyertlog_list.html. Well here is my explorer/base.html that works with the proposed changes: {% extends "explorer/base.html" %}
{% block extrastyle %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
{% endblock %}
{% block sql_explorer_navlinks %}
<li class="nav-item" id="admin:index">
<a id="admin-link"
class="nav-link"
href="{% url 'admin:index' %}"
data-toggle="tooltip"
title="Research Funding Data Administration"
>
<i class="fas fa-radiation"></i> RFDA Admin</a>
</li>
{% endblock %}
{% block sql_explorer_scripts %}
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip()
});
</script>
{% endblock %} and this is how it gets rendered: Without them, I would have to override almost the entire base.html. |
Actually, it was possible to refactor and dry a bit the templates and move the sql_explorer_navlinks block to the base.html. Assuming that "django.template.context_processors.request" isn't used I populate the context in the mixin with the current view name. |
@nad2000 Ok now I get what you're doing so that makes sense 👍 I'll have a proper look at this over the weekend hopefully 🤞 |
I'm overriding A possible workaround is to just copy-paste all the existing nav bar links, and add my two to the end, but it seems like Django's I frankly didn't follow the context processor part of the conversation (beyond a vague understanding of what a context processor is), but could that have something to do with this? Or have I just done something boneheaded? There is only this single file in {# ourapp/templates/explorer/base.html #}
{% block sql_explorer_navlinks %}
{{ block.super }}
<li><a href="{{ DEFAULT_URL }}/explorer/schema/readonly">Schema</a></li>
<li><a href="#">|</a></li>
<li><a href="{{ DEFAULT_URL }}/admin/">Back to {{ SITE_TITLE }}</a></li>
{% endblock %} I'm currently using Update: had nothing at all to do with this PR—my bad!We did this, and the fix was this: diff --git a/ourapp/settings.py b/ourapp/settings.py
index 15e8803..df73912 100644
--- a/ourapp/settings.py
+++ b/ourapp/settings.py
@@ -65,7 +65,9 @@ ROOT_URLCONF = "ourapp.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
- "DIRS": [os.path.join(BASE_DIR, "ourapp/templates")],
+ # no need to specify additional 'DIRS': [] here; see
+ # https://docs.djangoproject.com/en/3.2/topics/templates/#configuration
+ # and https://stackoverflow.com/a/75021565/785213
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [ |
The feature (the template block sql_explorer_navlinks) was removed with dc2b783 :( |
Fix for #477: