@Heavy10110

Другой url при запросе django?

url(r'^boards/(?P<pk>\d+)/topics/(?P<topic_pk>\d+)/reply/$', 
		reply_topic, 
		name='post_reply'),
	url(r'^boards/(?P<pk>\d+)/topics/(?P<topic_pk>\d+)/$',
		topic_posts,
		name='topic_posts'),
	url(r'^boards/(?P<pk>\d+)/new/$',
		new_topic, 
		name='new_topic'
		),
	url(r'^boards/(?P<pk>\d+)/$',
		board_topics, 
		name='board_topics'
		),
	url(r'^boards/$',
			board,
			name='board'
		),


views
def board(request):
	boards = Board.objects.all()
	html = 'boards.html'
	context = {
	'boards' : boards,
	}
	return render(request, html, context)

def topic_posts(request, pk, topic_pk):
	topic = get_object_or_404(Topic, board__pk=pk, pk=topic_pk)
	return render(request, 'topic_posts.html', {'topic': topic})

При запросе boards/

NoReverseMatch at /boards/

Reverse for 'topic_posts' with arguments '(1, '')' not found. 1 pattern(s) tried: ['boards/(?P<pk>\\d+)/topics/(?P<topic_pk>\\d+)/$']

Request Method: 	GET
Request URL: 	http://127.0.0.1:8000/boards/
Django Version: 	1.11.6
Exception Type: 	NoReverseMatch
Exception Value: 	
Reverse for 'topic_posts' with arguments '(1, '')' not found. 1 pattern(s) tried: ['boards/(?P<pk>\\d+)/topics/(?P<topic_pk>\\d+)/$']
Exception Location: 	/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py in _reverse_with_prefix, line 497
Python Executable: 	/usr/bin/python
Python Version: 	2.7.12
Python Path:


Что не так?
  • Вопрос задан
  • 247 просмотров
Пригласить эксперта
Ответы на вопрос 1
kentuck1213
@kentuck1213
В самый верх подними этот url:
url(r'^boards/$',
      board,
      name='board'
    ),
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы