3

I have used django for a while, It is very esay to understand and the documentation by the djangoproject.com is very good. Now i am thinking to work with twisted-python.But i didn't find any proper documentation like django(i did not find any mvp architecture like settings.py, views.py,models.py in django).Is it possible to do projects with twisted-python like django.?Thanks in advance

Mulagala
  • 8,231
  • 11
  • 29
  • 48

2 Answers2

4

I congratulate you on your choice to learn Twisted. Here are the key differences you should be aware about.

Django is a Web CMS (Content Management System) created especially for sites building. It's super good for fast site's creation. But it's threaded, that means it's not so good in supporting of high loads.

Twisted excels in scalability and high loads support. It's powerful asynchronous framework for any (all) kind of network development. Being asynchronous it's super performant. Youtube was written on twisted-like pythonic framework called Medusa. You might want to read more about comparisons of threaded vs asynchronous programming methods.

So yes, you can obviously implement your site's backend with Twisted, but keep in mind that Twisted is a little bit more of low level framework compared to Django (thought more flexible) and it requires a bit more of knowledge about network programming than Django.

To get started with Twisted and to get familiar yourself with asynchronous programming approach, I would recommend to go through this book.

It helped me a lot when I started to learn Twisted. Also there is a comprehensive documentation with a lot of code samples that, as for me, is very similar to one that Django has ;)

  • Please see the answers here: http://stackoverflow.com/questions/2099189/using-django-and-twisted-together. The answer is no. Don't combine them. Twisted is asynchronous and Django is not. Instead separate it to a stand alone service that Django will refer to. – Alexey Vishnevsky May 21 '14 at 13:20
  • 2
    @Mulagala there are a number of frameworks that sit on-top of twisted (or are the same style) that move you closer to the WebCMS world. The big-fish is [Tornado](http://www.tornadoweb.org) - its not technically twisted but its directly compatible. [Cyclone](http://cyclone.io) is a 100% twisted port of tornado though its a rev or two behind tornado now (I've used it with good results), and from the flask-like world there is [Klein](https://dreid.org/programming/2012/03/28/klein-a-twisted.web-microframework/). None are as complete as django but they get you closer – Mike Lutz May 21 '14 at 14:36
2

I have not really used Twisted (Only looked into it abit when i had one idea), but - You do not find the things you are looking for because they are not there. Django is web framework while Twisted, as they on their site are saying "Twisted is an event-driven networking engine written in Python and licensed under the open source"

So basically you can catch requests with twisted web, but you do not have that whole MVC that django offers.

There are other questions about using them together (using django and twisted together), but why would you do that? What are you looking to gain? Asynchronous non-blocking functions/snippets? Why not use celery then... instead of twisted.

Community
  • 1
  • 1
Odif Yltsaeb
  • 5,575
  • 12
  • 49
  • 80
  • I have an app that need to change from django to twisted, But i have MYSQL database in that, and other things.Can i do that project with twisted(i mean can we achieve everything in twisted as django). – Mulagala May 21 '14 at 11:25
  • 2
    Django and Twisted are not similar in the sense that django is web app, that runs on web server like nginx/apache and twisted is the nginx/apache. They are not similar at all. Look at these pages: http://stackoverflow.com/questions/1412169/twistedasynch-server-vs-djangoor-any-other-framework, http://ferretfarmer.net/2013/09/05/tutorial-real-time-chat-with-django-twisted-and-websockets-part-1/. How can you achieve same thing with twisted as django. How could you create web page with nginx? They are totally different tools. You can use them together, if you have to. – Odif Yltsaeb May 21 '14 at 11:30