Code

Opened 6 years ago

Closed 6 years ago

#6911 closed (duplicate)

edit_inline with multiple ForeignKeys referencing the same Model doesn't work

Reported by: jdi@… Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Happens with todays svn checkout, full error (when editing a material):

Template error

In template /usr/lib/python2.4/site-packages/django/contrib/admin/templates/admin/change_form.html, error at line 56
Caught an exception while rendering: 'bool' object is not callable
46 {% block after_field_sets %}{% endblock %}
47 {% if change %}
48 {% if ordered_objects %}
49 <fieldset class="module"><h2>{% trans "Ordering" %}</h2>
50 <div class="form-row{% if form.order_.errors %} error{% endif %} ">
51 {% if form.order_.errors %}{{ form.order_.html_error_list }}{% endif %}
52 <p><label for="id_order_">{% trans "Order:" %}</label> {{ form.order_ }}</p>
53 </div></fieldset>
54 {% endif %}
55 {% endif %}
56 {% for related_object in inline_related_objects %}{% edit_inline related_object %}{% endfor %}
57 {% block after_related_objects %}{% endblock %}
58 {% submit_row %}
59 {% if add %}
60 <script type="text/javascript">document.getElementById("{{ first_form_field_id }}").focus();</script>
61 {% endif %}
62 {% if auto_populated_fields %}
63 <script type="text/javascript">
64 {% auto_populated_field_script auto_populated_fields change %}
65 </script>
66 {% endif %}

Short example:

class Material(models.Model):

name = models.TextField()

class MaterialRelation(models.Model):

a = models.ForeignKey(Material,related_name='A', edit_inline=models.TABULAR, num_in_admin=5)
b = models.ForeignKey(Material, related_name='B')
c = models.ForeignKey(Material, blank=True, related_name='C')

def unicode(self):

return self.b.name

Please suggest a work around. As I'm new to django I'd rather not digg into
the code myself.

Thanks!

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #1939. This has been fixed in newforms-admin.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.