Hello, I'm battling with Django in order to try avoiding object persistence when initialising foreign key model attributes. The app I'm using Django for implements a facade for an already existing database. It's main purpose is to be used as a (read-only) ReST server returning objects built by aggregating attributes from the already existing database. The Django app itself has model classes (and associations) like any other Django app. Renderers and Serializers based on those supplied by the rest_framework modules have been written and tested. We started by configuring the Django app to use a SQLite file, as we're don't really care about object persistence. However, when building model instances (by extracting/aggregating data from the original non-Django managed database), we hit a severe perfomance bottleneck. Each time we initialize a model attribute which is a collection of related instances, all these are apparently persisted to the Django database.
For example, with a classical Order/Items association, we'd have : 01: orderattributes={...extract attributes from external database using > SQL...} > 02: order=Order(**orderattributes) > 03: orderitems=[] > 04: for item in ...items belonging to order... > 05: itemattributes={...extract attributes from external database using > SQL...} > 06: item=Item(**itemattributes) > 07: orderitems.append(item) > 08: order.items_set=orderitems When reaching line 8, it seems that every Item instance of the orderitems collection is persisted in the Django database, which considerably slows down the application. I tried to use an in-memory SQLite database, but couldn't make it work, as the syntax for declaring a shared in-memory database (file::memory:...) is not handled correctly, yielding a file-based database instead. Thus, I'd like to know if there is any means to by-pass the automatic persistence mechanism when using collection attributes which are foreign-key based. Thanks for any pointers ! Marc'h -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ba9a4637-26ac-4f59-923c-ff43d24be02a%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.