added urlified title in title_url
This commit is contained in:
@@ -7,7 +7,10 @@ from sqlalchemy import (
|
||||
UnicodeText, #<- will provide Unicode text field
|
||||
DateTime, #<- time abstraction field
|
||||
Index,
|
||||
ForeignKey,
|
||||
)
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from webhelpers2.text import urlify #<- will generate slugs
|
||||
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates
|
||||
|
||||
@@ -16,13 +19,16 @@ class BlogRecord(Base):
|
||||
__tablename__ = 'entries'
|
||||
id = Column(Integer, primary_key=True)
|
||||
title = Column(Unicode(255), unique=True, nullable=False)
|
||||
title_url = Column(Unicode(255))
|
||||
body = Column(UnicodeText, default='')
|
||||
body_html = Column(UnicodeText, default='')
|
||||
tag = Column(Unicode(25), index=True)
|
||||
topic = Column(Unicode(25), index=True)
|
||||
created = Column(DateTime, default=datetime.datetime.utcnow)
|
||||
edited = Column(DateTime, default=datetime.datetime.utcnow)
|
||||
|
||||
topic_id = Column(ForeignKey('topics.topic'), nullable=False)
|
||||
topic = relationship('Topics', backref='topic_pages')
|
||||
tag = Column(Unicode(25))
|
||||
|
||||
@property
|
||||
def slug(self):
|
||||
return urlify(self.title)
|
||||
@@ -37,7 +43,6 @@ class Topics(Base):
|
||||
topic = Column(Unicode(25), primary_key=True)
|
||||
topic_name = Column(Unicode(25), nullable=False)
|
||||
|
||||
|
||||
class Tags(Base):
|
||||
__tablename__ = 'tags'
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
Reference in New Issue
Block a user