Ich habe auf GitHub ein Repository runtergeladen, und versuche es zu starten es funktioniert leider nicht.
Meine Schritte:
Ich habe mir das als ZIP runtergeladen: https://github.com/Ronik22/Django_Social_Network_App
Ich habe es im CMD ausgewählt und habe eine virtuelle env geschaffen: virtualenv myenv
Danach: myenv\Scripts\activate
Danach als (myenv) aktiv war: pip install -r requirements.txt
Das hat geklappt, bzw. es sind keine ERRORS aufgeplopt.
Danach noch: python manage.py makemigrations
python manage.py migrate
Dann habe ich versucht es zu starten: python manage.py runserver
Dann kam der Text:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Win10\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Users\Win10\AppData\Local\Programs\Python\Python39\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
self.module.autodiscover()
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\contrib\admin\__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\Win10\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\contrib\auth\admin.py", line 6, in <module>
from django.contrib.auth.forms import (
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\contrib\auth\forms.py", line 11, in <module>
from django.contrib.auth.tokens import default_token_generator
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\contrib\auth\tokens.py", line 117, in <module>
default_token_generator = PasswordResetTokenGenerator()
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\contrib\auth\tokens.py", line 18, in __init__
self.secret = self.secret or settings.SECRET_KEY
File "C:\Users\Win10\Desktop\network-app\myenv\lib\site-packages\django\conf\__init__.py", line 90, in __getattr__
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
woran kann das legen?
Das sind meine Einstellungen:
"""
Django settings for myproject project.
Generated by 'django-admin startproject' using Django 3.1.4.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
import os
from dotenv import load_dotenv
from django.contrib.messages import constants as messages
# Loading ENV
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_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.1/h ... checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv("DEBUG")
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'crispy_forms',
'django_cleanup',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'ckeditor',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.github',
'blog.apps.BlogConfig',
'users.apps.UsersConfig',
'notification',
'chat',
'channels',
'friend',
]
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',
]
ROOT_URLCONF = 'myproject.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'users/templates')],
'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',
],
},
},
]
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
]
WSGI_APPLICATION = 'myproject.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/r ... #databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/r ... 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.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/h ... tic-files/
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGIN_REDIRECT_URL = 'blog-home'
LOGIN_URL = 'account_login'
CKEDITOR_CONFIGS = {
'default': {
'width':'auto',
},
}
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'exmp.gmail.com'
EMAIL_PORT = os.getenv("EMAIL_PORT")
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.getenv('EMAIL_USER') # environment variable containing username
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASS') # environment variable containing password
GOOGLE_RECAPTCHA_SECRET_KEY = os.getenv("SECRET_KEY")
MESSAGE_TAGS = {
messages.DEBUG: 'alert-secondary',
messages.INFO: 'alert-info',
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
messages.ERROR: 'alert-danger',
}
ASGI_APPLICATION = "myproject.routing.application"
CHANNEL_LAYERS = {
"default":{
"BACKEND":"channels.layers.InMemoryChannelLayer"
},
}
SITE_ID = 2 # considering 2nd site in 'Sites' to be 127.0.0.1 (for dev)
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
}
},
'github': {
'SCOPE': [
'user',
'repo',
'read:org',
],
}
}
Ich kann die Python Website nicht lokal starten.
Sagt die Fehlermeldung doch sehr klar. SECRET_KEY darf nicht leer sein. Ist sie aber. Musst du setzten. Ist auch lang und breit dokumentiert. https://docs.djangoproject.com/en/3.2/ref/settings/
Tut mir leid das ich nachfrage, aber wo muss ich setzen?__deets__ hat geschrieben: ↑Sonntag 10. Oktober 2021, 22:25 Sagt die Fehlermeldung doch sehr klar. SECRET_KEY darf nicht leer sein. Ist sie aber. Musst du setzten. Ist auch lang und breit dokumentiert. https://docs.djangoproject.com/en/3.2/ref/settings/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("muss ich hier etwas anderes setzen?")
oder hier:
GOOGLE_RECAPTCHA_SECRET_KEY = os.getenv("hier?")
- __blackjack__
- User
- Beiträge: 13071
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
@Benno12: Die Werte werden offenbar als Umgebungsvariablen erwartet. Als solche muss man sie vor dem Start des Programms setzen. Wie das geht ist vom Betriebssystem abhängig.
„All religions are the same: religion is basically guilt, with different holidays.” — Cathy Ladman