Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configpostgres #11

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
3 changes: 3 additions & 0 deletions lugares_seguros/listado_de_lugares/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions lugares_seguros/listado_de_lugares/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ListadoDeLugaresConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'listado_de_lugares'
30 changes: 30 additions & 0 deletions lugares_seguros/listado_de_lugares/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 4.1.7 on 2023-03-10 08:58

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='listado_de_lugares',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=56)),
('description', models.CharField(max_length=256)),
('address_state', models.CharField(max_length=32)),
('address_city', models.CharField(max_length=32)),
('address_colonia', models.CharField(max_length=32)),
('address_street', models.CharField(max_length=32)),
('address_zipcode', models.CharField(max_length=32)),
],
options={
'db_table': 'listado_de_lugares',
},
),
]
Empty file.
21 changes: 21 additions & 0 deletions lugares_seguros/listado_de_lugares/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import models

# Create your models here.


class listado_de_lugares(models.Model):

name = models.CharField(max_length=56)
description = models.CharField(max_length=256)
address_state = models.CharField(max_length=32)
address_city = models.CharField(max_length=32)
address_colonia = models.CharField(max_length=32)
address_street = models.CharField(max_length=32)
address_zipcode = models.CharField(max_length=32)

class Meta:
db_table = 'listado_de_lugares'

def __str__(self):
return self.name

7 changes: 7 additions & 0 deletions lugares_seguros/listado_de_lugares/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from rest_framework import serializers
from.models import listado_de_lugares

class listado_de_lugaresSerializer(serializers.ModelSerializer):
class Meta:
model = listado_de_lugares
fields = '_all_'
3 changes: 3 additions & 0 deletions lugares_seguros/listado_de_lugares/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
16 changes: 16 additions & 0 deletions lugares_seguros/listado_de_lugares/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#from django.shortcuts import render

from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from .models import Place
from .serializers import PlaceSerializer

# Create your views here
class PlaceAPIView(APIView):

def get(self, request):
places = Place.objects.all()
serializer = PlaceSerializer(places, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)

18 changes: 15 additions & 3 deletions lugares_seguros/lugares_seguros/settings/base.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como buena practica, y por cuestiones de seguridad, se recomienda no versionar datos de conexión a bases de datos u otros datos de usuarios y contraseñas, lo mejor es usar desde un inicio variables de entorno, pueden usar el modulo python-decouple para caargar y configurar estas variables de entorno

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
'rest_framework',
# local apps:
'initial',
'places'
'places',
'listado_de_lugares',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -78,14 +79,25 @@
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

#DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
#}
#}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgressql',
'NAME': 'db35trvdfu8el9',
'USER': 'priuindvmgqsa',
'HOST' : 'ec2-18-204-142-254.compute-1.amazonaws.com',
'PASSWORD':'b8bca417f2983bdcb3c478d505ba6c188c43faa0cf83a157338da38670de1e8e',
'PORT': 5432
}
}



# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators

Expand Down
Binary file modified lugares_seguros/requirements.txt
Binary file not shown.