Answer the question
In order to leave comments, you need to log in
How to pass parameters to django view?
There are models.
models.py
class Product(models.Model):
title = models.TextField(verbose_name='Номер',blank=True)
producte = models.TextField(verbose_name='Продукт')
order = models.ForeignKey('orders.Order', verbose_name='Заказ')
class Order(models.Model):
title = models.CharField(verbose_name='Название заказа', max_length=60)
slug = models.SlugField(verbose_name='URL',unique=True)
# view.py
def ViewOrder(request, slug):
order = Order.objects.select_related().get(slug=slug)
starts = order.start_set.all()
id = Order.pk
url(r'^(?P<slug>[-\w]+)/$', ViewOrder, name='view_order'),
class ProducteForm(ModelForm):
class Meta:
model = Producte
fields = ('title','producte', 'order')
Answer the question
In order to leave comments, you need to log in
porridge, it turns out somehow
This is how it should be from your words
class Category(models.Model):
name =....
class Product(models.Model):
category = models.ForeignKey(Category)
title = models.TextField(verbose_name='Номер',blank=True)
producte = models.TextField(verbose_name='Продукт')
class Order(models.Model):
products = models.ManyToMany(Product)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question