Answer the question
In order to leave comments, you need to log in
How to implement list of services in django models?
There is a list of contractor services that you need to set to the administrator.
The contractor, when filling out his profile, must go through all of them and indicate which he provides and which he does not (along with additional attributes such as surcharge).
What is the best way to implement this in the context of models?
Answer the question
In order to leave comments, you need to log in
Here is the simplest implementation of the model. Just when the performer adds services indicating additional. attributes, they will need to be entered and that's it. There is no need to block additional activity fields (only if the performer wants to temporarily disable services, and then return them back without losing the previously specified additional attributes).
from django.contrib.auth import get_user_model
Users = get_user_model()
class Services(models.Model):
name = models.CharField(max_length=125)
class Pref(models.Model):
service = models.ForeignKey("Service", on_delete=models.CASCADE)
user = models.ForeignKey(Users, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=18, decimal_places=2)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question