diff --git a/myproject/customers/templates/customers/customer_detail.html b/myproject/customers/templates/customers/customer_detail.html index 1ddba01..4600eec 100644 --- a/myproject/customers/templates/customers/customer_detail.html +++ b/myproject/customers/templates/customers/customer_detail.html @@ -19,7 +19,7 @@
-
+
Информация о клиенте
@@ -82,39 +82,6 @@
- - -
-
-
-
Адреса доставки
- Добавить адрес -
-
- {% if addresses %} - {% for address in addresses %} -
- {% if address.is_default %} - Адрес по умолчанию - {% endif %} -
{{ address.recipient_name }}
-

- Адрес: {{ address.full_address }}, {{ address.district }} -

- {% if address.delivery_instructions %} -

- Инструкции: {{ address.delivery_instructions }} -

- {% endif %} - -
- {% endfor %} - {% else %} -

У клиента нет сохраненных адресов доставки.

- {% endif %} -
-
-
{% endblock %} \ No newline at end of file diff --git a/myproject/customers/views.py b/myproject/customers/views.py index a7882ea..b2f4d31 100644 --- a/myproject/customers/views.py +++ b/myproject/customers/views.py @@ -79,11 +79,9 @@ def customer_list(request): def customer_detail(request, pk): """Детали клиента""" customer = get_object_or_404(Customer, pk=pk) - addresses = customer.addresses.all() - + context = { 'customer': customer, - 'addresses': addresses, } return render(request, 'customers/customer_detail.html', context) diff --git a/myproject/orders/management/commands/create_demo_orders.py b/myproject/orders/management/commands/create_demo_orders.py index 1299cb3..fcbbdba 100644 --- a/myproject/orders/management/commands/create_demo_orders.py +++ b/myproject/orders/management/commands/create_demo_orders.py @@ -108,12 +108,8 @@ class Command(BaseCommand): # Устанавливаем адрес или магазин if is_delivery and addresses: - # Для доставки выбираем адрес клиента или случайный - customer_addresses = list(customer.addresses.all()) - if customer_addresses: - order.delivery_address = random.choice(customer_addresses) - else: - order.delivery_address = random.choice(addresses) + # Для доставки выбираем случайный адрес (адреса теперь привязаны к заказам) + order.delivery_address = random.choice(addresses) order.delivery_cost = Decimal(random.randint(200, 500)) elif shops: order.pickup_shop = random.choice(shops)