first commit
This commit is contained in:
24
app/scripts.py
Normal file
24
app/scripts.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from rest_framework import status
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.response import Response
|
||||
|
||||
from app.models import PoultryHatching, Poultry
|
||||
from django.db import transaction
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from rest_framework.decorators import api_view, permission_classes
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@permission_classes([AllowAny])
|
||||
@csrf_exempt
|
||||
def update_poultry_city_province(request):
|
||||
hatchings = PoultryHatching.objects.select_related('poultry').only('poultry', 'LocationNameCity',
|
||||
'LocationNameProvince').filter(
|
||||
poultry__isnull=False).order_by('id')
|
||||
for hatching in hatchings:
|
||||
hatching.poultry.LocationNameProvince = hatching.LocationNameProvince
|
||||
hatching.poultry.LocationNameCity = hatching.LocationNameCity
|
||||
hatching.poultry.save()
|
||||
print(hatching.id)
|
||||
return Response({'message': 'done'}, status=status.HTTP_200_OK)
|
||||
# return Response({'message': len(hatchings)}, status=status.HTTP_200_OK)
|
||||
Reference in New Issue
Block a user