In need of immediate help from Django community

36 views
Skip to first unread message

Aritra Ray

unread,
May 24, 2021, 4:09:26 PM5/24/21
to django...@googlegroups.com
Hi,

I've been facing a problem recently in creating a Django Profile model for an E-commerce website.
Error: FieldError(message) django.core.exceptions.FieldError: Unknown field(s) (username) specified for Profile
Kindly help me out if possible. The screenshots have been attached below and the github link for the project has been provided.

Link: https://github.com/First-project-01/Django-ecommerce (Check out the 'changes' branch)

Regards,
Aritra
2021-05-25 (1).png
2021-05-25 (3).png
2021-05-25 (2).png
2021-05-25.png

Mottaz Hegaze

unread,
May 24, 2021, 4:25:45 PM5/24/21
to Django users
I think in second image ( usercreateform ) your model needs to be User not profile

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFecadvxBCa6w02%3DZ887%2BnaEdY-R6B9%2BVVFzVW5zYvkt1gA2hg%40mail.gmail.com.

Omkar Parab

unread,
May 24, 2021, 4:31:21 PM5/24/21
to django...@googlegroups.com
Error is in forms.py file. 

"model = User" not profile.

Default "User" model comes with username, email filed.

Why you're creating another email field in the Profile model?

Just fetch it using {{ user.email }} 


--

Kelvin Sajere

unread,
May 24, 2021, 7:10:15 PM5/24/21
to django...@googlegroups.com
Import the User model in your forms.py and use it instead of Profile. As the error clearly states, the Profile model does not have a username field. Django actually recommends using the AbstractUser, or the AbstractBaseUser to extend the default User model if you wish to create something like a profile. 



--
KeLLs

Aritra Ray

unread,
May 25, 2021, 2:53:26 AM5/25/21
to django...@googlegroups.com
Thank you for your response. It worked out perfectly.

Reply all
Reply to author
Forward
0 new messages