I am trying to install Django-rest-auth + registration. In the docs, it says to install Django-allauth which I did following the steps found here. However, once I did and migrated, my app seemed to be using a different template than the one I had set up originally.
I am using Django Rest Framework and Angular JS.
settings.py
INSTALLED_APPS = [
...
# Django Rest Framework
'rest_framework',
'rest_framework.authtoken',
# All auth
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
# Rest auth
'rest_auth',
'rest_auth.registration',
# My app
'myapp',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
# `allauth` needs this from django
'django.template.context_processors.request',
],
},
},
]
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
)
SITE_ID = 1
My urls.py in my project folder looks like this:
from django.conf.urls import url, include
from django.contrib import admin
from django.views.generic import TemplateView
urlpatterns = [
url(r'^admin/', admin.site.urls),
# My api url
url(r'^api/', include('myapp.urls')),
# My application url
url(r'^$', TemplateView.as_view(template_name='base.html')),
# all auth Url
url(r'^accounts/', include('allauth.urls')),
# Rest-auth url
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
]
Before installing the all-auth app, going to 127.0.0.1:8000 returned a page using the base.html file. However, now I get a page with the following things:
Menu:
Link to Change E-mail
Sign out
What am I doing wrong? and how do I fix the problem. Thanks.
Any help is greatly appreciated!
Related
I have built an app with an Django back-end, a React front-end and a Postgres database, and I am in the process of deploying them to Azure for the first time.
Key actions I have taken:
used django-webpack-loader and webpack-bundle-tracker, so my front and back-end code can be deployed as one app
set up Django app in Azure using the App service
migrated my postgres database into Azure using the Azure Database for PostgreSQL flexible server
Current outputs:
deployed code successfully using github continuous deployment
set my database, allowed_hosts, secreet_key and port values in application settings
successfully migrated my django folders into the Azure environment using the Web SSH in the Azure portal
My issue:
When I visit my url, the page times out, with 'Application Error'. I'm troubleshooting the error in the logs, which return the output below.
I have noticed two potential errors:
Within the error logs - TypeError: expected str, bytes or os.PathLike object, not PosixPath
When I run python manage.py runserver in the SSH, it returns 'port 8000 is already in use'. After killing and exiting processes on that port, it still remains. I am able to access the server when I run python manage.py runserver 9000, but still get no results.
Azure Error logs:
/home/LogFiles/2023_01_20_lw0sdlwk0000X9_default_docker.log (https://-test.scm.azurewebsites.net/api/vfs/LogFiles/2023_01_20_lw0sdlwk0000X9_default_docker.log)
2023-01-20T10:10:15.109452667Z File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2023-01-20T10:10:15.109456467Z File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2023-01-20T10:10:15.109460067Z File "/tmp/8dafa589514f05f/project/settings.py", line 94, in <module>
2023-01-20T10:10:15.109463967Z 'DIRS': [os.path.join(BASE_DIR, 'client')
2023-01-20T10:10:15.109467367Z File "/opt/python/3.9.7/lib/python3.9/posixpath.py", line 76, in join
2023-01-20T10:10:15.109471167Z a = os.fspath(a)
2023-01-20T10:10:15.109474567Z TypeError: expected str, bytes or os.PathLike object, not PosixPath
2023-01-20T10:10:15.109478267Z [2023-01-20 10:10:15 +0000] [122] [INFO] Worker exiting (pid: 122)
2023-01-20T10:10:15.227401497Z mkdir() got an unexpected keyword argument 'exist_ok'
/home/LogFiles/2023_01_20_lw0sdlwk0000X9_docker.log (https://-test.scm.azurewebsites.net/api/vfs/LogFiles/2023_01_20_lw0sdlwk0000X9_docker.log)
2023-01-20T10:05:20.883Z INFO - Stopping site -test because it failed during startup.
2023-01-20T10:09:33.036Z INFO - Starting container for site
2023-01-20T10:09:33.037Z INFO - docker run -d --expose=8000 --name-test_1_547d9150 -e WEBSITES_PORT=8000 -e WEBSITE_SITE_NAME=-test -e WEBSITE_AUTH_ENABLED=False -e PORT=8000 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=-test.azurewebsites.net -e WEBSITE_INSTANCE_ID=xyz -e HTTP_LOGGING_ENABLED=1 -e WEBSITE_USE_DIAGNOSTIC_SERVER=True appsvc/python:3.9_20221128.12.tuxprod
2023-01-20T10:09:36.544Z INFO - Initiating warmup request to container-test_1_547d9150 for site-test
2023-01-20T10:09:52.315Z INFO - Waiting for response to warmup request for container -test_1_547d9150. Elapsed time = 15.7713165 sec
2023-01-20T10:10:08.131Z INFO - Waiting for response to warmup request for container -test_1_547d9150. Elapsed time = 31.5870197 sec
2023-01-20T10:13:47.693Z ERROR - Container -test_1_547d9150 for site-test did not start within expected time limit. Elapsed time = 251.1494362 sec
2023-01-20T10:13:47.733Z ERROR - Container -test_1_547d9150 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2023-01-20T10:13:47.753Z INFO - Stopping site -test because it failed during startup.
/home/LogFiles/AppServiceAppLogs_Feature_Installer/startup_0.log (https://-test.scm.azurewebsites.net/api/vfs/LogFiles/AppServiceAppLogs_Feature_Installer/startup_0.log)
2023-01-20 09:45:55,527 [Thread-1 ] [DEBUG] : Did not find any previously bound socket
2023-01-20 09:55:42,312 [MainThread] [DEBUG] : Initializating AppServiceAppLogging
2023-01-20 09:55:42,316 [MainThread] [DEBUG] : Initialized AppServiceAppLogging
2023-01-20 09:55:42,359 [Thread-1 ] [DEBUG] : Did not find any previously bound socket
2023-01-20 10:05:11,655 [MainThread] [DEBUG] : Initializating AppServiceAppLogging
2023-01-20 10:05:11,658 [MainThread] [DEBUG] : Initialized AppServiceAppLogging
2023-01-20 10:05:11,706 [Thread-1 ] [DEBUG] : Did not find any previously bound socket
2023-01-20 10:10:08,028 [MainThread] [DEBUG] : Initializating AppServiceAppLogging
2023-01-20 10:10:08,030 [MainThread] [DEBUG] : Initialized AppServiceAppLogging
2023-01-20 10:10:08,039 [Thread-1 ] [DEBUG] : Did not find any previously bound socket
Django Settings.py file:
from pathlib import Path
import environ
import os
env = environ.Env()
environ.Env.read_env()
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = env('SECRET_KEY')
DEBUG = False
ALLOWED_HOSTS = [env('ALLOWED_HOSTS')]
# Application definition
INSTALLED_APPS = [
'whitenoise.runserver_nostatic',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'webpack_loader',
'rest_framework',
'jwt_auth',
'etc etc',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
ROOT_URLCONF = 'project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'client')
]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
print('templates ->', TEMPLATES)
WSGI_APPLICATION = 'project.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': env('DBNAME'),
'HOST': env('DBHOST'),
'PORT': 5432,
'USER': env('DBUSER'),
'PASSWORD': env('DBPASS')
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "client", "build", "static"),
)
print('static-files ->', STATICFILES_DIRS)
STATIC_ROOT = (
os.path.join(BASE_DIR, "static")
)
print('static-root ->', STATIC_ROOT)
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'jwt_auth.User'
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'jwt_auth.authentication.JWTAuthentication',
),
}
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
'POLL_INTERVAL': 0.1,
'IGNORE': [r'.+\.hot-update.js', r'.+\.map'],
}
}
Hm, here's a similar repository, the result of the cookiecutter-django project, that I successfully deployed to Azure:
https://github.com/pamelafox/cookiecutter-django-output/
Here's the settings file:
https://github.com/pamelafox/cookiecutter-django-output/blob/main/config/settings/base.py
It doesn't use os.path.join() and instead uses the "/" as a join operator. For example:
APPS_DIR = ROOT_DIR / "my_awesome_project"
From my reading of the os.path.join() docs, its not clear to me that it should work with a Path() object. It's interesting that it works locally but not on production, but perhaps you're using a different Python version locally than on production?
Perhaps you could try "/" path formation instead.
Here's a post I wrote recently with general tips for debugging Django apps on Azure App Service:
http://blog.pamelafox.org/2023/01/tips-for-debugging-django-app.html
Solved for anyone with a similar error:
Replaced this:
STATIC_ROOT = (
os.path.join(BASE_DIR, "static")
)
With:
STATIC_ROOT = (
BASE_DIR.as_posix() + '/static'
)
As per Pamela's response, os.path.join does not appear to be supported in production or on some Python versions.
i want to implement sitemap for static react routes and I get this error:
Reverse for 'contact' not found. 'contact' is not a valid view function or pattern name.
I added a list of my react routes REACT-ROUTES in settings.py and append them to urlpatterns in the root urls.py file
settings :
REACT_ROUTES = [
'contact',
'politique-de-confidentialite',
'mentions-legales',
'cookies',
.
.
]
INSTALLED_APPS = [
'corsheaders',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.sitemaps',
'rest_framework',
.
.
]
SITE_ID = 1
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'ess')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
STATIC_URL = '/static/'
STATIC_ROOT = basepath + '/app/static'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'ess', 'static')]
urls :
from django.conf import settings
from django.contrib.sitemaps.views import sitemap
from .sitemaps import StaticViewSitemap
react_routes = getattr(settings, 'REACT_ROUTES', [])
sitemaps = {
'static': StaticViewSitemap
}
urlpatterns = [
path('sitemap.xml/', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
re_path(r'^$', TemplateView.as_view(template_name='index.html')),
]
for route in react_routes:
urlpatterns += [
re_path('{}'.format(route), TemplateView.as_view(template_name='index.html'))
]
sitemaps.py :
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
class StaticViewSitemap(Sitemap):
def items(self):
return ['contact']
def location(self, item):
return reverse(item)
I don't know what I am missing, please help
I solved the problem by adding a sitemap.xml file inside my react build folder
then added in urlpatterns
path('sitemaps.xml/',TemplateView.as_view(template_name='sitemap.xml', content_type='text/xml'),
I am using django as backend and using react in the fronted and I recieve a problem when I try to access data from django server. When I open devtools I recieve the error:
Access to XMLHttpRequest at 'http://localhost:8000/wel' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
my settings.py:
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-vmainp*+c^_!0*f50a09f+)txe6wjt!#pge7%$#ak(=i*a4in*'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]
CORS_ORIGIN_ALLOW_ALL = True
# Application definition
INSTALLED_APPS = [
'rest_framework',
'corsheaders',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware'
]
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.AllowAny' ],
'CORS_ORIGIN_ALLOW_ALL' : True
}
ROOT_URLCONF = 'middleware.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'middleware.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
How come I recieve an error when I allowed all origins?
I have an application which uses Django for the backend and react for the frontend so I setup django-cors-headers. When I tested the application locally with the settings I added, I had no issues. But I deployed to my server, I kept getting 403 error on API requests (except GET requests).
Below is my settings.py file (only the relevant settings):
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '<my-secret-key>'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['<my-server-ip>']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'frontend',
'services',
'rest_framework',
'dj_rest_auth',
'rest_framework.authtoken',
'user',
'corsheaders',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
)
}
CORS_ALLOWED_ORIGINS = [
"http://<my-server-ip>:8000",
"http://localhost:8000",
"http://127.0.0.1:8000",
"http://0.0.0.0"
]
CSRF_TRUSTED_ORIGINS = [
"http://<my-server-ip>:8000",
"http://localhost:8000",
"http://127.0.0.1:8000",
"http://0.0.0.0"
]
CORS_ALLOW_CREDENTIALS = True
I make the API requests from React using axios in the form axios.post('http://:8000/api-endpoint', body, config) with then and catch blocks.
The specific errors that I am getting are:
xhr.js:177 POST http://<my-server-ip>:8000/api/auth/login/ 403 (Forbidden)
and
createError.js:16 Uncaught (in promise) Error: Request failed with status code 403
at createError (createError.js:16)
at settle (settle.js:17)
at XMLHttpRequest.handleLoad (xhr.js:62)
Thanks to dbuchet, I found that the problem here was not CORS, rather the fact that in my settings.py file, I had both session and token authentication listed as the default authentication classes - removing the session authentication class fixed the problem I was having.
Hello I have try make a website using ReactJS and Django with RESTAPI. When i run npm start and python manage.py runserver
separatly that work perfectly. But when i try to render the index.html with django from the react/build. The files that return 404 exists. It doesn't work. It render a blank page with the errors:
My folders:
There is my files.
settings.py
import os
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
DEBUG = True
ALLOWED_HOSTS = [
"127.0.0.1"
]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_framework.authtoken',
'rest_auth',
'polluser.apps.PolluserConfig',
'restapi.apps.RestapiConfig',
'django.contrib.sites',
'allauth',
'allauth.account',
'rest_auth.registration',
]
SITE_ID = 1
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
]
ROOT_URLCONF = 'template.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'static'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'template.wsgi.application'
...
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIR = [
os.path.join(BASE_DIR, 'static')
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
CORS_ORIGIN_ALLOW_ALL = True
ACCOUNT_EMAIL_VERIFICATION = "none"
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_EMAIL_REQUIRED = False
urls.py
from django.contrib import admin
from django.urls import path, include
from django.views.generic import TemplateView
urlpatterns = [
path('', TemplateView.as_view(template_name="build/index.html")),
path('admin/', admin.site.urls),
path('api/', include('restapi.urls')),
path('rest-auth/', include('rest_auth.urls')),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
]
Try to run python manage.py collectstatic command once and check.
Error 404 occur when you request a resource which is not present in the location you are pointing. make sure the request files to be present in <your-project>/static/ folder. static/ directory is along side manage.py file.
If you are passing authorization header in API request. Then make sure it is not forwarded in other request server make to fetch static resource. (Try making request on page without authorization in header and see if same error occurs.)
If you are required to pass authorization to access those resouce then try passing authorization in request header.