*views.py*
from django.shortcuts import render
from .models import inherit
# Create your views here.
def homepage(request):
ab = inherit.objects.filter(name__name__contains='karan')
return render(request, 'jobs/index.html', {'x':ab} )
Models.py
*from django.db import models*
*# Create your models here.*
*class main(models.Model):*
* name = models.CharField(max_length=200)*
* def __str__(self):*
* return self.name*
*class inherit(models.Model):*
* namein = models.CharField(max_length=200)*
* name = models.ForeignKey(main, on_delete=models.CASCADE)*
* slug = models.SlugField(max_length=40)*
* pas = models.CharField(max_length=200)*
index.html
{% for x in y.all %}
<h1>{{ y.namein }}</h1>
{% endfor %}
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/bda75925-ea05-4418-81b9-75151cd01945%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.