title: Remote access of django models
body: <p>I have a django 1.5 project using django models over mysql running on apache server. </p>
  
  <pre><code>class Person(models.Model):
      first_name = models.CharField(max_length=100)
      last_name = models.CharField(max_length=100)
      birthdate = models.DateField()
  
  class Book(models.Model):
      name = models.CharField(max_length=100)
      author = models.ForeignKey(Person)
  </code></pre>
  
  <p>I also have a python/django application (using django custom commands) running on a remote computer that must use these models.</p>
  
  <ul>
  <li>Remote application shares the same model definitions with server</li>
  <li>Remote application needs read only access to models</li>
  <li>Remote application cannot have a full dump of server database, as server must return a queryset based on user rights</li>
  <li>Remote application can only connect over http to server</li>
  <li>Server can expose the models over REST API (json)</li>
  </ul>
  
  <p>Is there any automated way to transfer models over http? I have tried to use django.core.serializers but I had the following issues:</p>
  
  <ul>
  <li>I cannot serialize the related objects in a queryset</li>
  <li>Remote application cannot work without local database</li>
  <li>Remote application searches related objects on local db after deserialization (that does not exist)</li>
  </ul>
  
  <p>Edit:</p>
  
  <p>I managed to serialize models like this:</p>
  
  <pre><code>books = Book.objects.prefetch_related('author').all()
  authors = [book.author for book in books]
  data = authors + list(books.all())
  serialized_data = django.core.serializers.serialize("json", data)
  </code></pre>
  
  <p>My problem is that the remote application cannot deserialize without having a local database.</p>