|
1 |
| -import os |
| 1 | +""" |
| 2 | +Test project for Django REST Knox |
| 3 | +""" |
2 | 4 |
|
3 |
| -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
4 |
| -SECRET_KEY = 'gcr$j^h2@d@sd(f#-ihtv6*hg7qno$otw62^*rzcf0tk2wz&sb' |
| 5 | +from pathlib import Path |
| 6 | + |
| 7 | +BASE_DIR = Path(__file__).resolve().parent.parent |
| 8 | +SECRET_KEY = "i-am-a-super-secret-key" |
5 | 9 | DEBUG = True
|
6 |
| -ALLOWED_HOSTS = [] |
7 |
| -INSTALLED_APPS = ( |
8 |
| - 'django.contrib.auth', |
9 |
| - 'django.contrib.contenttypes', |
10 |
| - 'django.contrib.sessions', |
11 |
| - 'rest_framework', |
12 |
| - 'knox', |
13 |
| -) |
14 |
| - |
15 |
| -MIDDLEWARE_CLASSES = ( |
16 |
| - 'django.contrib.sessions.middleware.SessionMiddleware', |
17 |
| - 'django.middleware.common.CommonMiddleware', |
18 |
| - 'django.middleware.csrf.CsrfViewMiddleware', |
19 |
| - 'django.contrib.auth.middleware.AuthenticationMiddleware', |
20 |
| - 'django.middleware.security.SecurityMiddleware', |
21 |
| -) |
22 |
| - |
23 |
| -ROOT_URLCONF = 'knox_project.urls' |
| 10 | +ALLOWED_HOSTS = ["*"] |
| 11 | + |
| 12 | +# Application definition |
| 13 | +INSTALLED_APPS = [ |
| 14 | + "django.contrib.admin", |
| 15 | + "django.contrib.auth", |
| 16 | + "django.contrib.contenttypes", |
| 17 | + "django.contrib.sessions", |
| 18 | + "django.contrib.messages", |
| 19 | + "django.contrib.staticfiles", |
| 20 | + "rest_framework", |
| 21 | + "knox", |
| 22 | +] |
| 23 | + |
| 24 | +MIDDLEWARE = [ |
| 25 | + "django.middleware.security.SecurityMiddleware", |
| 26 | + "django.contrib.sessions.middleware.SessionMiddleware", |
| 27 | + "django.middleware.common.CommonMiddleware", |
| 28 | + "django.middleware.csrf.CsrfViewMiddleware", |
| 29 | + "django.contrib.auth.middleware.AuthenticationMiddleware", |
| 30 | + "django.contrib.messages.middleware.MessageMiddleware", |
| 31 | + "django.middleware.clickjacking.XFrameOptionsMiddleware", |
| 32 | +] |
| 33 | + |
| 34 | +ROOT_URLCONF = "knox_project.urls" |
24 | 35 |
|
25 | 36 | TEMPLATES = [
|
26 | 37 | {
|
27 |
| - 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
28 |
| - 'DIRS': [], |
29 |
| - 'APP_DIRS': True, |
30 |
| - 'OPTIONS': { |
31 |
| - 'context_processors': [ |
32 |
| - 'django.template.context_processors.debug', |
33 |
| - 'django.template.context_processors.request', |
34 |
| - 'django.contrib.auth.context_processors.auth', |
| 38 | + "BACKEND": "django.template.backends.django.DjangoTemplates", |
| 39 | + "DIRS": [], |
| 40 | + "APP_DIRS": True, |
| 41 | + "OPTIONS": { |
| 42 | + "context_processors": [ |
| 43 | + "django.template.context_processors.debug", |
| 44 | + "django.template.context_processors.request", |
| 45 | + "django.contrib.auth.context_processors.auth", |
| 46 | + "django.contrib.messages.context_processors.messages", |
35 | 47 | ],
|
36 | 48 | },
|
37 | 49 | },
|
38 | 50 | ]
|
39 | 51 |
|
40 |
| -WSGI_APPLICATION = 'knox_project.wsgi.application' |
41 |
| - |
42 | 52 | DATABASES = {
|
43 |
| - 'default': { |
44 |
| - 'ENGINE': 'django.db.backends.sqlite3', |
45 |
| - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), |
| 53 | + "default": { |
| 54 | + "ENGINE": "django.db.backends.sqlite3", |
| 55 | + "NAME": "db.sqlite3", |
46 | 56 | }
|
47 | 57 | }
|
48 | 58 |
|
49 |
| -LANGUAGE_CODE = 'en-us' |
50 |
| -TIME_ZONE = 'UTC' |
| 59 | +WSGI_APPLICATION = "knox_project.wsgi.application" |
| 60 | + |
| 61 | +LANGUAGE_CODE = "en-us" |
| 62 | +TIME_ZONE = "UTC" |
51 | 63 | USE_I18N = True
|
52 | 64 | USE_TZ = True
|
53 | 65 |
|
54 |
| -STATIC_URL = '/static/' |
| 66 | +# Static files (CSS, JavaScript, Images) |
| 67 | +# https://docs.djangoproject.com/en/5.0/howto/static-files/ |
| 68 | + |
| 69 | +STATIC_URL = "static/" |
55 | 70 |
|
56 |
| -KNOX_TOKEN_MODEL = 'knox.AuthToken' |
| 71 | +# Default primary key field type |
| 72 | +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field |
| 73 | + |
| 74 | +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" |
| 75 | + |
| 76 | +# Django REST Knox settings |
| 77 | +REST_FRAMEWORK = { |
| 78 | + "DEFAULT_AUTHENTICATION_CLASSES": [ |
| 79 | + "rest_framework.authentication.BasicAuthentication", |
| 80 | + "rest_framework.authentication.SessionAuthentication", |
| 81 | + "knox.auth.TokenAuthentication", |
| 82 | + ] |
| 83 | +} |
0 commit comments