Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- URLS:
- urlpatterns = [
- # ADMIN
- url(r'^admin/', admin.site.urls),
- # COCOME
- url(r'^', include('cocome_app.urls')),
- ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
- ------------------------------
- SETTINGS: Esta compuesto de dos ficheros common.py y production.py
- --- COMMOM.PY
- # SECURITY WARNING: keep the secret key used in production secret!
- SECRET_KEY = ''
- # Locale
- LANGUAGES = (
- ('en', _('English')),
- ('es', _('Spanish')),
- )
- LOCALE_PATHS = (
- os.path.join(BASE_DIR, 'locale'),
- )
- # Application definition
- INSTALLED_APPS = [
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'cocome_app',
- 'compressor',
- 'django_countries',
- 'djmoney',
- 'bootstrap4',
- 'fa',
- ]
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- # Deben tener este orden para que funcione las traducciones
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.locale.LocaleMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'django.middleware.http.ConditionalGetMiddleware',
- ]
- ROOT_URLCONF = 'cocome_project.urls'
- WSGI_APPLICATION = 'cocome_project.wsgi.application'
- # Password validation
- # https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/
- LANGUAGE_CODE = 'en-us'
- LANGUAGE_COOKIE_NAME = 'lang'
- TIME_ZONE = 'UTC'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = True
- # Static files (CSS, JavaScript, Images)
- # https://docs.djangoproject.com/en/1.11/howto/static-files/
- STATIC_URL = '/static/'
- STATIC_ROOT = os.path.join(PROJECT_PATH, 'staticfiles')
- STATICFILES_DIRS = (
- os.path.join(PROJECT_PATH, 'static'),
- )
- # File storage
- MEDIA_URL = '/media/'
- MEDIA_ROOT = (
- os.path.join(BASE_DIR, 'media')
- )
- # Login static configuration
- LOGIN_REDIRECT_URL = "/"
- LOGIN_URL = '/login'
- LOGOUT_URL = '/'
- # Simplified static file serving.
- # https://warehouse.python.org/project/whitenoise/
- STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
- AUTHENTICATION_BACKENDS = ('cocome_app.backends.backend.EmailBackend',)
- EMAIL_HOST = 'smtp.1and1.es'
- EMAIL_PORT = 587
- EMAIL_HOST_USER = ''
- EMAIL_HOST_PASSWORD = ''
- EMAIL_USE_TLS = True
- DEFAULT_FROM_EMAIL = ''
- --- PRODUCTION.PY
- # SECURITY WARNING: don't run with debug turned on in production!
- DEBUG = False
- ALLOWED_HOSTS = ['.dominio.es', '.dominio.com']
- TEMPLATES = [
- {
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [os.path.join(PROJECT_PATH, 'templates'), ],
- # 'APP_DIRS': True,
- 'OPTIONS': {
- 'context_processors': [
- 'django.template.context_processors.i18n',
- 'django.template.context_processors.debug',
- 'django.template.context_processors.request',
- 'django.contrib.auth.context_processors.auth',
- 'django.contrib.messages.context_processors.messages',
- 'django.template.context_processors.media',
- ],
- 'loaders': [
- ('django.template.loaders.cached.Loader', [
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
- ]),
- ],
- },
- },
- ]
- COMPRESS_ENABLED = True
- STATICFILES_FINDERS = (
- 'django.contrib.staticfiles.finders.FileSystemFinder',
- 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
- # other finders..
- 'compressor.finders.CompressorFinder',
- )
- # Database
- # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.mysql',
- 'NAME': '',
- 'USER': '',
- 'PASSWORD': '',
- 'HOST': 'mysqldb', # Or an IP Address that your DB is hosted on
- 'PORT': '3306',
- }
- }
- Ejemplo de template llamando a static:
- {% load static %}
- {% load font_awesome %}
- {% load i18n %}
- {% load l10n %}
- <div class="col-md-9">
- <ul class="navbar-nav mr-auto flex-container">
- <li>
- <a class="nav-link" href="{% url 'cocome:login' %}">
- <img src="{% static 'img/icons/cocome-h.png' %}">
- <span>Encuentros</span>
- </a>
- </li>
- <li>
- <a class="nav-link" href="{% url 'cocome:login' %}">
- <img src="{% static 'img/icons/workshops-h.png' %}">
- <span>Talleres</span>
- </a>
- </li>
- <li>
- <a class="nav-link" href="{% url 'cocome:login' %}">
- <img src="{% static 'img/icons/chefs-h.png' %}">
- <span>Chefs</span>
- </a>
- </li>
- </ul>
- </div>
- <div class="col-md-3">
- <a class="btn btn-secondary btn-sm" href="{% url 'cocome:login' %}" data-turbolinks-action="replace">Iniciar sesión</a>
- <a class="btn btn-secondary btn-sm" href="{% url 'cocome:login' %}">Crear cuenta</a>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement