Integrate existing blog code into Django-CMS? - django

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.

Related

Adding Wagtail to an existing Django app

I'm quite new to Django and Wagtail, and I'm having some difficulty with what I think is a very basic use.
How do I allow Wagtail to edit an existing view's template, while serving that template using Django's serving mechanism?
Assume I have an app (HomePage) created to serve the site's main index (/). I have the HomePage's views set up to render template and certain elements dynamically. Now I want that template to be editable via Wagtail's CMS interface. Something as simple as an image on the frontpage, or a headline.
The closest I've gotten so far has been to follow the Wagtail beginner's tutorial to override the base HomePage class in my app's models.py. That only made my pages available via the /pages/ URL.
Thank you for any help.
Since your site's home page is not a Page object in the Wagtail sense, I'd suggest looking at Wagtail's facilities for managing non-page content - snippets and ModelAdmin would be possible candidates, but I reckon the site settings module would be the best fit.
A Setting model gives you a set of fields which can be configured for display in the Wagtail admin using a 'panels' definition, just like you'd get for a page model - with the important property that only one settings record exists per site. You can retrieve this record within your homepage view or template as shown in the docs, and output it on your template as desired.
One way do that, is to let Wagtail serve your homepage. You will need to change your project's url configuration accordingly, to make wagtail's urls serve the root of your site.
Then, you can pack your dynamic content into a custom template_tag and include in your homepage html template.

Django multilingual app with flatpages

Which way is better to create a simple multilingual app with Django? I need just one or two flatpages and navigation. The problem is as follows:
- Content and navigation panel on the page should be able to change from an admin-panel.
- I need multi-language application.
I would like to hear your advice. This can be a ready-made solution (package or github project).

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.

Should I use a blog app in Django?

I want to create my own admin panel and every users will can have their own blogs. I'm using a blog app called 'Zinnia', I liked it. Zinnia have some visual editors (WYMEditor, Tinymce) also have a tag system, etc. that I want to have in my admin panel.
I was wondering if should I create my own admin panel or blog app and integrate the visual editor programatically. What would be better?
Thanks for answers.
EDIT: My real question is: What's better?
create my admin and my blog app
create my admin integrating Zinnia or another blog app
use the django admin panel (but i want to customize the fully admin panel, so I guess that is not a good option)
Remembering, the users (not only admins) can post to their blogs. (this is the reason that I don't want to use the Django admin)
EDIT 2:
Exactly what I want: I want to use all the features (such as tagging, WYMEditor [I know i can implement this programmaticaly], etc.) of Zinnia (or another blog app) with my custom admin panel, with my buttons, my layout, my css, my everything!
Thanks for all answers, it's important for me.
Here is a simple tutorial for creating a django blog app:
http://lightbird.net/dbe/blog.html
If you are still learning django, I recommend it to create your own blog!!!
Creating a good Django blog application is straightforward, but tedious work, that can quite easily get unwieldy if you start implementing additional features such as multiple language support, linkback handling, search, sitemap generation, etc.
I definitely wouldn't suggest that you start from scratch. If your not completely satisfied by the full extent of possibilities or the initial feature set of Zinnia, you can check out all the Django blog applications on Django Packages.

Custom Django admin panel

I want to use Django for a web application I'm building that will have an admin panel. I know that you need to just activate the admin app and you're ready to go. However, I would like to have a custom panel, I mean, I want to design the layout myself, I want to add menus and forms for the admin to insert new data in the database etc. Is it possible? or I should write a similar application that will have such features?
For more control over the layout (custom menus etc.) you should check django-admin-tools.
And if you take a look at Django's docs you'll learn that you can easily tweak and override most parts of the admin. For example here is a demonstration on how to use a custom form:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin
So the admin is pretty customizable. But the question if you should build your own app or reuse the admin depends pretty much on your specific needs. At least make sure you know in which directions the admin can be easily bend.
The sole purpose for Django's admin is to allow you to manipulate (add/edit/remove) data in your database. I think you should at least try to check what the admin is capable of before trying to reinvent the wheel. You'll soon discover the level of complex insight the admin allows you to have. Then you'll discover that making it yourself is unnecessary excess of work and you'll end up with modifying a couple of admin-templates and CSS styles.
Yes, you can customize Django Admin Panel, Django provides some sort of customization for showing database tables structure from their own, for that you can follow DJANGO ADMIN SITE DOC , it will really help you.
For the customizations beyond the Django admin site settings, you can customize admin panel add manual layout, by adding manual detailing in Django template files which are stored in Django environment, django/django/contrib/admin/templates/admin/index.html of your current Django version. You can update its HTML, CSS, and JS according to need.