Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread Michał Sawicz
Dnia 2011-07-06, śro o godzinie 14:40 -0700, galgal pisze: > Full code: > class UserProfileAdmin(UserAdmin): > inlines = [UserProfileInline,] > list_filter = ('userprofile__type','userprofile__cities',) > search_fields = ['userprofile__type', 'username', > 'userprofile__cities__name',

Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread galgal
Environment: Request Method: GET Request URL: http://localhost:8000/admin/auth/user/2/ Django Version: 1.3 Python Version: 2.7.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages',

Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread Michał Sawicz
Dnia 2011-07-06, śro o godzinie 13:16 -0700, galgal pisze: > Any idea how to overwrite it dynamically? > def get_form(self, request, obj=None, **kwargs): > self.exclude = ('user_permissions',) > return super(UserProfileAdmin, self).get_form(request, > obj=None, **kwargs) > Throws:

Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread galgal
Any idea how to overwrite it dynamically? def get_form(self, request, obj=None, **kwargs): self.exclude = ('user_permissions',) return super(UserProfileAdmin, self).get_form(request, obj=None, **kwargs) Throws: TemplateSyntaxError at /admin/auth/user/2/ Caught KeyError while

Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread Michał Sawicz
Dnia 2011-07-06, śro o godzinie 00:31 -0700, galgal pisze: > Ok but like I said in previous post, exclude = ('groups',) etc doesn't > work :/ It does, you just need to override both exclude / fields _and_ fieldsets. The exception you've mentioned resulted from the fact that you've excluded the

Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread galgal
Ok but like I said in previous post, exclude = ('groups',) etc doesn't work :/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-exygvWEN9UJ. To post to

Re: Django admin - how to hide some fields in User edit?

2011-07-05 Thread Michał Sawicz
Dnia 2011-07-05, wto o godzinie 15:13 -0700, galgal pisze: > I made it in that way, and it works: Remember that you need to exclude the field from the form, too, if you don't want malicious attempts to inject the groups to work. -- Michał (Saviq) Sawicz signature.asc

Odp: Re: Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-05 Thread galgal
I made it in that way, and it works: def get_fieldsets(self, request, obj=None): if obj: if request.user.id == 1: return self.declared_fieldsets else: if obj.get_profile().type==1: return (

Re: Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread Michał Sawicz
Dnia 2011-07-04, pon o godzinie 15:20 -0700, galgal pisze: > Yes I read it. exclude = ('groups',) throws: > Caught KeyError while rendering: "Key 'groups' not found in Form" That's because the stock UserAdmin defines fieldsets in which 'groups' is a field, you need to modify the fieldsets, too.

Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
Yes I read it. exclude = ('groups',) throws: Caught KeyError while rendering: "Key 'groups' not found in Form" -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread Michał Sawicz
Dnia 2011-07-04, pon o godzinie 15:13 -0700, galgal pisze: > That's my code now - how to hide groups for example? Have you tried reading the Django Admin docs? [1] [2] [1] https://docs.djangoproject.com/en/1.3/ref/contrib/admin/ [2]

Odp: Re: Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
That's my code now - how to hide groups for example? admin.site.unregister(User) class UserProfileInline(admin.StackedInline): model = UserProfile filter_horizontal = ('cities',) extra = 1 max_num = 1 filter_horizontal = ('cities',) class UserProfileAdmin(UserAdmin):

Re: Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread Michał Sawicz
Dnia 2011-07-04, pon o godzinie 14:19 -0700, galgal pisze: > I'm rather searchung the way to do that in my admin.py file not in > core files. Obviously the proposal was... fundamentally wrong. Create your own UserAdmin, unregister the one registered by django.contrib.admin and register your

Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
I'm rather searchung the way to do that in my admin.py file not in core files. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sZ83LDHBIC8J. To post to

Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread leo
try to modify this file "Python26\Lib\site-packages\django\contrib\auth\admin.py" find this line (_('Groups'), {'fields': ('groups',)}), comment this line you will remove groups On 2011-7-5 4:59, galgal wrote: How can I hide fields in admin User edit? Mainly I want to hide

Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
How can I hide fields in admin User edit? Mainly I want to hide permissions and groups selecting in some exceptions, but exclude variable doesn't work :/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit