adde routers file and settings

This commit is contained in:
Sam
2021-01-22 11:01:20 +00:00
parent b051afb627
commit f6614768ab
3 changed files with 32 additions and 1 deletions

13
back_latienda/routers.py Normal file
View File

@@ -0,0 +1,13 @@
from rest_framework import routers
from companies.views import CompanyViewSet
from products.views import ProductViewSet
from history.views import HistorySyncViewSet
from stats.views import StatsLogViewSet
router = routers.DefaultRouter()
router.register('companies', CompanyViewSet)
router.register('products', ProductViewSet)
router.register('history', HistorySyncViewSet)
router.register('stats', StatsLogViewSet)

View File

@@ -40,6 +40,11 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
# 3rd party
'rest_framework',
'django_filters',
# local apps
'core',
'geo',
'companies',
@@ -103,6 +108,16 @@ AUTH_PASSWORD_VALIDATORS = [
AUTH_USER_MODEL = 'core.CustomUser'
# DRF Options
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
],
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend']
}
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

View File

@@ -14,11 +14,14 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from .routers import router
urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/', include(router.urls)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)