form to override autocomplete organization changed

This commit is contained in:
asamihassan 2022-03-28 10:46:30 +05:00
parent e8f8ee8ad3
commit 9dc9daa1e0
1 changed files with 14 additions and 9 deletions

View File

@ -9,19 +9,24 @@ from django.http import HttpResponse
import csv
from django import forms
from django.contrib.admin.widgets import AutocompleteSelect
class autocomplete_fields_form(forms.ModelForm):
class autocomplete_fields_form(forms.ModelForm):
"""This form overrides autocomplete
organization field for Person class
def __init__(self, *args, **kwargs):
super(autocomplete_fields_form, self).__init__(*args, **kwargs)
# self.fields['organization'].label = 'My new label'
class Meta:
widgets = {
'my_field': AutocompleteSelect(
attrs={'data-dropdown-auto-width': 'true'}
model = Person
fields = '__all__'
'organization': forms.Select(attrs={'style': 'width:750px'})
def download_csv(modeladmin, request, queryset):
name = queryset[0].__class__.__name__