Re: Rendering Many-to-Many with raw_id_admin=True in Template

2006-10-04 Thread Paul Childs

Sorry to be a pest folks.

I had forgotten that the {{object}} was still accessible.

So to get what I want I just had to do this:

{% for part in object.part.all %}
{{part}}
{% endfor %}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Rendering Many-to-Many with raw_id_admin=True in Template

2006-10-04 Thread Paul Childs

I have a Many-to-Many relationship between two models, Action and Part
(see below).

Part has thousands of records so I am using "raw_id_admin=True".  This
works great in the admin.

I am using a generic view to create an update form for an Action. This
works fine but it only displays the part ids and does not include the
__str__ representation of the parts like the admin interface does. I
looked at the output of {% debug %} in the template and I couldn't see
anything that might contain those values.

Does anyone know how to do this? Thanks in advance.

-
Models:
-
from django.db import models

class Action(models.Model):
name = models.CharField(maxlength=10)
part = models.ManyToManyField(Part,raw_id_admin=True)

class Admin:
pass

def __str__(self):
return self.name


class Part(models.Model):

part_number = models.CharField(maxlength=20,db_index=True)
description = models.CharField(maxlength=50,blank=True)

class Admin:
pass

def __str__(self):
return '%s - %s' % (self.part_number, self.id)

--
Template:
--


   Name:{{form.name}}

 
   Parts: {{ form.part }}






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---