-
Notifications
You must be signed in to change notification settings - Fork 699
Open
Description
Hi guys!
I added a custom dashboard (replacing admin/index.html template). Furthermore i added a custom view (controller).
The problem is the menu (doesn't render). My question is, which is the context that should be send?
My Code:
urls.py
from hospitalizations.views import dashboard
urlpatterns = [
url(r'^$', dashboard, name="dashboard"),
url(r'^hospitalizations/settings$', settings, name='settings'),
url(r'^', include(admin.site.urls)),
]
Dashboard view (controller)
views.py
@staff_member_required
def dashboard(request):
template_name = "admin/index.html"
context = {}
context['title'] = _('Dashboard')
context['site_title'] = site.site_title
context['site_header'] = site.site_header
context['user'] = request.user
context['total_hospitalizations'] = Hospitalization.objects.count()
context['total_patients'] = Patient.objects.count()
context['total_beds'] = Setting.get_total_beds()
context['active_hospitalizations'] = Hospitalization.active_hospitalizations()
context['free_beds'] = Hospitalization.get_free_beds()
context['percentage_occupied_beds'] = Hospitalization.percentage_occupied_beds()
# HERE MAYBE MENU ITEMS?
return render_to_response(template_name, context)
The template:
{% extends "admin/base_site.html" %}
{% load i18n admin_static %}
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.0.4/components/icon.min.css"/>
<link rel="stylesheet" type="text/css" href="{% static "admin/css/epicrisis.css" %}" />
{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block sidebar %}{% endblock %}
{% block header_time %}{% endblock %}
{% block content %}
... all content ...
{% endblock %}
Screenshot:
NOTE: I use django 1.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
