如何修复列表视图未在Django中显示!
当我看到html file
中没有显示数据时,我在基于类的视图中添加列表视图,我很累要解决,请您帮我!
这是我的 views.py
class Buy_List_View(ListView):
model = user_buy
template_name = 'index.html'
这是我的 models.py
class user_buy(models.Model):
users = models.ForeignKey(user_register_model,on_delete=models.CASCADE)
payment_method = models.CharField(max_length=500)
price = models.IntegerField()
limits = models.IntegerField()
这是我的 index.html
{% for buy in user_buy_list %}
<tr>
<td><a href="#">{{ buy.users }}</a></td>
<td>{{ buy.payment_method }}</td>
<td>{{ buy.price }}</td>
<td>{{ buy.limits }}</td>
</tr>
{% endfor %}
这是我的 urls.py
from . import views
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('',views.index,name='index'),path('accounts/signup/',views.user_reg,name='register'),path('profile/<username>',views.user_profile,name='user_profile'),path('buy/form/seller',views.Buy_List_View.as_view(),name='buy')
]