Reputation: 11
I'm attempting to write my first CMS in Django. So far I have managed to get a system up and running similar to flatpages but a little more flexible. I have two questions about how I'm approaching the structure of the CMS:
Firstly, I am storing HTML tags with the text content in a Postgres database. I've seen a lot of post'ers saying that this shouldn't be done for security reasons. If HTML should not be stored with the text then how do you embed information like bold typing, paragraph and image tags into the content?
Secondly, I have tried checking numerous content management systems (mainly PHP ones) on how they deal with directory structures. For instance, I might have a programming page which appears within the 'computers' category. In a static page I would just create a directory called 'computers' and place my static programming page inside that directory. How do I model directory structures like that inside a CMS? I can't find any info anywhere on the underneath structures of CMS's.
Thanks for any advice....
Upvotes: 1
Views: 577
Reputation: 4164
Do split this in 2 separate questions in the future.
Storing HTML is fine. When you output it be sure to use |safe in the templates. If you really want to be picky, you can avoid storing by using http://en.wikipedia.org/wiki/Textile_%28markup_language%29 or http://en.wikipedia.org/wiki/Markdown. They are wysiwig editors out there that do all your trouble.
You can create a Category model and all your pages with have a ForeignKey to this model. One of the most flexible solutions I found was to use tags, so a page can have multiple tags and thus fall under multiple 'categories' http://code.google.com/p/django-tagging/
Hope this helps.
Upvotes: 0
Reputation: 375634
Storing HTML tags is not inherently unsafe. You just have to scrub them of dangerous content before putting them in the database.
Your page model will need to include information about the category. Then when displaying a category, you'll query your pages by category to get all the "computer" pages to display on the computer page.
Upvotes: 2