Django Rest - ManyToManyField with SlugRelatedField Data Is Not Being Created

43 views
Skip to first unread message

Érika Barros

unread,
Jan 22, 2020, 10:07:30 AM1/22/20
to Django users
Hello friends!

I have a detailed question on this link (Stack Overflow).

In resume, I can't create a new object on database using SlugRelatedField by the method create() and I receive the following error:

return CalculatorNotFoundException(logger, request_json['name']).response

Can anybody help me?

Thank you so much!!!

Érika.

Motaz Hejaze

unread,
Jan 22, 2020, 11:49:18 AM1/22/20
to django...@googlegroups.com
Erika i think your models are not implemented correctly ..
why you have a foreign key field in TagLink linking to Tags , while you already have a manytomany relation between the Tag and Calculator through TagLink !!!!
try to remove the tag field from     " 
through_fields=('calculator', 'tag') "
or remove " tag = models.ForeignKey(Tag, on_delete=models.CASCADE, db_column='sTag') "

I think you are making a circular relation 

--
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/bced6744-7c53-460f-b3a4-dc6c0aaec252%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages