commit 112bc9eaea6514e0c6aa2d58aa58a8b6bfbbdc37 Author: AbnerAstete Date: Fri Nov 19 03:30:52 2021 -0300 Prueba consultas en Vistas diff --git a/App/__init__.py b/App/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/App/__pycache__/__init__.cpython-310.pyc b/App/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..948d804 Binary files /dev/null and b/App/__pycache__/__init__.cpython-310.pyc differ diff --git a/App/__pycache__/admin.cpython-310.pyc b/App/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..e853627 Binary files /dev/null and b/App/__pycache__/admin.cpython-310.pyc differ diff --git a/App/__pycache__/apps.cpython-310.pyc b/App/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..ffa53dc Binary files /dev/null and b/App/__pycache__/apps.cpython-310.pyc differ diff --git a/App/__pycache__/models.cpython-310.pyc b/App/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..d0b06d9 Binary files /dev/null and b/App/__pycache__/models.cpython-310.pyc differ diff --git a/App/__pycache__/urls.cpython-310.pyc b/App/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..477827b Binary files /dev/null and b/App/__pycache__/urls.cpython-310.pyc differ diff --git a/App/__pycache__/views.cpython-310.pyc b/App/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..14bdc95 Binary files /dev/null and b/App/__pycache__/views.cpython-310.pyc differ diff --git a/App/admin.py b/App/admin.py new file mode 100644 index 0000000..e593997 --- /dev/null +++ b/App/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from .models import Estudiante, Maestro +# Register your models here. +admin.site.register(Estudiante) +admin.site.register(Maestro) \ No newline at end of file diff --git a/App/apps.py b/App/apps.py new file mode 100644 index 0000000..9df3b1c --- /dev/null +++ b/App/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'App' diff --git a/App/migrations/0001_initial.py b/App/migrations/0001_initial.py new file mode 100644 index 0000000..1dab6a0 --- /dev/null +++ b/App/migrations/0001_initial.py @@ -0,0 +1,35 @@ +# Generated by Django 3.2.9 on 2021-11-19 03:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Estudiante', + fields=[ + ('año_ingreso', models.IntegerField(max_length=4, primary_key=True, serialize=False)), + ('nombre', models.CharField(max_length=20)), + ('apellido', models.CharField(max_length=20)), + ('edad', models.IntegerField(max_length=3)), + ('sexo', models.CharField(max_length=20)), + ], + ), + migrations.CreateModel( + name='Maestro', + fields=[ + ('ano_ingreso', models.IntegerField(max_length=4, primary_key=True, serialize=False)), + ('materia', models.CharField(max_length=20)), + ('nombre', models.CharField(max_length=20)), + ('apellido', models.CharField(max_length=20)), + ('edad', models.IntegerField(max_length=3)), + ('sexo', models.CharField(max_length=20)), + ], + ), + ] diff --git a/App/migrations/0002_auto_20211119_0020.py b/App/migrations/0002_auto_20211119_0020.py new file mode 100644 index 0000000..3256cbf --- /dev/null +++ b/App/migrations/0002_auto_20211119_0020.py @@ -0,0 +1,33 @@ +# Generated by Django 3.2.9 on 2021-11-19 03:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('App', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='estudiante', + name='año_ingreso', + field=models.IntegerField(primary_key=True, serialize=False), + ), + migrations.AlterField( + model_name='estudiante', + name='edad', + field=models.IntegerField(), + ), + migrations.AlterField( + model_name='maestro', + name='ano_ingreso', + field=models.IntegerField(primary_key=True, serialize=False), + ), + migrations.AlterField( + model_name='maestro', + name='edad', + field=models.IntegerField(), + ), + ] diff --git a/App/migrations/0003_delete_estudiante.py b/App/migrations/0003_delete_estudiante.py new file mode 100644 index 0000000..47ae2a8 --- /dev/null +++ b/App/migrations/0003_delete_estudiante.py @@ -0,0 +1,16 @@ +# Generated by Django 3.2.9 on 2021-11-19 03:50 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('App', '0002_auto_20211119_0020'), + ] + + operations = [ + migrations.DeleteModel( + name='Estudiante', + ), + ] diff --git a/App/migrations/0004_estudiante.py b/App/migrations/0004_estudiante.py new file mode 100644 index 0000000..73eb5d0 --- /dev/null +++ b/App/migrations/0004_estudiante.py @@ -0,0 +1,24 @@ +# Generated by Django 3.2.9 on 2021-11-19 03:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('App', '0003_delete_estudiante'), + ] + + operations = [ + migrations.CreateModel( + name='Estudiante', + fields=[ + ('curso', models.CharField(max_length=20, primary_key=True, serialize=False)), + ('año_ingreso', models.IntegerField()), + ('nombre', models.CharField(max_length=20)), + ('apellido', models.CharField(max_length=20)), + ('edad', models.IntegerField()), + ('sexo', models.CharField(max_length=20)), + ], + ), + ] diff --git a/App/migrations/0005_auto_20211119_0055.py b/App/migrations/0005_auto_20211119_0055.py new file mode 100644 index 0000000..a1f0c5e --- /dev/null +++ b/App/migrations/0005_auto_20211119_0055.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.9 on 2021-11-19 03:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('App', '0004_estudiante'), + ] + + operations = [ + migrations.AlterField( + model_name='maestro', + name='ano_ingreso', + field=models.IntegerField(), + ), + migrations.AlterField( + model_name='maestro', + name='materia', + field=models.CharField(max_length=20, primary_key=True, serialize=False), + ), + ] diff --git a/App/migrations/__init__.py b/App/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/App/migrations/__pycache__/0001_initial.cpython-310.pyc b/App/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000..b8648ff Binary files /dev/null and b/App/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/App/migrations/__pycache__/0002_auto_20211119_0020.cpython-310.pyc b/App/migrations/__pycache__/0002_auto_20211119_0020.cpython-310.pyc new file mode 100644 index 0000000..7ab197a Binary files /dev/null and b/App/migrations/__pycache__/0002_auto_20211119_0020.cpython-310.pyc differ diff --git a/App/migrations/__pycache__/0003_delete_estudiante.cpython-310.pyc b/App/migrations/__pycache__/0003_delete_estudiante.cpython-310.pyc new file mode 100644 index 0000000..a147422 Binary files /dev/null and b/App/migrations/__pycache__/0003_delete_estudiante.cpython-310.pyc differ diff --git a/App/migrations/__pycache__/0004_estudiante.cpython-310.pyc b/App/migrations/__pycache__/0004_estudiante.cpython-310.pyc new file mode 100644 index 0000000..d2fefad Binary files /dev/null and b/App/migrations/__pycache__/0004_estudiante.cpython-310.pyc differ diff --git a/App/migrations/__pycache__/0005_auto_20211119_0055.cpython-310.pyc b/App/migrations/__pycache__/0005_auto_20211119_0055.cpython-310.pyc new file mode 100644 index 0000000..225a55e Binary files /dev/null and b/App/migrations/__pycache__/0005_auto_20211119_0055.cpython-310.pyc differ diff --git a/App/migrations/__pycache__/__init__.cpython-310.pyc b/App/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..3209266 Binary files /dev/null and b/App/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/App/models.py b/App/models.py new file mode 100644 index 0000000..486b8c4 --- /dev/null +++ b/App/models.py @@ -0,0 +1,26 @@ +from django.db import models + +# Create your models here. + +class Estudiante(models.Model): + curso=models.CharField(primary_key=True,max_length=20,blank=False) + año_ingreso=models.IntegerField() + nombre=models.CharField(max_length=20) + apellido=models.CharField(max_length=20) + edad=models.IntegerField() + sexo=models.CharField(max_length=20) + + def __str__(self): + return self.nombre + +class Maestro(models.Model): + materia=models.CharField(primary_key=True,max_length=20) + ano_ingreso=models.IntegerField() + nombre=models.CharField(max_length=20) + apellido=models.CharField(max_length=20) + edad=models.IntegerField() + sexo=models.CharField(max_length=20) + + def __str__(self): + return self.materia + diff --git a/App/templates/estudiantes/estudiantes.html b/App/templates/estudiantes/estudiantes.html new file mode 100644 index 0000000..9f434ec --- /dev/null +++ b/App/templates/estudiantes/estudiantes.html @@ -0,0 +1,17 @@ + + + + + + + Document + + +

