orm - Django retrieve data from multiple tables -


i have 2 mysql models:

class registration(models.model):    name = models.charfield(max_length=30)    email = models.emailfield()    password = models.charfield(max_length=30)    company = models.charfield(max_length=30)   class personal_details(models.model):    reg = models.foreignkey(registration)    job = models.charfield(max_length=30)    experience = models.integerfield(default=0) 

i want filtering details using both experience , company keyword. want fetch , display details(name, email, company, job, experience) both tables in html page.

details = personal_details.objects.filter(experience=1,      reg__company="yourcompany").select_related()  {% detail in details %}     name: {{ detail.reg.name }}     email: {{ detail.reg.email }}     company: {{ detail.reg.company }}     job: {{ detail.job }}     experience: {{ detail.experience }}<br/> {% endfor %} 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -