Djnago Python (INNER JOIN Query Or JOIN Query)

22 views
Skip to first unread message

Pravin Yadav

unread,
Jun 26, 2018, 8:27:22 AM6/26/18
to Django users
Hello Everyone,


I want to make INNER JOIN Query Or JOIN Query with "Video" and "Thumbimages". Kindly let me know.

Below my Models:-

from __future__ import unicode_literals
from django.db import models
from django.utils import timezone
from django.template.defaultfilters import slugify
from django.urls import reverse
from django.apps import apps
from django.contrib.auth.models import User

# Create your models here.

class Video(models.Model):

STATUS_CHOICES = (
(1, 'Active'),
(0, 'Deactive'),
)
vid_cat_type = models.ForeignKey('category.Categorytype', on_delete=models.CASCADE, null=True, blank=True)
vid_cat = models.ForeignKey('category.Category', on_delete=models.CASCADE, null=True, blank=True)
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
videorand_id = models.BigIntegerField(null=True,blank=True)
video_name = models.FileField(upload_to='uploadvideo')
country = models.ForeignKey('countries.Countries', on_delete=models.CASCADE, null=True, blank=True)
vid_title = models.CharField(max_length=255)
vid_description = models.TextField(null=True,blank=True)
status = models.IntegerField(choices=STATUS_CHOICES, default=1)
created_at = models.DateTimeField(default=timezone.now,editable=True,blank=True,null=True)
updated_at = models.DateTimeField(auto_now=False,blank=True,null=True)

def __str__(self):
return self.video_name

class Thumbimages(models.Model):
THUMB_TYPE = (
(1, 'Active'),
(0, 'Deactive'),
)
video = models.ForeignKey(Video, on_delete=models.CASCADE, null=True, blank=True)
thumb_image = models.ImageField(upload_to='vidthumbimage',max_length=255,null=True,blank=True)
thumb_type = models.CharField(max_length=1,null=True,blank=True)
activateimg = models.IntegerField(choices=THUMB_TYPE, default=1)
created_at = models.DateTimeField(default=timezone.now,editable=True,blank=True,null=True)
updated_at = models.DateTimeField(auto_now=False,blank=True,null=True)



Thanks In Advance,
Pravin Yadav




Jason

unread,
Jun 26, 2018, 9:24:01 AM6/26/18
to Django users
I would suggest you look at the object relational model section of the tutorial.  And then browse the documentation for model references, relationships and lookups.  Quite frankly, everything you're asking here is covered in detail there.
Reply all
Reply to author
Forward
0 new messages