Python Forum
Django field model for HTML parser?
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django field model for HTML parser?
#1
The contents of my models.py looks like this:
from django.db import models

# Create your models here.
class Post(models.Model):
        title = models.CharField(max_length=256)
        pub_date = models.DateTimeField()
        image = models.ImageField(upload_to='media/')
        body = models.TextField()

        def __str__(self):
            return self.title

        def pub_date_pretty(self):
            return self.pub_date.strftime('%A %d %B %Y @ %-I:%M:%S %p')

        def summary(self):
            return self.body[:350]
Lines 5 through 8 initiate the model class variables for my blog dashboard. My dashboard looks like this. There is a title, pub date, image and body. The Udemy instructor suggests consulting the official Django doc for field types/options. I’m not sure I really understand most of it. There is just so much information there. My question for all of you: Which field option or field type initiates an HTML parser for body text? I mean, when I go to to create a new blog post, how do I create rich text with HTML formatting buttons like bold, underline and italics? It’s not really the buttons I care about. I just want my HTML tags to parse. Take note of the HTML tags I’ve circled in red here. How do I get the h5, hr and em to parse? Is there a field option/type for this? I don’t see it in the models fields doc.

Thanks for your attention.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: View is unable to find attributes of database model pythonpaul32 0 510 Dec-07-2023, 06:38 PM
Last Post: pythonpaul32
  Querying Django model db - from Jose Portilla’s Udemy course Drone4four 2 1,695 Aug-09-2022, 09:25 AM
Last Post: Addweb
  <title> django page title dynamic and other field (not working) lemonred 1 2,099 Nov-04-2021, 08:50 PM
Last Post: lemonred
Lightbulb Hypertag. New language for HTML templating w/ Django support mwojnars 0 1,767 Apr-06-2021, 12:53 PM
Last Post: mwojnars
Photo After using models.Model on my class Im getting 'ImproperlyConfigured' error Django khavro 1 2,173 Apr-05-2021, 03:11 PM
Last Post: SheeppOSU
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,617 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Easy HTML Parser: Validating trs by attributes several tags deep? runswithascript 7 3,560 Aug-14-2020, 10:58 PM
Last Post: runswithascript
  [Django]calculate value in model smabubakkar 0 1,655 Apr-15-2020, 03:40 PM
Last Post: smabubakkar
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,357 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  Why use HTML in Django Template ift38375 2 2,816 Dec-09-2019, 02:28 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020