john
2010-02-13 23:30:03 UTC
Hi, I just had fun creating a new Custom Admin Form to sort a
ManyToMany field by ABC order (why isnt it in ABC order by default on
the "def __unicode__" item?) It works great, but now the Green Plus
Sign to add more items to the list is missing, where did it go? I
guess its not enabled by default?
Does anyone know where I can search on this more, and/or what this
Green Plus Sign is called? Is this just an extra command that needs
to be entered or do I have to reinvent the wheel to get this back to
working?
thanks!
This is the Green Plus Sign im looking for (even though this is for a
ForeignKey field): Loading Image...
My code if you want to take a look (sorry that a lot of it has to be
redacted):
# more xyz/admin.py
from abc.xyz.models import Items,Stuff
from django.contrib import admin
from django import forms
class StuffForm(forms.ModelForm):
item=forms.ModelMultipleChoiceField(queryset=Items.objects.order_by('item'))
class Meta:
model=Stuff
class StuffAdmin(admin.ModelAdmin):
exclude=('items',)
form=StuffForm
admin.site.register(Stuff, StuffAdmin)
# more xyz/models.py
class Items(models.Model):
item=models.CharField(max_length=100)
def __unicode__(self):
return self.item
class Stuff(models.Model):
items=models.ManyToManyField(Items)
ManyToMany field by ABC order (why isnt it in ABC order by default on
the "def __unicode__" item?) It works great, but now the Green Plus
Sign to add more items to the list is missing, where did it go? I
guess its not enabled by default?
Does anyone know where I can search on this more, and/or what this
Green Plus Sign is called? Is this just an extra command that needs
to be entered or do I have to reinvent the wheel to get this back to
working?
thanks!
This is the Green Plus Sign im looking for (even though this is for a
ForeignKey field): Loading Image...
My code if you want to take a look (sorry that a lot of it has to be
redacted):
# more xyz/admin.py
from abc.xyz.models import Items,Stuff
from django.contrib import admin
from django import forms
class StuffForm(forms.ModelForm):
item=forms.ModelMultipleChoiceField(queryset=Items.objects.order_by('item'))
class Meta:
model=Stuff
class StuffAdmin(admin.ModelAdmin):
exclude=('items',)
form=StuffForm
admin.site.register(Stuff, StuffAdmin)
# more xyz/models.py
class Items(models.Model):
item=models.CharField(max_length=100)
def __unicode__(self):
return self.item
class Stuff(models.Model):
items=models.ManyToManyField(Items)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com.
To unsubscribe from this group, send email to django-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.