model
1 2 3 4 5 6 7 8 9 10 |
class ServicePod(models.Model): service_name = models.CharField(max_length=255) pod_ip = models.CharField(max_length=255) function = models.CharField(max_length=255) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) # Add other fields as necessary def __str__(self): return f"{self.service_name} - {self.pod_ip}" |
serilazer:
1 2 3 4 |
class ServicePodSerializer(serializers.ModelSerializer): class Meta: model = ServicePod fields = ['id', 'service_name', 'pod_ip', 'function', 'created_at', 'updated_at'] # Include other fields here |
path:
1 2 3 4 5 6 7 |
from rest_framework import routers from .views import ServicePodViewSet router = routers.DefaultRouter() # router.register(r'', ) # router.register(r'servicepods', ServicePodViewSet) router.register(r'servicepods', ServicePodViewSet) |
views:
[cra[……]