Answer the question
In order to leave comments, you need to log in
How to store the number of services?
How to organize the storage of the number of services.
There are two models:
Services (name, cost)
Orders/services performed (service,
cost
)
from the phone, I apologize for the format)
And how to store the quantity?
How to organize the choice of this number?
Answer the question
In order to leave comments, you need to log in
class Service(Model):
name = ...
price = ...
class Order(Model):
service = ForeignKey(Service, related_name=u'orders')
user = ForeignKey(User, related_name=u'orders')
done = BooleanField(default=False)
...
orders_by_user_and_service = some_service.orders.filter(user=some_user_instance, done=True)
# or
orders_by_user_and_service = some_user.orders.filter(service=some_service_instance, done=True)
# or
orders_by_user_and_service = Orders.objects.filter(user=some_user_instance, service=some_service_instance, done=True)
# or
orders_by_user_and_service = Orders.objects.filter(user_id=some_user_id, service_id=some_service_id, done=True)
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question