Monday, January 4, 2021

How to set daily Update limit on Django model

I'm new to Django. I have created one Django App where users can update their Shift Timing(Morning/Evening/General) and based on this Shift Timing I am taking real-time data from Django Model and running Linux script which will be evaluating user shift timing and allowed timing to use the application.

I have used Django import and export which allows the user to upload multiple users' data by using a .xls file from the front-end. Now here I want to apply some limit for example suppose my model is having 5000 records so I want that only 50% of its records should be allowed to modify whether it is added through .xls file or by clicking on update single records(I am doing this because I don't want that more than 50% of users should update Shift Timing). Is there any easiest way to implement this requirement?

I have checked https://pypi.org/project/django-limits/ (Django-limits 0.0.6)but did not understand from step 3.

I am adding my models.py


class CTS(models.Model): 

AConnectID = models.CharField(max_length=100,) Shift_timing = models.CharField(max_length=64, choices=SHIFT_CHOICES, default='9.00-6.00') EmailID = models.EmailField(max_length=64, unique=True, ) Vendor_Company = models.CharField(max_length=64, ) Project_name = models.CharField(max_length=25, default="") SerialNumber = models.CharField(max_length=19, default="") Reason = models.TextField(max_length=180) last_updated_time = models.DateTimeField(auto_now=True) class Meta: ordering = ['-id'] def get_absolute_url(self): return reverse('/ctall')

Is there any way through which I can set the max record updation limit in the models.py level?

Any help OR suggestion on this would be highly appreciated.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6d25bc5a-9ab1-4cf0-827e-40ba8713907bn%40googlegroups.com.

No comments:

Post a Comment