App with multiple categories in Django CMS - django

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.

Related

Adding a new section in Mezzanine CMS (Django) admin

I'm totally new to Mezzanine CMS. I got handed a site to work with and so far I've been able to do all the changes without problem. I've run across a problem in which they want a new section in the home page. I go to the admin section to edit the home page, but there is no extra content field.
On the home page, I see 4 sections "content" "priorities" "testimonials" and "clients". I would like to have another "content" area as a 5th section. How do I go on and add this section? I'm totally new to Django but would be appreciative if someone could explain or point in the right direction.
Here is a link to an image for reference.
https://imgur.com/a/sUKOtvS
Thanks in advance
The homepage content would be backed by a Django model with attributes for the partners and testimonial fields. You'll need to find the Python class for this model in your code base (you could search for those field names), and you'll need to add a new attribute for the new section you need.
Django and Mezzanine have lots of different field types you can use for these attributes, so consult their respective documentation for how those work (Django's are a lot more comprehensive, so start there).
Once you've done that, you'll need to create a database migration for the new attribute - that adds the field to the database table that will store the actual content, again consult the Django documentation for how these work.
Finally you may need to add the new field to the Admin class, which is the Python class (similar to the model) that controls which fields appear in the admin interface, and how they appear. I say "may" as these generally appear automatically without any code, but if things have been modified to a certain extent, you may need to do this manually.

Wordpress database integration/sync with Django

My company will be rolling out a new website to accompany our product launch and would like to switch over to Wordpress as our content management system. We will be utilizing a Wordpress theme that will allow users to create their own virtual events without having to log into the Wordpress dashboard (back-end). This event information will be displayed on the website for other users to view and register - this is all built into the theme we have purchased.
These virtual events will be held on our software platform, which is built on Django. We would like to utilize Wordpress to manage the login and event creation process, but would also like to have event information displayed on the Wordpress site AND imported to the Django database as well.
For example: Users will need to submit three items on the front-end Wordpress site to create an event: Title, Host Name, and Start Time. When that information is submitted can it be automatically duplicated to the Django database in addition to it being sent to the WP database?
I have already done some research on this matter, but what I have found thus far might not work for our needs. I found this presentation by Collin Anderson - it is similar to what we want to achieve, but I believe the application is a little different: http://www.confreaks.com/videos/4493-DjangoCon2014-integrating-django-and-wordpress-can-be-simple.
I have a lot of experience with Wordpress, but very limited experience with Django. This question is more for research purposes than a "how-to". We want to know if we can continue to plan on heading toward the Wordpress direction or if we should seek alternative methods for our site. I appreciate you taking moment to answer my question.
I'm working on something similar at the moment and found a good starting point was this:
http://agiliq.com/blog/2010/01/wordpress-and-django-best-buddies/
That way, as dan-klasson suggests, you can use the same database for both the wp side and the django side.
In short, first things first take a back up of the wp database in case anything goes wrong.
Create a new django project and set your settings.py to use the wp database.
In this new django project you can use ./manage.py inspectdb > models.py to autogenerate a models.py file of the wp database. Be careful here as there are differences between wp and django conventions. You will need to manually alter some of the auto generated models.py. Django supplies db_table and db_column arguments to allow you to rename tables and columns for the django part if you'd like to.
You can then create a new django app in your django project and place the models.py you've created in there. This new app will be using the same data as your wordpress site. I'm not sure exactly what you want to do but I would be very, very careful about having wordpress and django access the same data simultaneously. You may want to set the django side as read only.
You can then add other apps to extend the django side of things as you wish.
I should point out that I haven't completed my work on this yet but so far so good. I'll update as I find sticking points etc.

Does django-cms really integrate with django and models

I am migrating an existing small business admin system that uses a variety of spreadsheets and access databases to a Linux server to provide both intranet and internet access to our own office staff, to external partners and to customers.
There is some fairly complex database work which will be using postgreSQL and python.
There needs to be a professional looking public website which can access some of the database content both to generic "customers" and tailored data visibility to actual clients.
None of the traditional CMS offerings like wordpress, drupal, joomla etc seemed flexible enough, so I found my way to django.
I've built models, populated data tables, built some basic views to manipulate the data and started to play a bit with html layout tags and css, and I've started looking at forms including crispy-forms.
I need to work with pdf files - scanning, uploading, splitting into single pages, displaying on the site alongside form data entry etc.
I was hoping that I could use django-cms to handle the aspects of the public facing words and pictures and dealing with the jpgs pdfs etc, and to do the page layout stuff, while using django models and python to simplify the database access and provide the intelligence.
When I read the django-cms docs around integrating models I get the impression that there is not really a proper integration - that you can build a site that switches between cms pages and django pages or maybe embeds a django view into a cms page, but I'm not sure if I can do the look and feel and static bits in cms and the dynamic bits on the same page in django without still having to do the work in django as well.
the django system revolves around the models, the django-cms docs read as if models are some sort of extra bit you might want to use.
There's talk of the different ways to integrate django models but they all treat the django model as a foreign item that can be added.
I've found other people who've asked "how does django-cms work with django models" and the answers seem to be no different from those that ask "how do I ad a django model to a drupal site"
So my question really is - does django-cms integrate with django to provide ease of building sites with good integration between cms features and model features or are they really two separate systems that can share space on the same page with a bit of work but don't play nice together in any useful way?
Is there another tool I can use for my static stuff and page formatting and navigation to integrate with my models and python code?
Yes
Yes, it does integrate with django and it does provide ease of building sites with good integration between cms features and model features. Like comment by Simeon Visser hinted - you can create your own plugins to add managing different features into django cms part. And most often - most things will not need such integration - simple django admin views and models will suffice.

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.

How to port from Drupal to Django?

What would be the best way to port an existing Drupal site to a Django application?
I have around 500 pages (mostly books module) and around 50 blog posts. I'm not using any 3rd party modules.
I would like to keep the current URLS (for SEO purposes) and migrate database to Django. I will create a simple blog application, so migrating blog posts should be ok. What would be the best way to serve 500+ pages with Django? I would like to use Admin to edit/add new pages.
All Django development is similar, and yours will fit the pattern.
Define the Django model for your books and blog posts.
Unit test that model using Django's built-in testing capabilities.
Write some small utilities to load your legacy data into Django. At this point, you'll realize that your Django model isn't perfect. Good. Fix it. Fix the tests. Redo the loads.
Configure the default admin interface to your model. At this point, you'll spend time tweaking the admin interface. You'll realize your data model is wrong. Which is a good thing. Fix your model. Fix your tests. Fix your loads.
Now that your data is correct, you can create templates from your legacy pages.
Create URL mappings and view functions to populate the templates from the data model.
Take the time to get the data model right. It really matters, because everything else is very simple if your data model is solid.
It may be possible to write Django models which work with the legacy database (I've done this in the past; see docs on manage.py inspectdb).
However, I'd follow advice above and design a clean database using Django conventions, and then migrate the data over. I usually write migration scripts which write to the new database through Django and read the old one using the raw Python DB APIs (while it is possible to tie Django to multiple databases simultaneously, too).
I also suggest taking a look at the available blogging apps for Django. If the one included in Pinax suits your need, go ahead and use Pinax as a starting point.
S.Lott answer is still valid after years, I try to complete the analysis with the tools and format to do the job.
There are many Drupal export tools out of there by now but with the very same request I go for Views Datasource choosing JSON as format. This module is very solid and available for the last version of Drupal. The JSON format is very fast in both parsing and encoding and it's easy to read and very Python-friendly (import json).
Using Views Datasource you can create a node view sorted by node id (nid), show a limited number of elements per page, configure a view path, add to it a filter identifier and pass to it the nid to read all elements until you get an empty JSON response.
When importing in Django you have a wide set of tools as well, starting from loaddata to load fixtures. Views Datasource exported JSON but it's not formatted as Django expects fixtures: you can write a custom admin command to do the import, where you can have the full control of the import flow.
You can start your command passing a nid=0 as argument and then let the procedure read, import and then fetch data from the next page passing simply the last nid read in the previous HTTP request. You can even restrict access to the path on view but you need additional configuration on the import side.
Regarding performance, just for example I parsed and imported 15.000+ nodes in less than 10 minutes via a Django 1.8 custom admin command on an 8 core / 8 GB Linux virtual machine and PostgreSQL as DBMS, logging success and error information into a custom model for each node.
These are the basics for import/export between these two platform, for detailed information I described all the major steps for export from Drupal and then import to Django in this guide.