Def index (request) :
Latest_question_list=Question. Objects. Order_by (' - pub_date) [5]
The context={' latest_question_list: latest_question_list}
Return render (request, 'polls/index. HTML, context)
Use the code can not be normal display:
Class DetailView (generic DateDetailView) :
The model=Question
Template_name='polls/detail. HTML'
CodePudding user response:
Use the url is what kind of??Use the django - restframework?
I think you should be in the class the DetailView (generic. DateDetailView) define the get and post methods
CodePudding user response:
This is the urlUrlpatterns=[
Path (' 'views. IndexView. As_view (), name=' index '),
The path (' & lt; Int: question_id & gt;/'views. The detail name=' detail '),
The path (' & lt; Int: question_id & gt;/results/' views. The results, the name='results'),
The path (' & lt; Int: question_id & gt;/that/' views. That name='vote'),
]
This is the template
If error_message %} {% & lt; p> {{error_message}} & lt;/strong> Endif {% %}
{% for choice in question. Choice_set. All %}
{% endfor %}
CodePudding user response:
The path (' & lt; Slug: slug>/', ArticleDetailView as_view (), name='article - the detail'),This is other people's stories, you path useless as_view () method,
I will go directly django learned a little before and after the separation, brother, direct learning django - restframework