Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

djangos-select2 showing wrong form #7

Open
th3goose opened this issue Sep 15, 2014 · 0 comments
Open

djangos-select2 showing wrong form #7

th3goose opened this issue Sep 15, 2014 · 0 comments

Comments

@th3goose
Copy link

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'),)

c7829f38-3bbc-11e4-8188-8327d216b67c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant