Answer the question
In order to leave comments, you need to log in
How to do many to many editing with additional fields in Django?
Good day
In general, you need to create a menu from these dishes, but with dynamic prices (today a pie costs 5 rubles - 10 - the day after tomorrow 6.50, etc. according to the mood of the seller)
models.py
class Menu(models.Model):
day = models.OneToOneField( Day )
dishes = models.ManyToManyField( Dish, through='MenuDishes' )
class MenuDishes(models.Model):
menu = models.ForeignKey(Menu)
dish = models.ForeignKey(Dish)
price = models.DecimalField(...)
class MenuCreate(CreateView):
model = Menu
...
{% extends "base.html" %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{form}}
<input type="submit" value="{{submit_text}}">
</form>
{% endblock content %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question