Django
Restrict access to REST framework API
By default, the generated by the Django REST framework access is unrestricted. Any user can call any endpoint using any method. In order to set access to read-write for authenticated users, but read-only to anyone else, the following code should be added to settings.py
:
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
]
}
Reset superuser password
If you remember the user name:
python manage.py changepassword <username>
If you do not remember the user name, create another superuser:
python manage.py createsuperuser