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

Why TranslatedFieldsField assumes there is a parent.Meta.model? #17

Open
kemar opened this issue Jul 6, 2016 · 2 comments
Open

Why TranslatedFieldsField assumes there is a parent.Meta.model? #17

kemar opened this issue Jul 6, 2016 · 2 comments

Comments

@kemar
Copy link

kemar commented Jul 6, 2016

Hi,

I have a question regarding this commit : 5e9cc04

Sometimes we don't inherit from a ModelSerializer, e.g.:

class TemplateSerializer(drf_serializers.Serializer):
    translations = parler_serializers.TranslatedFieldsField(shared_model=models.Template)

The above mentioned commit breaks non-ModelSerializer:

AttributeError: 'FileSerializer' object has no attribute 'Meta'

Is there a valid reason why TranslatedFieldsField assumes there is a parent.Meta.model?

@vdboor
Copy link
Contributor

vdboor commented Sep 12, 2016

The TranslatedFieldsField only works on a TranslatableModelSerializer, see the example in the README. Both need to work together, as serialize fields can't control the model .save() call sadly.

I've highlighted this fact in the readme now.

@vdboor vdboor closed this as completed Sep 12, 2016
@vdboor vdboor reopened this Sep 12, 2016
@vdboor
Copy link
Contributor

vdboor commented Sep 12, 2016

Sorry, after closing reading I see you're trying to create a "mixin" or base class. I've moved the checks of the parent.Meta.model to the actual place they are used, instead of checking them too early (see 9a3dd7c). Does this work for you?

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

2 participants