I have a model for a blog post where the owner of the post is a foreign key to User. With that model any user can own a blog post. I would like to change it so that only the users in a certain group -let's call it 'bloggers'- can own a blog post object. Ideally it should appear in the admin too, I mean in the blog post admin right now the menu for 'owner' lists all the users, it should only list the ones in the 'bloggers' group. How do I do that with Django 1.3?
Use limit_choices_to
paramether in your ForeignKey definition like this:
author = models.ForeignKey("auth.User", limit_choices_to={'groups__name': "bloggers"})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With