On 31/08/2014 10:05 AM, stuartl@longlandclan.yi.org wrote:
> 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:
>
> |
> classIPv4SettingAdmin(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?)
I'm somewhat interested in your success with this because I enjoy it
when the user interface helps the user understand the software. But I
think you might have to dig a little deeper for a nice solution.
I found where the Admin has "add another" ...
Searching for: add another
options.py(945): msg = _('The %(name)s "%(obj)s" was added successfully.
You may add another %(name)s below.') % msg_dict
options.py(983): msg = _('The %(name)s "%(obj)s" was changed
successfully. You may add another %(name)s below.') % msg_dict
widgets.py(262): % (static('admin/img/icon_addlink.gif'), _('Add Another')))
Found 3 occurrence(s) in 2 file(s)
... which all looks interesting but maybe too big a job for the
anticipated benefit.
Good luck
Mike
>
> 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
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto: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
> <https://groups.google.com/d/msgid/django-users/9489756e-4813-43cf-8aa8-6cbfedbd87af%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
--
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/5402B69F.6070505%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment