описание
This commit is contained in:
1 parent
be880402ea
commit
3b9e647ddc
1115 files changed
+90
-931
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,37 @@
|
||||
from django.contrib import admin
|
||||
from .models import *
|
||||
# Register your models here.
|
||||
|
||||
# class MultiDBModelAdmin(admin.ModelAdmin):
|
||||
# # A handy constant for the name of the alternate database.
|
||||
# using = "add_base"
|
||||
# list_display=('title', 'order')
|
||||
# list_editable=('order', )
|
||||
|
||||
# def save_model(self, request, obj, form, change):
|
||||
# # Tell Django to save objects to the 'other' database.
|
||||
# obj.save(using=self.using)
|
||||
|
||||
# def delete_model(self, request, obj):
|
||||
# # Tell Django to delete objects from the 'other' database
|
||||
# obj.delete(using=self.using)
|
||||
|
||||
# def get_queryset(self, request):
|
||||
# # Tell Django to look for objects on the 'other' database.
|
||||
# return super().get_queryset(request).using(self.using)
|
||||
|
||||
# def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||
# # Tell Django to populate ForeignKey widgets using a query
|
||||
# # on the 'other' database.
|
||||
# return super().formfield_for_foreignkey(
|
||||
# db_field, request, using=self.using, **kwargs
|
||||
# )
|
||||
|
||||
# def formfield_for_manytomany(self, db_field, request, **kwargs):
|
||||
# # Tell Django to populate ManyToMany widgets using a query
|
||||
# # on the 'other' database.
|
||||
# return super().formfield_for_manytomany(
|
||||
# db_field, request, using=self.using, **kwargs
|
||||
# )
|
||||
|
||||
# admin.site.register(Carousels, MultiDBModelAdmin)
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class GarbageConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'garbage'
|
||||
@@ -0,0 +1,24 @@
|
||||
# This is an auto-generated Django model module.
|
||||
# You'll have to do the following manually to clean this up:
|
||||
# * Rearrange models' order
|
||||
# * Make sure each model has one field with primary_key=True
|
||||
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
|
||||
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
|
||||
# Feel free to rename the models, but don't rename db_table values or field names.
|
||||
from django.db import models
|
||||
|
||||
|
||||
|
||||
|
||||
class Carousels(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
text = models.TextField(blank=True, null=True)
|
||||
link = models.ImageField(upload_to='fns/%Y/%m/%d', default="newsimage/default.jpg", null=True, verbose_name='Картинка')
|
||||
order = models.IntegerField(blank=True, null=True)
|
||||
link2 = models.ImageField(upload_to='fns/%Y/%m/%d', null=True, verbose_name='Картинка2')
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'carousels'
|
||||
|
||||
def __str__(self):
|
||||
return str(self.title)
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
from rest_framework import serializers
|
||||
from .models import *
|
||||
|
||||
|
||||
|
||||
class CarouselsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
|
||||
model = Carousels
|
||||
fields = '__all__'
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,16 @@
|
||||
from django.urls import include, path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
from .views import *
|
||||
|
||||
from rest_framework_simplejwt.views import (
|
||||
TokenObtainPairView,
|
||||
TokenRefreshView,TokenVerifyView
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
path('links/', CaorusAPIView.as_view(), name='CaorusAPIView'),
|
||||
|
||||
|
||||
]
|
||||
@@ -0,0 +1,10 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework.generics import ListAPIView
|
||||
from .models import *
|
||||
from rest_framework.response import Response
|
||||
from .serializers import *
|
||||
|
||||
class CaorusAPIView(ListAPIView):
|
||||
def get(self, request):
|
||||
queryset = Carousels.objects.using('add_base').all().order_by('order')
|
||||
return Response(CarouselsSerializer(queryset, many=True).data)
|
||||
Reference in new issue
Block a user