Django-cms Edit model placeholder before model is added - django

Is there a good way to implement editing of a PlaceholderField before the model is added to an app?
I have an app with an apphook, and at present one has to create the model in the admin interface, save it (causing it to appear on the website), and then add the CMS content to the already-visible rendering of the model. Clearly this isn't very good.
Ideally I would like to be able to create the Placeholder content 'inline' along with the rest of the model.
What would be the best way to go about this? Is there an existing method, or do I hack the admin interface and the model's save method using the CMS API?
Thanks

Related

How to make a drop-down that show images in Django Admin?

I spent two hours trying to find out how to customize select2 widget in Django admin to implement this simple feature.
I have a model (Article) that contains many other objects (Pictures). Every Picture has a set of FileFields representing the original image file, the thumbnail, post-processed (using Pillow) preview and some meta stuff.
What I'm going to achieve is to be able to upload new images on the Article change page, and select/deselect them in the fancy Select2 dropdown widget.
How can I do that? Should I use ImageField instead of FileField? Should I use inlines and through for ManyToMany relation between Article and Pictures? Should I make my own widget? How do Django admin uses Select2 and how could I pass parameters like "templateResult" to be able to change the look of dropdown items?
Thank you in advance.

Is there a way to have custom content with mezzanie/Django

I'm new using Mezzanine and figured out how to set-up pages where I can manage content from Admin page.
But I have static pages, where I want to store some content and being able to control that content from Admin page.
Is this something I can do with Mezzanine?
I imagine that I need to create a model with richtext field add that model to admin interface and than somehow access to that model through templatage.
But any exact example would greatly appreciated.
Thanks!
See the docs on creating custom content types. The primary approach is to subclass the Page model and add your custom fields.
Alternatively, if your custom content is conceptually independent from your pages, it might make sense to create independent models with relational fields to the RichTextPage model and edit them through inlines.
Note that the mezzanine docs on custom content types and the django docs on inlines use the same author/book example so you can easily compare the two strategies.

Django model layout with multiple columns

My admin page for a specific model has two stackedInlines. Currently they display one under the other. I would like them to display side by side so The page would look like this (don't have enough reputation to embed the image :[ )
Any easy way to go about this without having to write my own admin page?
If that's the only solution, how exactly would I go about that?
you can override Django admin template for each app in your project.
you just have too create same folder as your app in template directory and overriding html.
How to override and extend basic Django admin templates?
You can add CSS/Javascript to admin page by defining class Media.
You'll have to override the admin template to accomplish this. See roshan's answer for more info.

Django admin: two change lists on the same page

I am trying to make an overview page for one of my models I have read through all of http://www.djangobook.com/en/1.0/.chapter17/ and understand how I can add my own custom views for a model to the django admin.
What I am currently trying to do is add multiple filtered change lists (presenting some child models) onto my "overview" page for the model. In these I would like to be able to make use of some of the admin features such as editable fields or actions.
Does anyone have some pointers on how I can best get started with this.
Check this out
He created a proxy model for the original model to avoid the conflict. You can create a new model admin or inherit the old ModelAdmin(as shown in the link)

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.
here is the documentation for Django Flatpages App, maybe you serve.
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.