Commit bc493bc7 authored by Henrique Luiz Hartmann's avatar Henrique Luiz Hartmann Committed by Yuri H. Salvador

Inicializar uma App, adicionar o Django-Rest-Framework e iniciar o banco de dados

parent 1eb09af4
---
version: "3.7"
services:
mongo-express:
image: mongo-express
ports:
- "8081:8081"
environment:
ME_CONFIG_BASICAUTH_USERNAME: usereventos
ME_CONFIG_BASICAUTH_PASSWORD: 123
ME_CONFIG_MONGODB_PORT: 27017
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: eventos
links:
- mongo
networks:
- mongo-compose-network
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: eventos
ports:
- "27017:27017"
volumes:
- db-data:/data/db
networks:
- mongo-compose-network
networks:
mongo-compose-network:
driver: bridge
volumes:
db:
# from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class CoreConfig(AppConfig):
name = "core"
# from django.db import models
# Create your models here.
from rest_framework import routers
routers.SimpleRouter()
# from django.test import TestCase
# Create your tests here.
# from django.shortcuts import render
# Create your views here.
"""
Django settings for eventos project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
import mongoengine
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "n2_w$9oe=5c57(ssh+!#i#y2jmo@dsx9dh=fg3v&iy1ncf=5x!"
# 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",
......@@ -37,6 +17,10 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"rest_framework_mongoengine",
"drf_yasg",
"eventos.core",
]
MIDDLEWARE = [
......@@ -69,15 +53,19 @@ TEMPLATES = [
WSGI_APPLICATION = "eventos.wsgi.application"
DATABASES = {"default": {"ENGINE": "", "NAME": ""}}
MONGO_USER = "root"
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
MONGO_PASS = "eventos"
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": os.path.join(BASE_DIR, "db.sqlite3")}}
MONGO_HOST = "localhost"
MONGO_NAME = "eventos"
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
MONGO_DATABASE_HOST = "mongodb://%s:%s@%s/%s" % (MONGO_USER, MONGO_PASS, MONGO_HOST, MONGO_NAME)
mongoengine.connect(MONGO_NAME, host=MONGO_DATABASE_HOST)
AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
......@@ -86,10 +74,6 @@ AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
......@@ -100,8 +84,6 @@ USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = "/static/"
REST_FRAMEWORK = {"DEFAULT_RENDERER_CLASSES": ["rest_framework.renderers.JSONRenderer"]}
"""eventos URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/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 drf_yasg import openapi
from drf_yasg.views import get_schema_view
# from eventos.core.router import router as core_router
schema_view = get_schema_view(openapi.Info(title="Eventos", default_version="v1"), public=True)
urlpatterns = [
# path("", include(core_router.urls)),
path("admin/", admin.site.urls),
path("swagger/", schema_view.with_ui()),
]
This diff is collapsed.
......@@ -7,6 +7,11 @@ authors = ["Henrique e Erick"]
[tool.poetry.dependencies]
python = "^3.7"
django = "^3.0.5"
django-rest-framework-mongoengine = "^3.4.1"
mongoengine = "^0.19.1"
djangorestframework = "^3.11.0"
blinker = "^1.4"
drf-yasg = "^1.17.1"
[tool.poetry.dev-dependencies]
black = "^19.10b0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment