What's a viewsets.py vs views.py

hello,
Hope you are well.

I found that very interesting tutorial about map with a very nice documentation, if you want to have map ( GeoDjango, PostGIS, Leaflet). As I used Leaflet I continue with it.

However, I have some doubts as I have to search how to adapt it.

If you go to that tutorial and you look for the string “Adding the Marker viewset”, he/she created a file named viewsets.py.
But whats the difference with the file views.py?

Should i create a file viewsets.py or should I copy the code to my file views.py?

If you continue reading below, he created a file api.py at the root of the application.
Does it will work, if copy the file as the following (in the case I use views.py instead of viewsets.py)

"""Markers API URL Configuration."""

from rest_framework import routers

from markers.views import MarkerView

router = routers.DefaultRouter()
router.register(r"markers", MarkerView)

urlpatterns = router.urls

and then in the urls.py

    path("api/", include("markers.api")),

I have not tried anythings yet, because I am confused with the naming viewsets.py vs views.py

Does viewsets and views have is own roles?
Is due to a version of Django?

Many thanks for your clarification

In that tutorial, what you’re referring to is in the section Activating Django REST Framework

Notice the imports at the top of that viewsets.py file:
from rest_framework import viewsets
from rest_framework_gis import filters

These are parts of the Django Rest Framework.

See Viewsets for more information.

1 Like

These are parts of the Django Rest Framework.

Ho ye, all right.
But can I rename the file mymap/markers/viewsets.py to mymap/markers/toto.py?
There is no rules about the naming of that file?

I think I have to try step by step, that I will do tomorrow. I could have more targeted questions.

Thanks a lot again!!