Failed to test ViewSet reverse to get route name in Django Rest Framework

failed to test ViewSet reverse getting route name in Django Rest Framework

urls.py:


-sharp course chapter without lesson
course_chapter_router = DefaultRouter()
course_chapter_router.register(r"", courses.views.CourseChapterViewSet,
                base_name="chapters")
-sharp URL Patterns
urlpatterns = [
    -sharp course courses
    url(r"^chapters/", include(course_chapter_router.urls)),
]
class GetAllChapterTest(TestCase):
    def test_get_all_multi(self):

        request = APIRequestFactory().get(reverse("chapters:chapters-list"))
        print(request)

        view = ChapterViewSet.as_view({"get": "retrieve"})
        course = Course.objects.create(course_code="xadf", title="Python", brief="a dynamic langiage", description="similar to Java, C")

        chapter = Chapter.objects.create(course=course, number=2, title="", description="Code Language")
        print(chapter)
        -sharpcourse = Course.objects.create(course_code="xadf", title="Python", brief="a dynamic langiage", description="similar to Java, C")
        response = view(request, pk=chapter.pk)
        print(response)
Mar.13,2021

use django-extensions and then. / manage.py show_urls to see your route and the corresponding name

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bed9aa-31b92.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bed9aa-31b92.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?