I am building a Django application which will be contacted by multiple external applications. Django application is supposed to provide UI and populate the database with the data received from external applications.
First idea was to use django_rest_framework but this seemed like creating a tightly coupled system because every external app will have to contact the Django app via REST call.
My other idea is best described with a picture: http://imgur.com/vakZvQs Several publishers would create messages on an RabbitMQ and my Django would consume those and create appropriate models in the DB.
Is something like this possible? I've used async examples from pika library for publisher and consumer and the messages are flowing as expected. Throwing Django in the mix produces errors such as:
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Code excerpts:
# pika consumer
def on_message(self, unused_channel, basic_deliver, properties, body):
# invoking view function
from myapp.views import create_one_foo
create_one_foo()
self.acknowledge_message(basic_deliver.delivery_tag)
# views.py
from .models import Foo
def create_one_foo():
foo = Foo()
foo.bar = "bar"
foo.save()