Closed ihakh closed 4 years ago
Hi @ihakh
Did #13 fix the problem you encountered? If so, do you agree to close this PR?
Thanks!
Close due to out of response and fixes #13 .
Hi Sorry for late response yes thanks it seems that will solve the problem I have made a lot of modification for my own purpose
I have a piece of code for checking the oneof field status which I think it maybe useful if you find it useful add it in your code so everyone can use it in ProtoBufMixin model I have added a clean method like this (Only one of oneof filed can have value):
def clean(self): super(ProtoBufMixin, self).clean() check_list = [sum([getattr(self, field.name) is None for field in oneof.fields]) == ( len(oneof.fields) - 1) for oneof in self.pb_model.DESCRIPTOR.oneofs] if not all(check_list): raise ValidationError("only one of %s fields must has value" % ', '.join( [field.name for field in self.pb_model.DESCRIPTOR.oneofs[check_list.index( False)].fields]))
On Mon, 2 Mar 2020 at 11:27, Meng-Ying Yang notifications@github.com wrote:
Closed #12 https://github.com/myyang/django-pb-model/pull/12.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/myyang/django-pb-model/pull/12?email_source=notifications&email_token=AK42CCDQIBCVQ6N3PTWP44DRFNRGNA5CNFSM4JOEMZUKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOW76IWOI#event-3086781241, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK42CCGNTMVL7MDGA3OGZPLRFNRGNANCNFSM4JOEMZUA .
-- Iman Hadji Ali Khamse
I couldn't get it work even with the test model I haven't worked with six package so I have done it the way I can understand I am sure you can improve it