Answer the question
In order to leave comments, you need to log in
How in the standard User to make a similar list as the choice of "Group"?
I need to make a similar list as "Groups" for a user. Only there will be a list of stores. I'm new to Django, I did something according to the documentation that didn't work. Can you provide an example code? Thanks
Answer the question
In order to leave comments, you need to log in
for starters, I would not redefine the user model, but simply expand it like this
, something like :
models.py
from django.contrib.auth.models import User
class Customer(models.Model):
user = models.OneToOneField(User)
shops = models.ManyToManyField(Shops)
class CustomerInline(admin.StackedInline):
model = Customer
fk_name = 'user'
can_delete = False
filter_horizontal = ('shops', )
class CustomerAdmin(UserAdmin):
inlines = (CustomerInline, )
admin.site.unregister(User)
admin.site.register(User, CustomerAdmin)
It's not very clear, but probably like this:
1) Redefine the user
2) Add the M2M store field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question