You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm following the admin.py example and can't seem to get select2 working with django-suit. Considering the following admin.py config any ideas on what I am missing? This is for a tags module I'm putting together to add searchability based on tagged content to a model called accounts. Would be useful in a bunch of other areas on my app but this is the quickest to work on currently. Screenshot of my accounts form...showing the legacy select method.
admin.py
from django.contrib import admin
from accounts.models import *
from inventory.models import *
from services.models import *
from tags.models import *
from import_export.admin import ImportExportModelAdmin
from import_export import resources
from django_select2 import *
from django.forms import TextInput, ModelForm, Textarea, Select
TAGS
class TagChoices(AutoModelSelect2Field):
queryset = tag.objects
search_fields = ['tag', ]
I'm following the admin.py example and can't seem to get select2 working with django-suit. Considering the following admin.py config any ideas on what I am missing? This is for a tags module I'm putting together to add searchability based on tagged content to a model called accounts. Would be useful in a bunch of other areas on my app but this is the quickest to work on currently. Screenshot of my accounts form...showing the legacy select method.
admin.py
from django.contrib import admin
from accounts.models import *
from inventory.models import *
from services.models import *
from tags.models import *
from import_export.admin import ImportExportModelAdmin
from import_export import resources
from django_select2 import *
from django.forms import TextInput, ModelForm, Textarea, Select
TAGS
class TagChoices(AutoModelSelect2Field):
queryset = tag.objects
search_fields = ['tag', ]
class TagsForm(ModelForm):
tag_verbose_name = tag._meta.verbose_name
country = TagChoices(
widget=AutoHeavySelect2Widget(
select2_options={
'width': '220px',
'placeholder': 'Lookup %s ...' % tag_verbose_name
}
)
)
ACCOUNT
class AccountsGeneral(admin.TabularInline):
model = account
suit_classes = 'suit-tab suit-tab-general'
class AccountsServices(admin.StackedInline):
model = service
suit_classes = 'suit-tab suit-tab-services'
extra = 0
can_delete = False
class AccountsNotes(admin.TabularInline):
model = note
suit_classes = 'suit-tab suit-tab-general'
extra = 0
can_delete = False
class AccountsAdmin(admin.ModelAdmin):
form = TagsForm
list_display = ('id', 'name', 'type', 'phone', 'address1', 'address2', 'city', 'state', 'zip', 'status')
list_display_links = ('id', 'name', 'type', 'phone', 'address1', 'address2', 'city', 'state', 'zip', 'status')
list_filter = ('type', 'city', 'state', 'status')
search_fields = ['id', 'name', 'phone', 'address1']
inlines = (AccountsServices, AccountsNotes,)
fieldsets = [
(None, {
'classes': ('suit-tab suit-tab-general',),
'fields': ['name', 'phone', 'type', 'status', 'tags',]
}),
('Billing Address:', {
'classes': ('suit-tab suit-tab-general',),
'fields': ['address1', 'address2', 'city', 'state', 'zip', 'url',]
}),
('Billing Info:', {
'classes': ('suit-tab suit-tab-general',),
'fields': ['parent_flag', 'parent_account','billid',]
}),
(None, {
'classes': ('suit-tab suit-tab-inventory',),
'fields': []
}),
(None, {
'classes': ('suit-tab suit-tab-services',),
'fields': []
}),
]
suit_form_tabs = (('general', 'General'), ('network', 'Network'), ('services', 'Services'),)
The text was updated successfully, but these errors were encountered: