text: from django.shortcuts import render, redirect
  from django.contrib.auth import authenticate, login, logout
  from django.contrib.auth import views as auth_views
  from .forms import RegisterForm, LoginForm
  
  def register_view(request):
      template_name = "account/register.html"
      if request.method == 'POST':
          form = RegisterForm(request.POST)
          if form.is_valid():
              user = form.save()
              username, raw_password = form.cleaned_data.get('username'), form.cleaned_data.get('password1')
              account = authenticate(username=username, password=raw_password)
              user.email_user('Bienvenido a IE Scraper', f'Bienvenido {user.username}, te has registrado con éxito.')
              login(request, account)
              return redirect('/home/')
      else: # GET request
          form = RegisterForm()
      context = {'form': form}
      return render(request, template_name, context)
  
  class LoginView_(auth_views.LoginView):
      authentication_form = LoginForm
  
  def login_view(request, **kwargs):
      if request.user.is_authenticated:
          return redirect('/home/')
      else:
          return auth_views.LoginView.as_view(authentication_form=LoginForm, template_name="account/login.html")(request)
  
  
  
  
  
  
  
  
  def logout_view(request):
      logout(request)
      return redirect('home')