Almost resolved with this code:

class EntryForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super(EntryForm, self).__init__(*args, **kwargs)
        self.fields['authorcategory'].queryset =
AuthorCategory.objects.filter(
            author=2)

class EntryAdmin(admin.ModelAdmin):
    form = EntryForm


Just need to get:

AuthorCategory.objects.filter(
            author=request.user)

instead of

AuthorCategory.objects.filter(
            author=2

On Aug 25, 4:28 pm, Alsond <fernand.als...@gmail.com> wrote:
> So, how to see AuthorCategory items filtered by currently loged in
> user in admin ?
>
> On Aug 25, 3:54 pm, Alsond <fernand.als...@gmail.com> wrote:
>
>
>
> > System needs to types of categories. First one is used by all. Second
> > one is created by author.
> > In admin on new Entry I would like tu see all items from Category
> > and in AuthorCategory would like to see AuthorCategory items where
> > User is current user.
>
> > from django.contrib.auth.models import User
>
> > class AuthorCategory(models.Model):
> >     title = models.CharField(max_length=250)
> >     author = models.ForeignKey(User)
>
> > class Category(models.Model):
> >     title = models.CharField(max_length=250)
>
> > class Entry(models.Model):
> >     title = models.CharField(max_length=250)
> >     category = models.ForeignKey(Category)
> >     authorcategory = models.ForeignKey(AuthorCategory)
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to