Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

601
Views
AttributeError: el objeto 'AnonymousUser' no tiene atributo 'perfil'

He creado una aplicación Django y funcionó bien. Cuando ejecuté otra aplicación Django en un puerto (localhost: 8000) y probé la aplicación que construí en el puerto, dice un error como este.

 AttributeError: 'AnonymousUser' object has no attribute 'profile'

Aquí está mi código:

 class DashboardView(auth_views.LoginView): template_name = "dashboard/home.html" verify_email_required = 'registration/verify_email_required.html' form_class = ProfiledAuthenticationForm def get(self, request, *args, **kwargs): # context = {'form': self.form_class()} context = self.get_context_data() context['form'] = self.form_class() if request.user.profile.is_verified: return render(request, self.template_name, context) else: return render(request, self.verify_email_required, context)

Nota: Inicial cuando construí la aplicación, funcionó bien, pero por ahora toma error. cuando el usuario no inicia sesión, la página de inicio se redirige a la página de inicio de sesión.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Cuando lo arreglé así, funciona bien.

 class DashboardView(auth_views.LoginView): template_name = "dashboard/home.html" verify_email_required = 'registration/verify_email_required.html' form_class = ProfiledAuthenticationForm def get(self, request, *args, **kwargs): # context = {'form': self.form_class()} context = self.get_context_data() context['form'] = self.form_class() if self.request.user.is_authenticated: if request.user.profile.is_verified: return render(request, self.template_name, context) return render(request, self.verify_email_required, context) return render(request, self.template_name, context)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!