Discussion:
edit_inline_stacked template
Niall Mccormack
2009-01-04 15:18:29 UTC
Permalink
Hi there,

I'm trying to override the edit_inline_stacked template so I can
dynamically add in extra inline data via javascript - similar to
http://www.arnebrodowski.de/blog/507-Add-and-remove-Django-Admin-Inlines-with-JavaScript.html


I can override the change_form admin template, but can't seem to use/
override the following line to hook into the inline objects loop
{% for related_object in inline_related_objects %}{% edit_inline
related_object %}{% endfor %}


If I directly reference a template from the inline, duplicating the
edit_inline_stacked.html template, I get 'Invalid Block Tag' errors
for the following two lines
{% field_widget bound_field %}
{% admin_field_line bound_field %}


I'm pretty new to Django, but am enjoying it, however I would like to
get this working for my own site.

If anyone has any advice, or any other methods of adding/removing data
dynamically from inlines then I'd really appreciate it!

Cheers
Niall



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Daniel Roseman
2009-01-04 16:33:14 UTC
Permalink
Post by Niall Mccormack
Hi there,
I'm trying to override the edit_inline_stacked template so I can  
dynamically add in extra inline data via javascript - similar tohttp://www.arnebrodowski.de/blog/507-Add-and-remove-Django-Admin-Inli...
I can override the change_form admin template, but can't seem to use/
override the following line to hook into the inline objects loop
{% for related_object in inline_related_objects %}{% edit_inline  
related_object %}{% endfor %}
If I directly reference a template from the inline, duplicating the  
edit_inline_stacked.html template, I get 'Invalid Block Tag' errors  
for the following two lines
{% field_widget bound_field %}
{% admin_field_line bound_field %}
I'm pretty new to Django, but am enjoying it, however I would like to  
get this working for my own site.
If anyone has any advice, or any other methods of adding/removing data  
dynamically from inlines then I'd really appreciate it!
Cheers
Niall
Rather than override the template just to add some javascript, it's
probably easier to use a custom form for the inline model, and add a
Media class referencing the URL of your javascript file.

Something like:

class CustomInlineForm(forms.ModelForm):
class Meta:
model = MyInlineModel

class Media:
js = ('/path/to/my/javascript.js',)

class CustomInlineAdmin(admin.TabularInline)
form = CustomInlineForm

class CustomMasterAdmin(admin.ModelAdmin):
inlines = [CustomInlineAdmin]

--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Niall Mccormack
2009-01-04 19:27:29 UTC
Permalink
After learning JQuery in a couple of hours I've done just that!!

I presume it's best to add simple functionality like this rather than
use templates?

Cheers
Niall
Post by Daniel Roseman
Post by Niall Mccormack
Hi there,
I'm trying to override the edit_inline_stacked template so I can
dynamically add in extra inline data via javascript - similar tohttp://www.arnebrodowski.de/blog/507-Add-and-remove-Django-Admin-Inli
...
I can override the change_form admin template, but can't seem to use/
override the following line to hook into the inline objects loop
{% for related_object in inline_related_objects %}{% edit_inline
related_object %}{% endfor %}
If I directly reference a template from the inline, duplicating the
edit_inline_stacked.html template, I get 'Invalid Block Tag' errors
for the following two lines
{% field_widget bound_field %}
{% admin_field_line bound_field %}
I'm pretty new to Django, but am enjoying it, however I would like to
get this working for my own site.
If anyone has any advice, or any other methods of adding/removing data
dynamically from inlines then I'd really appreciate it!
Cheers
Niall
Rather than override the template just to add some javascript, it's
probably easier to use a custom form for the inline model, and add a
Media class referencing the URL of your javascript file.
model = MyInlineModel
js = ('/path/to/my/javascript.js',)
class CustomInlineAdmin(admin.TabularInline)
form = CustomInlineForm
inlines = [CustomInlineAdmin]
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...