0
我想做一個簡單的查詢,但它會引發異常。django:分配之前引用的局部變量
查看:
from callidus_app.models import department
...
def select_department(request):
context = RequestContext(request)
department_list = department.objects.all() #local variable 'department' referenced before assignment
context_dict = {'departments': department_list}
for department in department_list:
department.url=department.departmentName.replace(' ','_')
return render_to_response('callidus_app/select_department.html', context_dict,context)
系車型:
class department(models.Model):
departmentName = models.CharField(max_length = 20)
leaders = models.CharField(max_length = 20)
logoPath = models.CharField(max_length = 150)
def __str__(self):
return self.departmentName
謝謝,這似乎有所幫助。 – ThomasMX