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:
------------------------------------------

<form method="POST" action=".">
   <p><label for="id_action.name">Name:</label>{{form.name}}</p>

     <p><label for="id_part">
       Parts:</label> {{ form.part }}</p>

<input type="submit" value="Submit" />

</form>


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to