On Sep 1, 2:53 pm, Nick Day <[EMAIL PROTECTED]> wrote:
> Would somebody be able to provide a simple example of using get_form()
> within the ModelAdmin to retrieve the currently logged-in user?
>
> Thanks in advance,
> Nick
>

Not difficult:

class MyAdmin(admin.ModelAdmin):
    def get_form(self, request, obj=None):
        form = super(MyAdmin, self).get_form(request, obj)
        if request.user.username == 'daniel':
            do_something()
        else:
            do_something_else()
        return form

admin.site.register(MyModel, MyAdmin)
--
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-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