Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. URLS:
  2.  
  3. urlpatterns = [
  4. # ADMIN
  5. url(r'^admin/', admin.site.urls),
  6. # COCOME
  7. url(r'^', include('cocome_app.urls')),
  8. ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
  9.  
  10. ------------------------------
  11.  
  12. SETTINGS: Esta compuesto de dos ficheros common.py y production.py
  13.  
  14. --- COMMOM.PY
  15.  
  16. # SECURITY WARNING: keep the secret key used in production secret!
  17. SECRET_KEY = ''
  18.  
  19. # Locale
  20.  
  21. LANGUAGES = (
  22. ('en', _('English')),
  23. ('es', _('Spanish')),
  24. )
  25.  
  26. LOCALE_PATHS = (
  27. os.path.join(BASE_DIR, 'locale'),
  28. )
  29.  
  30. # Application definition
  31.  
  32. INSTALLED_APPS = [
  33. 'django.contrib.admin',
  34. 'django.contrib.auth',
  35. 'django.contrib.contenttypes',
  36. 'django.contrib.sessions',
  37. 'django.contrib.messages',
  38. 'django.contrib.staticfiles',
  39.  
  40. 'cocome_app',
  41.  
  42. 'compressor',
  43. 'django_countries',
  44. 'djmoney',
  45. 'bootstrap4',
  46. 'fa',
  47. ]
  48.  
  49. MIDDLEWARE = [
  50. 'django.middleware.security.SecurityMiddleware',
  51. # Deben tener este orden para que funcione las traducciones
  52. 'django.contrib.sessions.middleware.SessionMiddleware',
  53. 'django.middleware.locale.LocaleMiddleware',
  54. 'django.middleware.common.CommonMiddleware',
  55. 'django.middleware.csrf.CsrfViewMiddleware',
  56. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  57. 'django.contrib.messages.middleware.MessageMiddleware',
  58. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  59. 'django.middleware.http.ConditionalGetMiddleware',
  60. ]
  61.  
  62. ROOT_URLCONF = 'cocome_project.urls'
  63.  
  64. WSGI_APPLICATION = 'cocome_project.wsgi.application'
  65.  
  66. # Password validation
  67. # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
  68.  
  69. AUTH_PASSWORD_VALIDATORS = [
  70. {
  71. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  72. },
  73. {
  74. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  75. },
  76. {
  77. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  78. },
  79. {
  80. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  81. },
  82. ]
  83.  
  84. # Internationalization
  85. # https://docs.djangoproject.com/en/1.11/topics/i18n/
  86.  
  87. LANGUAGE_CODE = 'en-us'
  88. LANGUAGE_COOKIE_NAME = 'lang'
  89. TIME_ZONE = 'UTC'
  90. USE_I18N = True
  91. USE_L10N = True
  92. USE_TZ = True
  93.  
  94. # Static files (CSS, JavaScript, Images)
  95. # https://docs.djangoproject.com/en/1.11/howto/static-files/
  96.  
  97. STATIC_URL = '/static/'
  98. STATIC_ROOT = os.path.join(PROJECT_PATH, 'staticfiles')
  99. STATICFILES_DIRS = (
  100. os.path.join(PROJECT_PATH, 'static'),
  101. )
  102.  
  103. # File storage
  104. MEDIA_URL = '/media/'
  105. MEDIA_ROOT = (
  106. os.path.join(BASE_DIR, 'media')
  107. )
  108.  
  109. # Login static configuration
  110. LOGIN_REDIRECT_URL = "/"
  111. LOGIN_URL = '/login'
  112. LOGOUT_URL = '/'
  113.  
  114. # Simplified static file serving.
  115. # https://warehouse.python.org/project/whitenoise/
  116.  
  117. STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
  118. AUTHENTICATION_BACKENDS = ('cocome_app.backends.backend.EmailBackend',)
  119.  
  120. EMAIL_HOST = 'smtp.1and1.es'
  121. EMAIL_PORT = 587
  122. EMAIL_HOST_USER = ''
  123. EMAIL_HOST_PASSWORD = ''
  124. EMAIL_USE_TLS = True
  125. DEFAULT_FROM_EMAIL = ''
  126.  
  127. --- PRODUCTION.PY
  128.  
  129. # SECURITY WARNING: don't run with debug turned on in production!
  130. DEBUG = False
  131.  
  132. ALLOWED_HOSTS = ['.dominio.es', '.dominio.com']
  133.  
  134. TEMPLATES = [
  135. {
  136. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  137. 'DIRS': [os.path.join(PROJECT_PATH, 'templates'), ],
  138. # 'APP_DIRS': True,
  139. 'OPTIONS': {
  140. 'context_processors': [
  141. 'django.template.context_processors.i18n',
  142. 'django.template.context_processors.debug',
  143. 'django.template.context_processors.request',
  144. 'django.contrib.auth.context_processors.auth',
  145. 'django.contrib.messages.context_processors.messages',
  146. 'django.template.context_processors.media',
  147. ],
  148. 'loaders': [
  149. ('django.template.loaders.cached.Loader', [
  150. 'django.template.loaders.filesystem.Loader',
  151. 'django.template.loaders.app_directories.Loader',
  152. ]),
  153. ],
  154. },
  155. },
  156. ]
  157.  
  158. COMPRESS_ENABLED = True
  159.  
  160. STATICFILES_FINDERS = (
  161. 'django.contrib.staticfiles.finders.FileSystemFinder',
  162. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  163. # other finders..
  164. 'compressor.finders.CompressorFinder',
  165. )
  166.  
  167. # Database
  168. # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
  169.  
  170. DATABASES = {
  171. 'default': {
  172. 'ENGINE': 'django.db.backends.mysql',
  173. 'NAME': '',
  174. 'USER': '',
  175. 'PASSWORD': '',
  176. 'HOST': 'mysqldb', # Or an IP Address that your DB is hosted on
  177. 'PORT': '3306',
  178. }
  179. }
  180.  
  181.  
  182. Ejemplo de template llamando a static:
  183.  
  184. {% load static %}
  185. {% load font_awesome %}
  186. {% load i18n %}
  187. {% load l10n %}
  188.  
  189. <div class="col-md-9">
  190. <ul class="navbar-nav mr-auto flex-container">
  191. <li>
  192. <a class="nav-link" href="{% url 'cocome:login' %}">
  193. <img src="{% static 'img/icons/cocome-h.png' %}">
  194. <span>Encuentros</span>
  195. </a>
  196. </li>
  197. <li>
  198. <a class="nav-link" href="{% url 'cocome:login' %}">
  199. <img src="{% static 'img/icons/workshops-h.png' %}">
  200. <span>Talleres</span>
  201. </a>
  202. </li>
  203. <li>
  204. <a class="nav-link" href="{% url 'cocome:login' %}">
  205. <img src="{% static 'img/icons/chefs-h.png' %}">
  206. <span>Chefs</span>
  207. </a>
  208. </li>
  209. </ul>
  210. </div>
  211. <div class="col-md-3">
  212. <a class="btn btn-secondary btn-sm" href="{% url 'cocome:login' %}" data-turbolinks-action="replace">Iniciar sesión</a>
  213. <a class="btn btn-secondary btn-sm" href="{% url 'cocome:login' %}">Crear cuenta</a>
  214. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement