Have you already defined a view in django rest framework?
El sáb., 31 ago. 2019 a las 16:45, Soumen Khatua (<soumenkhatua258@gmail.com>) escribió:
Hi Folks,--At the time of post request I want to provide only ID and then I want to fetch the details related to that ID from another model and then I want to commit all the deatils inside my ForeignKey table,Please guys tell me How can I do that bu using django rest framewoek?models.pyclass DoctorProfile(models.Model):
# doctor_id = models.IntegerField(primary_key=True)
user = models.OneToOneField(User, on_delete = models.CASCADE,related_name = 'user_profile')
specialities = models.CharField(max_length=100)
start_time = models.TimeField(null = True)
end_time = models.TimeField(null = True)
cost = models.DecimalField(max_digits=6, decimal_places=2)
craeted_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(auto_now = True)
def __str__(self):
return self.user.usernameclass Hospital(models.Model):
# hospital_id = models.IntegerField(primary_key=True)
doctor_name = models.ForeignKey(DoctorProfile,on_delete=models.DO_NOTHING)
permanent = models.BooleanField(default = False)
consultant = models.BooleanField(default = False)
craeted_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(auto_now = True)I want to add profile details inside Hospital table ForeignKey column, but I want to post opeartion by using this format:{"id":2," permanent": true,}ThanksRegards,Soumen
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WYoYA1nrT7Ne%3DvT1%3Djmk1Omf%3DFo%2BiyuA_ZxsTd152t4EA%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF6hzDMcb-cuhSq7r8dT%3DqYPXBZ5TO_M92%3DL3CBW%2B731kpP4YA%40mail.gmail.com.
No comments:
Post a Comment