Herramientas de usuario

Herramientas del sitio


wiki2:python:django:project

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:python:django:project [2020/12/25 09:32]
alfred [Preparing a Django project]
wiki2:python:django:project [2021/02/08 18:45] (actual)
Línea 1: Línea 1:
 ====== Preparing a Django project ====== ====== Preparing a Django project ======
 +===== Pipeline =====
  
  
Línea 8: Línea 9:
 poetry add django poetry add django
  
-poetry run django-admin startproject {project}+poetry run django-admin startproject {project} ​.
  
 - fix directory generation - - fix directory generation -
Línea 41: Línea 42:
  
 - Configure whitenoise - Configure whitenoise
 +
 +- Add STATIC_ROOT = os.path.join(BASE_DIR,​ '​static'​)
  
 poetry env list --full-path poetry env list --full-path
Línea 72: Línea 75:
     }     }
 } }
 +
 +ln -s ../​daauth/​daauth daauth
 +
 +- Remove admin from urls.py and from settings -
 +
 +- Add models.py, views.py and the package migrations. Also the apps.py. - 
 +
 +- Add to INSTALLED_APPS:​ daauth & {project}
 +
 +- Add the next lines to settings/​default.py:​
 +AUTH_USER_MODEL = '​{project}.User'​
 +LOGIN_REDIRECT_URL = '/'​
 +
 +python manage.py migrate
 +
 +mkddir -p static/​styles/​sass
 +
 +touch static/​styles/​sass/​main.scss static/​styles/​sass/​stylesheet.scss
 +
 +- Add @import "​stylesheet";​ to main.scss
 +
 +sass --watch static/​styles/​sass/​main.scss:​static/​styles/​stylesheet.css
 +
 +- Add to repository those last files
 +
 +git commit
 +
 +mkdir -p {project}/​templates
 +
 +touch {project}/​templates/​base.html
 +
 +
 +
  
 </​code>​ </​code>​
Línea 171: Línea 207:
 </​code>​ </​code>​
  
 +==== apps.py ====
 +<​code>​
 +from django.apps import AppConfig
 +
 +
 +class {Project}Config(AppConfig):​
 +    name = '​{project}'​
 +</​code>​
 +
 +==== models.py ====
 +<​code>​
 +from django.db import models
 +from daauth.models import BaseUser
 +
 +
 +class User(BaseUser):​
 +    class Meta:
 +        db_table = "​users"​
 +</​code>​
 +
 +==== base.html ====
 +
 +  * http://​htmlshell.com/​
 +
 +<​code>​
 +<​!DOCTYPE html>
 +<!--[if lte IE 6]><​html class="​preIE7 preIE8 preIE9"><​![endif]-->​
 +<!--[if IE 7]><​html class="​preIE8 preIE9"><​![endif]-->​
 +<!--[if IE 8]><​html class="​preIE9"><​![endif]-->​
 +<!--[if gte IE 9]><​!--><​html><​!--<​![endif]-->​
 + {% load dutils %}
 +  <​head>​
 +    <meta charset="​UTF-8">​
 +  <meta http-equiv="​X-UA-Compatible"​ content="​IE=edge,​chrome=1">​
 +  <meta name="​viewport"​ content="​width=device-width,​initial-scale=1">​
 +    <​title>​title</​title>​
 +  <meta name="​author"​ content="​name">​
 +  <meta name="​description"​ content="​description here">​
 +  <meta name="​keywords"​ content="​keywords,​here">​
 +  <link rel="​stylesheet"​ href="​{% dstatic '​styles/​stylesheet.css'​ %}" type="​text/​css">​
 +  </​head>​
 +  <​body>​
 +    aaaaa
 +  </​body>​
 +</​html>​
 +</​code>​
wiki2/python/django/project.1608888770.txt.gz · Última modificación: 2020/12/25 10:32 (editor externo)