Boa tarde pessoal, estou na parte do curso onde o professor ensina a configurar as urls para entrar no local host:
Até ai tudo bem, mas quando eu clico na url "student" apresenta este erro:
views.py
from rest_framework import viewsets
from school.models import Student_models, Course_models
from school.serializer import StudentSerializer, CourseSerializer
class StudentViewSet(viewsets.ModelViewSet):
"""Exibindo todos os alunos e alunas"""
queryset = Student_models.objects.all()
serializer_class = StudentSerializer
class CourseViewSet(viewsets.ModelViewSet):
"""Exibindo todos os cursos"""
queryset = Course_models.objects.all()
serializer_class = CourseSerializer
urls.py:
from django.urls import path, include
from school.views import StudentViewSet, CourseViewSet
from rest_framework import routers
router = routers.DefaultRouter()
router.register('student', StudentViewSet, basename='Student')
router.register('course', CourseViewSet, basename='Course')
urlpatterns = [
path('admin/', admin.site.urls),
path('', include(router.urls) )
]
serializer.py =
from rest_framework import serializers
from school.models import Student_models, Course_models
class StudentSerializer(serializers.ModelSerializer):
class Meta:
model = 'Student_models'
fields = '__all__'
class CourseSerializer(serializers.ModelSerializer):
class Meta:
model = 'Course_models'
fields = '__all__'
admin.py
from django.contrib import admin
from school.models import Student_models, Course_models
class Student_admin(admin.ModelAdmin):
list_display = ('id', 'name', 'rg', 'cpf', 'birthday')
list_display_links = ('id', 'name')
search_fields = ('name', )
list_per_page = 20
admin.site.register(Student_models, Student_admin)
class Course_admin(admin.ModelAdmin):
list_display = ('id', 'id_course', 'description')
list_display_links = ('id', 'id_course')
search_fields = ('id_course', )
admin.site.register(Course_models, Course_admin)