Skip to content

Commit 665d3eb

Browse files
committed
DRF Quickstart atualizado
1 parent 3e23253 commit 665d3eb

File tree

1 file changed

+45
-9
lines changed

1 file changed

+45
-9
lines changed

content/django-rest-framework-quickstart.md

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,55 @@ Category: Python, Django, REST
1010

1111
Veremos aqui uma forma rápida de criar uma API REST com [Django Rest Framework][0].
1212

13-
Este tutorial é a parte 0/6 de uma série de posts sobre DRF.
13+
> Este artigo foi atualizado em 14 de Fevereiro de 2018.
14+
15+
Este artigo está usando:
16+
17+
* Python 3.5.2
18+
* Django 2.0.2
19+
* djangorestframework 3.7.7
20+
21+
Favor clonar o projeto do [GitHub](https://github.com/rg3915/drf#clonando-o-projeto), favor ler o README para instalação.
22+
23+
Repare nas alterações das urls na nova versão do Django.
24+
25+
```python
26+
urls.py
27+
from django.urls import include, path
28+
from django.contrib import admin
29+
30+
urlpatterns = [
31+
path('', include('core.urls')),
32+
path('admin/', admin.site.urls),
33+
]
34+
```
35+
36+
```python
37+
# core/urls.py
38+
from django.urls import path
39+
from core import views
40+
41+
urlpatterns = [
42+
path('persons/', views.person_list),
43+
path('persons/<int:pk>/', views.person_detail),
44+
]
45+
```
46+
47+
Além disso, tivemos alterações significativas em [settings.py](https://github.com/rg3915/drf/blob/master/myproject/settings.py).
1448

1549
**Obs**: *Tem coisas que é melhor nem traduzir. ;)*
1650

1751
* 0 - **Quickstart**
1852
* 1 - [Serialization][11]
1953
* 2 - Requests & Responses
2054
* 3 - Class based views
21-
* 4 - Authentication & permissions
22-
* 5 - Relationships & hyperlinked APIs
23-
* 6 - Viewsets & routers
2455

2556
> **Obs**: se você não sabe [Django][3] sugiro que leia este [tutorial][4] antes.
2657
2758
## Começando
2859

2960
```bash
30-
$ virtualenv -p python3 env
61+
$ python3 -m venv .venv
3162
$ source env/bin/activate
3263
$ mkdir drf-quickstart
3364
$ cd drf-quickstart
@@ -41,10 +72,15 @@ $ python manage.py createsuperuser --username='admin' --email=''
4172

4273
Veja o meu requirements.txt
4374

44-
Django==1.8.6
45-
argparse==1.2.1
46-
djangorestframework==3.3.1
47-
wsgiref==0.1.2
75+
```bash
76+
dj-database-url==0.4.2
77+
Django==2.0.2
78+
django-extensions==1.9.9
79+
django-filter==1.1.0
80+
djangorestframework==3.7.7
81+
drf-nested-routers==0.90.0
82+
python-decouple==3.1
83+
```
4884

4985
## Editando `settings.py`
5086

0 commit comments

Comments
 (0)