Handling multiple Foreign keys from mutiple models in django within one api endpoint #7974
              
                Unanswered
              
          
                  
                    
                      godomainz
                    
                  
                
                  asked this question in
                Question & Answer
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
I have my parishioner model like below (Only pasting relevant CODE)
Parishioner can have
one FamilyandOne rolein that familySo I'm trying to achieve this in my Family Serializer.
Basically What I'm trying to do is When I add family I can add members(Parishioners) to that family and assign a role each member.
What am I doing wrong here ? because when I load my
api/family/I'm getting below error
'Family' object has no attribute 'role'But you can clearly see I added
related_name='role'in my Parishioner model.So how can I achieve what I want ?
I want to add members(Parishioners) to Family and assign Role to each member in that Family.
Examples for
FamilyRole: Father, Mother, son, daughterMy frontend will be similar to this in my Create Family page (and I expect to send only one request to server to achieve this by using
api/family/endpoint)Beta Was this translation helpful? Give feedback.
All reactions