How to link to authors posts(mini-blogs) in models django?

In General, there is model posts:
class Post(models.Model):

 author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
 title = models.CharField(max_length=255)
 text = models.TextField()
 created_date = models.DateTimeField(
 published_date = models.DateTimeField(blank=True, null=True)

 def __str__(self):
 return self.title

 def get_absolute_url(self):
 return reverse('post-detail', args=[str(])

 def publish(self):
 self.published_date =

 class Meta:
 ordering = ['published_date']

How do I make it so that any user could add any author and, correspondingly, show only their posts?
March 19th 20 at 08:57
1 answer
March 19th 20 at 08:59
As an option to inherit from User model and add a ManyToManyField on itself

class ' CustomUser(User):
 preferred_author = models.ManyToManyField('self', symmetrical=False, related_name='preferred', ...)

When the user selects a new author just add

Further filtering to vivezli all articles selected by the user authors


SELECTED_USER where is the user for which to display articles.

The code is written from head so for the accuracy I can not vouch for example

Find more questions by tags Django