1

I´m working on a simple CMS on Django, I have a model for the articles and use the User Model that django provides.

I have my model with an authors atribute of type User:

class Article(models.Model):
    authors = models.ManyToManyField(User)

I added this model to admin panel and what I would like to accomplish is to automatically select the author based on the user that is logged in whenever someone adds a new Article.

enter image description here

Can anyone help me with this?

Thanks in advance.

Pablo Estrada
  • 3,182
  • 4
  • 30
  • 74
  • 1
    possible duplicate of [Default value for user ForeignKey with Django admin](http://stackoverflow.com/questions/5632848/default-value-for-user-foreignkey-with-django-admin) – bruno desthuilliers Jul 25 '14 at 15:19
  • I don´t really know if the way to do it is the same since I have a ManyToManyField on my model. Maybe I have to change the method name? – Pablo Estrada Jul 26 '14 at 01:24
  • You'll have to check the source code for `ModelAdmin` to find out the exact method to override. FWIW the source code is often the best documentation.... – bruno desthuilliers Jul 26 '14 at 15:52

0 Answers0