2👍
It means create the file you have as core/api.py
(along with an empty core/__init__.py
file) and then add the line url(r" ˆ api/", include("core.api"), namespace="api")
to the root urls.py
file of your project.
You don’t have to call it core/api.py
, that is just a suggestion from the authors
what does we write the REST views in the views.py modules mean?
It means what you’ve done, for each of the Django apps in your project, such as flavors
, users
they will have a views.py
(or views/*.py
) in them where you’d put the code for both the API and non-API views. (this is just a sane naming convention, nothing more… Django relies on the urlpatterns
to tell it how to connect url routes to view code)
It’s great to build up stuff like this from scratch as a way to learn Django. If you’re doing a serious REST API project have a look at Django REST framework.