Problem with follow button in django.
I have a web-site with database of some events. Registered users should be able to follow this events. I mean there should be a button "Follow" on an event page. Users who clicked it should see this event on their home page. But i just cant understand how it should work...
There is event model:
class Event(models.Model):name = models.CharField(max_length=26)second_name = models.CharField(max_length=60)description = models.CharField(max_length=200)type = models.CharField(max_length=3, default='cin')date = models.DateField()user = models.ForeignKey(User)image = models.ImageField(upload_to='images/',default='images/default.png')
And i have a view to output events on a page:
def home(request):all_events = Event.objects.all.order_by('date')return render(request, 'events/home.html', {'events': all_events})
in template -
{% block content %}<h1>{{ Event.name }}</h1><pre>{{ Event.date }}</pre><pre>{{ Event.description }}</pre>
{% endblock %}
I tried to use ManyToManyField like this but i dont understand exactly how it should work - what code should be in views.py, models.py and in template (button). Please help me