Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm comming from java world (apache wicket) and need to use python for my project.
I've heard about Turbogear2, Pyramid(Pylons) or Django and read some about them.
My first choice will be TurboGears2 built on top of Pylons, with tools already packaged, but
perhaps someone as some advice.
I do not need to create a lot of content like wikis or blog, but represent and
give access to some objects in my database, and then build a javascript interface
to work on this data.
What I need the web framework to to for me :
authentication system with roles (admin, user, group,...)
use of enhanced javascript tools like dojo outside the app, but
it would be good if I could share components between the app and the javascript library.
easy AJAX : components have to be refreshed 'onChange' (I don't like submit buttons)
a good ORM. Don't know SQLAlchemy but it seems nice, mapping object to/from database, database pooling,....
easy deployment (coming from java I think it will be ok ;))
add easily css or js to pages
a framework that don't break my nerves ;)
a good documentation and/or good support
threading/multiprocess support (there are a lot of calculations. Some of them taking huge amout of memory, some other taking
processing time. So I want to be able to lauch procees out of application. But I think it's more about using a python library
and nothing to do with this question? )
THX
For myself, mako + sqlalchemy in Pyramid are what seal the deal. If you're into some decent DB work, SqlAlchemy is just the best to work with. I'm also a big fan of the mako templates. The ability to create presentation type functions in mako itself that are reusable vs trying to do things in python modules that you end up trying to import in is a plus in my book.
What I really wanted to mention is that for your final item, you should really look at farming that stuff out to outside workers by using a message queue and something like Celery to do the work and use the web app more for submission/results display than actually trying to split the work out of your web application.
As pointed out by S.Lott in his comment, your requirements do not give a clear-cut "winner" as at least most of the frameworks have that capability.
Three dimensions along which which python web framework diverge more are IMO:
Closeness to the concept of "pythonic"
Lightness
Overhead
Typically lighter frameworks will: require more overhead and have a more pythonic approach (webpy, cherrypy...), while heavier frameworks (django, turbogear...) will let you have your app up and running in minutes but will somehow oblige you to shape your code in a certain (logical but not necessarily pythonic) way.
That said, I believe 95% of your answer relies on personal preference.
HTH!
In addition to the frameworks you have mentioned, you should definitely check out web2py. I think you'll find it among the easiest to set up, learn, and use, particularly given the breadth of functionality it offers. One if its primary goals is to not "break your nerves." It includes an excellent authentication system; integrated Javascript/AJAX support (see also components); a fast and powerful database abstraction layer; web services; automatic RESTful API generation; great documentation; and a very helpful and responsive mailing list. Development is very active, with new releases at least every month (without ever breaking backward compatibility). Here is a recent presentation.
An opinion piece...
I like the character of Pylons (now replaced by Pyramid) and the wide support of new initiatives by the Django framework (though not its keeness to reinvent so many wheels - esp. MVC).
I like the Data Abstraction Layer in Web2py that enables deployment to Google's AppEngine. This was a key feature in making my decision. Web2py is RoR inspired which some may shirk but which I've appreciated and so far hasn't blocked any development path.
In the end having tried several frameworks I've used Web2py (using the offical book as reference). A great community with very fast response.
Related
EDIT: Since you are asking for specifics, consider a photo-sharing site (like Flickr or picasa - - I know that one uses PHP, while the other uses Python) for instance. If it proves to be successful, it needs to scale enormously. I hope this is specific enough.
It's been sometime since I heard any discussion on this, and since I am in the decision making process of choosing between Ruby and Python for a web project, here come the questions:
[1] Can current versions of Rails (Ruby) and Django (Python) query more than one database at a time?
[2] I also read on SO that "If your focus is building web-sites or web-applications go Ruby" (because it has fully featured, web-focused Rails). But that was about 2 years ago. What's the state of Python web framework Django today? Is it head-to-head with Rails now?
EDIT: [3] Don't know if I can ask this here, it's really surprising how quickly the Stack Exchange sites load. Do SE sites still use the same technology mentioned here? If not, does anyone have an update?
There's nothing in either of the languages that would prevent you from connecting to more than one database at a time. The real question is why would you want to?
The reason the StackOverflow sites are so fast is not so much the choice of technology but they way it's applied. Database optimization techniques are largely independent of the platform involved, just based on common-sense principles and proven methods of scaling.
Ruby on Rails offers a number of methods for connecting to multiple databases, though you might mean connecting to a system that's divided into shards, into multi-tenant partitions, or where different forms of data are stored on different databases. All of these approaches are supported, but they are quite different in implementation.
You should post a new question with an outline of the problem you're trying to solve if you want a specific answer.
Multi-database support exists in Django. In our Django project we have models pulling data from Postgres, MySQL, Oracle, and MS SQL Server (there are various issues depending on the database, but it all generally works). From what I've read, RoR supports multiple databases as well. Each framework comes with its own set of strengths and weaknesses which you have to evaluate against your particular needs and requirements. I don't think anyone can give you a (valid/useful) general answer without knowing the specifics of your situation.
The site won't be that complicated and will resemble a modern blog (users, messages, news and other similar features).
Do I need to use a framework for this, and if so, which is best?
Pyramid, Django?
You certainly don't need a webframework to create a simple website. Given that you're new to python and interested in building a python website, I imagine this implies: you're interested in learning python. If you're exclusively interested in learning django-python, there's no reason you can't jump in to django, as Ronak said, of course. He's right. It has a lot of documentation. But it will make for somewhat of an odd intro to python.
If I were in your shoes, I'd either start making some offline programs first, or consider an ultra-lightweight framework. Many would advocate web2py or pyramid for ultralightweight. I might consider going even lighter. Something like Bottle, where you're more or less just pairing functions with urls. This way you can at least do a bit of hacking/trial-and-error, instead of launching right into django.
It's not that django doesn't use python-- it will tell you many times that it is in fact 'just python.' But it's adapted at its core to be used in a large business setting (the chicago something or other online, i think). So it enforces various rules that are helpful in managing many different employees working on a project together. You may or may not wish for this kind of 'help.' It also means the scale of projects is assumed to be large and the time-horizon, limitless. If you want to see how a python dictionary works, you may not want to spend a long time configuring settings and creating the pseudo-static-typing you need for your database, and so on, just to execute your project and see a result.
I realize I will automatically get downvoted for this, but I believe it to be sound advice.
It depends on what kind of website you are planning to come up with. If the website is going to be just a set of static HTML files, then you don't really need a framework. But if your website will have lots of dynamic content that will get updated on regular basis, you should go with some framework. That will make your life maintaining the website much more simpler.
Django is the most popular framework written in Python. It has very good documentation and a strong community base too.
Go with Django - 10,000 Elvis fans can't be wrong.
Or roll your own from scratch. You'll learn a lot, know everything about how you site works, and better appreciate what a framework does for you.
As RonakG first pointed, it all depends on the kind of website you intend to have up and running. Actually, your question is too general for a single, definitive answer. There are more aspects to consider other than just being in python. For example, deadlines. This means considering the learning curve to achieve your results. If you don't have much time, a steep learning curve (time to learn it in order to develop it) is certainly something you will want to avoid. Perhaps you already develop in other languages, and need integration and/or migration support, need scalability, reusability, etc, etc, etc.
Another thing that is not so clear in your question is what you mean by "The site won't be that complicated and will resemble a modern blog (users, messages, news and other similar features)". If it really resembles just a modern blog, with users, messages and news, you could google for CMS (Content Management Systems). There are many options available, that could make you have your site up and running in almost no-time. All you'll have to learn is how to customize whatever it has to as to comply to your needs.
That said, if you prefer python, there are some good CMSs available which you can develop your site fast, like Plone. And if you prefer Django, there's Django CMS and there's the excellent Pinax project, which takes the django code reusability to deliver you sample fully customizable, complete websites.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I really want to build a web application; something simple, maybe a database of Pokémon cards for instance?
I've heard excellent things about Django. Where would be the best place to start?
This is from a post I made on my blog, answering almost exactly same question. It contains many of the answers already given here, as well as some extra advice, and some of it is my personal opinion, and others may differ from me. Hopefully someone finds it useful:
Build Something
The best advice I can give is to start by building something. A typical "Hello world" for Django is a blog website, and I would also recommend starting with that. The Django framework tries to make common tasks extremely easy and simple, and a website with simple blogging functionality is a typical example. A fluent Djangonaut can code up a simple blog website in less than an hour by using all the libraries available, and therefore it's a good place to start and get a feel for how Django does things.
The Django Book
Of course, before you can just jump in and start coding, you need to get your system up and running with Django, and learn the basics. A great resource for that is the Django Book. The authors haven't worked on it in a while or kept it quite up to date (due to its young nature, Django changes quite frequently), but It's freely available online and highly recommended. Read the first few chapters on how to set up your system, how all the parts of Django fit together into the MVC model, and be amazed by how Django does things so simply that other frameworks made unnecisarily tiresome.
The Django Tutorials and Documentation
There are so many great tutorials on the Django website, that you'll almost need nothing else once you have the basics of Django down. The documentation is also fantastic, go take a look for yourself.
Pick a Django Version
For a beginner, it will be a good idea to pick a Django version, and stick with it. At the time of this writing, there are two main versions being used by most, Django 1.2 and Django 1.3, as well as the development version (the version that the Django developers work on and test changes in before it gets released as a major version). Don't use the development version when you're starting out - you're bound to run into trouble.
The big thing is that Django has existed for around four or five years now, and much of the tutorials you'll find scattered over Google will be aimed at Django 1.0 and 1.1. That's fine, and mostly not a problem, but Django's added quite a lot of functionality since then that makes most of those tutorials and code snippets obsolete. Try to stick to tutorials that are aimed at your version, where possible.
Once you've picked a version, make sure you always read the correct version of the Django documentation. You'll see on the right-hand side sidebar and in the url of the page you are on that you can change the version you're looking at. Django's documentaion is truly excellent and far beyond anything else out there, and the authors take great care to specifically state which functions are new to that version, and which are deprecated in later versions. Just make sure you're aware of that, so that you don't waste countless hours trying to make something work that's not available in your version.
Know what DRY means, and practice it
DRY: "Don't Repeat Yourself" is one of the core principles behind Django. If you find yourself copy-pasting anything in Django, there's almost certainly a better way to do it. Most programmers will know from experience why repitition like that is bad, but in short, if something in your code needs to change later on or if you made a mistake somewhere, you only need to change it in one place. That's useful, because if there is more than one place needing change, and you forget about that instance, you'll be introducing errors and bugs into your code.
Stay away from Class-based views
A new addition to Django 1.3 is a whole array of Class-based Generic Views. If you don't know what that means, don't worry. The vast majority of tutorials and books about Django won't make any mention of it, mainly because it is so new. It's a feature that is meant to lessen the repitition in creating views, thereby following the DRY principle. While it does do that to some extent, it also introduces a lot of black magic and the need to frequently go scratch around in the Django source code to see what's going on. For the beginner, that is less than ideal. In addition, the error messages as they are now provided for Class-based views often point you in the completely wrong direction. Stay away from them, and rather use functional views in the beginning, as most tutorials will tell you to. When you're a bit more used to Django and you find the repitition of functional views frustrating, look into Class-based Generic Views.
Don't start out hosting on Google App Engine
While GAE is free and great for scalable Django apps, it also introduces a lot of restrictions on your login process, and the documentation on that is extremely scarce. As a beginner, don't start out with that route, since lots of the normal Django documentation will suddenly not apply, and you won't know what to do. Rather, start with a service like epio, gondor.io, or many others . Epio's still in beta, but have a free hosting option as well (up to a certain amount of monthly usage). Developed by two of the Django core developers, I strongly recommend using them - it's comparable to Heroku for Ruby on Rails. Ep.io is closing down, but Heroku also recently added a Python hosting option.
Use StackOverflow, Ask questions
My final piece of advice is to make use of StackOverflow any time you get stuck. First off, they already have the answer to just about any question you can dream of. If you can't find it on the site, a good way to find the answer to your question is to append "stackoverflow" as part of your google search terms. Otherwise, post a question and let the Django community help you out. It's proven to be my greatest resource in learning the darker sides of Django over the last few years, apart from physically reading the Django code (which you should also do!). Good luck, and enjoy!
Build your first Django web application by reading Django tutorial.
Read through the Django book.
Build something. Anything. Keep it relatively simple and short, but start building it and make sure you finish building it. The project you have in mind right there might be perfect.
Reading documentation and books is extremely helpful, of course, but like any programming the only way to really learn Django is to practice with it. Building something tangible is pretty much the only way to get that practice.
If you don't know Python, start your learning with that. People tend to get very frustrated when they try to learn a framework without knowing at least something about its programming language.
After obtaining basic knowledge of Django/Python, start reading Django by Examples, great articles.
The following screencast/tutorial is a nice way to jump in and create a Wiki from scratch:
Learn Django: Create a Wiki in 20 minutes
After that, you might work through the tutorials and documentation available at the excellent django documentation site.
You can try "Learn Django in 4 hours - a fast track tutorial"
For a kickstart into Django, please see:
http://slash4.de/blog/learn-django-in-4-hours
It is designed to get you started with Django as fast as possible (no installation routines, etc.). It shows all the most important parts of Django - of course it is not possible to cover all aspects of Django in 4 hours, but this is not the intention of this course.
I got a project in mind that makes it worth to finally take the plunge into programming.
After reading a lot of stuff, here and elsewhere, I'm set on making Python the one I learn for now, over C# or java. What convinced me the most was actually Paul Graham's excursions on programming languages and Lisp, though Arc is in the experimental stage, which wouldn't help me do this web app right now.
As for web app fast, I've checked out Django, Turbo Gears and Py2Web. In spite of spending a lot of time reading, I still have no clue which one I should use.
1) Django certainly has the nicest online presence, and a nicely done onsite tutorial, they sure know how to show off their thing.
2) Web2Py attracted me with its no-install-needed and the claim of making Django look complicated. But when you dig around on their website, you quickly find content that hasn't been updated in years with broken external links... There's ghosts on that website that make someone not intimately familiar with the project worry if it might be flatlining.
3) Turbo Gears ...I guess its modular too. People who wrote about it loved it... I couldn't find anything specific that might make it special over Django.
I haven't decided on an IDE yet, though I read all the answers to the Intellisense code completion post here. Showing extra code snippets would be cool too for noobs like me, but I suppose I should choose my web frame work first and then pick an editor that will work well with it.
Since probably no framework is hands down the best at everything, I will give some specifics on the app I want to build:
It will use MySQL, it needs register/sign-in, and there will be a load of simple math operations on data from input and SQL queries. I've completed a functional prototype in Excel, so I know exactly what I want to build, which I hope will help me overcome my noobness. I'll be a small app, nothing big.
And I don't want to see any HTML while building it ;-)
PS: thanks to the people running Stackoverflow, found this place just at the right moment too!
You should look at the web2py online documentation (http://web2py.com/book). It comes with a Role Based Access Control (the most general access control mechanism) and it is very granular, you can grant access for specific operation on specific records. It comes with a web based IDE but you can use WingIDE, Eclipse and PyCharm too. It comes with helper system that allows you to generate HTML without using HTML. Here is an example of a complete app that requires users to register/login/post messages:
db.define_table('message',Field('body'),Field('author',db.auth_user))
#auth.requires_login()
def index():
db.message.author.default=auth.user.id
db.message.author.writable=False
return dict(form=crud.create(db.message),
messages=db(db.message.id>0).select())
The web2py project is very active as you can see from the list of changes http://code.google.com/p/web2py/source/list
If you have web2py related questions I strongly suggest you join the web2py mailing list:
http://groups.google.com/group/web2py/topics
We are very active and your questions will be answered very quickly.
I have to say as not particularly skilled developer, the speed at which I have been able to create using web2py has blown my mind. In large part due to the amazing community and the core value Massimo has of making the framework accessible.
When I started I had written 0 lines of code in Python
Never heard of web2py
I've been at it seriously for about a month and have progressed (in my usual fashion) from asking questions that no one could answer (because they didn't make any sense) to coding for hours at a time without picking up a book or asking a question.
I'm really impressed.
I've had positive experiences with Django.
Built-In Authentication and easy to use extensions for registration
Very good documentation
You probable write your HTML templates mostly in base.html, then just use template inheritance (Note: You'll need to write at least a little bit of HTML)
In contrast to Turbogears, Django is more 'out-of-the-box'
I don't have any experience with web2py, but from my impression, it tries to do a little to much 'out-of-the-box'
If you decide to go with Django, make sure that you use its Generic Views. They will save you from writing lots of code, both Python and HTML.
Also, unless there is a very specific reason for you to use MySQL, I advise you to switch to PostgreSQL. Django is much more oriented towards PostgreSQL and it's a much better database anyway.
The online Django documentation is great, this is what put it apart from all the other frameworks. I also recommend the book Practical Django Projects by James Bennett
Django: Heard it has the best administrative
interface. But uses it's own ORM, i.e. doesn't use SQL-Alchemy.
Web2py: Didn't research this.
Turbogears2:
Uses SQL-Alchemy by default, uses Catwalk for admin
interface, but documentation isn't as
great.
I chose Turbogears2 because it uses popular components, so I didn't have to learn anything new...
I've used both web2py and RoR extensively, and while RoR has gotten a lot of popularity and support in the past few years, web2py is simpler, cleaner, less "magical", and yet also offers more (useful) out-of-the-box functionality. I'd say that web2py has more potential than RoR, but it is a relatively new framework and does yet not have the maturity of RoR. (Despite that, though, I'd choose web2py over RoR any day...)
If you "don't want to see any HTML while building it" then you can forget Django. It is not focused on "point-click-done," it is focused on pros going from concept to production in the shortest time possible. The hierarchical nature of the templating language can lead to some very clean overall site layouts. I use Django for all of my larger sites and I love it.
Although it's written in PHP, not Python, you might take a look at the major new version of WordPress that came out about 2 or 3 months ago. In 3.0 they have come a long way from being a "blogs only" environment and there are tons of ready-made templates for it. Of course if you want to tweak a template, well, there's that nasty old HTML again. I am considering using it for my smaller clients that can't deal with the admin of a dedicated server, etc., that tends to come with a Django site.
Update:
Ah, I missed the semi-joke -- I was up too early and that tends to make me tone deaf to humor. As far as using templates from existing sites, I have done this quite successfully with a couple of sites, both those that were static and those originally driven by well-written PHP scripts. I recommend a careful reading of the {% extends %} and {% include %} docs. Both take either a string literal or a variable. I have used the later method and it can be quite useful for a site that has strong hierarchy distinguished by style changes across branches.
It is also worth the time to understand the search order for templates -- it can be used to good effect, but it can be puzzling if you don't grok it. See the template-related items in the settings.py file for this and other useful goodies.
Closed. This question is opinion-based. It is not currently accepting answers.
Closed 1 year ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support.
Any advice?
TG2 is built on top of Pylons which has a fairly large community as well. TG got faster compared to TG1 and it includes a per-method (not just web pages) caching engine.
I think it's more AJAX-friendly than Django by the way pages can be easly published in HTML or JSON .
2011 update: after 3 years of bloated frameworks I'm an happy user of http://bottlepy.org/
I have experience with both Django and TG1.1.
IMO, TurboGears strong point is it's ORM: SQLAlchemy. I prefer TurboGears when the database side of things is non-trivial.
Django's ORM is just not that flexible and powerful.
That being said, I prefer Django. If the database schema is a good fit with Django's ORM I would go with Django.
In my experience, it is simply less hassle to use Django compared with TurboGears.
I have been using Django for a year now and when I started I had no experience of Python or Django and found it very intuitive to use.
I have created a number of hobbyist Google App Engine apps using Django with the latest one being a CMS for my site. Using Django has meant that I have been able to code a lot quicker and with a lot less bugs.
Am sure you would have read from plenty of comparison between TurboGears and DJango on web.
But as for your temptation on CMS and GAE, i can really think you got to go DJango way.
Check these out, and decide youself.
Django with GAE
Django for CMS
Ive only got one question...is the app you are developing directed towards social networking
or customized business logic?
I personally find Django is good for social networking and pylons/turbogears if you really
want the flexibility and no boundaries...
just my 2c
TG2 seem much complicated and confusing, even for doing somewhat simple like a login page with multimple error messages
How to extend the Turbogears 2.1 login functionality
I think thats because of intemperance in modularity...
Django ORM uses the active record implementation – you’ll see this implementation in most ORMs. Basically what it means is that each row in the database is directly mapped to an object in the code and vice versa. ORM frameworks such as Django won’t require predefining the schema to use the properties in the code. You just use them, as the framework can ‘understand’ the structure by looking at the database schema. Also, you can just save the record to the database, as it’s mapped to a specific row in the table.
SQLAlchemy uses the Data Mapper implementation – When using this kind of implementation, there is a separation between the database structure and the objects structure (they are not 1:1 as in the Active Record implementation). In most cases, you’ll have to use another persistence layer to keep interact with the database (for example, to save the object). So you can’t just call the save() method as you can when using the Active Record implementation (which is a con) but on the other hand, you code doesn’t have to know the entire relational structure in the database to function, as there is no direct relationship between the code and the database.
So which of them wins this battle? None. It depends on what you’re trying to accomplish. It’s my believe that if your application is a mostly a CRUD (Create, Read, Update, Delete) application which no hard and complex rules to apply on the relationships between the different data entities, you should use the Active Record implementation (Django). It will allow you to easily and quickly set up an MVP for your product, without any hassle. If you have a lot of “business rules” and restrictions in your applications, you might be better with the Data Mapper model, as it won’t tie you up and force you to think strictly as Active Record does.