I'm building a personal project in Tornado and MongoExpress, and the only thing I can see about structuring my models is to put all of them in one file called models.py
I'm used to the RoR way of doing things, so this seems very counter-intuitive to me.
In addition, whenever I try to break the classes into different files, I'm not sure of where to store my DB connection logic, and how to ensure that all models are accessible from the controllers.
Ideas?
Also, you shouldn't need to worry about database connection logic in Django unless you're doing something very specific.
For common functionality (ie an abstract model or a mixin that is used/inherited by multiple models/views) I like to add another django app named common or core that is used by the other apps.
The problem with Tornado is that it doesn't come with an in-built ORM like Django, which means I need to actually create a connection to the Mongo instance I'm using. Hence the confusion. Python doesn't have initializers like Ruby does (that I know of).
Or am i wrong?
PS... Django <3
Just wanted to make sure I know what I'm getting before I jumps in further into either Wordpress or Django :D
Wordpress is old, and they've built up a shit-ton of technical debt for the sake of BC. To put it bluntly, it's not a pleasure to work with, at all. On the up side, something like 20% of the surface net runs on Wordpress. There's a huge market for WP skills, and it's got enormous mindshare amongst non-technical types. If you want to invest effort in WP, do it because of the adoption metrics; if you're more technically oriented, pick Django (or Laravel/Symfony if PHP is more your speed).
Actually there are some great cms built on top of django, for example django-cms or wagtail!
If you start from scratch and want to build a simple cms it will be easier to do it with wp, if ofcourse you tolerate php - some people won't use php for reasons that should be well known to hn readers. However, for any other web development I recommed using django (or another normal web framework).
Using wp to build non-cms stuff reminds me the "when your only tool is a hammer everything looks like a nail" argument! You may use your hammer to cut (break) wood but using your saw would be easier and safer!
What?
Django website have "The Web framework for perfectionists with deadlines".
You can compare WP with Drupal or Joomla. With Django you can build you own CMS.
Sorry, one of the first links when I searched for Django on Bing (currently in China) is django-cms.org.
I'd use Wordpress when building simple websites that serve as landing pages or blogs. If the main use for the site is showing some basic static info that never changes or the owner coming in, writing a few articles and clicking save, then Wordpress might be a good fit.
I'd use Django when building more complex websites and web applications where a CMS just doesn't fit due to the complexity of the logic, functionality or data. For example you might build an inventory management system with Django since it can have complex business logic and the data doesn't really fit a blog format. You might build an online store with Django, since you need to model and handle logic for products, inventory, payments, customers and such.
* A great (really great) orm
* Best documentation I've ever seen in a project
* Predictable, no magic
* Easy to start but very powerful forms
* Great community, positive attitude, always willing to help
* Batteries included and, for anything missing, lots of add-ons (in the form of apps) for all your needs
* It's in python and supports both 2 and 3
* Good i18n support (english is not my primary language)
* Good templating
* MVT (model view template) architecture works great, especually after you switch to CBVs
* Great support for REST (through django-rest-framework)
* Easy and to-the-point project configuration supporting multiple deploys (development, production etc) and non-commited to vcs settings
I've tried other frameworks in the past but I've always stuck in a missing feature or just wanted to do things in the django way.