title: Django RabbitMQ consumer
body: <p>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.</p>
  
  <p>First idea was to use <code>django_rest_framework</code> but this seemed like creating a tightly coupled system because every external app will have to contact the Django app via REST call.</p>
  
  <p>My other idea is best described with a picture: <a href="http://imgur.com/vakZvQs" rel="noreferrer">http://imgur.com/vakZvQs</a> Several publishers would create messages on an RabbitMQ and my Django would consume those and create appropriate models in the DB.</p>
  
  <p>Is something like this possible? I've used async examples from <code>pika</code> library for publisher and consumer and the messages are flowing as expected. Throwing Django in the mix produces errors such as:</p>
  
  <pre><code>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></pre>
  
  <p>Code excerpts:</p>
  
  <pre><code># 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()
  </code></pre>