Consider this what seems to be a simple Django/DRF API which works:

class CourseViewSet(viewsets.ModelViewSet):
  queryset = Course.objects.all()
  serializer_class = CourseSerializer

router = DefaultRouter()
router.register(r'courses', CourseViewSet)

urlpatterns = [
   path('', include(router.urls)),
]

POST to: *http://localhost:9000/courses/* works from cURL

But this code:
class CourseAPITest(TestCase):
  def setUp(self):
    self.client = APIClient()
    self.course_data = {'description': 'course number 1', 'name': 'intro to 
something'}
    self.response = self.client.post(reverse('courses'),          
self.course_data, 
format='json')

Gives me the error:

*django.urls.exceptions.NoReverseMatch: Reverse for 'courses' not found. 
'courses' is not a valid view function or pattern name.*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21615aab-a01a-4a1c-bc79-ed88908cafbbn%40googlegroups.com.

Reply via email to