class Links(TemplateView):
template_name = "home/links.html"
def get_context_data(self, **kwargs):
cOntext= super(Links, self).get_context_data(**kwargs)
context['link'] = Friend_Links.objects.all()
context['latest_article_list'] = latest_article_list
context['now'] = time.strftime('%Y-%m-%d %X', time.localtime())
context['ip'] = self.request.META['REMOTE_ADDR']
return context
class Index(Links):
template_name = "home/index.html"
def get_context_data(self, **kwargs):
cOntext= super(Index, self).get_context_data(**kwargs)
return context
class PythonNav(Links):
template_name = "home/python.html"
def get_context_data(self, **kwargs):
cOntext= super(PythonNav, self).get_context_data(**kwargs)
context['python_list'] = Article.objects.filter(category="Python")
return context
class Detail(DetailView):
model = Article
context_object_name = "ar"
template_name = "home/detail.html"
def get_context_data(self, **kwargs):
cOntext= super(Detail, self).get_context_data(**kwargs)
context['latest_article_list'] = latest_article_list
context['now'] = time.strftime('%Y-%m-%d %X', time.localtime())
return context
class ContactMe(Links, CreateView):
model = Contact
template_name = "home/contact.html"
success_url = '/'
def get_context_data(self, **kwargs):
cOntext= super(ContactMe, self).get_context_data(**kwargs)
return context
ContactMe我想继承 Links的 context
为什么会报错
AttributeError at /nav/contact
'ContactMe' object has no attribute 'object'
Detail也想继承Links的
但是也是同样的错误
template_name = "home/links.html"
def get_context_data(self, **kwargs):
cOntext= super(Links, self).get_context_data(**kwargs)
context['link'] = Friend_Links.objects.all()
context['latest_article_list'] = latest_article_list
context['now'] = time.strftime('%Y-%m-%d %X', time.localtime())
context['ip'] = self.request.META['REMOTE_ADDR']
return context
class Index(Links):
template_name = "home/index.html"
def get_context_data(self, **kwargs):
cOntext= super(Index, self).get_context_data(**kwargs)
return context
class PythonNav(Links):
template_name = "home/python.html"
def get_context_data(self, **kwargs):
cOntext= super(PythonNav, self).get_context_data(**kwargs)
context['python_list'] = Article.objects.filter(category="Python")
return context
class Detail(DetailView):
model = Article
context_object_name = "ar"
template_name = "home/detail.html"
def get_context_data(self, **kwargs):
cOntext= super(Detail, self).get_context_data(**kwargs)
context['latest_article_list'] = latest_article_list
context['now'] = time.strftime('%Y-%m-%d %X', time.localtime())
return context
class ContactMe(Links, CreateView):
model = Contact
template_name = "home/contact.html"
success_url = '/'
def get_context_data(self, **kwargs):
cOntext= super(ContactMe, self).get_context_data(**kwargs)
return context
ContactMe我想继承 Links的 context
为什么会报错
AttributeError at /nav/contact
'ContactMe' object has no attribute 'object'
Detail也想继承Links的
但是也是同样的错误
