Hi Folks,
 I have three models like Company,Employee and images. Images is foreignkey
in my Company table. At the time of creating Company deatils I want to add
image also, How I add these image in my image tables and at the time to get
method how i can show company details along with image using django rest
framework.

*models.py*






















*class Image(models.Model):    company_image =
 models.ImageField(upload_to='company_image',default = 'default.jpg')
created_at = models.DateField(auto_now_add = True)    updated_at =
models.DateField(auto_now = True)    class Meta:        verbose_name =
'image'    def  __str__(self):        return self.company_imageclass
Company(models.Model):    cmp_image = models.ForeignKey(Image,related_name
= 'comp_image',on_delete =
                                  models.CASCADE)    name =
models.CharField(max_length = 100)    reg_no = models.IntegerField()    ceo
= models.CharField(max_length = 100)    location =
models.CharField(max_length = 100)    active =
models.BooleanField(default=True)    created_at =
models.DateField(auto_now_add = True)    updated_at =
models.DateField(auto_now = True)    def __str__(self):        return
self.name <http://self.name>*


Thank You

Regards,
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPUw6WYjj4ByDwcKWhdnwCU0039WW0frfG0qF715HqAONgi1eg%40mail.gmail.com.

Reply via email to