Saturday, August 30, 2014

Change "Add another" text in inline views

Hi all,

This is a bit of a silly question, but I wonder if it is possible to change the "Add Another" text that appears on inline forms with related models.  I'm in the process of writing a network configuration module in Django that talks with NetworkManager with the intent on using it for headless appliances for energy management and possibly SCADA applications.

I have a number of polymorphic models (thank-you django-polymorphic!) that describe the various types of network connection, and attached to these, are some "settings" objects that describe different aspects of the connection.  Some of these are one-to-many relationships (e.g. IP addresses, routes, DNS servers), but some are one-to-one relationships (IPv4/IPv6 options: which specify things like DHCP vs static, 802.1x settings, bridge port configuration, etc).

The form at present looks like this: http://www.longlandclan.yi.org/~stuartl/images_tmp/django-inlines-add-another.png

Also of note is the capitalisation of some objects, e.g. "Ipv4" instead of "IPv4", but I guess I just missed a Meta variable somewhere.  I think I have seen something that sets this.

For the related objects that are one-to-one, I've defined my admin models like so:

class IPv4SettingAdmin(admin.StackedInline):
    model
= models.NetIPv4Setting
    extra
= 0
    min_num
= 0
    max_num
= 1

i.e. the related object is optional, not provided by default, and at most there can only be one.  You'll note that despite max_num being set to 1, it still says "Add another".  Is it possible to delete the word "another" from that text to make it more sensible?  (Better yet, can it drop the word "another" when the count currently sits at 0 since "another" implies an object of that type already exists?)

Apologies if this has been asked: I've only seen replies to the question of how to remove the "add another" option completely, which isn't what I want to do.

Regards,
Stuart Longland

--
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+unsubscribe@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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9489756e-4813-43cf-8aa8-6cbfedbd87af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment