Re: HTML Source on Browser Rendering

52 views
Skip to first unread message

Joseph Mutumi

unread,
Jan 6, 2013, 2:46:44 PM1/6/13
to django...@googlegroups.com
Hello,

I think you should also check the 'Content-Type' being received client-side
in the HTTP headers. You can use something curl or Firebug.

On Sun, Jan 6, 2013 at 1:40 PM, Ryoichiro Kamiya <ryoichir...@gmail.com> wrote:
Hi,

I'm testing Django template rendering in development environment, but one of the page shows HTML source (after all Django tag executed) instead of HTML.

1. Content Type
The first thing I check is the Content Type but it's correctly set up (and it's in header template and shared with other pages that show contents correctly.

<meta http-equiv="Content-Type" content="text/html" charset="utf-8">

When I copied & pasted to another template and it works.

2. Browser
I checked it in another browser (i.e. Chrome) but it returned the same result.

3. Reboot runserver
also it didn't change the output.

Is there anything else I should check?
Thanks in advance.

Regards,
Ryo

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/FyjKgMAxm0YJ.
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.

stayros kroustouris

unread,
Jan 6, 2013, 3:22:30 PM1/6/13
to django...@googlegroups.com
Hello,
maybe any "autoescape"  template tags on the wrong spot?
--
Stavros

Ryoichiro Kamiya

unread,
Jan 7, 2013, 8:29:53 PM1/7/13
to django...@googlegroups.com
Thanks jjmutumi, stauros!

I am not using "autoescape" tag in my template. Thanks.

I am just checking the source on the back of HTML source displayed with Firebug as jmutumi suggested.
It seemed an auto-inserted <pre> tag before & after the source. (Please find the attached. thanks)

Any ideas how this can be added?

Ryo
Screenshot_8_1_13_10_27_AM-2.png

djangobie

unread,
Jan 8, 2013, 12:31:16 AM1/8/13
to django...@googlegroups.com
Than <pre> is the issues, as it 'll display the content (inside it) as it is .. making it preformated.
can't guess how you got your code wrapped in it in the first place.

Thanks
Message has been deleted

Ryoichiro Kamiya

unread,
Jan 8, 2013, 9:07:14 PM1/8/13
to django...@googlegroups.com
Thanks all for seeing this thread.

With further experiment, the result shows the HTML source with <pre> tag even after emptying the contents of the Django template file. When I tested it in various browsers, the browser automatically added basic HTML structure with <pre> tag on top of my contents. I compared the line endings and encoding with another page that working correctly, but couldn't find any difference.

I'll mark this as closed as it seemed not an issue resulting from Django.
Everyone, thanks for replying to my question. Have a nice day!

Regards,
Ryo

Ryoichiro Kamiya

unread,
Jan 9, 2013, 3:57:58 AM1/9/13
to django...@googlegroups.com
It's been resolved. The following mimetype property in views.py added the <pre> tags.

return render_to_response('prayer/service_index.html', datadict, mimetype="application/json; charset=utf-8")

Thanks,
Ryo

Peter of the Norse

unread,
Jan 13, 2013, 2:35:18 PM1/13/13
to django...@googlegroups.com
You're looking at the wrong thing. The <pre> tags were added by your browser. Chrome and Firefox show cleaned up HTML in firebug/web inspector. In the case of a bad MIME type, it treats it as text, and wraps everything in HTML for displaying. When people say to check the Content-Type header, you should look in the network tab.

To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/52PmLUnVVSIJ.

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.

Peter of the Norse



Reply all
Reply to author
Forward
0 new messages