diff --git a/ProyectoWeb/ProyectoWeb/settings.py b/ProyectoWeb/ProyectoWeb/settings.py
index dfd9693..124760e 100644
--- a/ProyectoWeb/ProyectoWeb/settings.py
+++ b/ProyectoWeb/ProyectoWeb/settings.py
@@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'ProyectoWebApp',
+ 'servicios',
]
MIDDLEWARE = [
diff --git a/ProyectoWeb/ProyectoWeb/urls.py b/ProyectoWeb/ProyectoWeb/urls.py
index 5596116..9c622f0 100644
--- a/ProyectoWeb/ProyectoWeb/urls.py
+++ b/ProyectoWeb/ProyectoWeb/urls.py
@@ -21,4 +21,5 @@ from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('ProyectoWebApp.urls')),
+ path('servicios/', include('servicios.urls')),
]
diff --git a/ProyectoWeb/ProyectoWebApp/apps.py b/ProyectoWeb/ProyectoWebApp/apps.py
new file mode 100644
index 0000000..a99c0ba
--- /dev/null
+++ b/ProyectoWeb/ProyectoWebApp/apps.py
@@ -0,0 +1,7 @@
+from django.apps import AppConfig
+
+
+class ProyectowebappConfig(AppConfig):
+ name = 'ProyectoWebApp'
+
+
diff --git a/ProyectoWeb/ProyectoWebApp/models.py b/ProyectoWeb/ProyectoWebApp/models.py
deleted file mode 100644
index 71a8362..0000000
--- a/ProyectoWeb/ProyectoWebApp/models.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.
diff --git a/ProyectoWeb/ProyectoWebApp/templates/ProyectoWebApp/base.html b/ProyectoWeb/ProyectoWebApp/templates/ProyectoWebApp/base.html
index 46bb9fb..d166e5f 100644
--- a/ProyectoWeb/ProyectoWebApp/templates/ProyectoWebApp/base.html
+++ b/ProyectoWeb/ProyectoWebApp/templates/ProyectoWebApp/base.html
@@ -8,7 +8,7 @@
-
+
@@ -28,7 +28,7 @@
diff --git a/ProyectoWeb/ProyectoWebApp/templates/ProyectoWebApp/servicios.html b/ProyectoWeb/ProyectoWebApp/templates/ProyectoWebApp/servicios.html
deleted file mode 100644
index 29ec10a..0000000
--- a/ProyectoWeb/ProyectoWebApp/templates/ProyectoWebApp/servicios.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{% extends 'ProyectoWebApp/base.html' %}
-
-{% load static %}
-
-{% block content %}
-
-
-
-{% endblock %}
-
diff --git a/ProyectoWeb/ProyectoWebApp/urls.py b/ProyectoWeb/ProyectoWebApp/urls.py
index 1504684..e49fca1 100644
--- a/ProyectoWeb/ProyectoWebApp/urls.py
+++ b/ProyectoWeb/ProyectoWebApp/urls.py
@@ -1,17 +1,17 @@
from django.urls import path
from ProyectoWebApp import views
+
from django.conf import settings
from django.conf.urls.static import static
-
urlpatterns = [
path('', views.home, name="Inicio"),
- path('servicios', views.servicios, name ='Servicios'),
path('tienda', views.tienda, name ='Tienda'),
path('blog', views.blog, name ='Blog'),
path('contacto', views.contacto, name='Contacto'),
path('sample/', views.sample, name ='Sample'),
]
+
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
diff --git a/ProyectoWeb/ProyectoWebApp/views.py b/ProyectoWeb/ProyectoWebApp/views.py
index ab11ca6..317fe77 100644
--- a/ProyectoWeb/ProyectoWebApp/views.py
+++ b/ProyectoWeb/ProyectoWebApp/views.py
@@ -2,9 +2,6 @@ from django.shortcuts import render, HttpResponse
def home(request):
return render(request, "ProyectoWebApp/home.html")
-
-def servicios(request):
- return render(request, "ProyectoWebApp/servicios.html")
def tienda(request):
return render(request, "ProyectoWebApp/tienda.html")
@@ -18,4 +15,3 @@ def contacto(request):
def sample(request):
return render(request, "ProyectoWebApp/sample.html")
-
diff --git a/ProyectoWeb/README.md b/ProyectoWeb/README.md
index f7f85ab..89b07f0 100644
--- a/ProyectoWeb/README.md
+++ b/ProyectoWeb/README.md
@@ -1,21 +1,173 @@
-# 📚️ [Proyecto Web Completo](https://gitea.kickto.net/jp.av.dev/intro_Django/src/branch/master/ProyectoWeb)
+**Ejémplo estructura común página web**
+```
++---------------------------------------+
+| +------+ +-------------------+ |
+| | Logo | | Menu | |<---- cont. estatico y dinamico
+| +------+ +-------------------+ |
+| |
+| |
+| +-------------------------------+ |
+| | | |
+| | | |
+| | Zona de Carga | |
+| | | |
+| | de Contenido | |<---- cont. estatico y dinamico
+| | | |
+| | | |
+| | | |
+| +-------------------------------+ |
+| |
+| +-------------------------------+ |
+| | Pie de página | | <---- rrss, contacto
+| +-------------------------------+ |
++---------------------------------------+
+```
+El contenido a mostar en la zona de carga dependerá
+de lo seleccionado en menú o pie de página.
+
+- Crear URLs y Vistas
+- Crear Plantillas y herencias
+- Manejar archivos externos
+- Conf. panel de administración
+- Conf. conexión a BBDD
+- CRUD con BBDD
+- Trabajo con formularios y envío de mails
+- Depsliege
+
+
+## Inicio ProyectoWeb
+```
+django-admin startproject ProyectoWeb
+
+cd ProyectoWeb
+
+python3 manage.py startapp ProyectoWebApp
+
+# configuar settings.py (TimeZone, idioma, ip , mail, bd...)
+
+python3 manage.py runserver 192.168.0.4:8000'
+```
+
+### Menu:
+- Home
+- Servicios
+- Tienda
+- Blog
+- Contacto
+- *(admin)*
+
+
+App/
+*views.py*
+```
+from django.shortcuts import render, HttpResponse
+
+def home(request):
+ return HttpResponse("Inicio")
+
+def servicios(request):
+ return HttpResponse("Servicios")
+
+def tienda(request):
+ return HttpResponse("Tienda")
+
+def blog(request):
+ return HttpResponse("Blog")
+
+def contacto(request):
+ return HttpResponse("Contacto")
+```
+Project/*urls.py*
+```
+from django.contrib import admin
+from django.urls import path
+from ProyectoWebApp import views
+
+urlpatterns = [
+ path('admin/', admin.site.urls),
+ path('', views.home, name="Inicio"),
+ path('servicios/', views.servicios, name ='Servicios'),
+ path('tienda/', views.tienda, name ='Tienda'),
+ path('blog/', views.blog, name ='Blog'),
+ path('contacto/', views.contacto, name='Contacto'),
+]
+```
+
+*Como es común un proyecto se compone de varias Apps*
+*Y una App puede ser reutilizada en otro proyecto*
+*urls.py explica como organizar urls para manejar multiples Apps*
+
+
+### Organizar URLs
+
+**Including another URLconf**
+ - 1. Import the include() function: *from django.urls import include, path*
+ - 2. Add a URL to urlpatterns: *path('blog/', include('blog.urls'))*
+
+
+Project/*urls.py*
+```
+from django.contrib import admin
+from django.urls import path, include
+
+
+urlpatterns = [
+ path('admin/', admin.site.urls),
+ path('ProyectoWebApp/', include('ProyectoWebApp.urls')),
+]
+```
+**Para evitar tener que escribir misitio.com/ProyectoWebApp/home**
+**Dejar '' en vez de 'Proyec...' en el path de ProyectoWeb/urls.py**
+
+### Crear urls.py en la carpeta de la aplicacion
+*App/urls.py*
+```
+from django.urls import path
+from ProyectoWebApp import views
+
+urlpatterns = [
+ path('', views.home, name="Inicio"),
+ path('servicios/', views.servicios, name ='Servicios'),
+ path('tienda/', views.tienda, name ='Tienda'),
+ path('blog/', views.blog, name ='Blog'),
+ path('contacto/', views.contacto, name='Contacto'),
+]
+```
+
+## Crear Templates
+
+***ProyectoWebApp/templates/ProyectoWebApp/ por convención***
+inicio - servicios - tienda - blog - contacto
+
+### Registrar App
+***Project/settings.py***
+```
+INSTALLED_APPS = [
+ ...
+ 'ProyectoWebApp',
+]
+```
+
+### Modificar vistas para html
+App/*views.py*
+```
+from django.shortcuts import render, HttpResponse
+
+def home(request):
+ return render(request, "ProyectoWebApp/home.html")
+
+def servicios(request):
+ return render(request, "ProyectoWebApp/servicios.html")
+
+def tienda(request):
+ return render(request, "ProyectoWebApp/tienda.html")
+
+def blog(request):
+ return render(request, "ProyectoWebApp/blog.html")
+
+def contacto(request):
+ return render(request, "ProyectoWebApp/contacto.html")
+```
-## [Proyecto Web](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-proyecto-web)
-- [Iniciar Proyecto Django](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-inicio-proyectoweb)
-- [Creación Vistas](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-creaci%C3%B3n-de-las-vistas)
-- [Registro de URLs](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-registro-de-urls)
-- [Organizar URLs por App](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-organizar-urls-por-app)
-- [Crear Templates](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-crear-templates)
-- [Restrar App](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-registrar-app)
-- [Registro Vistas html](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7a_Proyecto_Web_Completo#user-content-modificar-vistas-para-html)
-## [Bootstrap y Herencia en la estructura del sitio](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo)
-- [Formato del sitio con Bootstrap](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-dar-formato-al-sitio-con-bootstrap)
-- [TAG {% load static %}](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-tag-load-static)
-- [Herencia de Plantillas](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-herencia-de-plantillas-y-estructura-del-sitio)
-- [Creación de plantilla base](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-creaci%C3%B3n-plantilla-base)
-- [Barra de navegación, destacar sitio en visita](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-barra-de-navegacion-destacar-sitio-en-visita)
-- [Creación App servicios](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-creacion-de-otra-app)
-- [ORM Creación modelo](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-orm-object-relational-mapping)
-- [Pillow, almacenar imagenes](https://gitea.kickto.net/jp.av.dev/intro_Django/wiki/7b_Proyecto_Web_Completo#user-content-para-usar-imagenes)
diff --git a/ProyectoWeb/manage.py b/ProyectoWeb/manage.py
new file mode 100755
index 0000000..bab5e1a
--- /dev/null
+++ b/ProyectoWeb/manage.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+ """Run administrative tasks."""
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ProyectoWeb.settings')
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError as exc:
+ raise ImportError(
+ "Couldn't import Django. Are you sure it's installed and "
+ "available on your PYTHONPATH environment variable? Did you "
+ "forget to activate a virtual environment?"
+ ) from exc
+ execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ProyectoWeb/servicios/migrations/0008_auto_20201120_1523.py b/ProyectoWeb/servicios/migrations/0008_auto_20201120_1523.py
new file mode 100644
index 0000000..61795bd
--- /dev/null
+++ b/ProyectoWeb/servicios/migrations/0008_auto_20201120_1523.py
@@ -0,0 +1,22 @@
+# Generated by Django 3.1.3 on 2020-11-20 18:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('servicios', '0007_auto_20201119_0323'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='servicio',
+ options={'verbose_name': 'servicio', 'verbose_name_plural': 'servicios'},
+ ),
+ migrations.AlterField(
+ model_name='servicio',
+ name='imagen',
+ field=models.ImageField(upload_to='servicios'),
+ ),
+ ]
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0001_initial.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0001_initial.cpython-38.pyc
new file mode 100644
index 0000000..c2f4e45
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0001_initial.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0002_auto_20201118_2354.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0002_auto_20201118_2354.cpython-38.pyc
new file mode 100644
index 0000000..c647c4d
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0002_auto_20201118_2354.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0003_auto_20201118_2357.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0003_auto_20201118_2357.cpython-38.pyc
new file mode 100644
index 0000000..229cd8e
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0003_auto_20201118_2357.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0004_auto_20201119_0000.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0004_auto_20201119_0000.cpython-38.pyc
new file mode 100644
index 0000000..b77c144
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0004_auto_20201119_0000.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0005_auto_20201119_0010.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0005_auto_20201119_0010.cpython-38.pyc
new file mode 100644
index 0000000..e801f46
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0005_auto_20201119_0010.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0006_auto_20201119_0323.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0006_auto_20201119_0323.cpython-38.pyc
new file mode 100644
index 0000000..b84cbb4
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0006_auto_20201119_0323.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0007_auto_20201119_0323.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0007_auto_20201119_0323.cpython-38.pyc
new file mode 100644
index 0000000..8b49af6
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0007_auto_20201119_0323.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/0008_auto_20201120_1523.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/0008_auto_20201120_1523.cpython-38.pyc
new file mode 100644
index 0000000..e5a1968
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/0008_auto_20201120_1523.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/migrations/__pycache__/__init__.cpython-38.pyc b/ProyectoWeb/servicios/migrations/__pycache__/__init__.cpython-38.pyc
new file mode 100644
index 0000000..979cff9
Binary files /dev/null and b/ProyectoWeb/servicios/migrations/__pycache__/__init__.cpython-38.pyc differ
diff --git a/ProyectoWeb/servicios/models.py b/ProyectoWeb/servicios/models.py
index e4f1738..9f25194 100644
--- a/ProyectoWeb/servicios/models.py
+++ b/ProyectoWeb/servicios/models.py
@@ -5,10 +5,10 @@ from django.db import models
class Servicio(models.Model):
titulo = models.CharField( max_length = 50 )
contenido = models.CharField( max_length = 50 )
- imagen = models.ImageField(upload_to = 'servicios')
+ imagen = models.ImageField( upload_to= 'servicios' )
created = models.DateTimeField( auto_now_add = True)
updated = models.DateTimeField( auto_now_add = True)
-
+
class Meta:
verbose_name = 'servicio'
verbose_name_plural = 'servicios'
@@ -17,5 +17,3 @@ class Servicio(models.Model):
def __str__(self):
return self.titulo
-
-
diff --git a/ProyectoWeb/servicios/templates/servicios/servicios.html b/ProyectoWeb/servicios/templates/servicios/servicios.html
new file mode 100644
index 0000000..7fac6f8
--- /dev/null
+++ b/ProyectoWeb/servicios/templates/servicios/servicios.html
@@ -0,0 +1,18 @@
+{% extends 'ProyectoWebApp/base.html' %}
+
+{% load static %}
+
+{% block content %}
+
+ {% for servicio in servicios %}
+
+
+
{{servicio.titulo}}
+
{{servicio.contenido}}
+

+
+
+ {% endfor %}
+
+{% endblock %}
+
diff --git a/ProyectoWeb/servicios/urls.py b/ProyectoWeb/servicios/urls.py
new file mode 100644
index 0000000..2bc8be9
--- /dev/null
+++ b/ProyectoWeb/servicios/urls.py
@@ -0,0 +1,11 @@
+from django.urls import path
+from . import views
+from django.conf import settings
+from django.conf.urls.static import static
+
+urlpatterns = [
+ path('', views.servicios, name ='Servicios'),
+]
+
+
+urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
diff --git a/ProyectoWeb/servicios/views.py b/ProyectoWeb/servicios/views.py
index 91ea44a..e22f045 100644
--- a/ProyectoWeb/servicios/views.py
+++ b/ProyectoWeb/servicios/views.py
@@ -1,3 +1,8 @@
from django.shortcuts import render
+from servicios.models import Servicio
# Create your views here.
+def servicios(request):
+ servicios = Servicio.objects.all()
+ return render(request, "servicios/servicios.html", {"servicios":servicios})
+