{"id":69519,"date":"2024-07-16T05:30:00","date_gmt":"2024-07-16T02:00:00","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/desarrollo-de-ecommerce-con-django-parte-4-1ic\/"},"modified":"2024-07-16T05:30:00","modified_gmt":"2024-07-16T02:00:00","slug":"desarrollo-de-ecommerce-con-django-parte-4-1ic","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/desarrollo-de-ecommerce-con-django-parte-4-1ic\/","title":{"rendered":"\u062a\u0648\u0633\u0639\u0647 \u062a\u062c\u0627\u0631\u062a \u0627\u0644\u06a9\u062a\u0631\u0648\u0646\u06cc\u06a9 \u0628\u0627 \u062c\u0646\u06af\u0648 (\u0642\u0633\u0645\u062a 4)"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang<br \/>\n            \u062f\u0631 \u0627\u06cc\u0646 \u0686\u0647\u0627\u0631\u0645\u06cc\u0646 \u0648 \u0622\u062e\u0631\u06cc\u0646 \u0622\u0645\u0648\u0632\u0634 \u0646\u06a9\u0627\u062a \u0632\u06cc\u0631 \u067e\u0648\u0634\u0634 \u062f\u0627\u062f\u0647 \u062e\u0648\u0627\u0647\u062f \u0634\u062f:<\/p>\n<p>\u067e\u0631\u062f\u0627\u0632\u0634 \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f\u0646\u0645\u0627\u06cc\u0634 \u0633\u0627\u0628\u0642\u0647 \u0633\u0641\u0627\u0631\u0634\u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0628\u0646\u062f\u06cc \u0641\u06cc\u0644\u062a\u0631 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>1. \u067e\u0631\u062f\u0627\u0632\u0634 \u06cc\u06a9 \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f<\/p>\n<p>\u062f\u0627\u062e\u0644 \u0628\u0633\u062a\u0647 &#8220;\u0645\u062f\u0644&#8221; \u0628\u0631\u0646\u0627\u0645\u0647 store\u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u067e\u0627\u06cc\u062a\u0648\u0646 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f: &#8220;order.py&#8221; \u0648 \u062a\u0639\u0631\u06cc\u0641 \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0645\u062f\u0644 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f:<\/p>\n<p>&#8230;<br \/>\n&#8230;<br \/>\nfrom store.models import Pedido<\/p>\n<p>from django.db import models<br \/>\nfrom django.contrib.auth.models import User<br \/>\nfrom .producto import Producto<\/p>\n<p>class Pedido(models.Model):<br \/>\n    usuario = models.ForeignKey(User, on_delete=models.CASCADE)<br \/>\n    producto = models.ForeignKey(Producto, on_delete=models.CASCADE)<br \/>\n    cantidad = models.PositiveIntegerField(default=1)<br \/>\n    total = models.DecimalField(max_digits=12, decimal_places=2)<br \/>\n    fecha_registro = models.DateTimeField(auto_now_add=True)<br \/>\n    fecha_ult_act = models.DateTimeField(auto_now=True)<\/p>\n<p>    def __str__(self) -&gt; str:<br \/>\n        return f'{self.id}&#8217;<\/p>\n<p>    class Meta:<br \/>\n        db_table=&#8221;st_pedidos&#8221;<br \/>\n        verbose_name=&#8221;Pedido&#8221;<br \/>\n        verbose_name_plural=&#8221;Pedidos&#8221;`<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0628\u0631\u0627\u06cc \u062b\u0628\u062a \u0633\u0641\u0627\u0631\u0634 \u0647\u0627\u06cc \u062c\u062f\u06cc\u062f \u0627\u0632 \u0645\u062f\u0644 Order \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f.<\/p>\n<p>\u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0645\u0627 \u06cc\u06a9 \u0645\u062f\u0644 \u062c\u062f\u06cc\u062f \u0627\u06cc\u062c\u0627\u062f \u06a9\u0631\u062f\u0647 \u0627\u06cc\u0645\u060c \u0628\u0627\u06cc\u062f \u0645\u0647\u0627\u062c\u0631\u062a \u0645\u0631\u0628\u0648\u0637\u0647 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u0648 \u0627\u0639\u0645\u0627\u0644 \u06a9\u0646\u06cc\u0645 \u062a\u0627 \u0622\u0646 \u0631\u0627 \u062f\u0631 \u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647 \u0645\u0646\u0639\u06a9\u0633 \u06a9\u0646\u06cc\u0645\u060c \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062f\u0633\u062a\u0648\u0631\u0627\u062a:<\/p>\n<p>poetry run python manage.py makemigrations\u060c ypoetry run python manage.py migrate<\/p>\n<p>\u062f\u0631 \u0645\u0631\u062d\u0644\u0647 \u0628\u0639\u062f\u060c \u0645\u0627 \u0628\u0627\u06cc\u062f &#8220;URL&#8221; \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645 \u06a9\u0647 \u0627\u0632 \u0637\u0631\u06cc\u0642 \u0622\u0646 \u062b\u0628\u062a \u0647\u0631 \u0633\u0641\u0627\u0631\u0634 \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc \u0634\u0648\u062f.  \u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0641\u0627\u06cc\u0644 urls.py \u0628\u0631\u0646\u0627\u0645\u0647 \u062e\u0648\u062f \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f store:<\/p>\n<p>urlpatterns = [<br \/>\n  # Otras rutas<br \/>\n  path(&#8216;pedidos\/&#8217;, views.crear_pedido, name=&#8221;crear_pedido&#8221;)<br \/>\n]\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0647\u0646\u06af\u0627\u0645\u06cc \u06a9\u0647 \u0645\u0633\u06cc\u0631 \u0627\u06cc\u062c\u0627\u062f \u0634\u062f\u060c \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u0645 \u0622\u0646 \u0631\u0627 \u0628\u0627 \u062a\u0627\u0628\u0639 view \u0645\u0631\u0628\u0648\u0637\u0647 \u0645\u0631\u062a\u0628\u0637 \u06a9\u0646\u06cc\u0645\u060c \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646 \u06a9\u0627\u0631\u060c \u062a\u0627\u0628\u0639 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc\u200c\u06a9\u0646\u06cc\u0645 crear_pedido \u062f\u0631 \u0641\u0627\u06cc\u0644 views.py \u0628\u0631\u0646\u0627\u0645\u0647 store:<\/p>\n<p>def crear_pedido(request):<br \/>\n    try:<br \/>\n        datos_pedido = json.loads(request.body)<br \/>\n        producto_id = int(datos_pedido.get(&#8216;producto_id&#8217;))<br \/>\n        cantidad = int(datos_pedido.get(&#8216;cantidad&#8217;))<\/p>\n<p>        producto = Producto.objects.get(pk=producto_id)<\/p>\n<p>        nuevo_pedido = Pedido(  usuario=request.user,<br \/>\n                                producto=producto,<br \/>\n                                cantidad=cantidad,<br \/>\n                                total=cantidad*producto.precio)<\/p>\n<p>        nuevo_pedido.save()<\/p>\n<p>        return JsonResponse({&#8216;success&#8217;: True, &#8216;message&#8217;: f&#8217;Se registr\u00f3 el pedido exitosamente. Pedido # {nuevo_pedido.id}&#8217;}, status=200)        <\/p>\n<p>    except Exception as ex:<br \/>\n        return JsonResponse({&#8216;success&#8217;: False, &#8216;message&#8217;: str(ex)}, status=500)<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0628\u0639\u062f\u0627\u064b \u062f\u0631\u062e\u0648\u0627\u0633\u062a http \u0631\u0627 \u0627\u0632 \u0637\u0631\u06cc\u0642 Ajax \u0627\u0646\u062c\u0627\u0645 \u062e\u0648\u0627\u0647\u06cc\u0645 \u062f\u0627\u062f \u06a9\u0647 \u0645\u0633\u0626\u0648\u0644 \u0645\u0635\u0631\u0641 \u0645\u0633\u06cc\u0631 \u0627\u06cc\u062c\u0627\u062f \u0633\u0641\u0627\u0631\u0634 \u062f\u0631 \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a \u06a9\u0647 \u06a9\u0627\u0631\u0628\u0631 \u0645\u06cc \u062e\u0648\u0627\u0647\u062f \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f\u06cc \u0648\u0627\u0631\u062f \u06a9\u0646\u062f.  \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646 \u06a9\u0627\u0631\u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u062c\u0627\u0648\u0627 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0627\u0633\u062a\u0627\u062a\u06cc\u06a9 \u062c\u062f\u06cc\u062f \u062f\u0631 \u062f\u0627\u062e\u0644 \u067e\u0648\u0634\u0647 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc \u06a9\u0646\u06cc\u0645 static\/js\u060c \u0641\u0627\u06cc\u0644 \u0631\u0627 \u0645\u06cc \u062a\u0648\u0627\u0646 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u06a9\u0631\u062f pedido.js.<\/p>\n<p>\u062f\u0631 \u062f\u0627\u062e\u0644 \u0641\u0627\u06cc\u0644\u060c \u062a\u0627\u0628\u0639 \u0632\u06cc\u0631 \u0631\u0627 \u062b\u0628\u062a \u0645\u06cc \u06a9\u0646\u06cc\u0645:<\/p>\n<p>function crearPedido(producto_id, csrf_token){<\/p>\n<p>    const jsonData= {<br \/>\n        producto_id: producto_id,<br \/>\n        cantidad: 1<br \/>\n    }<\/p>\n<p>    axios.post(&#8216;\/pedidos\/&#8217;, jsonData, {<br \/>\n        headers: {<br \/>\n            &#8216;X-CSRFToken&#8217;: csrfToken<br \/>\n        }<br \/>\n    })<br \/>\n    .then(response =&gt; {<br \/>\n        alert(response.data.message);<br \/>\n    })<br \/>\n    .catch(error =&gt; {<br \/>\n        if (error.response) {<br \/>\n            alert(error.response.data.message);<br \/>\n        }else {<br \/>\n            alert(error.message);<br \/>\n        }<br \/>\n    });<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u062f\u0631 \u0646\u0647\u0627\u06cc\u062a\u060c \u0645\u0627 \u0645\u06cc \u062e\u0648\u0627\u0647\u06cc\u0645 \u0647\u0645\u0647 \u0686\u06cc\u0632 \u0631\u0627 \u0627\u0632 \u0642\u0627\u0644\u0628 &#8220;catalog.html&#8221; \u0648\u0635\u0644 \u06a9\u0646\u06cc\u0645\u060c \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u062a\u0627\u0628\u0639 \u0631\u0627 \u0627\u062c\u0631\u0627 \u0645\u06cc \u06a9\u0646\u06cc\u0645 crearPedido \u06a9\u0647 \u0645\u0627 \u0628\u0647 \u062a\u0627\u0632\u06af\u06cc \u0627\u06cc\u062c\u0627\u062f \u06a9\u0631\u062f\u0647 \u0627\u06cc\u0645.  \u062f\u0631 \u062f\u06a9\u0645\u0647 &#8220;Place Order&#8221; \u0628\u0627 \u0627\u062c\u0631\u0627\u06cc \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u062a\u0627\u0628\u0639\u060c \u0631\u0648\u06cc\u062f\u0627\u062f onclick \u0631\u0627 \u0645\u062f\u06cc\u0631\u06cc\u062a \u0645\u06cc \u06a9\u0646\u06cc\u0645. crearPedido \u0628\u0647 \u0634\u0631\u062d \u0632\u06cc\u0631 \u0627\u0633\u062a:<\/p>\n<p>onclick=&#8221;crearPedido(&#8216;{{producto.id}}&#8217;, &#8216;{{csrf_token}}&#8217;)&#8221;<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0628\u0631\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u06a9\u0627\u0631 \u06a9\u0646\u062f \u0628\u0627\u06cc\u062f \u0641\u0627\u06cc\u0644 \u062c\u0627\u0648\u0627 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0631\u0627 \u062b\u0628\u062a \u06a9\u0646\u06cc\u0645 pedido.js \u062f\u0627\u062e\u0644 \u0642\u0627\u0644\u0628:<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0645\u0627 \u0628\u0647 \u0627\u062c\u0631\u0627\u06cc \u0647\u0645\u0647 \u0686\u06cc\u0632 \u0627\u062f\u0627\u0645\u0647 \u0645\u06cc \u062f\u0647\u06cc\u0645 \u062a\u0627 \u062a\u0623\u06cc\u06cc\u062f \u06a9\u0646\u062f \u06a9\u0647 \u0633\u0641\u0627\u0631\u0634\u0627\u062a \u062c\u062f\u06cc\u062f \u0627\u06cc\u062c\u0627\u062f \u0634\u062f\u0647 \u0627\u0646\u062f.<\/p>\n<p>2. \u0646\u0645\u0627\u06cc\u0634 \u062a\u0627\u0631\u06cc\u062e\u0686\u0647 \u0633\u0641\u0627\u0631\u0634 \u06a9\u0627\u0631\u0628\u0631<\/p>\n<p>\u062d\u0627\u0644\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0627\u0628\u0639 view \u0631\u0627 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645 get_mis_pedidos \u0628\u0631\u0627\u06cc \u0645\u0634\u0648\u0631\u062a \u0628\u0627 \u0633\u0641\u0627\u0631\u0634\u0627\u062a \u06a9\u0627\u0631\u0628\u0631 \u0648 \u0646\u0645\u0627\u06cc\u0634 \u0622\u0646\u0647\u0627.<\/p>\n<p>\u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0627\u0628\u0639 view \u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u0632\u06cc\u0631 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645:<\/p>\n<p>def get_mis_pedidos(request):<br \/>\n    pedidos = Pedido.objects.filter(usuario=request.user).order_by(&#8216;-id&#8217;)<br \/>\n    return render(request, &#8216;mis-pedidos.html&#8217;, {&#8216;pedidos&#8217;: pedidos})<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0648 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u0627\u0644\u06af\u0648\u06cc &#8220;my-orders.html&#8221; \u0631\u0627 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645 \u062a\u0627 \u0633\u0641\u0627\u0631\u0634\u0627\u062a \u06a9\u0627\u0631\u0628\u0631 \u062f\u0631 \u06cc\u06a9 \u062c\u062f\u0648\u0644 \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0634\u0648\u062f:<\/p>\n<p>                    #<br \/>\n                    Pedido<br \/>\n                    Producto<br \/>\n                    Cantidad<br \/>\n                    Total<br \/>\n                    Fecha Reg.<\/p>\n<p>            {% for pedido in pedidos %}<\/p>\n<p>                    {{ forloop.counter }}<br \/>\n                    {{ pedido.id }}<br \/>\n                    {{ pedido.producto.nombre }}<br \/>\n                    {{ pedido.cantidad }}<br \/>\n                    {{ pedido.total }}<br \/>\n                    {{ pedido.fecha_registro }}                    <\/p>\n<p>            {% endfor %}            <\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>3. \u0627\u062c\u0627\u0632\u0647 \u0641\u06cc\u0644\u062a\u0631 \u06a9\u0631\u062f\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0628\u0646\u062f\u06cc \u0631\u0627 \u0628\u062f\u0647\u06cc\u062f<\/p>\n<p>\u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0622\u062e\u0631\u06cc\u0646 \u0646\u06a9\u062a\u0647\u060c \u0641\u06cc\u0644\u062a\u0631 \u0645\u062d\u0635\u0648\u0644 \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0628\u0646\u062f\u06cc \u0641\u0639\u0627\u0644 \u0645\u06cc \u06a9\u0646\u06cc\u0645\u060c \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0628\u0627\u06cc\u062f \u06cc\u06a9 \u067e\u0631\u062f\u0627\u0632\u0634\u06af\u0631 \u0632\u0645\u06cc\u0646\u0647 (context_processor) \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645.<\/p>\n<p>\u06cc\u06a9 context_processor \u062f\u0631 \u062c\u0646\u06af\u0648 \u062a\u0627\u0628\u0639\u06cc \u0627\u0633\u062a \u06a9\u0647 \u06cc\u06a9 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u06cc\u200c\u06a9\u0646\u062f \u0648 \u06cc\u06a9 \u0641\u0631\u0647\u0646\u06af \u0644\u063a\u062a \u062f\u0627\u062f\u0647 \u0631\u0627 \u0628\u0631\u0645\u06cc\u200c\u06af\u0631\u062f\u0627\u0646\u062f \u06a9\u0647 \u0628\u0647 \u0637\u0648\u0631 \u062e\u0648\u062f\u06a9\u0627\u0631 \u0628\u0647 \u0645\u062a\u0646 \u0647\u0645\u0647 \u0642\u0627\u0644\u0628\u200c\u0647\u0627\u06cc \u0631\u0646\u062f\u0631 \u0634\u062f\u0647 \u0627\u0636\u0627\u0641\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f \u0648 \u0628\u0647 \u062f\u0627\u062f\u0647\u200c\u0647\u0627\u06cc \u062e\u0627\u0635\u06cc \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc\u200c\u062f\u0647\u062f \u062a\u0627 \u062f\u0631 \u0633\u0637\u062d \u062c\u0647\u0627\u0646\u06cc \u0628\u062f\u0648\u0646 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0627\u0631\u0633\u0627\u0644 \u0635\u0631\u06cc\u062d \u062f\u0631 \u0647\u0631 \u0646\u0645\u0627 \u062f\u0631 \u062f\u0633\u062a\u0631\u0633 \u0628\u0627\u0634\u0646\u062f.<\/p>\n<p>\u0627\u0628\u062a\u062f\u0627 \u0628\u0627\u06cc\u062f \u0641\u0627\u06cc\u0644 context_processors.py \u0631\u0627 \u062f\u0631 \u062f\u0627\u06cc\u0631\u06a9\u062a\u0648\u0631\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 &#8220;store&#8221; \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645.  \u067e\u0633 \u0627\u0632 \u0627\u06cc\u062c\u0627\u062f\u060c \u0645\u0627 \u0628\u0647 \u0627\u06cc\u062c\u0627\u062f context_processor \u0627\u062f\u0627\u0645\u0647 \u0645\u06cc \u062f\u0647\u06cc\u0645 \u062a\u0627 \u0647\u0645\u0647 \u062f\u0633\u062a\u0647 \u0647\u0627 \u0631\u0627 \u0628\u0631\u0631\u0633\u06cc \u06a9\u0646\u06cc\u0645:<\/p>\n<p>from store.models import Categoria<\/p>\n<p>def get_all_categorias(request):<br \/>\n    categorias = Categoria.objects.all()<br \/>\n    return {&#8216;categorias&#8217;: categorias}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0628\u0639\u062f\u060c \u0628\u0627\u06cc\u062f context_processor \u0631\u0627 \u062f\u0631 \u067e\u06cc\u06a9\u0631\u0628\u0646\u062f\u06cc \u067e\u0631\u0648\u0698\u0647 \u062b\u0628\u062a \u06a9\u0646\u06cc\u0645.  \u0628\u0631\u0648\u06cc\u0645 \u0628\u0647 ecommerce\/settings.py \u0648 \u062f\u0631 \u062f\u0627\u062e\u0644 \u0641\u0627\u06cc\u0644 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u0645 \u0628\u062e\u0634 TEMPLATES \u0631\u0627 \u0628\u06cc\u0627\u0628\u06cc\u0645\u060c \u062f\u0631 \u0627\u06cc\u0646 \u0628\u062e\u0634 context_processors \u0631\u0627 \u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0647 \u0648 \u0642\u0633\u0645\u062a \u062e\u0648\u062f \u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u0632\u06cc\u0631 \u0627\u0636\u0627\u0641\u0647 \u0645\u06cc\u200c\u06a9\u0646\u06cc\u0645:<\/p>\n<p>TEMPLATES = [<br \/>\n    {<br \/>\n        &#8216;BACKEND&#8217;: &#8216;django.template.backends.django.DjangoTemplates&#8217;,<br \/>\n        &#8216;DIRS&#8217;: [],<br \/>\n        &#8216;APP_DIRS&#8217;: True,<br \/>\n        &#8216;OPTIONS&#8217;: {<br \/>\n            &#8216;context_processors&#8217;: [<br \/>\n                &#8230;<br \/>\n                &#8230;<br \/>\n                &#8216;store.context_processors.get_all_categorias&#8217;<br \/>\n            ],<br \/>\n        },<br \/>\n    },<br \/>\n]\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0633\u067e\u0633 \u0628\u0627\u06cc\u062f \u0628\u0647 \u0627\u0644\u06af\u0648\u06cc &#8220;index.html&#8221; \u0628\u0631\u0648\u06cc\u0645 \u062a\u0627 \u0647\u0645\u0647 \u062f\u0633\u062a\u0647\u200c\u0647\u0627 \u0631\u0627 \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u06cc\u06a9 \u06af\u0632\u06cc\u0646\u0647 \u0632\u06cc\u0631 \u0645\u0646\u0648\u06cc \u062f\u0631\u0648\u0646 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u0645\u060c \u0628\u0647 \u0634\u0631\u062d \u0632\u06cc\u0631:<\/p>\n<p>{% for categoria in categorias %}<br \/>\n   {{categoria.nombre}}<br \/>\n{% endfor %}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u062f\u0631 \u0646\u0647\u0627\u06cc\u062a \u06cc\u06a9 URL \u062c\u062f\u06cc\u062f \u0648 \u0639\u0645\u0644\u06a9\u0631\u062f \u0645\u0634\u0627\u0647\u062f\u0647 \u062f\u0631 \u062f\u0627\u062e\u0644 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f store \u06a9\u0647 \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u0634\u0627\u0648\u0631\u0647 \u0648 \u0646\u0645\u0627\u06cc\u0634 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0641\u06cc\u0644\u062a\u0631 \u0634\u062f\u0647 \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0631\u0627 \u0645\u06cc \u062f\u0647\u062f.<\/p>\n<p>\u062a\u0627\u0628\u0639 view \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u0628\u0647 \u0634\u06a9\u0644 \u0632\u06cc\u0631 \u0628\u0627\u0634\u062f:<\/p>\n<p>def get_productos_por_categoria(request, categoria_id):<br \/>\n    productos = Producto.objects.filter(categorias__in=[categoria_id])<br \/>\n    return render(request, &#8216;catalog.html&#8217;, {&#8216;productos&#8217;: productos})<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0648 URL \u062c\u062f\u06cc\u062f \u0645\u0627\u0646\u0646\u062f \u0627\u06cc\u0646:<\/p>\n<p>urlpatterns = [<br \/>\n  # Otras rutas<br \/>\n  path(&#8216;categorias\/\/productos\/&#8217;, views.get_productos_por_categoria, name=&#8221;productos_por_categoria&#8221;),<br \/>\n]\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0628\u06cc\u0627\u06cc\u06cc\u062f \u0633\u0639\u06cc \u06a9\u0646\u06cc\u0645 \u0622\u0646 \u0631\u0627 \u0639\u0645\u0644\u06cc \u06a9\u0646\u06cc\u0645 \u0648 \u067e\u0631\u0648\u0698\u0647 \u0645\u0627 \u06a9\u0627\u0645\u0644 \u0634\u0648\u062f.<\/p>\n<div data-article-id=\"1924789\" id=\"article-body\">\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0686\u0647\u0627\u0631\u0645\u06cc\u0646 \u0648 \u0622\u062e\u0631\u06cc\u0646 \u0622\u0645\u0648\u0632\u0634 \u0646\u06a9\u0627\u062a \u0632\u06cc\u0631 \u067e\u0648\u0634\u0634 \u062f\u0627\u062f\u0647 \u062e\u0648\u0627\u0647\u062f \u0634\u062f:<\/p>\n<p>\u067e\u0631\u062f\u0627\u0632\u0634 \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f<br \/>\u0646\u0645\u0627\u06cc\u0634 \u0633\u0627\u0628\u0642\u0647 \u0633\u0641\u0627\u0631\u0634<br \/>\u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0628\u0646\u062f\u06cc \u0641\u06cc\u0644\u062a\u0631 \u06a9\u0646\u06cc\u062f.<\/p>\n<p><strong>1. \u067e\u0631\u062f\u0627\u0632\u0634 \u06cc\u06a9 \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f<\/strong><\/p>\n<ul>\n<li>\u062f\u0627\u062e\u0644 \u0628\u0633\u062a\u0647 &#8220;\u0645\u062f\u0644&#8221; \u0628\u0631\u0646\u0627\u0645\u0647 <code>store<\/code>\u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u067e\u0627\u06cc\u062a\u0648\u0646 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f: &#8220;order.py&#8221; \u0648 \u062a\u0639\u0631\u06cc\u0641 \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0645\u062f\u0644 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f:\n<\/li>\n<\/ul>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>...\n...\nfrom store.models import Pedido\n\nfrom django.db import models\nfrom django.contrib.auth.models import User\nfrom .producto import Producto\n\nclass Pedido(models.Model):\n    usuario = models.ForeignKey(User, on_delete=models.CASCADE)\n    producto = models.ForeignKey(Producto, on_delete=models.CASCADE)\n    cantidad = models.PositiveIntegerField(default=1)\n    total = models.DecimalField(max_digits=12, decimal_places=2)\n    fecha_registro = models.DateTimeField(auto_now_add=True)\n    fecha_ult_act = models.DateTimeField(auto_now=True)\n\n    def __str__(self) -&gt; str:\n        return f'{self.id}'\n\n    class Meta:\n        db_table=\"st_pedidos\"\n        verbose_name=\"Pedido\"\n        verbose_name_plural=\"Pedidos\"`\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0628\u0631\u0627\u06cc \u062b\u0628\u062a \u0633\u0641\u0627\u0631\u0634 \u0647\u0627\u06cc \u062c\u062f\u06cc\u062f \u0627\u0632 \u0645\u062f\u0644 Order \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f.<\/p>\n<p>\u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0645\u0627 \u06cc\u06a9 \u0645\u062f\u0644 \u062c\u062f\u06cc\u062f \u0627\u06cc\u062c\u0627\u062f \u06a9\u0631\u062f\u0647 \u0627\u06cc\u0645\u060c \u0628\u0627\u06cc\u062f \u0645\u0647\u0627\u062c\u0631\u062a \u0645\u0631\u0628\u0648\u0637\u0647 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u0648 \u0627\u0639\u0645\u0627\u0644 \u06a9\u0646\u06cc\u0645 \u062a\u0627 \u0622\u0646 \u0631\u0627 \u062f\u0631 \u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647 \u0645\u0646\u0639\u06a9\u0633 \u06a9\u0646\u06cc\u0645\u060c \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062f\u0633\u062a\u0648\u0631\u0627\u062a:<\/p>\n<p><code>poetry run python manage.py makemigrations<\/code>\u060c y<br \/><code>poetry run python manage.py migrate<\/code><\/p>\n<ul>\n<li>\u062f\u0631 \u0645\u0631\u062d\u0644\u0647 \u0628\u0639\u062f\u060c \u0645\u0627 \u0628\u0627\u06cc\u062f &#8220;URL&#8221; \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645 \u06a9\u0647 \u0627\u0632 \u0637\u0631\u06cc\u0642 \u0622\u0646 \u062b\u0628\u062a \u0647\u0631 \u0633\u0641\u0627\u0631\u0634 \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc \u0634\u0648\u062f.  \u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0641\u0627\u06cc\u0644 urls.py \u0628\u0631\u0646\u0627\u0645\u0647 \u062e\u0648\u062f \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f <code>store<\/code>:\n<\/li>\n<\/ul>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>urlpatterns = [\n  # Otras rutas\n  path('pedidos\/', views.crear_pedido, name=\"crear_pedido\")\n]\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li>\u0647\u0646\u06af\u0627\u0645\u06cc \u06a9\u0647 \u0645\u0633\u06cc\u0631 \u0627\u06cc\u062c\u0627\u062f \u0634\u062f\u060c \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u0645 \u0622\u0646 \u0631\u0627 \u0628\u0627 \u062a\u0627\u0628\u0639 view \u0645\u0631\u0628\u0648\u0637\u0647 \u0645\u0631\u062a\u0628\u0637 \u06a9\u0646\u06cc\u0645\u060c \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646 \u06a9\u0627\u0631\u060c \u062a\u0627\u0628\u0639 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc\u200c\u06a9\u0646\u06cc\u0645 <code>crear_pedido<\/code> \u062f\u0631 \u0641\u0627\u06cc\u0644 views.py \u0628\u0631\u0646\u0627\u0645\u0647 <code>store<\/code>:\n<\/li>\n<\/ul>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\ndef crear_pedido(request):    \n    try:    \n        datos_pedido = json.loads(request.body)\n        producto_id = int(datos_pedido.get('producto_id'))\n        cantidad = int(datos_pedido.get('cantidad'))\n\n        producto = Producto.objects.get(pk=producto_id)\n\n        nuevo_pedido = Pedido(  usuario=request.user,\n                                producto=producto,\n                                cantidad=cantidad,\n                                total=cantidad*producto.precio)\n\n        nuevo_pedido.save()\n\n        return JsonResponse({'success': True, 'message': f'Se registr\u00f3 el pedido exitosamente. Pedido # {nuevo_pedido.id}'}, status=200)        \n\n    except Exception as ex:\n        return JsonResponse({'success': False, 'message': str(ex)}, status=500)\n\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li>\u0628\u0639\u062f\u0627\u064b \u062f\u0631\u062e\u0648\u0627\u0633\u062a http \u0631\u0627 \u0627\u0632 \u0637\u0631\u06cc\u0642 Ajax \u0627\u0646\u062c\u0627\u0645 \u062e\u0648\u0627\u0647\u06cc\u0645 \u062f\u0627\u062f \u06a9\u0647 \u0645\u0633\u0626\u0648\u0644 \u0645\u0635\u0631\u0641 \u0645\u0633\u06cc\u0631 \u0627\u06cc\u062c\u0627\u062f \u0633\u0641\u0627\u0631\u0634 \u062f\u0631 \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a \u06a9\u0647 \u06a9\u0627\u0631\u0628\u0631 \u0645\u06cc \u062e\u0648\u0627\u0647\u062f \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f\u06cc \u0648\u0627\u0631\u062f \u06a9\u0646\u062f.  \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646 \u06a9\u0627\u0631\u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u062c\u0627\u0648\u0627 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0627\u0633\u062a\u0627\u062a\u06cc\u06a9 \u062c\u062f\u06cc\u062f \u062f\u0631 \u062f\u0627\u062e\u0644 \u067e\u0648\u0634\u0647 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc \u06a9\u0646\u06cc\u0645 <code>static\/js<\/code>\u060c \u0641\u0627\u06cc\u0644 \u0631\u0627 \u0645\u06cc \u062a\u0648\u0627\u0646 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u06a9\u0631\u062f <code>pedido.js<\/code>.<\/li>\n<\/ul>\n<p>\u062f\u0631 \u062f\u0627\u062e\u0644 \u0641\u0627\u06cc\u0644\u060c \u062a\u0627\u0628\u0639 \u0632\u06cc\u0631 \u0631\u0627 \u062b\u0628\u062a \u0645\u06cc \u06a9\u0646\u06cc\u0645:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>function crearPedido(producto_id, csrf_token){\n\n    const jsonData= {\n        producto_id: producto_id,\n        cantidad: 1\n    }\n\n    axios.post('\/pedidos\/', jsonData, {\n        headers: {\n            'X-CSRFToken': csrfToken\n        }\n    })\n    .then(response =&gt; {\n        alert(response.data.message);\n    })\n    .catch(error =&gt; {\n        if (error.response) {           \n            alert(error.response.data.message);\n        }else {\n            alert(error.message);\n        }\n    });\n}\n\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li>\u062f\u0631 \u0646\u0647\u0627\u06cc\u062a\u060c \u0645\u0627 \u0645\u06cc \u062e\u0648\u0627\u0647\u06cc\u0645 \u0647\u0645\u0647 \u0686\u06cc\u0632 \u0631\u0627 \u0627\u0632 \u0642\u0627\u0644\u0628 &#8220;catalog.html&#8221; \u0648\u0635\u0644 \u06a9\u0646\u06cc\u0645\u060c \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u062a\u0627\u0628\u0639 \u0631\u0627 \u0627\u062c\u0631\u0627 \u0645\u06cc \u06a9\u0646\u06cc\u0645 <code>crearPedido<\/code> \u06a9\u0647 \u0645\u0627 \u0628\u0647 \u062a\u0627\u0632\u06af\u06cc \u0627\u06cc\u062c\u0627\u062f \u06a9\u0631\u062f\u0647 \u0627\u06cc\u0645.  \u062f\u0631 \u062f\u06a9\u0645\u0647 &#8220;Place Order&#8221; \u0628\u0627 \u0627\u062c\u0631\u0627\u06cc \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u062a\u0627\u0628\u0639\u060c \u0631\u0648\u06cc\u062f\u0627\u062f onclick \u0631\u0627 \u0645\u062f\u06cc\u0631\u06cc\u062a \u0645\u06cc \u06a9\u0646\u06cc\u0645. <code>crearPedido<\/code> \u0628\u0647 \u0634\u0631\u062d \u0632\u06cc\u0631 \u0627\u0633\u062a:\n<\/li>\n<\/ul>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>onclick=\"crearPedido('{{producto.id}}', '{{csrf_token}}')\"\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0628\u0631\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u06a9\u0627\u0631 \u06a9\u0646\u062f \u0628\u0627\u06cc\u062f \u0641\u0627\u06cc\u0644 \u062c\u0627\u0648\u0627 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0631\u0627 \u062b\u0628\u062a \u06a9\u0646\u06cc\u0645 <code>pedido.js<\/code> \u062f\u0627\u062e\u0644 \u0642\u0627\u0644\u0628:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code><script src=\"https:\/\/dev.to\/villacisg93\/{% static\" js=\"\"\/> \n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0645\u0627 \u0628\u0647 \u0627\u062c\u0631\u0627\u06cc \u0647\u0645\u0647 \u0686\u06cc\u0632 \u0627\u062f\u0627\u0645\u0647 \u0645\u06cc \u062f\u0647\u06cc\u0645 \u062a\u0627 \u062a\u0623\u06cc\u06cc\u062f \u06a9\u0646\u062f \u06a9\u0647 \u0633\u0641\u0627\u0631\u0634\u0627\u062a \u062c\u062f\u06cc\u062f \u0627\u06cc\u062c\u0627\u062f \u0634\u062f\u0647 \u0627\u0646\u062f.<\/p>\n<p><strong>2. \u0646\u0645\u0627\u06cc\u0634 \u062a\u0627\u0631\u06cc\u062e\u0686\u0647 \u0633\u0641\u0627\u0631\u0634 \u06a9\u0627\u0631\u0628\u0631<\/strong><\/p>\n<p>\u062d\u0627\u0644\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0627\u0628\u0639 view \u0631\u0627 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645 <code>get_mis_pedidos<\/code> \u0628\u0631\u0627\u06cc \u0645\u0634\u0648\u0631\u062a \u0628\u0627 \u0633\u0641\u0627\u0631\u0634\u0627\u062a \u06a9\u0627\u0631\u0628\u0631 \u0648 \u0646\u0645\u0627\u06cc\u0634 \u0622\u0646\u0647\u0627.<\/p>\n<p>\u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0627\u0628\u0639 view \u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u0632\u06cc\u0631 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>def get_mis_pedidos(request):\n    pedidos = Pedido.objects.filter(usuario=request.user).order_by('-id')\n    return render(request, 'mis-pedidos.html', {'pedidos': pedidos})\n\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0648 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u0627\u0644\u06af\u0648\u06cc \"my-orders.html\" \u0631\u0627 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645 \u062a\u0627 \u0633\u0641\u0627\u0631\u0634\u0627\u062a \u06a9\u0627\u0631\u0628\u0631 \u062f\u0631 \u06cc\u06a9 \u062c\u062f\u0648\u0644 \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0634\u0648\u062f:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code><div class=\"mt-5 table-responsive\">\n        <table class=\"table table-hover\">\n            <thead>\n                <tr>\n                    <th scope=\"col\">#<\/th>\n                    <th scope=\"col\">Pedido<\/th>\n                    <th scope=\"col\">Producto<\/th>\n                    <th scope=\"col\">Cantidad<\/th>\n                    <th scope=\"col\">Total<\/th>\n                    <th scope=\"col\">Fecha Reg.<\/th>\n                    <th\/>\n                <\/tr>\n            <\/thead>\n            <tbody>                \n            {% for pedido in pedidos %}\n                <tr>\n                    <th scope=\"row\">{{ forloop.counter }}<\/th>\n                    <td>{{ pedido.id }}<\/td>\n                    <td>{{ pedido.producto.nombre }}<\/td>\n                    <td>{{ pedido.cantidad }}<\/td>\n                    <td>{{ pedido.total }}<\/td>\n                    <td>{{ pedido.fecha_registro }}<\/td>                    \n                <\/tr>\n            {% endfor %}            \n            <\/tbody>\n        <\/table>\n<\/div>\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><strong>3. \u0627\u062c\u0627\u0632\u0647 \u0641\u06cc\u0644\u062a\u0631 \u06a9\u0631\u062f\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0628\u0646\u062f\u06cc \u0631\u0627 \u0628\u062f\u0647\u06cc\u062f<\/strong><\/p>\n<p>\u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0622\u062e\u0631\u06cc\u0646 \u0646\u06a9\u062a\u0647\u060c \u0641\u06cc\u0644\u062a\u0631 \u0645\u062d\u0635\u0648\u0644 \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0628\u0646\u062f\u06cc \u0641\u0639\u0627\u0644 \u0645\u06cc \u06a9\u0646\u06cc\u0645\u060c \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0628\u0627\u06cc\u062f \u06cc\u06a9 \u067e\u0631\u062f\u0627\u0632\u0634\u06af\u0631 \u0632\u0645\u06cc\u0646\u0647 (context_processor) \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645.<\/p>\n<p><em>\u06cc\u06a9 context_processor \u062f\u0631 \u062c\u0646\u06af\u0648 \u062a\u0627\u0628\u0639\u06cc \u0627\u0633\u062a \u06a9\u0647 \u06cc\u06a9 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u06cc\u200c\u06a9\u0646\u062f \u0648 \u06cc\u06a9 \u0641\u0631\u0647\u0646\u06af \u0644\u063a\u062a \u062f\u0627\u062f\u0647 \u0631\u0627 \u0628\u0631\u0645\u06cc\u200c\u06af\u0631\u062f\u0627\u0646\u062f \u06a9\u0647 \u0628\u0647 \u0637\u0648\u0631 \u062e\u0648\u062f\u06a9\u0627\u0631 \u0628\u0647 \u0645\u062a\u0646 \u0647\u0645\u0647 \u0642\u0627\u0644\u0628\u200c\u0647\u0627\u06cc \u0631\u0646\u062f\u0631 \u0634\u062f\u0647 \u0627\u0636\u0627\u0641\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f \u0648 \u0628\u0647 \u062f\u0627\u062f\u0647\u200c\u0647\u0627\u06cc \u062e\u0627\u0635\u06cc \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc\u200c\u062f\u0647\u062f \u062a\u0627 \u062f\u0631 \u0633\u0637\u062d \u062c\u0647\u0627\u0646\u06cc \u0628\u062f\u0648\u0646 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0627\u0631\u0633\u0627\u0644 \u0635\u0631\u06cc\u062d \u062f\u0631 \u0647\u0631 \u0646\u0645\u0627 \u062f\u0631 \u062f\u0633\u062a\u0631\u0633 \u0628\u0627\u0634\u0646\u062f.<\/em><\/p>\n<p>\u0627\u0628\u062a\u062f\u0627 \u0628\u0627\u06cc\u062f \u0641\u0627\u06cc\u0644 context_processors.py \u0631\u0627 \u062f\u0631 \u062f\u0627\u06cc\u0631\u06a9\u062a\u0648\u0631\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 \"store\" \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645.  \u067e\u0633 \u0627\u0632 \u0627\u06cc\u062c\u0627\u062f\u060c \u0645\u0627 \u0628\u0647 \u0627\u06cc\u062c\u0627\u062f context_processor \u0627\u062f\u0627\u0645\u0647 \u0645\u06cc \u062f\u0647\u06cc\u0645 \u062a\u0627 \u0647\u0645\u0647 \u062f\u0633\u062a\u0647 \u0647\u0627 \u0631\u0627 \u0628\u0631\u0631\u0633\u06cc \u06a9\u0646\u06cc\u0645:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>from store.models import Categoria\n\ndef get_all_categorias(request):\n    categorias = Categoria.objects.all()\n    return {'categorias': categorias}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0628\u0639\u062f\u060c \u0628\u0627\u06cc\u062f context_processor \u0631\u0627 \u062f\u0631 \u067e\u06cc\u06a9\u0631\u0628\u0646\u062f\u06cc \u067e\u0631\u0648\u0698\u0647 \u062b\u0628\u062a \u06a9\u0646\u06cc\u0645.  \u0628\u0631\u0648\u06cc\u0645 \u0628\u0647 <code>ecommerce\/settings.py<\/code> \u0648 \u062f\u0631 \u062f\u0627\u062e\u0644 \u0641\u0627\u06cc\u0644 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u0645 \u0628\u062e\u0634 TEMPLATES \u0631\u0627 \u0628\u06cc\u0627\u0628\u06cc\u0645\u060c \u062f\u0631 \u0627\u06cc\u0646 \u0628\u062e\u0634 context_processors \u0631\u0627 \u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0647 \u0648 \u0642\u0633\u0645\u062a \u062e\u0648\u062f \u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u0632\u06cc\u0631 \u0627\u0636\u0627\u0641\u0647 \u0645\u06cc\u200c\u06a9\u0646\u06cc\u0645:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>TEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                ...\n                ...\n                'store.context_processors.get_all_categorias'\n            ],\n        },\n    },\n]\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0633\u067e\u0633 \u0628\u0627\u06cc\u062f \u0628\u0647 \u0627\u0644\u06af\u0648\u06cc \"index.html\" \u0628\u0631\u0648\u06cc\u0645 \u062a\u0627 \u0647\u0645\u0647 \u062f\u0633\u062a\u0647\u200c\u0647\u0627 \u0631\u0627 \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u06cc\u06a9 \u06af\u0632\u06cc\u0646\u0647 \u0632\u06cc\u0631 \u0645\u0646\u0648\u06cc \u062f\u0631\u0648\u0646 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u0645\u060c \u0628\u0647 \u0634\u0631\u062d \u0632\u06cc\u0631:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>{% for categoria in categorias %}\n  <li> {{categoria.nombre}} <\/li>\n{% endfor %}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062f\u0631 \u0646\u0647\u0627\u06cc\u062a \u06cc\u06a9 URL \u062c\u062f\u06cc\u062f \u0648 \u0639\u0645\u0644\u06a9\u0631\u062f \u0645\u0634\u0627\u0647\u062f\u0647 \u062f\u0631 \u062f\u0627\u062e\u0644 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f <code>store<\/code> \u06a9\u0647 \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u0634\u0627\u0648\u0631\u0647 \u0648 \u0646\u0645\u0627\u06cc\u0634 \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0641\u06cc\u0644\u062a\u0631 \u0634\u062f\u0647 \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0631\u0627 \u0645\u06cc \u062f\u0647\u062f.<\/p>\n<p>\u062a\u0627\u0628\u0639 view \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u0628\u0647 \u0634\u06a9\u0644 \u0632\u06cc\u0631 \u0628\u0627\u0634\u062f:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>def get_productos_por_categoria(request, categoria_id):\n    productos = Producto.objects.filter(categorias__in=[categoria_id])\n    return render(request, 'catalog.html', {'productos': productos})\n\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0648 URL \u062c\u062f\u06cc\u062f \u0645\u0627\u0646\u0646\u062f \u0627\u06cc\u0646:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>urlpatterns = [\n  # Otras rutas\n  path('categorias\/<categoria_id>\/productos\/', views.get_productos_por_categoria, name=\"productos_por_categoria\"),\n]\n<\/categoria_id><\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0628\u06cc\u0627\u06cc\u06cc\u062f \u0633\u0639\u06cc \u06a9\u0646\u06cc\u0645 \u0622\u0646 \u0631\u0627 \u0639\u0645\u0644\u06cc \u06a9\u0646\u06cc\u0645 \u0648 \u067e\u0631\u0648\u0698\u0647 \u0645\u0627 \u06a9\u0627\u0645\u0644 \u0634\u0648\u062f.<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u062f\u0631 \u0627\u06cc\u0646 \u0686\u0647\u0627\u0631\u0645\u06cc\u0646 \u0648 \u0622\u062e\u0631\u06cc\u0646 \u0622\u0645\u0648\u0632\u0634 \u0646\u06a9\u0627\u062a \u0632\u06cc\u0631 \u067e\u0648\u0634\u0634 \u062f\u0627\u062f\u0647 \u062e\u0648\u0627\u0647\u062f \u0634\u062f: \u067e\u0631\u062f\u0627\u0632\u0634 \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f\u0646\u0645\u0627\u06cc\u0634 \u0633\u0627\u0628\u0642\u0647 \u0633\u0641\u0627\u0631\u0634\u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u062f\u0633\u062a\u0647 \u0628\u0646\u062f\u06cc \u0641\u06cc\u0644\u062a\u0631 \u06a9\u0646\u06cc\u062f. 1. \u067e\u0631\u062f\u0627\u0632\u0634 \u06cc\u06a9 \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f \u062f\u0627\u062e\u0644 \u0628\u0633\u062a\u0647 &#8220;\u0645\u062f\u0644&#8221; \u0628\u0631\u0646\u0627\u0645\u0647 store\u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u067e\u0627\u06cc\u062a\u0648\u0646 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f: &#8220;order.py&#8221; \u0648 \u062a\u0639\u0631\u06cc\u0641 \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0645\u062f\u0644 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":69520,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-69519","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/69519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=69519"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/69519\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/69520"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=69519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=69519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=69519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}