Django, django-socketio and mongodb backend - django

I have a running django-nonrel application and I would like to add a real time module using web sockets.
I would like to use django-socketio but it seems that gevent (which is used to serve the site) does not work properly with mongodb (link) which is the backend of the Django application.
Does anyone already try to set up django-socketio with mongodb as a backend ?
Dry

I found that using Tornado/Tornadio2 with Django is much easier than the gevent-based alternatives. If you need help setting that up I'd be happy to share my runserver_socketio.py script.

Related

Integration of cloudant with django

I am new to cloudantdb and django. Is there any way to integrate cloudantdb with danjgo framework. Is it possible to connect cloudant with django?
As you may be aware, Cloudant is built on Apache CouchDB, so if you can't find references for Cloudant, it's usually worth also searching for CouchDB. I don't really use Django, but a quick search throws up the following references:
http://leok.me/2013/05/02/what-you-need-to-know-couchdb-django/
https://lethain.com/an-introduction-to-using-couchdb-with-django/
http://eflorenzano.com/blog/2008/11/10/using-couchdb-django/
https://djangopackages.org/grids/g/couchdb/
Most if not all solutions on the web are very outdated.
The solution used by IBM in a capstone project on Coursera was:
Use SQLite backend in your Django app
Create Cloud Functions for communicating with Cloudant
Create REST API definitions in your Django app that utilize the Cloud Functions to communicate with Cloudant
I don't know if it's the best solution, but it works. I do feel like SQLite is redundant at this point but without it, I couldn't get the app to work.

Is it reliable to build desktop applications using web frameworks like Django?

Is it reliable to build desktop applications using web frameworks like Django?
The idea is to
build the interface with HTML, CSS, and JavaScript
use Python and Django for backend operations (calculations, storage and databases, etc)
and then run a server locally so that
the interaction with the application is done through the browser
other local devices can access the application by connecting to the device on which the server is running.
If that is possible and yields a reliable experience, then
is the development server that comes with Django enough? If no, what servers are most suitable for our purpose? Is Nginx good for example?
what database should be used? PostgreSQL, MySQL, etc? The app will need to store a large number of entries.
I've never done this, but I can't see why not. You can use the Django REST Framework to create an API that your desktop application can talk to, in exactly the same way as you might with a JavaScript single page app.
But no, you should not use the dev server for production, even in a limited scenario like this. Apache/mod_wsgi or nginx/gunicorn are simple to set up and deploy.
For the database, it makes no difference. The Django core devs prefer postgres, but you should use whatever you are comfortable with.
You are asking for a webApp, so yes you can. Is not use the Django server, instead is very common use nginx for Django, and the best database is postgres for Django.
If you want to pass your project like a desktop app is better use Django server and SQLite for avoid create a new database server.
Database
I find this answer explaining why is postgres better for Django

Modifying existing Django site

I am completely new to this Django world. I haven't tried it ever before.
Now the problem is as below;
One of my clients was hosting his site somewhere else that I don't know and they built the site using Django. The host company doesn't allow to make any changes on their server, instead they provided the zip file for all the files in the site to me; so that now I can host my client's site.
As I don't know anything about Django, can someone please shed a light where I should start from?
Thanks in advance.
Cheers.
Sach
First of all, install Django on the development machine. Start by trying to get the development server run on your machine.
Gather requirements: check the settings.py for installed apps against the default Django settings.py file. See if there are any popular django apps that site depends on. If there are any, then you probably will have to install them, too.
In which format was the database provided? Will you move to another more appropriate format? Python bindings for databases are required too.
Considering the fact that you have inherited this project and probably will need to make some changes, consider installing django-south, so you can easily make changes to the database schema.
If you get the site running properly on your own machine, consider deplyoment. Is there a lot of static content? (if so, consider nginx). Set up apache2 and install the mod_wsgi module. Deploy.
Work your way through the Django tutorial first. Then look into Django Book as has been mentioned. Django IRC channel (#django) on Freenode is also great for help.
Your best bet would be to learn about Django before trying to jump in head first - https://www.djangoproject.com/ contains documentation as well as tutorials on creating Django apps.
Django is fairly easy to setup if you already have the code written. You'll need to install the chosen database and then simply follow the tutorial on the Django website
Django comes with a built-in server so it's very easy to run the website for development without needing Apache, nginx or much else.
I learned using the Django Book. Django is an easy-to-use framework, you should be fine.
Also, in the short-term there's a file called views.py and separate folder containing templates. If you're familiar with MVC (MVT in Django) this contains the views for the site in function form. There's probably (but not always) a folder for templates which contains a lot of the HTML for the site. Just a good starting pointing for basic modifications.
You can perhaps start here. https://docs.djangoproject.com/en/dev/howto/deployment/
First, find out the django version required by your client. Install that on a server (not a production one), setup apache and mod_wsgi. The zip files may go to a dir which can be included in the mod_wsgi configuration.
Find about the static files and setup apache or any other lightweight webserver to server it.
You may not be a developer, but have a try with the django book. It can give you a good idea how its structured.

Profiling django app hosted on apache2

I am having a django app which was hosted on apache2. The webapp basically makes a request to a server using thrift and renders the output on the webpage. I notice that webapp is really slow. I am not sure if it is machine problem or the API problem. I verified the API's and they are returning responses in few milliseconds. I am not sure, if django is the problem. Is there a way to profile the webapp. I am using python 2.5.2.
Please help.
Thank you
the simplest thing would be to enable logging, if you are using the latest django 1.3, it is nicely integrated with the python logging module, see:
http://docs.djangoproject.com/en/1.3/topics/logging/
here you can define a Formatter which saves the time each log message is written, see example in django docs:
http://docs.djangoproject.com/en/1.3/topics/logging/#an-example

is tornado is the same as django?

is tornado is the same as django ?
can I upload tornado project to normal host providers
No. Tornado is a full web server. Django is a web framework that happens to have a web server included that can be used for testing. You will need more than just basic shared hosting to run it, preferably a full VPS.
Probably you will find this article interesting. Note that you cannot really compare Django to Tornado. Like #Ignacio said above they are not the same thing.
The article:
http://5cience.net/blog/tornado-vs-django,4258/
And yes if you can upload tornado project to normal host providers.