Growth Mindset
Growth Mindset

Reputation: 1233

Django form to enter/save html to database

I'm in my first week of Django development and am working on an admin page that will let me write some quick html using TinyMCE and then save it to the database. I don't need to display this web page on the site or add it to urls.py, etc. The html snippet will be loaded from the database and used in a view function.

I've read in "Practical Django Projects" how to integrate TinyMCE, so my question is more concerned with the best approach for the form itself. Specifically:

1. Is there a built-in form like flatpage that works well for this? I only need one field in the form for the html.

2. How do I save the form's text after it's entered?

I created a model with a JSONField to save the html in, but I'm not clear on what to do next. Thanks.

Upvotes: 1

Views: 2422

Answers (2)

Growth Mindset
Growth Mindset

Reputation: 1233

I ended up using the ModelAdmin class to get what I wanted. I created a new model in models.py and then used ModelAdmin to enable an admin-editable form for the model's data.

Hope this helps someone.

Upvotes: 0

eos87
eos87

Reputation: 9353

here is the documentation for Django Flatpages App, maybe you serve.

Upvotes: 1

Related Questions