django过滤器表单不显示它应该显示一个表单但只显示提交按钮
models.py:
class Profile(models.Model):
user = models.OneToOneField(User,on_delete=models.CASCADE,null=True)
bio = models.TextField()
phone_number = models.IntegerField(blank=True, null=True)
Birth_date = models.DateField(blank=True, null=True)
age = models.IntegerField(blank=True, null=True)
education = models.TextField(blank=True, null=True,max_length=45)
WorkType = models.CharField(blank=True, null=True,max_length=150)
desired_wage = models.IntegerField(blank=True, null=True)
location = models.CharField(blank=True, null=True,max_length=25)
gender = models.PositiveSmallIntegerField(blank=True, null=True,choices=GENDER_CHOICES)
def __str__(self):
return str(self.user) if self.user else ''
视图:
def ListingsPage(request):
Profile = Profile.objects.all()
profile_filter = ProfileFilter(request.GET,queryset=Profile)
profile = profile_filter.qs
context = {
"filter":profile_filter,
"profile":Profile,
}
return render(request,"base/Listings.html",context)
filters.py:
import django_filters
from .models import Profile
class ProfileFilter(django_filters.FilterSet):
class Meta:
model = Profile
fields = ['bio','location']
温度:
<div>
<form method="GET" action="{% url 'listings' %}">
{{filter.form}}
<button type="submit" value="Submit">Submit</button>
</form>
</div>
它应该显示一种形式,它没有
1条答案
按热度按时间iklwldmw1#
您在
profile
查询集中有这样的拼写错误...您需要写入
Profile
而不是profile