Answer the question
In order to leave comments, you need to log in
What are the options for solving questions about filters in Django?
According to the TK, there are 2 tasks that need to be solved. How to solve it seems very vague.
1) The ability to select several elements in the Django admin panel, and somewhere show the result of processing the data of the selected elements (well, if it’s easier, show the sum of the fields of all the selected elements).
It seems that here somehow through Actions it is necessary to exit, but it is not clear where the summation result could be displayed.
2) You need to display data from the table in the Django admin panel for a certain period (i.e. from one date to another). Naturally, the dates must be entered by the user. Sorting by months in Django is already there, but it’s not clear how and where to add a panel for entering dates, and subsequent filtering.
Can anyone suggest options? I am using Django 1.4 + admin_tools
Answer the question
In order to leave comments, you need to log in
The ability to select several elements in the Django admin panel, and somewhere show the result of processing the data of the selected elements (well, if it’s easier, show the sum of the fields of all the selected elements).
It seems that here it is necessary to exit somehow through Actions, but it is not clear where the result of the summation could be displayed.
def action_name(request, queryset):
"""
В queryset попадут выбранные модели.
"""
You need to display data from the table in the Django admin panel for a certain period (i.e. from one date to another). Naturally, the dates must be entered by the user. Sorting by months in Django is already there, but it’s not clear how and where to add a panel for entering dates, and subsequent filtering.
Templates can not be touched, everything has already been invented before us:
class MyAppAdmin(admin.ModelAdmin):
...
class Meta:
js = ['/static/my_app/js/sum_fields.js']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question