简体   繁体   中英

ip address hyperlink in Django

In my Django template I am having some problem to hyperlink. The link is a dynamically generated IP (not a file location).

in views.py

def basestations(request, host_id):
 'ipaddr': basestation.mni_address
 some code 

return render_to_response('basestations.html', locals(), context_instance=RequestContext(request))

This variable holding the dynamically produced IP address from database and passes to front end in the variable name basestation.mni_address

In Django template, I want the basestation should be hyperlinked with the basestation.mni_address

<td><a href="{% url what should I write here? %}"><i
                                        class="icon-th-large"></i> {{ basestation.name }}</a></td>

eg basestation.name is also passed to front end dynamically. This basestation.name should be hyperlinked with the IP address, means while clicking on the name, user should be forwarded to a link as ex -' http://192.168.255.66 '

Any help is much appreciated.

You wouldn't use {% url %} at all. That's for generating links to other URLs within your Django app. You want to link to an IP address, so just put that value in directly:

<a href="{{ basestation.mni_address }}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM