514 lines
17 KiB
HTML
514 lines
17 KiB
HTML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
|
|
<title></title>
|
|
<style type="text/css">
|
|
|
|
h1, h2, h3, h4,
|
|
#table-of-contents
|
|
{
|
|
color: #47c;
|
|
}
|
|
h1 { padding-top: 15px; }
|
|
h2 { padding-top: 10px; }
|
|
h3 { padding-top: 7px; }
|
|
|
|
a:hover { border-bottom: 1px solid #0066cc; }
|
|
a {color: #0066cc; text-decoration: none;}
|
|
|
|
li {
|
|
padding-top: 5px;
|
|
padding-bottom: 5px;
|
|
}
|
|
|
|
tt {
|
|
color: #080;
|
|
}
|
|
|
|
blockquote tt {
|
|
color: #000
|
|
}
|
|
|
|
.first {
|
|
margin-top: 0 }
|
|
|
|
.last {
|
|
margin-bottom: 0 }
|
|
|
|
/*
|
|
a.toc-backref {
|
|
text-decoration: none ;
|
|
color: black }
|
|
*/
|
|
|
|
dd {
|
|
margin-bottom: 0.5em }
|
|
|
|
div.abstract {
|
|
margin: 2em 5em }
|
|
|
|
div.abstract p.topic-title {
|
|
font-weight: bold ;
|
|
text-align: center }
|
|
|
|
div.attention, div.caution, div.danger, div.error, div.hint,
|
|
div.important, div.note, div.tip, div.warning {
|
|
margin: 2em ;
|
|
border: medium outset ;
|
|
padding: 1em }
|
|
|
|
div.attention p.admonition-title, div.caution p.admonition-title,
|
|
div.danger p.admonition-title, div.error p.admonition-title,
|
|
div.warning p.admonition-title {
|
|
color: red ;
|
|
font-weight: bold ;
|
|
font-family: sans-serif }
|
|
|
|
div.hint p.admonition-title, div.important p.admonition-title,
|
|
div.note p.admonition-title, div.tip p.admonition-title {
|
|
font-weight: bold ;
|
|
font-family: sans-serif }
|
|
|
|
div.dedication {
|
|
margin: 2em 5em ;
|
|
text-align: center ;
|
|
font-style: italic }
|
|
|
|
div.dedication p.topic-title {
|
|
font-weight: bold ;
|
|
font-style: normal }
|
|
|
|
div.figure {
|
|
margin-left: 2em }
|
|
|
|
div.footer, div.header {
|
|
font-size: smaller }
|
|
|
|
div.system-messages {
|
|
margin: 5em }
|
|
|
|
div.system-messages h1 {
|
|
color: red }
|
|
|
|
div.system-message {
|
|
border: medium outset ;
|
|
padding: 1em }
|
|
|
|
div.system-message p.system-message-title {
|
|
color: red ;
|
|
font-weight: bold }
|
|
|
|
div.topic {
|
|
margin: 2em }
|
|
|
|
h1.title {
|
|
text-align: center }
|
|
|
|
h2.subtitle {
|
|
text-align: center }
|
|
|
|
hr {
|
|
width: 75% }
|
|
|
|
ol.simple, ul.simple {
|
|
margin-bottom: 1em }
|
|
|
|
ol.arabic {
|
|
list-style: decimal }
|
|
|
|
ol.loweralpha {
|
|
list-style: lower-alpha }
|
|
|
|
ol.upperalpha {
|
|
list-style: upper-alpha }
|
|
|
|
ol.lowerroman {
|
|
list-style: lower-roman }
|
|
|
|
ol.upperroman {
|
|
list-style: upper-roman }
|
|
|
|
p.caption {
|
|
font-style: italic }
|
|
|
|
p.credits {
|
|
font-style: italic ;
|
|
font-size: smaller }
|
|
|
|
p.label {
|
|
white-space: nowrap }
|
|
|
|
p.topic-title {
|
|
font-weight: bold }
|
|
|
|
pre.address {
|
|
margin-bottom: 0 ;
|
|
margin-top: 0 ;
|
|
font-family: serif ;
|
|
font-size: 100% }
|
|
|
|
pre.line-block {
|
|
font-family: serif ;
|
|
font-size: 100% }
|
|
|
|
pre.literal-block, pre.doctest-block {
|
|
margin-left: 2em ;
|
|
margin-right: 2em ;
|
|
background-color: #eeeeee }
|
|
|
|
span.classifier {
|
|
font-family: sans-serif ;
|
|
font-style: oblique }
|
|
|
|
span.classifier-delimiter {
|
|
font-family: sans-serif ;
|
|
font-weight: bold }
|
|
|
|
span.interpreted {
|
|
font-family: sans-serif }
|
|
|
|
span.option-argument {
|
|
font-style: italic }
|
|
|
|
span.pre {
|
|
white-space: pre }
|
|
|
|
span.problematic {
|
|
color: red }
|
|
|
|
table {
|
|
margin-top: 0.5em ;
|
|
margin-bottom: 0.5em }
|
|
|
|
table.citation {
|
|
border-left: solid thin gray ;
|
|
padding-left: 0.5ex }
|
|
|
|
table.docinfo {
|
|
margin: 2em 4em }
|
|
|
|
table.footnote {
|
|
border-left: solid thin black ;
|
|
padding-left: 0.5ex }
|
|
|
|
td, th {
|
|
padding-left: 0.5em ;
|
|
padding-right: 0.5em ;
|
|
vertical-align: top }
|
|
|
|
th.docinfo-name, th.field-name {
|
|
font-weight: bold ;
|
|
text-align: left ;
|
|
white-space: nowrap }
|
|
|
|
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
|
font-size: 100% }
|
|
|
|
tt, pre.literal-block, pre.doctest-block {
|
|
font-size: 115%;
|
|
line-height: 150% }
|
|
|
|
ul.auto-toc {
|
|
list-style-type: none }
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="document">
|
|
|
|
|
|
<div class="section" id="django-polymorphic">
|
|
<h1><em>django_polymorphic</em></h1>
|
|
</div>
|
|
<div class="section" id="changelog">
|
|
<h1>Changelog</h1>
|
|
<div class="section" id="v1-0-beta-2">
|
|
<h2>2010-11-11 V1.0 Beta 2</h2>
|
|
<div class="section" id="this-is-a-v1-0-testing-release">
|
|
<h3>This is a V1.0 Testing Release</h3>
|
|
<p>Beta 2 accumulated somewhat more changes than intended, and also
|
|
has been delayed by DBMS benchmark testing I wanted to do on model
|
|
inheritance. These benchmarks show that there are considerable
|
|
problems with concrete model inheritance and contemporary DBM systems.
|
|
The results will be forthcoming on the google discussion forum.</p>
|
|
<p>Please also see:
|
|
<a class="reference external" href="http://www.jacobian.org/writing/concrete-inheritance/">http://www.jacobian.org/writing/concrete-inheritance/</a></p>
|
|
<p>The API should be stable now with Beta 2, so it's just about potential
|
|
bugfixes from now on regarding V1.0.</p>
|
|
<p>Beta 2 is still intended for testing and development environments and not
|
|
for production. No complaints have been heard regarding Beta 1 however,
|
|
and Beta 1 is used on a few production sites by some enterprising users.</p>
|
|
<p>There will be a release candidate for V1.0 in the very near future.</p>
|
|
</div>
|
|
<div class="section" id="new-features-and-api-changes-in-beta-2-since-beta-1">
|
|
<h3>New Features and API changes in Beta 2 since Beta 1</h3>
|
|
<ul>
|
|
<li><p class="first">API CHANGE: <tt class="docutils literal">.extra()</tt> has been re-implemented. Now it's polymorphic by
|
|
default and works (nearly) without restrictions (please see docs). This is a (very)
|
|
incompatible API change regarding previous versions of django_polymorphic.
|
|
Support for the <tt class="docutils literal">polymorphic</tt> keyword parameter has been removed.
|
|
You can get back the non-polymorphic behaviour by using
|
|
<tt class="docutils literal"><span class="pre">ModelA.objects.non_polymorphic().extra(...)</span></tt>.</p>
|
|
</li>
|
|
<li><p class="first">API CHANGE: <tt class="docutils literal">ShowFieldContent</tt> and <tt class="docutils literal">ShowFieldTypeAndContent</tt> now
|
|
use a slightly different output format. If this causes too much trouble for
|
|
your test cases, you can get the old behaviour back (mostly) by adding
|
|
<tt class="docutils literal">polymorphic_showfield_old_format = True</tt> to your model definitions.
|
|
<tt class="docutils literal"><span class="pre">ShowField...</span></tt> now also produces more informative output for custom
|
|
primary keys.</p>
|
|
</li>
|
|
<li><p class="first"><tt class="docutils literal">.non_polymorphic()</tt> queryset member function added. This is preferable to
|
|
using <tt class="docutils literal"><span class="pre">.base_objects...</span></tt>, as it just makes the resulting queryset non-polymorphic
|
|
and does not change anything else in the behaviour of the manager used (while
|
|
<tt class="docutils literal">.base_objects</tt> is just a different manager).</p>
|
|
</li>
|
|
<li><p class="first"><tt class="docutils literal">.get_real_instances()</tt>: implementation modified to allow the following
|
|
more simple and intuitive use:</p>
|
|
<pre class="literal-block">
|
|
>>> qs = ModelA.objects.all().non_polymorphic()
|
|
>>> qs.get_real_instances()
|
|
</pre>
|
|
<p>which is equivalent to:</p>
|
|
<pre class="literal-block">
|
|
>>> ModelA.objects.all()
|
|
</pre>
|
|
</li>
|
|
<li><p class="first">added member function:
|
|
<tt class="docutils literal">normal_q_object = ModelA.translate_polymorphic_Q_object(enhanced_q_object)</tt></p>
|
|
</li>
|
|
<li><p class="first">misc changes/improvements</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="bugfixes">
|
|
<h3>Bugfixes</h3>
|
|
<ul class="simple">
|
|
<li>Custom fields could cause problems when used as the primary key.
|
|
In derived models, Django's automatic ".pk" field does not always work
|
|
correctly for such custom fields: "some_object.pk" and "some_object.id"
|
|
return different results (which they shouldn't, as pk should always be just
|
|
an alias for the primary key field). It's unclear yet if the problem lies in
|
|
Django or the affected custom fields. Regardless, the problem resulting
|
|
from this has been fixed with a small workaround.
|
|
"python manage.py test polymorphic" also tests and reports on this problem now.
|
|
Thanks to Mathieu Steele for reporting and the test case.</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<hr class="docutils" />
|
|
<div class="section" id="v1-0-beta-1">
|
|
<h2>2010-10-18 V1.0 Beta 1</h2>
|
|
<div class="section" id="this-is-a-v1-0-beta-testing-release">
|
|
<h3>This is a V1.0 Beta/Testing Release</h3>
|
|
<p>This release is mostly a cleanup and maintenance release that also
|
|
improves a number of minor things and fixes one (non-critical) bug.</p>
|
|
<p>Some pending API changes and corrections have been folded into this release
|
|
in order to make the upcoming V1.0 API as stable as possible.</p>
|
|
<p>This release is also about getting feedback from you in case you don't
|
|
approve of any of these changes or would like to get additional
|
|
API fixes into V1.0.</p>
|
|
<p>The release contains a considerable amount of changes in some of the more
|
|
critical parts of the software. It's intended for testing and development
|
|
environments and not for production environments. For these, it's best to
|
|
wait a few weeks for the proper V1.0 release, to allow some time for any
|
|
potential problems to show up (if they exist).</p>
|
|
<p>If you encounter any such problems, please post them in the discussion group
|
|
or open an issue on GitHub or BitBucket (or send me an email).</p>
|
|
<p>There also have been a number of minor API changes.
|
|
Please see the README for more information.</p>
|
|
</div>
|
|
<div class="section" id="new-features">
|
|
<h3>New Features</h3>
|
|
<ul>
|
|
<li><p class="first">official Django 1.3 alpha compatibility</p>
|
|
</li>
|
|
<li><p class="first"><tt class="docutils literal">PolymorphicModel.__getattribute__</tt> hack removed.
|
|
This improves performance considerably as python's __getattribute__
|
|
generally causes a pretty large processing overhead. It's gone now.</p>
|
|
</li>
|
|
<li><p class="first">the <tt class="docutils literal">polymorphic_dumpdata</tt> management command is not needed anymore
|
|
and has been disabled, as the regular Django dumpdata command now automatically
|
|
works correctly with polymorphic models (for all supported versions of Django).</p>
|
|
</li>
|
|
<li><p class="first"><tt class="docutils literal">.get_real_instances()</tt> has been elevated to an official part of the API:</p>
|
|
<pre class="literal-block">
|
|
real_objects = ModelA.objects.get_real_instances(base_objects_list_or_queryset)
|
|
</pre>
|
|
<p>allows you to turn a queryset or list of base objects into a list of the real instances.
|
|
This is useful if e.g. you use <tt class="docutils literal"><span class="pre">ModelA.base_objects.extra(...)</span></tt> and then want to
|
|
transform the result to its polymorphic equivalent.</p>
|
|
</li>
|
|
<li><p class="first"><tt class="docutils literal">translate_polymorphic_Q_object</tt> (see DOCS)</p>
|
|
</li>
|
|
<li><p class="first">improved testing</p>
|
|
</li>
|
|
<li><p class="first">Changelog added: CHANGES.rst/html</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="id1">
|
|
<h3>Bugfixes</h3>
|
|
<ul class="simple">
|
|
<li>Removed requirement for primary key to be an IntegerField.
|
|
Thanks to Mathieu Steele and Malthe Borch.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="api-changes">
|
|
<h3>API Changes</h3>
|
|
<p><strong>polymorphic_dumpdata</strong></p>
|
|
<p>The management command <tt class="docutils literal">polymorphic_dumpdata</tt> is not needed anymore
|
|
and has been disabled, as the regular Django dumpdata command now automatically
|
|
works correctly with polymorphic models (for all supported versions of Django).</p>
|
|
<p><strong>Output of Queryset or Object Printing</strong></p>
|
|
<p>In order to improve compatibility with vanilla Django, printing quersets
|
|
(__repr__ and __unicode__) does not use django_polymorphic's pretty printing
|
|
by default anymore. To get the old behaviour when printing querysets,
|
|
you need to replace your model definition:</p>
|
|
<pre class="doctest-block">
|
|
>>> class Project(PolymorphicModel):
|
|
</pre>
|
|
<p>by:</p>
|
|
<pre class="doctest-block">
|
|
>>> class Project(PolymorphicModel, ShowFieldType):
|
|
</pre>
|
|
<p>The mixin classes for pretty output have been renamed:</p>
|
|
<blockquote>
|
|
<tt class="docutils literal">ShowFieldTypes, ShowFields, ShowFieldsAndTypes</tt></blockquote>
|
|
<p>are now:</p>
|
|
<blockquote>
|
|
<tt class="docutils literal">ShowFieldType, ShowFieldContent and ShowFieldTypeAndContent</tt></blockquote>
|
|
<p>(the old ones still exist for compatibility)</p>
|
|
<p><strong>Running the Test suite with Django 1.3</strong></p>
|
|
<p>Django 1.3 requires <tt class="docutils literal">python manage.py test polymorphic</tt> instead of
|
|
just <tt class="docutils literal">python manage.py test</tt>.</p>
|
|
</div>
|
|
</div>
|
|
<hr class="docutils" />
|
|
<div class="section" id="id2">
|
|
<h2>2010-2-22</h2>
|
|
<p>IMPORTANT: API Changed (import path changed), and Installation Note</p>
|
|
<p>The django_polymorphic source code has been restructured
|
|
and as a result needs to be installed like a normal Django App
|
|
- either via copying the "polymorphic" directory into your
|
|
Django project or by running setup.py. Adding 'polymorphic'
|
|
to INSTALLED_APPS in settings.py is still optional, however.</p>
|
|
<p>The file <cite>polymorphic.py</cite> cannot be used as a standalone
|
|
extension module anymore, as is has been split into a number
|
|
of smaller files.</p>
|
|
<p>Importing works slightly different now: All relevant symbols are
|
|
imported directly from 'polymorphic' instead from
|
|
'polymorphic.models':</p>
|
|
<pre class="literal-block">
|
|
# new way
|
|
from polymorphic import PolymorphicModel, ...
|
|
|
|
# old way, doesn't work anymore
|
|
from polymorphic.models import PolymorphicModel, ...
|
|
</pre>
|
|
<ul class="simple">
|
|
<li>minor API addition: 'from polymorphic import VERSION, get_version'</li>
|
|
</ul>
|
|
<div class="section" id="id3">
|
|
<h3>New Features</h3>
|
|
<p>Python 2.4 compatibility, contributed by Charles Leifer. Thanks!</p>
|
|
</div>
|
|
<div class="section" id="id4">
|
|
<h3>Bugfixes</h3>
|
|
<p>Fix: The exception "...has no attribute 'sub_and_superclass_dict'"
|
|
could be raised. (This occurred if a subclass defined __init__
|
|
and accessed class members before calling the superclass __init__).
|
|
Thanks to Mattias Brändström.</p>
|
|
<p>Fix: There could be name conflicts if
|
|
field_name == model_name.lower() or similar.
|
|
Now it is possible to give a field the same name as the class
|
|
(like with normal Django models).
|
|
(Found through the example provided by Mattias Brändström)</p>
|
|
</div>
|
|
</div>
|
|
<hr class="docutils" />
|
|
<div class="section" id="id5">
|
|
<h2>2010-2-4</h2>
|
|
<div class="section" id="new-features-and-documentation">
|
|
<h3>New features (and documentation)</h3>
|
|
<p>queryset order_by method added</p>
|
|
<p>queryset aggregate() and extra() methods implemented</p>
|
|
<p>queryset annotate() method implemented</p>
|
|
<p>queryset values(), values_list(), distinct() documented; defer(),
|
|
only() allowed (but not yet supported)</p>
|
|
<p>setup.py added. Thanks to Andrew Ingram.</p>
|
|
<p>More about these additions in the docs:
|
|
<a class="reference external" href="http://bserve.webhop.org/wiki/django_polymorphic/doc">http://bserve.webhop.org/wiki/django_polymorphic/doc</a></p>
|
|
</div>
|
|
<div class="section" id="id6">
|
|
<h3>Bugfixes</h3>
|
|
<ul class="simple">
|
|
<li>fix remaining potential accessor name clashes (but this only works
|
|
with Django 1.2+, for 1.1 no changes). Thanks to Andrew Ingram.</li>
|
|
<li>fix use of 'id' model field, replaced with 'pk'.</li>
|
|
<li>fix select_related bug for objects from derived classes (till now
|
|
sel.-r. was just ignored)</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="restrictions-caveats-updated">
|
|
<h3>"Restrictions & Caveats" updated</h3>
|
|
<ul class="simple">
|
|
<li>Django 1.1 only - the names of polymorphic models must be unique
|
|
in the whole project, even if they are in two different apps.
|
|
This results from a restriction in the Django 1.1 "related_name"
|
|
option (fixed in Django 1.2).</li>
|
|
<li>Django 1.1 only - when ContentType is used in models, Django's
|
|
seralisation or fixtures cannot be used. This issue seems to be
|
|
resolved for Django 1.2 (changeset 11863: Fixed #7052, Added
|
|
support for natural keys in serialization).</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<hr class="docutils" />
|
|
<div class="section" id="id7">
|
|
<h2>2010-1-30</h2>
|
|
<p>Fixed ContentType related field accessor clash (an error emitted
|
|
by model validation) by adding related_name to the ContentType
|
|
ForeignKey. This happened if your polymorphc model used a ContentType
|
|
ForeignKey. Thanks to Andrew Ingram.</p>
|
|
</div>
|
|
<hr class="docutils" />
|
|
<div class="section" id="id8">
|
|
<h2>2010-1-29</h2>
|
|
<p>Restructured django_polymorphic into a regular Django add-on
|
|
application. This is needed for the management commands, and
|
|
also seems to be a generally good idea for future enhancements
|
|
as well (and it makes sure the tests are always included).</p>
|
|
<p>The <tt class="docutils literal">poly</tt> app - until now being used for test purposes only
|
|
- has been renamed to <tt class="docutils literal">polymorphic</tt>. See DOCS.rst
|
|
("installation/testing") for more info.</p>
|
|
</div>
|
|
<hr class="docutils" />
|
|
<div class="section" id="id9">
|
|
<h2>2010-1-28</h2>
|
|
<p>Added the polymorphic_dumpdata management command (github issue 4),
|
|
for creating fixtures, this should be used instead of
|
|
the normal Django dumpdata command.
|
|
Thanks to Charles Leifer.</p>
|
|
<p>Important: Using ContentType together with dumpdata generally
|
|
needs Django 1.2 (important as any polymorphic model uses
|
|
ContentType).</p>
|
|
</div>
|
|
<hr class="docutils" />
|
|
<div class="section" id="id10">
|
|
<h2>2010-1-26</h2>
|
|
<p>IMPORTANT - database schema change (more info in change log).
|
|
I hope I got this change in early enough before anyone started
|
|
to use polymorphic.py in earnest. Sorry for any inconvenience.
|
|
This should be the final DB schema now.</p>
|
|
<p>Django's ContentType is now used instead of app-label and model-name
|
|
This is a cleaner and more efficient solution
|
|
Thanks to Ilya Semenov for the suggestion.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|