models.py的内容如下:
from django.db import models
work= (
('r','remote'),
('l','local'),
)
class Client(models.Model):
client_name=models.CharField(max_length=50)
type= models.CharField(max_length=20, choices=work)
work_time=models.DateField()
def __unicode__(self):
return self.name
views.py中的内容如下
from django.shortcuts import render_to_response
from work.models import Client
from django.conf import settings
from django.db import models
def show_search(request):
client_list =Client.objects.all()
return render_to_response(search.html', {'aa:': aa})
search.html内容大致如下:
{% for temp in aa %}
<li>Client name:{{ temp }}</li>
{% empty %}
<h1>this is empty,</h1>
{% endfor %}
现在遇到一个怪的问题:
在manage.py shell下查询没有任何问题
但是在pycharm里,Client.后面,没有objects相关的任何东西,直接写进去,返回给html里内容也是空的,页面里直接显示this is empty,
查了好多东西,但是一直找不到原因,不知道为什么Client.后没有objects的东西,求各位大神指点一二,非常感谢!!!!!