Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-parler with unique field raise IntegrityError #344

Open
MehdiDRISSIB opened this issue Dec 3, 2023 · 0 comments
Open

django-parler with unique field raise IntegrityError #344

MehdiDRISSIB opened this issue Dec 3, 2023 · 0 comments

Comments

@MehdiDRISSIB
Copy link

MehdiDRISSIB commented Dec 3, 2023

Hello

I have this field in my Product Model:
translations = TranslatedFields( name=models.CharField( max_length=256, unique=True, verbose_name=_('Name'), help_text=_("Enter a descriptive name for your product. This will be its title in your store.")), )

with unique=True

When I try to add the name qwerty to this object in english et french,

translations: {"en":{"name":"qwerty"},"fr":{"name":"qwerty"}}

I got this error:

django.db.utils.IntegrityError: duplicate key value violates unique constraint "product_product_translation_me_c1a12fbb_uniq" DETAIL: Key (name)=(qwerty) already exists.
But unique should be unique by product object, not unique by object and translations.

Many thanks for you help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant