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

get_or_create not working #333

Open
minifisk opened this issue Feb 4, 2023 · 2 comments
Open

get_or_create not working #333

minifisk opened this issue Feb 4, 2023 · 2 comments

Comments

@minifisk
Copy link

minifisk commented Feb 4, 2023

I'm getting an error when trying to use get_or_create, it say that the field is not recognized.

This works:

golf = ReceiptCategory.objects.language('en').create(name="Golf")

This don't work
golf = ReceiptCategory.objects.language('en').get_or_create(name="Golf")

The error I'm getting is
django.core.exceptions.FieldError: Cannot resolve keyword 'name' into field. Choices are: id, kind, receipts, translations, user, user_id

The model

class ReceiptCategory(TranslatableModel):
    user = models.ForeignKey('core.user', null=True, blank=True, on_delete=models.SET_NULL)
    translations = TranslatedFields(
        name = models.CharField("Name", max_length=128)
    )
    kind = models.IntegerField(choices=OwnershipType.choices, default=OwnershipType.STANDARD)

@sam-val
Copy link

sam-val commented Feb 16, 2023

same with get()

@MehdiDRISSIB
Copy link

MehdiDRISSIB commented Dec 4, 2023

Try to query with translations__name

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

3 participants