change livestock types weight
This commit is contained in:
18
apps/livestock/migrations/0012_livestocktype_weight_type.py
Normal file
18
apps/livestock/migrations/0012_livestocktype_weight_type.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0 on 2025-07-14 08:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('livestock', '0011_remove_livestock_age_by_day_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='livestocktype',
|
||||
name='weight_type',
|
||||
field=models.CharField(choices=[('L', 'Light'), ('H', 'Heavy')], max_length=50, null=True),
|
||||
),
|
||||
]
|
||||
@@ -18,6 +18,15 @@ class LiveStockSpecies(BaseModel): # noqa
|
||||
class LiveStockType(BaseModel): # noqa
|
||||
""" types like sheep, cow, camel, etc """
|
||||
name = models.CharField(max_length=50)
|
||||
weight_types = (
|
||||
('L', 'Light'),
|
||||
('H', 'Heavy')
|
||||
)
|
||||
weight_type = models.CharField(
|
||||
choices=weight_types,
|
||||
max_length=50,
|
||||
null=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.name}'
|
||||
|
||||
@@ -9,7 +9,8 @@ class LiveStockTypeSerializer(serializers.ModelSerializer):
|
||||
model = livestock_models.LiveStockType
|
||||
fields = [
|
||||
'id',
|
||||
'name'
|
||||
'name',
|
||||
'weight_type'
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ from rest_framework import status
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
from datetime import datetime
|
||||
from asgiref.sync import sync_to_async, async_to_sync
|
||||
from django.http import JsonResponse
|
||||
|
||||
|
||||
def trash(queryset, pk): # noqa
|
||||
|
||||
Reference in New Issue
Block a user