Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get parent model object based on child model filter in django

#Model
class Kid(models.Model):
    name = models.CharField(max_length=200)

class Toy(models.Model):
    name = models.CharField(max_length=200)
    owner = models.ForeignKey(Kid)
#view
Kid.objects.distinct().filter(toy__name__icontains='star')
Comment

PREVIOUS NEXT
Code Example
Python :: convert series to dataframe pandas 
Python :: django prevent duplicate entries 
Python :: Redirect the Python Script Output to File 
Python :: python list with several same values 
Python :: python destructuring 
Python :: handling timezone in python 
Python :: get parent of current directory python 
Python :: for i in range 
Python :: github3 python 
Python :: python responses 
Python :: check if string is python code 
Python :: install pyimagesearch python3 
Python :: how to count all files on linux 
Python :: python call function that need args with decorator 
Python :: PermissionError: [Errno 13] Permission denied on flask 
Python :: discord bot python get message id 
Python :: numpy.sort 
Python :: python dict delete key 
Python :: python code to convert csv to xml 
Python :: python list equality 
Python :: show percentage in seaborn countplot site:stackoverflow.com 
Python :: python floor float 
Python :: what is data normalization 
Python :: Use operator in python list 
Python :: scrapy with selenium 
Python :: test pypi 
Python :: cast as float python 
Python :: variable referenced before assignment python 
Python :: how to find ascii value by python 
Python :: service 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =