Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Django's ORM does not implement an <a href="http://en.wikipedia.org/wiki/Identity_map" rel="noreferrer">identity map</a> (it's in the <a href="http://code.djangoproject.com/ticket/17" rel="noreferrer">ticket tracker</a>, but it isn't clear if or when it will be implemented; at least one core Django committer has <a href="http://spreadsheets.google.com/ccc?key=pSqnCvef6OXmGWQ9qbEVMeA" rel="noreferrer">expressed opposition to it</a>). This means that if you arrive at the same database object through two different query paths, you are working with different Python objects in memory.</p> <p>This means that your design (load everything into memory at once, modify a lot of things, then save it all back at the end) is unworkable using the Django ORM. First because it will often waste lots of memory loading in duplicate copies of the same object, and second because of "overwriting" issues like the one you're running into.</p> <p>You either need to rework your design to avoid these issues (either be careful to work with only one QuerySet at a time, saving anything modified before you make another query; or if you load several queries, look up all relations manually, don't ever traverse ForeignKeys using the convenient attributes for them), or use an alternative Python ORM that implements identity map. <a href="http://www.sqlalchemy.org/" rel="noreferrer">SQLAlchemy</a> is one option.</p> <p>Note that this doesn't mean Django's ORM is "bad." It's optimized for the case of web applications, where these kinds of issues are rare (I've done web development with Django for years and never once had this problem on a real project). If your use case is different, you may want to choose a different ORM.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload