Re: Many-to-Many with quantities

2007-06-01 Thread Gio
Yes, you are right. Removing core=True solved the issue. However I think an error message from admin web interface is needed when things go wrong. Or should the default model validator to point to the error? As during all my experiments in the terminal where the server was running I always got: -

Re: Many-to-Many with quantities

2007-06-01 Thread chrominance
class PizzaTopping(models.Model): pizza = models.ForeignKey(Pizza, help_text = 'Toppings to go on Pizza: num in admin is how many will show up in Pizza', edit_inline = models.TABULAR, num_in_admin = 3,

Re: Many-to-Many with quantities

2007-06-01 Thread Gio
Let me add that it isn't a Python version problem, it's the same with python 2.4 and 2.5. Giovanni. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-

Re: Many-to-Many with quantities

2007-06-01 Thread Gio
@Malcom Thanks. I forgot about that example! @Michael This is what I do: 1. I create a new project with the model file made by a copy-and-paste of the code I posted above. I add my new app to configuration files. 2. I create a new db and I create tables it with syncdb 3. manage.py runserver and I

Re: Many-to-Many with quantities

2007-06-01 Thread Michael Newman
I use this code in quite a few of my programs and never have issues. I don't know why you are having this problem and it is not throwing any errors. Are you using the Web interface at all? If so when saving are there any errors. If the objects aren;t saving to the db generally Python throughs some

Re: Many-to-Many with quantities

2007-06-01 Thread Malcolm Tredinnick
On Fri, 2007-06-01 at 07:46 +, Gio wrote: > > > The usual process when you have one version of code that is working and > > a more complicated version that is not working is to add features to the > > working version, one at a time, until it stops working. In that way you > > will be able to

Re: Many-to-Many with quantities

2007-06-01 Thread Gio
> The usual process when you have one version of code that is working and > a more complicated version that is not working is to add features to the > working version, one at a time, until it stops working. In that way you > will be able to narrow down exactly which is the problematic step and >

Re: Many-to-Many with quantities

2007-06-01 Thread Malcolm Tredinnick
On Fri, 2007-06-01 at 06:56 +, Gio wrote: > I deleted the db and resync done, but still got the same problem. > I add a few toppings and it works. > I add one pizza with some toppings and their quantities: admin says > everything is right, but really it isn't: pizza_pizzatopping is an > empty

Re: Many-to-Many with quantities

2007-05-31 Thread Gio
I deleted the db and resync done, but still got the same problem. I add a few toppings and it works. I add one pizza with some toppings and their quantities: admin says everything is right, but really it isn't: pizza_pizzatopping is an empty table, while pizza_pizza got the right entry. The pizza

Re: Many-to-Many with quantities

2007-05-31 Thread Michael Newman
Because of the dependants you might need to either manually add the tables to the db or if you don't have any values in that table delete all the rows in pizza and run syncdb again. Sometimes when working within the same class the syncdb doesn't change the database all the way (and rightly so). Gi

Re: Many-to-Many with quantities

2007-05-31 Thread Gio
Thanks to you all, I took something from all the replies and I wrote this modifying Michael code: class Topping(models.Model): name = models.CharField(maxlength=255, unique=True) def __str__(self): return self.name class Admin: pass class Pizza(models.Model): n

Re: Many-to-Many with quantities

2007-05-31 Thread Michael Newman
Nis; Thanks for catching that I left the manytomany field there. There is no need for that. revised code: class Topping(models.Model): # ... class Pizza(models.Model): # ... class PizzaToppings(model.Model): pizza = models.ForeignKey(Pizza, help_text='Toppings to go on Pizza: num in

Re: Many-to-Many with quantities

2007-05-31 Thread Tim Chase
> And what if I need to say that I can have two or three times the same > topping on my pizza? Something like twice mozzarella cheese and 3 > times green olives topping? > > I though about an intermediary class and indeed this is the same > solution found in those old posts mentioned before: > >

Re: Many-to-Many with quantities

2007-05-31 Thread Nis Jorgensen
Gio wrote: > Hi, > I searched about this subject and found only a few very old posts, so > maybe there is a better solution now. > > As you may guess the model I'd like to code is similar to the Pizza - > Toppings you know from the "Creating Models" documentation: > > class Topping(models.Model):

Re: Many-to-Many with quantities

2007-05-31 Thread Michael Newman
You could need an extra class for this but it should work: class Topping(models.Model): # ... class Pizza(models.Model): # ... toppings = models.ManyToManyField(Topping) class PizzaToppings(model.Model): pizza = models.ForeignKey(Pizza, help_text='Toppings to go on Pizza: num in

Many-to-Many with quantities

2007-05-31 Thread Gio
Hi, I searched about this subject and found only a few very old posts, so maybe there is a better solution now. As you may guess the model I'd like to code is similar to the Pizza - Toppings you know from the "Creating Models" documentation: class Topping(models.Model): # ... class Pizza(mo