본문 바로가기

web/Django

Accessor for field 'FIELDNAME' clashes with related field 'MODEL.FIELDNAME'. Add a related_name argument to the definition for 'FIELDNAME'




if you see an error 

APPNAME.MODELNAME : Accessor for field 'FIELDNAME' clashes with related field 'MODEL.FIELDNAME'. Add a related_name argument to the definition for 'FIELDNAME'


This error is your model have two FK. so The name overlaps. Do not know ORM relateed field


my model is as follows:


after: add related_name="FIELDNAME"


and you use the related_name in views.py code


ex)

It's error code.

$ User.obejcts.get(skill_first=skill)


It's worked code.

$ User.objects.get(skill_first_profile=skill)


using the Write a declared related_name.