So I set up a login view, and upon successful login I'd like to go to a page of my choice by referencing another class based view. I'm not entirely sure how to achieve this.
Login view
def login_view(request):
if request.method == 'POST':
form =AuthenticationForm(data=request.POST)
if form.is_valid():
user=form.get_user()
login(request,user)
#Not sure what to do next
#return HttpResponseRedirect(reverse(request, Dashboard))?
else:
#TODO
else:
form = AuthenticationForm()
Dashboard class I'm trying to get to
class Dashboard(ListView):
model = models.Note
template_name = 'notemanager/dashboard.html'
def get_context_data(self, request,**kwargs):
context = super().get_context_data(**kwargs)
notedata = models.Note.objects.filter(added_by = User)
reminderdata = models.Reminder.objects.filter(added_by = User)
context['notes'] = notedata
context['reminder'] = reminderdata
return context
urls.py
urlpatterns = [
path('login/',views.Login.as_view(),name="login"),
path('',views.Dashboard.as_view(), name ="dash")
]
urls.pywhere you assign a route toDashboardto help.