我的意愿是使用以下选项制作一个选择菜单:
models.py
TITLE_CHOICES = (
('MR', 'Mr.'),
('MRS', 'Mrs.'),
('MS', 'Ms.'),
)
并将其显示在hello.html
. 但我不断收到此错误:ImportError: No module named hello
对象:#continuation of models.py
class hello(models.Model):
title = models.CharField(max_length=3, choices=TITLE_CHOICES)
def __unicode__(self):
return self.name
view.py 上的请求:
from django.http import HttpResponse
from django.template.loader import get_template
from django.template import Context
from testApp.models import hello
from testApp.models.hello import title
from django.shortcuts import render_to_response
from django.template import RequestContext
def contato(request):
form = hello()
return render_to_response(
'hello.html',
locals(),
context_instance=RequestContext(request),
)
def hello_template(request):
t = get_template('hello.html')
html = t.render(Context({'name' : title}))
return HttpResponse(html)
我在INSTALLED_APPS
( setting.py
) 中的应用程序:
INSTALLED_APPS = (
'testApp',
'hello',
)
任何帮助表示赞赏。