Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
| Següent revisió | Revisió prèvia | ||
|
django_railway [2023/05/11 16:14] enric_mieza_sanchez creat |
django_railway [2023/05/12 14:05] (actual) enric_mieza_sanchez [Setup BD] |
||
|---|---|---|---|
| Línia 6: | Línia 6: | ||
| {{https:// | {{https:// | ||
| + | |||
| + | Referències: | ||
| + | * CLI Railway: https:// | ||
| + | * ... | ||
| {{tag> #FpInfor #DawMp07 #DawMp07Uf3 # | {{tag> #FpInfor #DawMp07 #DawMp07Uf3 # | ||
| + | \\ | ||
| + | |||
| + | ===== Tutorial bàsic ===== | ||
| + | |||
| + | Aquest [[https:// | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ===== Setup BD ==== | ||
| + | |||
| + | A part de la pujada de codi que hem fet anteriorment, | ||
| + | - Fer les migracions | ||
| + | - Recollir arxius estàtics | ||
| + | - Crear un superusuari d' | ||
| + | - Crear dades de mostra amb Faker o altres que haguem pogut fer. | ||
| + | |||
| + | Per realitzar això caldrà anar a | ||
| + | Settings -> Build Command | ||
| + | |||
| + | {{railway-build-settings.png}} | ||
| + | |||
| + | I hi posarem les instruccions per a que tot funcioni: | ||
| + | <WRAP prewrap> | ||
| + | . / | ||
| + | </ | ||
| + | |||
| + | Això sí, un cop posat en producció, entra i posa-hi una password més segura. | ||
| + | |||
| + | Si hem fet una comanda personalitzada per crear dades amb el Faker, es pot afegir a la comanda indicada més amunt. Per exemple, si has seguit l' | ||
| + | python3 manage.py crea_lliga "Lliga 1a divisió" | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ===== Servir arxius estàtics ===== | ||
| + | Si encara que fem el '' | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | Només cal tocar l' | ||
| + | |||
| + | <file python urls.py> | ||
| + | from django.contrib import admin | ||
| + | from django.urls import include, | ||
| + | from django.conf.urls.static import static | ||
| + | from django.conf import settings | ||
| + | |||
| + | from lliga.views import profile | ||
| + | |||
| + | urlpatterns = [ | ||
| + | path(' | ||
| + | path(' | ||
| + | path(" | ||
| + | path(" | ||
| + | |||
| + | ] + static(settings.STATIC_URL, | ||
| + | |||
| + | </ | ||
| + | |||
| + | \\ | ||