You have a mix of techniques here. You are allowing markup to be saved into the database and then when being displayed in a template you are again adding mark up there to! Why don't you have a model which has a "title" field and a "body" field. That way the user doesn't have to get involved with entering in any markup at all. Then you template can do the following:
<h2>{{ heading }}</h2> {{ body|linebreaks }} On Feb 21, 9:41 pm, Ali Rıza Keleş <ali.r.ke...@gmail.com> wrote: > Hi all, > > I have a problem about template language. > > In my model there is a text field for body text of entries. And I markup > my text with some html. Like below: > > Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod > tempor incididunt ut labore et dolore magna aliqua. <strong>"Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip > ex ea commodo consequat."</strong> > > <h2>Section 1.10.32 of "de Finibus Bonorum et Malorum"</h2> > > Duis aute irure dolor in reprehenderit in voluptate velit esse cillum > dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non > proident, sunt in culpa qui officia deserunt. > > Sed ut perspiciatis unde omnis iste natus error sit voluptatem > accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab > illo inventore veritatis et quasi architecto beatae vitae dicta sunt > explicabo. > > and in my templates use this text like that: > > {{ body|safe|linebreaks }} > > and the result is: > > <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. <strong>"Ut > enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat."</strong></p> > > <p><h2>Section 1.10.32 of "de Finibus Bonorum et Malorum"</h2></p> > > <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum > dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non > proident, sunt in culpa qui officia deserunt.</p> > > <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem > accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab > illo inventore veritatis et quasi architecto beatae vitae dicta sunt > explicabo.</p> > > As you see, h2 tag is inside p tag. And this is not a valid usage for > xhtml which is my document's type. > > I need paragraphs because their styles are applied by css. Also h2s are > same. > > I don't want users-editors- do paragraphs manually, because many of > texts are quite long, this is not efficient, so I use linebreaks. Users > have some capability of writing html as much as they need. So they can > markup h2, strong etc, if it is necessary in text. > > How can I fix this? > > Thanks. > > -- > Ali Rıza Keleş -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.