Lista Estudiantes

+ {% block content %} + {% for x in estudiante%} +
  • {{x}}
  • + {% endfor %} + {% endblock %} + + \ No newline at end of file diff --git a/App/templates/maestros/maestros.html b/App/templates/maestros/maestros.html new file mode 100644 index 0000000..31e1a75 --- /dev/null +++ b/App/templates/maestros/maestros.html @@ -0,0 +1,17 @@ + + + + + + + Document + + +

    Lista Maestros

    + {% block content %} + {% for x in maestro%} +
  • {{x}}
  • + {% endfor %} + {% endblock %} + + \ No newline at end of file diff --git a/App/tests.py b/App/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/App/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/App/urls.py b/App/urls.py new file mode 100644 index 0000000..ffabb4a --- /dev/null +++ b/App/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from .views import * + +urlpatterns = [ + path('',ListaEstudiantes,name = 'ListaEstudiantes'), + path('',ListaMaestros,name = 'ListaMaestros') +] \ No newline at end of file diff --git a/App/views.py b/App/views.py new file mode 100644 index 0000000..a7f6b0c --- /dev/null +++ b/App/views.py @@ -0,0 +1,16 @@ +from django.shortcuts import render +from django.shortcuts import HttpResponse + +from App.models import Estudiante, Maestro + +# Create your views here. + + +def ListaEstudiantes(request): + estudiante = Estudiante.objects.all() + return render(request,'estudiantes/estudiantes.html',{"estudiante":estudiante}) + + +def ListaMaestros(request): + maestro = Maestro.objects.all() + return render(request,'maestros/maestro.html',{"maestro":maestro}) \ No newline at end of file diff --git a/ProyectoColegio/__init__.py b/ProyectoColegio/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ProyectoColegio/__pycache__/__init__.cpython-310.pyc b/ProyectoColegio/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..c4489c7 Binary files /dev/null and b/ProyectoColegio/__pycache__/__init__.cpython-310.pyc differ diff --git a/ProyectoColegio/__pycache__/settings.cpython-310.pyc b/ProyectoColegio/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..96dff84 Binary files /dev/null and b/ProyectoColegio/__pycache__/settings.cpython-310.pyc differ diff --git a/ProyectoColegio/__pycache__/urls.cpython-310.pyc b/ProyectoColegio/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..c4d1a19 Binary files /dev/null and b/ProyectoColegio/__pycache__/urls.cpython-310.pyc differ diff --git a/ProyectoColegio/__pycache__/wsgi.cpython-310.pyc b/ProyectoColegio/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..138c295 Binary files /dev/null and b/ProyectoColegio/__pycache__/wsgi.cpython-310.pyc differ diff --git a/ProyectoColegio/asgi.py b/ProyectoColegio/asgi.py new file mode 100644 index 0000000..c05efca --- /dev/null +++ b/ProyectoColegio/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for ProyectoColegio project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ProyectoColegio.settings') + +application = get_asgi_application() diff --git a/ProyectoColegio/settings.py b/ProyectoColegio/settings.py new file mode 100644 index 0000000..6342192 --- /dev/null +++ b/ProyectoColegio/settings.py @@ -0,0 +1,130 @@ +""" +Django settings for ProyectoColegio project. + +Generated by 'django-admin startproject' using Django 3.2.9. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-k0fezfvak#9yel&!4+%h--o_@2=c2^&9fp^&w&2f$u6e!%8v!@' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'App', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'ProyectoColegio.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'ProyectoColegio.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'colegio', + 'USER': 'root', + 'PASSWORD':'123321', + 'HOST':'localhost', + 'PORT':3306 + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.2/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/ProyectoColegio/urls.py b/ProyectoColegio/urls.py new file mode 100644 index 0000000..f9e8170 --- /dev/null +++ b/ProyectoColegio/urls.py @@ -0,0 +1,24 @@ +"""ProyectoColegio URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +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')) +""" +from django.contrib import admin +from django.urls import path +from django.urls.conf import include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('estudiantes/',include('App.urls')), + path('maestros/',include('App.urls')) +] diff --git a/ProyectoColegio/wsgi.py b/ProyectoColegio/wsgi.py new file mode 100644 index 0000000..bc9b1eb --- /dev/null +++ b/ProyectoColegio/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for ProyectoColegio project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ProyectoColegio.settings') + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..d497b19 --- /dev/null +++ b/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', 'ProyectoColegio.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()