'Compare Date from a database to current date and alert user if it's late
I have a database set up, I am running Django for the backend and React.js for the front. This is a project for school but I am having a hard time finding information on how to do this properly.
I want to take the date put for the inspection_date and compare that to the local time, and if local time is greater than inspection_date, alert the user that they are past the inspection date.
Here is my class model
class Hive(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
hive_number = models.IntegerField()
inspection_date = models.DateField()
My Serializer
class HiveSerializer(serializers.ModelSerializer):
class Meta:
model = Hive
fields = ['id', 'hive_number', 'inspection_date', 'user_id']
depth = 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
