Discussion:
ManyToMany widget in admin - the "user - permission way.."
Anders
2009-02-27 13:21:31 UTC
Permalink
Hi.

In the users admin of Django admin there is a nice way of selecting
permissions for each user by adding and removing permissions from a
list of available permissions. (<div class="selector">)

I have models set up similar to the ones used for users and
permissions, but I am not able to get the nice "select from list on
left side and add to right side"-widget. I only get a normal multi-
select box.

My models could look like this:

class Interest(models.Model):
name= models.CharField(max_length=255)

class Person(models.Model):
name= models.CharField(max_length=255)
.....
interests = models.ManyToManyField(Interest)

How can I get the fancy manytomany-widget in the Person admin?

thanks

Anders

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Daniel Roseman
2009-02-27 14:14:13 UTC
Permalink
Post by Anders
Hi.
In the users admin of Django admin there is a nice way of selecting
permissions for each user by adding and removing permissions from a
list of available permissions. (<div class="selector">)
I have models set up similar to the ones used for users and
permissions, but I am not able to get the nice "select from list on
left side and add to right side"-widget. I only get a normal multi-
select box.
    name= models.CharField(max_length=255)
    name= models.CharField(max_length=255)
    .....
    interests = models.ManyToManyField(Interest)
How can I get the fancy manytomany-widget in the Person admin?
thanks
Anders
Specify a 'filter-horizontal' tuple in the admin model declaration:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#filter-horizontal
--
DR.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Allan Nava
2017-11-28 10:16:47 UTC
Permalink
Il giorno venerdì 27 febbraio 2009 15:14:13 UTC+1, Daniel Roseman ha
Post by Daniel Roseman
Post by Anders
Hi.
In the users admin of Django admin there is a nice way of selecting
permissions for each user by adding and removing permissions from a
list of available permissions. (<div class="selector">)
I have models set up similar to the ones used for users and
permissions, but I am not able to get the nice "select from list on
left side and add to right side"-widget. I only get a normal multi-
select box.
name= models.CharField(max_length=255)
name= models.CharField(max_length=255)
.....
interests = models.ManyToManyField(Interest)
How can I get the fancy manytomany-widget in the Person admin?
thanks
Anders
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#filter-horizontal
--
DR.
I have this error:

Unhandled exception in thread started by <function
check_errors.<locals>.wrapper at 0x7f2fa8d646a8>

Traceback (most recent call last):

File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py",
line 228, in wrapper

fn(*args, **kwargs)

File
"/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py",
line 125, in inner_run

self.check(display_num_errors=True)

File
"/usr/local/lib/python3.5/dist-packages/django/core/management/base.py",
line 405, in check

raise SystemCheckError(msg)

django.core.management.base.SystemCheckError: *SystemCheckError: System
check identified some issues:*


ERRORS:

*<class 'bootcamp.groups_manager.admin.GroupAdmin'>: (admin.E001) The value
of 'raw_id_fields' must be a list or tuple.*

this is my admin.py

from django.contrib import admin

from bootcamp.groups_manager.models import Group, Member, GroupType,
GroupEntity, GroupMember, GroupMemberRole
from guardian.admin import GuardedModelAdmin

# With object permissions support
class GroupAdmin(GuardedModelAdmin):
#fields = ('group_members', 'django_group')
raw_id_fields = ('group_members')
#search_fields = ('group_members', 'django_group')
pass

#admin.site.register(models.Group)
admin.site.register(Group, GroupAdmin)
admin.site.register(Member)
admin.site.register(GroupType)
admin.site.register(GroupEntity)
admin.site.register(GroupMember)
admin.site.register(GroupMemberRole)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/951cd1bc-5888-4d4f-b92b-fc855cb963a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matemática A3K
2017-11-29 04:54:43 UTC
Permalink
Post by Allan Nava
Unhandled exception in thread started by <function
check_errors.<locals>.wrapper at 0x7f2fa8d646a8>
File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py",
line 228, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/core/
management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py",
line 405, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: *SystemCheckError: System
check identified some issues:*
*<class 'bootcamp.groups_manager.admin.GroupAdmin'>: (admin.E001) The
value of 'raw_id_fields' must be a list or tuple.*
this is my admin.py
Because for making a tuple of one element you need a trailing comma,
Post by Allan Nava
from django.contrib import admin
from bootcamp.groups_manager.models import Group, Member, GroupType,
GroupEntity, GroupMember, GroupMemberRole
from guardian.admin import GuardedModelAdmin
# With object permissions support
#fields = ('group_members', 'django_group')
raw_id_fields = ('group_members', )
#search_fields = ('group_members', 'django_group')
pass
#admin.site.register(models.Group)
admin.site.register(Group, GroupAdmin)
admin.site.register(Member)
admin.site.register(GroupType)
admin.site.register(GroupEntity)
admin.site.register(GroupMember)
admin.site.register(GroupMemberRole)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/django-users/951cd1bc-5888-4d4f-b92b-fc855cb963a2%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/951cd1bc-5888-4d4f-b92b-fc855cb963a2%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BFDnhJAae_MaO6j2RaA1%2B3Ka%3DqdYP_DFcH4F3iUYiVARchimA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...