I have a problem with retrieving data from this ManyToManyField (users) of a model Event:
class Event(models.Model):
name = models.CharField(max_length=26)
description = models.CharField(max_length=200)
date = models.DateField()
user = models.ForeignKey(User)
users = models.ManyToManyField(User, related_name="users", blank=True)
image = models.ImageField(
upload_to='images/',
default='images/default.png'
)
users = models.ManyToManyField creates an additional table "events_event_users", It stores user_id and event_id fields. So I want to output all event information from Event model, where user_id from that additional table is equal to request.user. Please help, how should I do this?