diff --git a/.gitignore b/.gitignore index 6372c66..8dda0c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .idea/ .venv/ .media/ +*/__pycache__/ */*.pyc +NewMediaMonitoring/local_settings.py \ No newline at end of file diff --git a/NewMediaMonitoring/__pycache__/__init__.cpython-38.pyc b/NewMediaMonitoring/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 99b6d01..0000000 Binary files a/NewMediaMonitoring/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/NewMediaMonitoring/__pycache__/settings.cpython-38.pyc b/NewMediaMonitoring/__pycache__/settings.cpython-38.pyc deleted file mode 100644 index b2e3f98..0000000 Binary files a/NewMediaMonitoring/__pycache__/settings.cpython-38.pyc and /dev/null differ diff --git a/NewMediaMonitoring/__pycache__/urls.cpython-38.pyc b/NewMediaMonitoring/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 5e1a0e1..0000000 Binary files a/NewMediaMonitoring/__pycache__/urls.cpython-38.pyc and /dev/null differ diff --git a/NewMediaMonitoring/settings.py b/NewMediaMonitoring/settings.py index 6cbb2b9..809781a 100644 --- a/NewMediaMonitoring/settings.py +++ b/NewMediaMonitoring/settings.py @@ -37,6 +37,8 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django_token', + 'corsheaders', 'bootstrap3', 'captcha', 'dashboard', @@ -47,11 +49,13 @@ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django_token.middleware.TokenMiddleware', ] ROOT_URLCONF = 'NewMediaMonitoring.urls' @@ -106,6 +110,11 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] +AUTHENTICATION_BACKENDS = ( + 'django.contrib.auth.backends.ModelBackend', + 'django_token.backends.TokenBackend' +) + # Internationalization # https://docs.djangoproject.com/en/2.1/topics/i18n/ @@ -134,6 +143,10 @@ MEDIA_ROOT = '/var/www/p3/NewMediaMonitoring/media/' AUTH_PROFILE_MODULE = 'djangoadmin.myadmin.UserProfile' """用户模块扩展完成""" +CORS_ORIGIN_ALLOW_ALL = True + +CORS_URLS_REGEX = r'^/polls/.*$' + try: from .local_settings import * except ImportError as e: diff --git a/NewMediaMonitoring/urls.py b/NewMediaMonitoring/urls.py index eb317f4..40cdde0 100644 --- a/NewMediaMonitoring/urls.py +++ b/NewMediaMonitoring/urls.py @@ -17,8 +17,9 @@ from django.contrib import admin from django.urls import path, include urlpatterns = [ + path('polls/', include('polls.urls')), path('admin/', admin.site.urls), path('', include('dashboard.urls')), path('captcha/', include('captcha.urls')), - path('management/',include('management.urls')) + path('management/', include('management.urls')) ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..0abe539 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# install + + pip install git+https://github.com/RobWeber3/django-token.git \ No newline at end of file diff --git a/dashboard/__pycache__/__init__.cpython-38.pyc b/dashboard/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 75a8ad2..0000000 Binary files a/dashboard/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/dashboard/__pycache__/admin.cpython-38.pyc b/dashboard/__pycache__/admin.cpython-38.pyc deleted file mode 100644 index 13d00f5..0000000 Binary files a/dashboard/__pycache__/admin.cpython-38.pyc and /dev/null differ diff --git a/dashboard/__pycache__/models.cpython-38.pyc b/dashboard/__pycache__/models.cpython-38.pyc deleted file mode 100644 index 37f4d79..0000000 Binary files a/dashboard/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/dashboard/__pycache__/urls.cpython-38.pyc b/dashboard/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 643ebd7..0000000 Binary files a/dashboard/__pycache__/urls.cpython-38.pyc and /dev/null differ diff --git a/dashboard/__pycache__/views.cpython-38.pyc b/dashboard/__pycache__/views.cpython-38.pyc deleted file mode 100644 index c4ceea7..0000000 Binary files a/dashboard/__pycache__/views.cpython-38.pyc and /dev/null differ diff --git a/management/__pycache__/__init__.cpython-38.pyc b/management/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 4691ee3..0000000 Binary files a/management/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/management/__pycache__/admin.cpython-38.pyc b/management/__pycache__/admin.cpython-38.pyc deleted file mode 100644 index 4b53c65..0000000 Binary files a/management/__pycache__/admin.cpython-38.pyc and /dev/null differ diff --git a/management/__pycache__/models.cpython-38.pyc b/management/__pycache__/models.cpython-38.pyc deleted file mode 100644 index 85798c6..0000000 Binary files a/management/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/management/__pycache__/urls.cpython-38.pyc b/management/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 5d3fcab..0000000 Binary files a/management/__pycache__/urls.cpython-38.pyc and /dev/null differ diff --git a/management/__pycache__/views.cpython-38.pyc b/management/__pycache__/views.cpython-38.pyc deleted file mode 100644 index 24294fe..0000000 Binary files a/management/__pycache__/views.cpython-38.pyc and /dev/null differ diff --git a/polls/__init__.py b/polls/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/polls/admin.py b/polls/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/polls/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/polls/apps.py b/polls/apps.py new file mode 100644 index 0000000..d0f109e --- /dev/null +++ b/polls/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PollsConfig(AppConfig): + name = 'polls' diff --git a/polls/migrations/__init__.py b/polls/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/polls/models.py b/polls/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/polls/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/polls/tests.py b/polls/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/polls/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/polls/urls.py b/polls/urls.py new file mode 100644 index 0000000..02ddd72 --- /dev/null +++ b/polls/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + path('login', views.polls_login, name='polls_login'), +] diff --git a/requirements.txt b/requirements.txt index 53d730e..f17dc87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ Django~=2.2.15 django-bootstrap3 django-simple-captcha psycopg2-binary +django-cors-headers