Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 821633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:40:20+00:00 2026-05-15T02:40:20+00:00

I have a simple Blog model with a TextField. What is the best way

  • 0

I have a simple Blog model with a TextField.
What is the best way to save links in the TextField ?

1) Saving link in the database in this form: http://www.example.com
and then using some filter in the template to trasform it in form:

<a rel="nofollow" href="http://www.example.com>http://www.example.com</a>

2) Saving link in the database directly in this form:

<a rel="nofollow" href="http://www.example.com>http://www.example.com</a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:40:21+00:00Added an answer on May 15, 2026 at 2:40 am

    Assuming you are talking about how to save links (or any HTML formatting really) that you are including in your blog posts, not standalone links (like for a blogroll):

    You might want to think about adopting some sort of markup language like Markdown or BBCode. You’d then store the blog post in the pure markup syntax, and provide a method (like blog.get_post()) that would parse the stored markup and return HTML. You’d then use the safe filter in your template to avoid escaping the HTML.

    Even better, to avoid parsing your markup on every request, cache it in the database. Add a TextField called something like text_html to your Blog model. Override your Blog model’s save method to parse the markup into HTML and save the HTML to the text_html field.

    Then when you want to render the blog post in a template, you can use {{ post.text_html|safe }} without having to parse your markup each time.

    So your Blog model might look like this (only text field shown for clarity)

    import markdown
    
    class BlogPost(models.Model):
        text = models.TextField()
        text_html = models.TextField(editable=False) # don't want to see this in Admin
    
        def save(self, force_insert=False, force_update=False):
            self.text_html = markdown(self.text)
            super(BlogPost, self).save(force_insert, force_update)
    

    To make things simpler on the data entry side, you could also add in a nice javascript editor – like the one I’m typing this answer in right now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple Blog model: class Blog(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True)
I have a simple (and possibly crude) way of moderating comments on a blog
I have this simple Post model: class Post(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True)
I have a simple blog app with the model Post. If I delete all
So I have a simple post model that has_many tags :through post_tags. This allows
I'm trying to model this inheritance for a simple blog system Blog has many
I have a very simple model form, but for some reason, the code fails
I do a simple blog on rails. I have a Post model and a
I'm trying to create a basic version of this example in CoffeeScript: http://davidsulc.com/blog/2012/04/15/a-simple-backbone-marionette-tutorial/ .
Have a painfully simple blog Post creator, and I'm trying to check if the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.