How can I build a django homepage with updatable content? - django

I an building a kind of social network (think of it as last.fm, but gaming related). I want to have a homepage which will feature:
site news, announcements etc. in the main part
featured items in the right sidebar
player of the week in the right sidebar
I am trying to think of a way not to be hand coding these every time they need to change, which I understand is terrible design. However, I can't think of much.
I realize I need some kind of simple blog engine for the site news and such, but what about the featured content in the sidebar? Should there be a table in the database containing the featured items of the week? I think that will pollute my models.py with unnecessary stuff.
Please share any ideas.

There are lots of ready-to-go solutions ie.
Pinax - great package of reusable apps,
Django CMS - not so great, but could be useful.
Django's static pages - for basic stuff :)
I'd try pinax first - it has all of what you need.
As for your featured stuff - it all depends on what exactly you need, on your content.
If you need something special you'd probably finish up writing this stuff by yourself,
or overriding parts of ready-to-go solutions.

Featured Items and Player of the Week will depend (usually) on your project specific Player / Item models. It shouldn't take long to program these small pieces.
As far as news, there are quite a few different solutions out there. Here's one that I've created (because I can't think of a better one off hand):
http://github.com/monokrome/django-news/
The best bet with django is to find the smaller apps you might be able to leverage, and then write your own project with your custom wants/needs in mind.

Related

Integrating django apps in your own views

Let's say I'm writing a complex site in django with wikis, forums, ... or writing my own apps that I intend to reuse from different sites.
I really want to create, for example, a wiki page that has a forum at the bottom, or reuse my previously written wiki app with a different graphical layout.
What is the best way to structure my app to allow this kind of reuse?
So far, I have been giving apps their own urls in urls.py. This however does not work if I want to combine multiple apps together in a single page.
Additionally, most of the apps I found online come with their own templates, which has the full html, and do not separate the logic of creating / preparing a context from that of handling a request and generating a reply.
What is the best practice here? What do you do? edit the templates that come from applications you download online? refactor them to fit in your application?
what should I do for my own applications? structure them so they have a method to get the context, and a method to render it?
Django hasn't great support out of the box to component-oriented architectures. I find this problematic some times too. You'll face to problems here.
Architecture
Code
Architecture: As Django is not component oriented, all the apps aren't component oriented neither. The designers and coders for those apps haven't thought about that. So they've just built "views" to interface with their apps. You'll need to get something more "pluggable".
Code: Once you decide to build that, you'll have to find what support you have for that. Most Django apps are pretty well coded, so you won't have much code in views, but abstracted in other places. That way you could reuse that code and build your own components.
Example: Suppose you're working with a third-party Wiki app. That wiki has a view to display highest ranked Tags and other view to create a wiki entry. If the code is good enough (that I'm assuming it is because Django has a pretty good community), you could refactor that to use components. The view to create an entry must be using some Form, that you can plug in your own site. And the view to get highest ranked tags probably uses some utility function, or some Tag manager's method. In that case you could refactor it to your own needs.
Hope it helps.

Django vs. Grok / Zope3 vs. Pylons

I am a computer programmer by training but have been away from web development for a while. I am doing a little bit of background research on various Python web development frameworks. I understand that Django, Grok / Zope 3, and Pylons are all good solid frameworks, but have little in the way of background working with them. Can someone explain to me the difference in approach of the each of the frameworks, and where one shines when compared to the others?
My specific use case is in building a web application that will recommend products to users based on a variety of user supplied information. Thus, it will take a fair bit of user input in the shape of a basic profile, product preferences, attempt to establish social relationships between users. It will also need to support staff uploading products into the system with labeled features that can be then matched to users.
On the last point, would parts of Plone help with providing an interface for non-tech people to upload products and descriptions of the products? Are piece of Plone easy to borrow? Seems like I shouldn't have to reinvent the wheel in terms of having a way for people to upload items for sale / recommendation along with some metadata to describe the items. Thanks for the help.
Based on your background and requirements, I'd advise you to go with something like http://pinaxproject.com/ which is based on Django.
Pyramid (the successor to Pylons) is a very low-level framework and you need to either choose the libraries or write all your application code yourself. For someone experienced this makes sense and gives you full control over your code. But it is a bit of a hurdle if you start from scratch and aren't familiar with the available libraries.
Django and Grok are both high level frameworks, with Django being the more popular choice. If you aren't familiar yet with using object databases or URL traversal, Grok is more time consuming to learn.
Plone is not suited for your use-case. It's a content management system and not a general web framework. Very little of the libraries it uses can be reused in a different context, certainly none of its UI. If you want to provide an engaging user experience with personalized content, Plone isn't for you - that's not what its been build to handle.
Disclaimer: I'm a release manager for Plone and Zope 2 / Zope Toolkit and have used Pyramid but not Django.
Dolmen project is a CMS built on top of Grok. Is very simple, but there are very few that use it. If you go with Grok, you could be able to reuse the GUI.
But As Hanno said, Grok is more time-consuming to learn than Django. Also Django has far more users than Grok.
The advantage of using Grok is that you can profit from Zope Component Architecture almost without writing ZCML and using decorators instead.
With Pyramid/Pylons you get a very simple framework and nothing else. It is a decoupled framework, so you are free to use whatever templating enginge you want (Mako, Genshi, Jinja, Cheetah), you are free to choose sqlalchemy, zodb, mongoDb, etc., and you are also free to choose the url mapping scheme (traversal vs. django-style mapping or a combination of both). You can also use ZCA here if you want. For starters this might become quite confusing or verbose.
Django is a kind of monolithic framework that gives you one way to do stuff. That's why it's easy to learn and a very good option. But, in my experience, you sometimes get to a point where you want to deviate from Django standards and it simply cannot be done without patching a bunch of stuff.
And, as for Zope3, I'd recommend you to download a copy of BlueBream and se how it does for you.
As a Plone user I can say that creating Content Objects in Plone is difficult. There is not much documentation on how to do it and it is complicated. Some recommend using UML and specialized Plone products to make it easier but that introduces yet another dependency.
I mention the problem with content objects because your "products" (not the same as a Plone product) would probably be represented in Plone as a content object which you would need to write yourself.
Plone is best when users and editors are entering and approving text in the form of news articles, press releases, photos etc. When that is the use case there are predefined content objects for such things so one does not need to write them oneself.
--Jonathan Mark

