Answer the question
In order to leave comments, you need to log in
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.
urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^admin/otchet/$', statot, name='отчет')
]
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question