Skip to content

Commit b06e34b

Browse files
committed
ready for local
1 parent 24fe194 commit b06e34b

23 files changed

+377
-6
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,7 @@ MigrationBackup/
351351

352352
# Ionide (cross platform F# VS Code tools) working folder
353353
.ionide/
354+
355+
venv
356+
db.sqlite3
357+
__pycache__

Pipfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[scripts]
7+
start = "python manage.py runserver"
8+
makem = "python manage.py makemigrations"
9+
# django-admin createapp <name> -> crear un proyecto django
10+
# pipenv shell -> activate virtualenv
11+
# python manage.py startapp <name> -> create new app
12+
13+
[packages]
14+
django = "*"
15+
djangorestframework = "*"
16+
17+
[dev-packages]
18+
19+
[requires]
20+
python_version = "3.11"

Pipfile.lock

+68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
(En proceso) Backend básico con django implementado en python. Componente modular para arquitecturas web de microservicios.
44

55
## Generalidades
6-
* Gestor de paquetes: Pip ([Pyckages](https://pypi.org/))
6+
* Gestor de paquetes: Pipenv ([Pyckages](https://pypi.org/))
77

88
```bash
9-
$ mkdir <project-name>
10-
$ git clone <repo> backend
11-
$ cd backend
12-
$ git update-index --assume-unchanged .env
13-
$ .\image.ps1
9+
$ pypenv install
10+
$ npm run start # development
11+
$ npm run image # levantar contenedor de prod en docker
1412
```
File renamed without changes.

appcore/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for appcore project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'appcore.settings')
15+
16+
application = get_asgi_application()

appcore/settings.py

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
"""
2+
Django settings for appcore project.
3+
4+
Generated by 'django-admin startproject' using Django 4.1.4.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.1/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
import os
15+
import sys
16+
17+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
18+
BASE_DIR = Path(__file__).resolve().parent.parent
19+
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
20+
21+
22+
# Quick-start development settings - unsuitable for production
23+
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
24+
25+
# SECURITY WARNING: keep the secret key used in production secret!
26+
SECRET_KEY = 'django-insecure-7^4o4!d7!io$10zgb+4n=(ti&ysxtj!iozk@m1cxmqn1j__4t+'
27+
28+
# SECURITY WARNING: don't run with debug turned on in production!
29+
DEBUG = True
30+
31+
ALLOWED_HOSTS = []
32+
33+
34+
# Application definition
35+
36+
INSTALLED_APPS = [
37+
'django.contrib.admin',
38+
'django.contrib.auth',
39+
'django.contrib.contenttypes',
40+
'django.contrib.sessions',
41+
'django.contrib.messages',
42+
'django.contrib.staticfiles',
43+
'rest_framework',
44+
'users'
45+
]
46+
47+
MIDDLEWARE = [
48+
'django.middleware.security.SecurityMiddleware',
49+
'django.contrib.sessions.middleware.SessionMiddleware',
50+
'django.middleware.common.CommonMiddleware',
51+
'django.middleware.csrf.CsrfViewMiddleware',
52+
'django.contrib.auth.middleware.AuthenticationMiddleware',
53+
'django.contrib.messages.middleware.MessageMiddleware',
54+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
55+
]
56+
57+
ROOT_URLCONF = 'appcore.urls'
58+
59+
TEMPLATES = [
60+
{
61+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
62+
'DIRS': [],
63+
'APP_DIRS': True,
64+
'OPTIONS': {
65+
'context_processors': [
66+
'django.template.context_processors.debug',
67+
'django.template.context_processors.request',
68+
'django.contrib.auth.context_processors.auth',
69+
'django.contrib.messages.context_processors.messages',
70+
],
71+
},
72+
},
73+
]
74+
75+
WSGI_APPLICATION = 'appcore.wsgi.application'
76+
77+
78+
# Database
79+
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
80+
81+
DATABASES = {
82+
'default': {
83+
'ENGINE': 'django.db.backends.sqlite3',
84+
'NAME': BASE_DIR / 'db.sqlite3',
85+
}
86+
}
87+
88+
89+
# Password validation
90+
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
91+
92+
AUTH_PASSWORD_VALIDATORS = [
93+
{
94+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
95+
},
96+
{
97+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
98+
},
99+
{
100+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
101+
},
102+
{
103+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
104+
},
105+
]
106+
107+
108+
# Internationalization
109+
# https://docs.djangoproject.com/en/4.1/topics/i18n/
110+
111+
LANGUAGE_CODE = 'en-us'
112+
113+
TIME_ZONE = 'UTC'
114+
115+
USE_I18N = True
116+
117+
USE_TZ = True
118+
119+
120+
# Static files (CSS, JavaScript, Images)
121+
# https://docs.djangoproject.com/en/4.1/howto/static-files/
122+
123+
STATIC_URL = 'static/'
124+
125+
# Default primary key field type
126+
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
127+
128+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

appcore/urls.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""appcore URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/4.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path, include
18+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
path('', include('users.urls'))
22+
]

appcore/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for appcore project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'appcore.settings')
15+
16+
application = get_wsgi_application()
File renamed without changes.
File renamed without changes.

apps/users/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

apps/users/api.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from users.models import UserModel
2+
from rest_framework import viewsets, permissions
3+
from .serializers import UserSerializer
4+
5+
# @brief ¿Qué consultas se van a poder hacer?
6+
# @params ModelViewSet,
7+
8+
class UserViewSet(viewsets.ModelViewSet):
9+
queryset = UserModel.objects.all()
10+
permission_classes = [permissions.AllowAny]
11+
serializer_class = UserSerializer

apps/users/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class UsersConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'users'

apps/users/migrations/0001_initial.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 4.1.4 on 2022-12-08 19:10
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='UserModel',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('username', models.CharField(max_length=200)),
19+
('email', models.EmailField(max_length=254)),
20+
('password', models.CharField(max_length=50)),
21+
],
22+
),
23+
]
File renamed without changes.

apps/users/models.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.db import models
2+
from django import forms
3+
4+
5+
# @brief clase auxilial para la generacón de entradas en la base de datos
6+
# @params Model,
7+
8+
class UserModel(models.Model):
9+
username = models.CharField(max_length=200)
10+
email = models.EmailField(max_length=254)
11+
password = models.CharField(max_length=50)

apps/users/serializers.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from rest_framework import serializers
2+
from .models import UserModel
3+
4+
# @brief convertir un modelo en datos que podrán ser consultados
5+
# @params ModelSerializers,
6+
7+
class UserSerializer(serializers.ModelSerializer):
8+
class Meta:
9+
model = UserModel
10+
fields = ('id', 'username', 'email', 'password')
11+
#read_only_fields = ('')

apps/users/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

apps/users/urls.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from rest_framework import routers
2+
from .api import UserViewSet
3+
4+
router = routers.DefaultRouter()
5+
router.register('users', UserViewSet, 'users')
6+
urlpatterns = router.urls

apps/users/views.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

0 commit comments

Comments
 (0)