While doing the project I was taking notes about many steeps. Here are some of them.
pip install django-extensions==3.2.3pip install pydot==3.0.2python manage.py graph_models -a -o mini_twitter_models.pngpip install coverage==7.6.4coverage run --source='.' manage.py test
coverage report
coverage html
coverage xmlRefs.:
pip install black==24.10.0black --check .black .Choosen the drf-spectacular library.
REST_FRAMEWORK = {
...
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
...
}WIP: when other parts are finished came back to this.
Add the library to requirements.txt:
dj-rest-auth==6.0.0Add this to settings.py:
INSTALLED_APPS = [
...
'rest_framework.authtoken',
'dj_rest_auth',
...
]from dj_rest_auth.views import LoginView
path('login', LoginView.as_view(), name='login'),python manage.py startapp userauthREST_AUTH = {
'USE_JWT': True,
'JWT_AUTH_COOKIE': 'jwt-auth-c00kie',
'JWT_AUTH_REFRESH_COOKIE': 'jwt-auth-refresh-c00kie',
}docker-compose exec apidrf python manage.py createsuperuserExample:
myadmin
[email protected]
dd4095ea391a
dd4095ea391adocker-compose exec apidrf python manage.py makemigrationsAccess
When searching for JWT found that there are more than one library:
- https://github.com/iMerica/dj-rest-auth sucessor of django-rest-auth
- https://github.com/Tivix/django-rest-auth deprecated in favor of dj-rest-auth
- https://github.com/jazzband/djangorestframework-simplejwt seens updated
Videos:
If using only docker:
docker build . --tag minitwitter:0.0.1docker run -it --publish=8000:8000 --rm minitwitter:0.0.1python3 -m venv .venv \
&& source .venv/bin/activate \
&& pip install --upgrade pip==24.2
pip \
install \
djangorestframework==3.15.2pip3 freeze > requirements.txtpip3 install --requirement requirements.txtdjango-admin startproject minitwitter .python manage.py migratepython manage.py runservercurl http://127.0.0.1:8000/ | grep -q 'The install worked successfully! Congratulations!'
echo $?