Closed cecilulysess closed 4 years ago
I think it's ok to skip since m2m mapping from pb to django already does this from very beginning of this lib. 😂 Leave an hook function for customization and flexibility would be enough.
@cecilulysess Do you mind to submit a PR?
It's common that model add
related_name
at a FK field and the related model can use reverse relationship to access the model.For example
And you have the corresponding message:
While pb-model does not necessarily want to expand this reverse relationship when Author's to_pb is called, however, it should not throw an error since it's common case that the proto has has the
books
field.I created test case for this error: https://github.com/cecilulysess/django-pb-model/commit/f2966952bc2939260c9fb8a60a7ffb18323171f4
Exception thrown as:
I think the quick fix is simply add this at begining of
_relation_to_protobuf
method:WDYT?