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
Post a Comment