Re: How to edit many-to-many relationships with data from custom intermediary table?

2013-08-21 Thread DJ-Tom


I'm not sure what the easiest way would be to make the Quantity field 
> editable - I thought about a* fieldset *but how do I get the data from 
> the intermediary table into that???
>
>
ooops - I meant FORMset, not fieldset... (why is there no way to edit my 
own post?) 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


How to edit many-to-many relationships with data from custom intermediary table?

2013-08-21 Thread DJ-Tom
Hi,

I'm currently working on a room management application for events.

One part of it is a list of room setups with associated equipment, each 
room can have an arbitrary number of  different equipment (such as screens, 
IT-equipment, A/, tables etc.)

Each equipment also has an attribute "number/quantity" to define how many 
of it is needed, so I created a custom intermediary table (instead of 
relying on the built-in one):

class roomsetup(models.Model):
name = models.CharField("Name", max_length=60)
equipments = models.ManyToManyField(equipment, 
through='roomsetup_equipments')  # use custom intermediary  table

class equipment(models.Model):
name = models.CharField("Name", max_length=60)

# custom intermediary m2m table...
class roomsetup_equipments(models.Model):
roomsetup = models.ForeignKey(roomsetup)
equipment = models.ForeignKey(equipment)
number = models.DecimalField('Quantity/number', max_digits=6, 
decimal_places=2, blank=True, null=False, default=1)

The "standard" roomsetup form I created just displays a plain list of 
equipment, there is no way to change the quantity:

class RoomsetupForm(ModelForm):
class Meta:
model = roomsetup
fields = ('active', 'name', 'roomlayout', 'equipments', 'notes',)

I'm not sure what the easiest way would be to make the Quantity field 
editable - I thought about a fieldset but how do I get the data from the 
intermediary table into that???

Any hint/sample would be appreciated.

thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.