You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorial/quickstart.md
+25-25
Original file line number
Diff line number
Diff line change
@@ -18,32 +18,32 @@ Create a new Django project named `tutorial`, then start a new app called `quick
18
18
pip install djangorestframework
19
19
20
20
# Set up a new project with a single application
21
-
django-admin startproject tutorial . # Note the trailing '.' character
22
-
cd tutorial
21
+
django-admin startproject my_project . # Note the trailing '.' character
22
+
cd my_project
23
23
django-admin startapp quickstart
24
24
cd ..
25
25
26
26
The project layout should look like:
27
27
28
28
$ pwd
29
-
<some path>/tutorial
29
+
<some path>/my_project
30
30
$ find .
31
31
.
32
-
./tutorial
33
-
./tutorial/asgi.py
34
-
./tutorial/__init__.py
35
-
./tutorial/quickstart
36
-
./tutorial/quickstart/migrations
37
-
./tutorial/quickstart/migrations/__init__.py
38
-
./tutorial/quickstart/models.py
39
-
./tutorial/quickstart/__init__.py
40
-
./tutorial/quickstart/apps.py
41
-
./tutorial/quickstart/admin.py
42
-
./tutorial/quickstart/tests.py
43
-
./tutorial/quickstart/views.py
44
-
./tutorial/settings.py
45
-
./tutorial/urls.py
46
-
./tutorial/wsgi.py
32
+
./my_project
33
+
./my_project/asgi.py
34
+
./my_project/__init__.py
35
+
./my_project/quickstart
36
+
./my_project/quickstart/migrations
37
+
./my_project/quickstart/migrations/__init__.py
38
+
./my_project/quickstart/models.py
39
+
./my_project/quickstart/__init__.py
40
+
./my_project/quickstart/apps.py
41
+
./my_project/quickstart/admin.py
42
+
./my_project/quickstart/tests.py
43
+
./my_project/quickstart/views.py
44
+
./my_project/settings.py
45
+
./my_project/urls.py
46
+
./my_project/wsgi.py
47
47
./env
48
48
./env/...
49
49
./manage.py
@@ -62,7 +62,7 @@ Once you've set up a database and the initial user is created and ready to go, o
62
62
63
63
## Serializers
64
64
65
-
First up we're going to define some serializers. Let's create a new module named `tutorial/quickstart/serializers.py` that we'll use for our data representations.
65
+
First up we're going to define some serializers. Let's create a new module named `my_project/quickstart/serializers.py` that we'll use for our data representations.
66
66
67
67
from django.contrib.auth.models import Group, User
68
68
from rest_framework import serializers
@@ -83,12 +83,12 @@ Notice that we're using hyperlinked relations in this case with `HyperlinkedMode
83
83
84
84
## Views
85
85
86
-
Right, we'd better write some views then. Open `tutorial/quickstart/views.py` and get typing.
86
+
Right, we'd better write some views then. Open `my_project/quickstart/views.py` and get typing.
87
87
88
88
from django.contrib.auth.models import Group, User
89
89
from rest_framework import permissions, viewsets
90
90
91
-
from tutorial.quickstart.serializers import GroupSerializer, UserSerializer
91
+
from my_project.quickstart.serializers import GroupSerializer, UserSerializer
92
92
93
93
94
94
class UserViewSet(viewsets.ModelViewSet):
@@ -114,12 +114,12 @@ We can easily break these down into individual views if we need to, but using vi
114
114
115
115
## URLs
116
116
117
-
Okay, now let's wire up the API URLs. On to `tutorial/urls.py`...
117
+
Okay, now let's wire up the API URLs. On to `my_project/urls.py`...
118
118
119
119
from django.urls import include, path
120
120
from rest_framework import routers
121
121
122
-
from tutorial.quickstart import views
122
+
from my_project.quickstart import views
123
123
124
124
router = routers.DefaultRouter()
125
125
router.register(r'users', views.UserViewSet)
@@ -139,7 +139,7 @@ Again, if we need more control over the API URLs we can simply drop down to usin
139
139
Finally, we're including default login and logout views for use with the browsable API. That's optional, but useful if your API requires authentication and you want to use the browsable API.
140
140
141
141
## Pagination
142
-
Pagination allows you to control how many objects per page are returned. To enable it add the following lines to `tutorial/settings.py`
142
+
Pagination allows you to control how many objects per page are returned. To enable it add the following lines to `my_project/settings.py`
0 commit comments