Answer the question
In order to leave comments, you need to log in
How to insert a form into a ListView?
I have a model
class Notif(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
date = models.DateTimeField(default=timezone.now)
text = models.CharField(max_length=100)
class Home(ListView):
template_name ='main.html'
context_object_name = 'p'
model = Notif
def get_context_data(self, **kwargs):
context = super(Home, self).get_context_data(**kwargs)
context['form'] = Notif()
return context
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question