Getting node.js and Django on same domain - django

For a brief overview/desciption, I am using Django as the bread and butter for a webapp. I want to add a bunch of "real-time" features to the app. More so then I can do with stuff like Torndao or django-socketio. So what I would like to do is take the full dive and use Django with node.js. Basically, Django will get all the data and and handle all the accounts. Then when a piece of data changes, it will send a message using AMQP which will route the message to node.js. Node.js will then use socket.io to get the fresh data to the browser.
My question is how to get the two to play together. Specifically, how can I get both on the same domain so that when the client connects to
var socket = io.connect('http://thedomain.com');
it will be dealt with by node.js and all the other requests will go to Django? Also, I would ideally like to have the Django app running on Heroku as a standalone app and have the node.js also running on Heorku on the standalone app, if possible. Any tips or pointers would be greatly appreciated! Thanks!

Related

How to make vue js ssr using the django framework

I want to make some part of my application capable of supporting server rendering. In the project, we actively use vuex and vue router.
We receive all data using api requests
Tell me where to go or provide any working code snippet.
Thank you in advance
An example of an answer might be this. You are creating a fully isolated SPA application with SSR. Django acts only as an API for your application (including you will need to receive data for INITIAL_STATE by API). Next, you start your NodeJs server on any port. Next, you need to configure nginx for redirect requests from port 80 for specific routes to the port of your application.
This is just a theory. Until hands reached a full-fledged example

Running a meteor app as part of a wider django project

I'm currently working on a project which would require some realtime functionalities such as Multi-user chatrooms etc.
Ideally, I’m looking to have meteor run the chat application(on a different port) and mongodb act as message broker to the django back-end which would take care of user registration , management and everything 'non-realtime' related.
This would involve setting up a reverse-proxy which would redirect to a different port based on the url (please let me know if i'm wrong in this)
Would this be possible(or even advisable)? Another option would be to implement the same with tornado. but I have no experience with building tornado-based apps and rather do this with a framework I’m comfortable with.
Thanks,
You can have Django serve the Meteor front-end while providing access to its data using django-ddp, giving you some distinct advantages:
Continue to serve your existing Django project/apps.
No extra services or ports to manage.
Scale out by simply adding more front-end Python/Django servers (server to server IPC is done via the existing database connection).
Use django.contrib.auth user accounts in your Meteor app.
Familiar Python/Django code (no "callback" style such as with Tornado).
Use time-tested, trusted relational databases.
Use Django migrations to effectively manage schema changes.
There's a Gitter chat room where I can give you assistance if you need it.
DISCLAIMER: I'm the author of django-ddp.
A meteor application is more than capable of handling the user registration flow and many other things. Why not just build the application entirely in meteor? Your application sounds like a perfect candidate for meteor, with realtime interaction with your database at the core.
The other option would be to use swampdragon which adds realtime data binding within django. It allows for simple bi directional communication between the server and the client. Again, essential for a chat application. It nice and easy to get setup and running as well.
Are there any specific reasons to not implementing your application in one framework alone?

Apache/wsgi/django configuration

We have two django applications running on the same server that interact with an API that uses oauth. They function as expected, communicating with each other, when run under the django development server. However, when deployed using apache/wsgi they don't work together.
(To be more specific, one application is an instance of the Indivo server; the other one is a custom application that interacts with Indivo.)
What is the best way to trouble shoot this?
Make sure that the Django instances are working by themselves first. For example, one app could be started under Apache, and the other using ./manage.py runserver. Reverse which one is running using Apache and verify that all works as expected.
Use the Apache error logs to look for errors such as failed requests.
Since one of your apps appears to implement a web API, use something like the Google Chrome Postman App to exercise the site from a web browser.
Learn how to use the Django logging framework to log information about your apps as they execute.

Accessing a django-piston REST API via a django view within the same project

I'm building a small web service. To showcase what the service can do I am going to build a lite-weight interface. I'm having a hard time figuring out how my REST API and regular Django views can play nicely together.
Here's my setup:
Using django-piston to build a simple CRUD REST web service.
Using Django views with httplib2 to GET/POST to/from that web service.
Both are being run from the same Django project (and thus same web server).
Right now I have simple read REST service working in the browser. But when I try to use httplib2 from the Django view the request just hangs.
My questions:
-Am I thinking about this the right way?
-Is there a better way to accomplish this?
-Should my REST web service be a different project (and web server) than my REST interface?
Any help would be greatly appreciated!
Generally, I'd demonstrate an API working via unit tests, rather than live views, but can see how that might not be what you need.
So (in line with akonsu's comment above) if you're experiencing this problem local dev, it's the single threaded devserver that's blocking the API from running while the view is executing.
Have you tried a multi-threaded version of the runserver? Like this one?

Django Deployment

I am given a responsibility in my project to develop a Equipment tracking tool with following requirements
New Equipment can be added by admin to a particular user
Once equipment is assigned to a person he will a request to accept the request so he will be responsible
User can transfer his equipment to other users.
At the same time Admin should be sent a mail or message whenever there is a change in status.
It should be deployed locally on a PC( So it is not actually a web app) that is connected to network which can be accessed by everyone
I thought I can use Django for this( I am new to it ), but I do not know much about deployment on a local PC , How can I do this, or is there any better Idea for this?
It still sounds like you want a web app, you just won't be deploying it on a traditional web server. One thing to note, client versions of Windows (XP, Vista) will limit you to 10 incoming connections per computer.
You'll want to follow these instructions on how to install Django. If you haven't installed python yet, I'll recommend that you install version 2.5, since that will include sqlite, an embedded database that makes it very easy to get started developing with Django. Django includes its own development web server, which you will come across naturally as you go through the tutorial.
Start by installing and then jump right into the tutorial. Your deployment options will be much easier to understand once you're comfortable with developing in Django.
Try http://docs.djangoproject.com/en/dev/howto/deployment/#howto-deployment-index
and if you should deploy using IIS then try http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer