You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am following this guide and stumbled on an weird issue. The website works perfectly when i try it in the web browser. But it seems that all the test cases are failing with 404 error page not found (even though i can access everything myself via web browser).
OS: Debian GNU/Linux 9.4 (stretch), Python: Python 3.5.3, Django: (2, 0, 7, 'final', 0).
urls.py
#######
from django.contrib import admin
from django.urls import path, re_path
from boards import views as board_views
from django.conf.urls import url
#######
views.py:
from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponse
from .models import Board, Topic, Post
Hello!
I am following this guide and stumbled on an weird issue. The website works perfectly when i try it in the web browser. But it seems that all the test cases are failing with 404 error page not found (even though i can access everything myself via web browser).
OS: Debian GNU/Linux 9.4 (stretch), Python: Python 3.5.3, Django: (2, 0, 7, 'final', 0).
urls.py
#######
from django.contrib import admin
from django.urls import path, re_path
from boards import views as board_views
from django.conf.urls import url
urlpatterns = [
path('', board_views.home, name='home'),
path('boards/int:pk/', board_views.board_topics, name='board_topics'),
path('boards/int:pk/new/', board_views.new_topic, name='new_topic'),
path('admin/', admin.site.urls),
]
#######
#######
views.py:
from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponse
from .models import Board, Topic, Post
def board_topics(request, pk):
board = get_object_or_404(Board, pk=pk)
return render(request, 'topics.html', {'board': board})
tests.py:
class BoardTopicsTests(TestCase):
def setUp(self):
Board.objects.create(name='Django', description='Django board.')
When i print the variables, i can see that DB object exists, but 404 page not found is returned:
<QuerySet [<Board: Django>]>
b'
Not Found
The requested URL /boards/1/ was not found on this server.
'404
Thanks!
The text was updated successfully, but these errors were encountered: