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
This commit corrects the file paths provided in the documentation, changing from dot notation to the correct slash notation. It also removes an empty item in the requirements list in the documentation.
Copy file name to clipboardExpand all lines: docs/images/index.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@
5
5
The goal of this tutorial is for you to have Music API ready to receive songs, albums, and artists. While you learn [Django](https://www.djangoproject.com/) and [Django Rest Framework a.k.a DRF](https://www.django-rest-framework.org/) to build you first API
6
6
7
7
Requirements list:
8
+
8
9
1. Python 3
9
10
2. Git
10
-
3.
11
11
12
12
-**Total Duration:** 3 hours 30 minutes
13
13
-**Lecture:** 1 hour (approximately 30%)
@@ -104,7 +104,7 @@ This will create the app structure for us. Something similar to this below:
104
104
105
105
Don't forget to add the app music to your INSTALLED_APPS in your `settings.py`
106
106
```python
107
-
# settings.py
107
+
#first_api/settings.py
108
108
...
109
109
INSTALLED_APPS= [
110
110
"django.contrib.admin",
@@ -131,7 +131,7 @@ We are going to create 3 models in the file models.py
131
131
Let's start with the artist model.
132
132
133
133
```python
134
-
# music.models.py
134
+
# music/models.py
135
135
classArtist(models.Model):
136
136
name = models.CharField(max_length=100)
137
137
@@ -145,7 +145,7 @@ from django.db import models
145
145
```
146
146
Now the album model
147
147
```python
148
-
# music.models.py
148
+
# music/models.py
149
149
classAlbum(models.Model):
150
150
title = models.CharField(max_length=100)
151
151
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
@@ -158,7 +158,7 @@ class Album(models.Model):
158
158
The last model will be the song model that will have relationship with artist and album.
159
159
160
160
```python
161
-
# music.models.py
161
+
# music/models.py
162
162
classSong(models.Model):
163
163
author = models.CharField(max_length=100)
164
164
title = models.CharField(max_length=100)
@@ -173,7 +173,7 @@ Now let's go to the URL Mapping, we need to associate the url with the handler f
173
173
174
174
175
175
```python
176
-
# first_api.urls.py
176
+
# first_api/urls.py
177
177
from django.contrib import admin
178
178
from django.urls import path, include
179
179
@@ -186,7 +186,7 @@ urlpatterns = [
186
186
You need to create a file `urls.py` inside music folder and make it look like the example below.
187
187
188
188
```python
189
-
# music.urls.py
189
+
# music/urls.py
190
190
from django.urls import path
191
191
192
192
from . import views
@@ -200,7 +200,7 @@ And last but not least you need to create this
200
200
you need to create the view. A function view in this case.
201
201
202
202
```python
203
-
# music.views.py
203
+
# music/views.py
204
204
from django.http import HttpResponse
205
205
206
206
@@ -247,7 +247,7 @@ With the serializer in place we need more 2 steps, the url mapping and the view.
247
247
Let's do both in sequence, first the view. For the view we are going to use a [ModelViewSet](https://www.django-rest-framework.org/api-guide/viewsets/#modelviewset). Inside our file `music.views.py` we need to add this snipper.
248
248
249
249
```python
250
-
# music.views.py
250
+
# music/views.py
251
251
...
252
252
classArtistViewSet(viewsets.ModelViewSet):
253
253
queryset = Artist.objects.all()
@@ -270,7 +270,7 @@ from music.serializers import ArtistSerializer
270
270
Ok, now we just need to map our ArtistViewSet to a URL. In our `music.urls.py` we are going to use one more resource that DRF provides us, the [Default Router](https://www.django-rest-framework.org/api-guide/routers/#defaultrouter). It will create a set of common routes for our ViewSet.
0 commit comments