admin.py
----
    def get_form(self, request, obj=None, **kwargs):
        self._request = request
        return super(PaginaOptions, self).get_form(request, obj=obj,
**kwargs)

    def queryset(self, request):
        """
        Method of ModelAdmin, override it if you want to change
        list of objects visible by the current user.
        """
        mgr = self.model._default_manager
        if request.user.is_superuser:
            return mgr.all()
        return mgr.filter(grupo__in=request.user.groups.all())

    def formfield_for_dbfield(self, db_field, **kwargs):
        field = super(PaginaOptions,
self).formfield_for_dbfield(db_field, **kwargs)
        if db_field.name == 'grupo':
            my_choices = [('', '---------')]

my_choices.extend(self._request.user.groups.all().values_list('id','name'))
            field.choices = my_choices
        return field

On Sep 16, 1:32 pm, Bruno Gomes <[EMAIL PROTECTED]> wrote:
> I have the following question: I'm using the "def
> queryset(self,request):" to change the list of results that the admin
> offers me from the object listenig.
>
> I would like to know if I can change the list of results that is
> generated for a combo list, in the time of reg editioning... but I do
> not want to do this by changing templantes, but only overwriting a
> method that returns the query to this object using the same standard
> template administration.
>
> My ending goal is to use the model to create groups of Auth to create
> regs with levels of permission to users group in my modules.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to