django-admin-filters

django admin override filter_horizontal

左心房为你撑大大i 提交于 2021-02-07 03:53:28
问题 I'm aiming to make an "advanced" filter_horizontal, one with more filters, but I can't seem to find the widget to override. I know it uses the related_widget_wrapper.html, but if I want to add functionalities to it in a clear way, what is the widget to override. For now my backup solution is to do a full javascript solution to prepend it with a dropdown on form load (created from javascript) and make ajax calls to modify the filter...but this seems as an overkill. What i've done so far : #

django admin override filter_horizontal

三世轮回 提交于 2021-02-07 03:52:25
问题 I'm aiming to make an "advanced" filter_horizontal, one with more filters, but I can't seem to find the widget to override. I know it uses the related_widget_wrapper.html, but if I want to add functionalities to it in a clear way, what is the widget to override. For now my backup solution is to do a full javascript solution to prepend it with a dropdown on form load (created from javascript) and make ajax calls to modify the filter...but this seems as an overkill. What i've done so far : #

django admin override filter_horizontal

☆樱花仙子☆ 提交于 2021-02-07 03:49:25
问题 I'm aiming to make an "advanced" filter_horizontal, one with more filters, but I can't seem to find the widget to override. I know it uses the related_widget_wrapper.html, but if I want to add functionalities to it in a clear way, what is the widget to override. For now my backup solution is to do a full javascript solution to prepend it with a dropdown on form load (created from javascript) and make ajax calls to modify the filter...but this seems as an overkill. What i've done so far : #

Django admin add custom filter

梦想与她 提交于 2020-01-13 07:38:08
问题 i'm using django 1.10 and I need to display data and create a filter based on a value from a different model(which has a foreign key referencing my model that is used on the admin template) These are my 2 models: This one is used to generate the template: class Job(models.Model): company = models.ForeignKey(Company) title = models.CharField(max_length=100, blank=False) description = models.TextField(blank=False, default='') store = models.CharField(max_length=100, blank=True, default='')

Django 1.4 User Admin list_filter using UserProfile field

瘦欲@ 提交于 2020-01-03 17:17:09
问题 EDIT: I updated the code to reflect one mistake in the queryset filter, where I had user__user_type, has been replaced with the correct userprofile__user_type. I'm using Django 1.4, and I understand there's a new feature to create custom list_filters for the admin, that replaced the FilterSpec API. I've read countless SO posts about creating custom admin list_filters, but I'm still stuck. My use case is for a list_filter for my User objects that's referencing a field in the UserProfile Model.

django ForeignKey model filter in admin-area?

风格不统一 提交于 2019-12-23 03:51:34
问题 Hi I need really very very simple example. First my models: #This my student models from django.db import models SEX_CHOICES= ( ('M', 'Male'), ('F', 'Female'), ) class Students(models.Model): student_name = models.CharField(max_length=50) student_sex = models.CharField(max_length=8, choices=SEX_CHOICES) student_city = models.Charfield(max_length=50) student_bio = models.TextField() def __unicode__(self): return self.student_name O.K. Let see my ClassRooms Model. #This my ClassRooms models

How can I ask for user input with an action in django admin?

↘锁芯ラ 提交于 2019-12-23 02:32:56
问题 In my code, I am writing an action for grouping, I would like to ask the user how many people would they like per group and then respond with an alert box that says something along the lines of you have 4 groups, based on user input. How do I do this in django admin, how do I create some kind of pop up that asks for the amount of people that they would like to put in a group? (I'm trying to achieve this with an action) admin.py: Def howmany (modeladmin, request, queryset): people = queryset

Auto increament the invoice number in django backend for new invoice

主宰稳场 提交于 2019-12-21 04:39:29
问题 I want to auto increament the invoice number which is 3 digits char and 4 digits number. class Invoice: invoice_no = models.CharField(max_length=500, null=True, blank=True, validators=[RegexValidator(regex='^[a-zA-Z0-9]*$',message='Invoice must be Alphanumeric',code='invalid_invoice number'),]) I register this model in backend. But now when i click on create invoice in admin the invoice should be auto filled. When i again click on create new invoice in admin, the invoice_number should be

Filtering select field options in django-admin

北城以北 提交于 2019-12-13 02:48:14
问题 I am using django-xadmin for one of my project which is based on django-admin. I need help in a case. Suppose, i have two models like this - class Foo(models.Model): CHOICES = ( ('a', 'Option A'), ('b', 'Option B') ) status = models.CharField(max_length=10, choices=CHOICES) class Bar(models.Model): foo = models.ForeignKey(Foo) remarks = models.CharField(max_length=200) In xadmin, when i try to add Bar via default form provided by xadmin, in the select Field Foo , all Foos (both with Option A

Django: Filtering by %filter% not allowed

旧时模样 提交于 2019-12-12 07:25:00
问题 I inherited a Django v1.2.4 application and am in the process of adding several fixes and improvements. During this process, I suddenly began to encounter the following error: SuspiciousOperation at /hometeam/admin/players/playeryear/ Filtering by team__season__season_start_date__year not allowed This error is displayed in the admin interface popups when I try to select an item for an input field (accessed via the magnifying glass associated with the fields). I have debugging turned on, but I