How to build a system for an editorial team

I'm developing a web portal that mostly works like a newspaper site. In the focus, there are articles, containing text, videos and images. These articles have attachments which shall be presented in a sidebar. These attachments might be the same objects that will be displayed within the body text.
I have been thinking a lot about how to create the structure and - and this is a major point - how to enable the editor to edit all this stuff comfortably.
What I evaluated were Django-CMS and feincms as complete systems, and several third-party-modules that do snippets of the work.
Now, I a have solution for inline objects: I forked the inline-module of django-basic-apps which is now able to take additional parameters for the objects to embed. Their parameters are an important thing to e.g. embed "an image with object id x, but max x pixels in size".
What is not solved with my approach is, to generate a sidebar containing a bunch of inline tokens. I could create a custom widget for this, though. A better solution would surely be to add a functionaly like somehow attaching generic objects (videos, images...) to an article object.
While my solution is working so far, I'm not sure if there are other ways to solve these common scenario, and I would like to hear some other experiences about this topic, and if there are any other ways you deal with it.
For there does not seem to be a bigger need of a solution for this generic problem, I will use my solution and see whether it proves in practice.
Take a look at Armstrong CMS. It's specifically designed to meet the needs of news organizations. It was developed out of the code that powers The Texas Tribune, a very large Django news site that won the Edward R. Murrow Award for best local news website in 2010.
Armstrong scales very well, is fast and can handle just about any kind of content you want to throw at it.

CMS for Multilingual Localization and Translation Workflow

I'm helping build a multilingual website in English, Chinese and French (after in Spanish, Korean and Arabic). I've collected a database of over 2000+ entries. It is essentially a huge product catalog (specifically travel packages) where more or less the info is the same (prices, sizes, numbers, etc.) but the labels change (of course excluding certain intro texts that must be written manually). I want to avoid having to translate piece by piece manually.
There needs to be a way for users to save the things they are interested in and rate their favorites. Also, I need an e-commerce shopping cart. Search functionality is a must since people tend to start general (one or two categories or wants) and work towards specifics. Another need is to localization and internationalization. The other need is a specific workflow system so as content is updated and new additions are made, editors can be notified and translators can translate what needs to be done. Work flow is key since the project will involve dozens of non-technical people from around the world.
I originally tried to a work-around solution in Drupal but it seemed ill-equipped and clunky. I tried a self-built PHP CMS but the project seems to big for purely manual. I'm considering Plone and Django, but I don't have any experience working in Python, only PHP. I'm open to trying a new CMS if it meets my needs of internationalization, translation work flow, search functionality and on-going user experience.
Any suggestions on the best CMS for all this?
Plone would be a good solution for the CMS, workflow, search and multilingual.
Ecommerce is not Plone's strength though. I would recommend integrating Plone with something like Satchmo than doing the ecommerce in Plone itself. (This has been done with success in other deployements)
If you are looking at a Django solution to these problems you might consider Satchmo or Lightning Fast Shop for the e-commerce part and Pootle for the translation process...

integrating a shopping cart, not the other way around

ZEN Cart seems to be able to do anything I could possibly ever want, but seems a bit bloated (for me) and more importantly - it's design process seems unbearable. I don't want to have reform a default design, I have my website design completed other than the shopping cart related items. I want to be able to add them in, working the shopping cart into my site, rather than the other way around. I need a shopping cart that can handle discounts and inventories and such, and of course as small as possible. Can anyone help recommend an OS cart that will allow this?
Thank so much for your time and suggestions!!
You didn't ask for any platform/languages in particular, so.
If you're using Django, then Satchmo looks to be an attractive option. Even if you're not, it might be fairly trivial to mash in, depending on how your site is set up.
You could consider using the cart that Google Checkout provides — is a JS system , easily themed with CSS (if you can learn to accept the !important tag), but SimpleCartJs is as easy as it comes, and it's for PayPal. Re-styles easily and it's pretty elegant.