class Category(models.Model):
name = models.CharField(max_length=100,null=True,blank=True)

def __str__(self):
return str(self.name)
class Items(models.Model):
name = models.CharField(max_length=100)
category = models.ForeignKey(Category,on_delete=models.CASCADE 
,related_name='items')

def __str__(self):
return str(self.name)

I have data in category model,while creating items object i want to use 
data from category to add category to the item
can some one tell me how to do this

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/5c4bc38c-6b5c-4a96-af38-1cb48777ed0bn%40googlegroups.com.

Reply via email to