I have created a CRUD application in Django.
and want to know how I can check if the input JSON data is empty or not
for example:
I am getting a JSON input dictionary as

```
{'status':'abc','name':'xyz','address':'abc@123','city':'abc'}etc

```

I want to check if name is not empty and city is not empty.
I don't want a required field in model but to handle the JSON data.
If the JSON input is not valid i.e if username and email is valid then save the data into database else give a warning 400.

serializers.py

```
from rest_framework import serializers
from .models import Location
class LocationSerializer(serializers.ModelSerializer):
    class Meta:
        model = Location
        fields= '__all__'

```

views.py

```
@api_view(['POST'])
def locationAdd(request):
    serializer = LocationSerializer(data=request.data)
    if serializer.is_valid():
        serializer.save()
        return Response("data entered successfully")
    else:
        return Response("data entered is not valid")
    return Response(serializer.data)

```

models.py

```
class Location(models.Model):
    status = models.CharField(max_length=100)
    name = models.CharField(max_length=100)
    address = models.CharField(max_length=100)
    city = models.CharField(max_length=100)
    postalCode = models.IntegerField(null=True)
    state = models.CharField(max_length=100)

```