title: 404 Page Not Found "GET /accounts/login/?next=/profile/ HTTP/1.1" 404
body: <p>I am getting some issues with my urls. I don't have any 'account/' route but i when I want to visit 'login/' and after logging in it should redirect me to my profile... but it is taking me to this route: "<a href="http://127.0.0.1:8000/accounts/login/?next=/profile/" rel="nofollow noreferrer">http://127.0.0.1:8000/accounts/login/?next=/profile/</a>"</p>
  
  <p>I am sorry if I've posted any unnecessary kinds of stuff: </p>
  
  <p>mainapp.urls</p>
  
  <pre><code>from django.contrib import admin
  from django.contrib.auth import views as auth_views
  from django.urls import path, include
  from forms.views import RegisterView,LoginView
  from django.conf import settings
  from django.conf.urls.static import static
  from user_profile import views as profile_views
  from blog import views
  
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('register/',RegisterView.as_view(), name='register'),
      path('login/', LoginView.as_view(), name = 'login'),
      path('profile/',profile_views.profile,name='profile'),
   path('updateprofile/',profile_views.updateprofile,name='update_profile'),
      path('',include('blog.urls')),
  ]
  
  if settings.DEBUG:
      urlpatterns += static(settings.MEDIA_URL, 
      document_root=settings.MEDIA_ROOT)
  </code></pre>
  
  <p>forms.views(Login/Logout)View</p>
  
  <pre><code>from django.shortcuts import render, redirect,reverse
  from django.http import HttpResponse
  from django.contrib.auth import authenticate, get_user_model, logout
  from django.utils.http import is_safe_url
  from django.contrib.auth.decorators import login_required
  from django.views.generic import CreateView, FormView
  from .models import User
  from .forms import RegisterForm,LoginForm 
  
  class LoginView(FormView):
      form_class = LoginForm #instance
      template_name = 'forms/login.html'
      success_url = '/profile/' 
  def User_logout(request):
      if request.method == "POST":
          logout(request)
      return redirect(reverse('login'))   
  </code></pre>
  
  <p>LoginForm:</p>
  
  <pre><code>class LoginForm(forms.Form):
  email = forms.EmailField(label='email')
  password = forms.CharField(widget=forms.PasswordInput)
  
  def form_valid(self,form):
      request=self.request
      next_=request.GET.get('next')
      next_post=request.POST.get('next')
      redirect_path=next_ or next_post or None
      email=form.cleaned_data.get('email')
      password=form.cleaned_data.get('password')
      user=authenticate(username=email, password=password)
      if user is not None:
          login(request, user)
          try:
              del request.session['UserProfile.html']
          except:
              pass
          if is_safe_url(redirect_path, request.get_host()):
              return redirect(redirect_path)
          else:
              return redirect("login")
      return super(LoginView, self).form_invalid(form)
  </code></pre>