django cms placeholder not in structure view - django

My co programmer developed a django plugin for use in a django project and on his setup, the plugin works. he can write a placeholder in the django template being used and load that with the custom plugin via the django-cms structure view. I tried doing the same thing but i noticed that the placeholder i put in the html in the same place he put it in isn't appearing in the structure view. the only placeholders appearing in the structure view and can be edited are static placeholders. placeholders entered like the ones in the django tutorial
http://docs.django-cms.org/en/release-3.3.x/introduction/templates_placeholders.html
and are placed with this code
{% placeholder "custom_name" %}
aren't appearing in the structure view. i couldn't find a similar scenario here in stackoverflow. I have a fairly similar setup to my co programmer too. i copied the same repo he's working on and i even used a dump from his postgres database in case there's something wrong with my own setup but still no luck. there are no DEBUG errors appearing in the console or the webpage so I am out of ideas. Has anyone encountered a similar situation? The django-cms we are using is version 3.1.0.
Thanks

I just found out earlier today what was wrong. I didn't notice immediately, that the page i was trying to edit was not a django-cms managed page which is why the placeholder wasn't working in it. In django-cms managed pages, the placeholder is working properly.
Thanks

Related

Django admin page layout changed with new version

I am working on an existing django project where admin console is extensively used.
With my latest run of package upgrade for my application admin page layout has changed.
Models have started appearing on all the pages, leaving a small space to display form fields.
For example this is how form page look like now:
Original Form view was occupying the whole page like this:
Any clue on what has been changed and which setting to change to get back the original view?
From the django-3.1 release notes,
The admin now has a sidebar on larger screens for easier navigation.
It is enabled by default but can be disabled by using a custom
AdminSite and setting AdminSite.enable_nav_sidebar
to False.
You can refer Customizing the AdminSite class - (django doc) to know more about customizing the AdminSite
Try this, open your browser and clear all the history then login back in again and it should work. I am sure the browser has cached an old version of Django admin.
I had the same problem when using version 3.1. I started a new demo app with version 2.2 to demonstrate something and when I got back to version 3.1 I got that issue, So what I did was just clear the browser history and everything came to its original state.

Changing from Django form to ReactJS

Currently I have a django sign up form rendered with a django template. I'm starting to switch to ReactJS so I wanted to change that form to a Modal window rendered with react.
The modal will replace the form so it will contain a form in its body containing the same input fields as the django form, before starting i need to know if the modal will work the same as the form or do I need to do some changes like binding it to the django view.
I'm using this setup now for the frontend of one project. This is far from trivial and took me some days to figure out. Start with this webpack-django library. You will need to setup your paths carefully along the road. Also for decent development experience, you will need to run webpack in watch mode as the rendering is dealt by django server, not webpack-dev-server (I run this mode in the start script of packages.json). After you can make this work, you will have some obstacles like: csrf tokens and confilct of urls.py with react-routing.
Well, I'm not being more speficic because not sure if you want to follow down this road. Also it requires a tutorial on setting up npm, webpack,django that would raise tons of questions. Besides, I would not recommend doing this just for a login form. You can give up on django forms and build your modal in vanilla javascript/html/css using django's template engine and bootstrap.
Hope this helps!

Using Polymer Inside Django

I have a Django project already running with its UI created using Bootstrap and some custom CSS, JS.
Currently going through the Polymer Starter project, I want to do a UI makeover for my Django project using Polymer. Being a beginner with Polymer, my first question is, Is it feasible?
If yes, I would like to know from where should I start? I am not getting should I just remove all bootstrap and CSS already used and start replacing my old elements with newer Polymer elements? I have tried including Polymer elements in Django templates, but it doesn't seem to work this way.
I am just not getting the steps to follow for such a UI makeover.
Any piece of help will be greatly appreciated.
Refer to this https://groups.google.com/forum/?fromgroups=#!searchin/polymer-dev/django/polymer-dev/N2R8qknalOI/58ZhC1gWFh4J.
You should be able to wrap Polymer elements in Django templates. They are just static files. Just make sure you are using {% verbatim %} tags to wrap around your polymer elements.
However, if you are going for a complete UI makeover, use AJAX calls to the REST services running in the background on Django. Or if you do not want to use django-rest-framework or tastypie or something new, you can slightly modify your existing view functions to serve JSON that packs all the data you need for a dynamic page.

App with multiple categories in Django CMS

we are trying to migrate a project written with Drupal to Django CMS and we faced a problem with article module. Our site is divided in sections and we have a news module installed in every section with a category, url structure is looking like this:
/section1
/news-category1
/section2
/news-category2
/etc..
This is the same news module, just split in categories (some news articles can pop up in multiple sections, in this case one section is chosen as base to form unique article URL). The only one method I found makes this structure:
/news
/caregory1
/category2
/etc...
Which is not good for us as we would prefer to keep the current URL structure for SEO purposes. Is there a correct way to implement this in Django CMS beside creating each section as a module and plugging in in to a page? Or can I some-how install the same module to multiple pages and pass the section information to it?
One way to do this I found myself would be to plug-in the same module to every page it will be on and then have it to parse the path of the page to figure out it's category. Not super-officiant but might work. Not sure if there is any other way.

Integrate existing blog code into Django-CMS?

If I already have a blog app done with Django and I want to use it with my new Django CMS site, is it okay to simply drop it into my new Django CMS project as a decoupled app and match anything /blog/ to the blog app as apposed to a Django CMS plugin? I guess what I need to know is when is it best to write my Django app as a plugin vs an entire app?
Thx
JeffC
Yes, but you don't just drop it into the urls.py, instead you can write an AppHook to tie your blog's URL scheme to a particular page in your CMS.
Plugins on the other hand are useful if you want to inserts particular aspects of you app into other page's placeholders - for example to show your latest 3 posts on the frontpage.
You might also want to include your blog's paths in a breadcrumb or menu on your site - in that case you need to write a custom Menu too.
Finally, it might also be useful to make use of django cms's placeholders in you blog model. His would allow you to post a variety of content via plugins.