Ramin,
That's an HTML question, and nothing to do with Django. In HTML whitespace all just collapses to a single space, newlines included, and you need to request them explicitly.
You can wrap it all in a <pre> </pre> tag pair or replace \n with <br> in your string, but that is just two of a plethora of options (including CSS styling, tables, and more, you can even use Django template filters and tags to to help, literally no shortage of ways to format and render this stuff), and you'd be the one to decide which is best for your desired layout.
No simple answer I'm afraid :-(.
Regards,
Bernd.
Ramin Farajpour Cami wrote:
That's an HTML question, and nothing to do with Django. In HTML whitespace all just collapses to a single space, newlines included, and you need to request them explicitly.
You can wrap it all in a <pre> </pre> tag pair or replace \n with <br> in your string, but that is just two of a plethora of options (including CSS styling, tables, and more, you can even use Django template filters and tags to to help, literally no shortage of ways to format and render this stuff), and you'd be the one to decide which is best for your desired layout.
No simple answer I'm afraid :-(.
Regards,
Bernd.
Ramin Farajpour Cami wrote:
--Thanks Bernd,
Your right, but i have problem show in view with output format ipconfig in html,
i try display :
PPP adapter VPN:
Connection-specific DNS Suffix . :Link-local IPv6 Address . . . . . : fe80::50a6:e568:7895:590d%24IPv4 Address. . . . . . . . . . . : 172.32.87.176Subnet Mask . . . . . . . . . . . : 255.255.255.255Default Gateway . . . . . . . . . : 0.0.0.0
but now i have :
PPP adapter VPN:Connection-specific DNS Suffix . :Link-local IPv6 Address . . . . . : fe80::50a6:e568:7895:590d%24IPv4 Address. . . . . . . . . . . : X.X.X.XSubnet Mask . . . . . . . . . . . : 255.255.255.255Default Gateway . . . . . . . . . : 0.0.0.0
Do you have idea?
On Thursday, September 7, 2017 at 12:44:17 PM UTC+4:30, Bernd Wechner wrote:Ramin,
I'm sorry but your question is not very clear. How about you capture the output of "ipconfig /all" with something like:
IPconfig = subprocess.check_output(["ipconfig", "/all"], stderr=devnull)
then add Config to your template context in a view something like:
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['IPconfig'] = IPconfig
return context
Though it depends on whether you're using class based generic views or standard views for example, but just look on-line for how to add data to a templates context.
Good luck. But if you want better help, try and be more clear about what you want and how you envisage achieving it I guess, share a description or sample of your template and view etc.
Regards
Bernd.
Ramin Farajpour Cami wrote:
Hi,--
Hi,
I going to show output command "ipconfig /all" in html django template but i have string uncomfortable,
for example :
i going to show this in html :
Windows IP Configuration
PPP adapter VPN:
Connection-specific DNS Suffix . :Link-local IPv6 Address . . . . . : fe80::50a6:e568:7895:590d%24IPv4 Address. . . . . . . . . . . : 172.32.87.176Subnet Mask . . . . . . . . . . . : 255.255.255.255Default Gateway . . . . . . . . . : 0.0.0.0
please see image attached,
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...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0a2a15a4- .6be1-4cde-bbac-a1274330c5da% 40googlegroups.com
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b16ad13-18d1-4e0c-88f6-8b8689664e70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment