M
M
Mooris2017-05-11 23:41:17
Django
Mooris, 2017-05-11 23:41:17

Display your page in django admin?

Hello, I need help. How to "correctly" display your page in the django admin, in the admin.py itself? The page added to urls.py by link goes like this, but it can’t be displayed through ModelAdmin.get_urls():
Example, view as a Users and groups block, only instead of users or group, my name and link.
1b811a7e228842f292807010dcacc6d1.PNG
urls.py

urlpatterns = [ 
url(r'^admin/', admin.site.urls), 
url(r'^admin/otchet/$', statot, name='отчет') 
]

views.py
def statot(request): 
uslugi = Uslugi.objects.all() 
form = UslugiFilterForm(request.GET) 

if form.is_valid(): 
if form.cleaned_data["start_date"]: 
uslugi = uslugi.filter(data_zakaza__gte=form.cleaned_data["start_date"]) 
if form.cleaned_data["end_date"]: 
uslugi = uslugi.filter(data_zakaza__lte=form.cleaned_data["end_date"]) 

field_name_sum = uslugi.aggregate(Sum('price')).get('price__sum', 0.00) 
kolab = uslugi.count() 
print(form) 
return render(request, 'clients/statot.html', {'uslugi': uslugi, "form": form, "field_name_sum": field_name_sum, "kolab": kolab})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2017-05-12
@Mooris

I think you can't do without redefining the template django/contrib/admin/templates/admin/index.htmlin your project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question