Django: Ticket Queryhttps://code.djangoproject.com/query?status=!closed&version=1.1&order=summary
The Web framework for perfectionists with deadlines.en-USDjangohttps://www.djangoproject.com/s/img/site/hdr_logo.gifhttps://code.djangoproject.com/query?status=!closed&version=1.1&order=summary
Trac 1.2.2https://code.djangoproject.com/ticket/13295
https://code.djangoproject.com/ticket/13295#13295: Add a Meta.sequence option to modelsThu, 08 Apr 2010 10:35:07 GMTMax Shabalihin<p>
PostgreSQL users need to be able to override the name of the serial sequence. Mostly to match existing databases, but also to solve issues like <a class="closed ticket" href="https://code.djangoproject.com/ticket/15682" title="#15682: Bug: Postgresql last_insert_id() failing when using custom schemas (closed: duplicate)">#15682</a>, <a class="closed ticket" href="https://code.djangoproject.com/ticket/13179" title="#13179: Bug: last_insert_id method cannot find sequence (closed: duplicate)">#13179</a> and <a class="closed ticket" href="https://code.djangoproject.com/ticket/1946" title="#1946: New feature: Allow overriding of default sequence name (closed: duplicate)">#1946</a>.
</p>
Resultshttps://code.djangoproject.com/ticket/13295#changeloghttps://code.djangoproject.com/ticket/12733
https://code.djangoproject.com/ticket/12733#12733: Added support for Extent aggregate on mysql databasesSat, 30 Jan 2010 03:41:35 GMTjann.kleen@…<p>
This patch enables the usage of extent aggregates for mysql backends, using MIN/MAX queries.
</p>
Resultshttps://code.djangoproject.com/ticket/12733#changeloghttps://code.djangoproject.com/ticket/12044
https://code.djangoproject.com/ticket/12044#12044: Add extra_context to admin action delete_selectedFri, 16 Oct 2009 16:06:11 GMTrjc<p>
We need to pass extra context in admin action delete_selected, just like admin view's delete_view.
</p>
Resultshttps://code.djangoproject.com/ticket/12044#changeloghttps://code.djangoproject.com/ticket/12566
https://code.djangoproject.com/ticket/12566#12566: admin action templates cannot be overriden on a per-app basisSun, 10 Jan 2010 05:49:54 GMTBen Jackson<p>
For example, if you want to customize the 'actions' dropdown menu you might think you could copy in <code>actions.html</code> and modify it. However, it is rendered in <code>change_list.html</code> by calling the <code>admin_actions</code> templatetag. Those templatetags use <code>register.inclusion_tag</code> which does not search for application- or model-specific versions of a template.
</p>
<p>
You can't even work around it by overriding callers like <code>change_list.html</code> without also overriding the templatetag (copying it and changing the template name).
</p>
Resultshttps://code.djangoproject.com/ticket/12566#changeloghttps://code.djangoproject.com/ticket/11803
https://code.djangoproject.com/ticket/11803#11803: Admin does not update every ForeignKey select of the same modelSun, 30 Aug 2009 14:18:30 GMTdanilo <danilo.cabello@…><p>
Consider I have the following models:
</p>
<div class="wiki-code"><div class="code"><pre><span class="k">class</span> <span class="nc">City</span><span class="p">(</span>models<span class="o">.</span>Model<span class="p">):</span>
name <span class="o">=</span> models<span class="o">.</span>CharField<span class="p">(</span><span class="mi">80</span><span class="p">)</span>
state <span class="o">=</span> models<span class="o">.</span>CharField<span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">Person</span><span class="p">(</span>models<span class="o">.</span>Model<span class="p">):</span>
living_city <span class="o">=</span> models<span class="o">.</span>ForeignKey<span class="p">(</span>City<span class="p">)</span>
born_city <span class="o">=</span> models<span class="o">.</span>ForeignKey<span class="p">(</span>City<span class="p">,</span> related_name<span class="o">=</span><span class="s1">'born_city_set'</span><span class="p">)</span>
</pre></div></div><p>
When I go to admin to add a new <code>Person</code>, I have the option to add a city at <code>living_city</code> select and <code>born_city</code> select, if I add a city at <code>living_city</code> select, for example, the <code>born_city</code> select does not update automatically, it remains empty or without the new option.
</p>
Resultshttps://code.djangoproject.com/ticket/11803#changeloghttps://code.djangoproject.com/ticket/12221
https://code.djangoproject.com/ticket/12221#12221: Allow custom management commands to define bash completion argumentsSun, 15 Nov 2009 22:46:41 GMTEric Holscher<p>
What it says on the tin. Sent a proposal to -dev, this ticket is to track the progress of the patches.
</p>
<p>
<a class="ext-link" href="http://groups.google.com/group/django-developers/browse_thread/thread/a076744059cace3f"><span class="icon">​</span>http://groups.google.com/group/django-developers/browse_thread/thread/a076744059cace3f</a>
</p>
Resultshttps://code.djangoproject.com/ticket/12221#changeloghttps://code.djangoproject.com/ticket/12264
https://code.djangoproject.com/ticket/12264#12264: calendar.js depends on jsi18n but date widgets using it do not specify as required mediaWed, 25 Nov 2009 17:51:43 GMTtblanchard@…<p>
Its nice that we can just use the admin widgets in our own public forms - except trying to include the split date/time widget results in a need for gettext which is in the jsi18n package which requires a separate urlconf entry and view to pull into my app. This is messy. Dependent code should automatically pull in its dependencies.
</p>
Resultshttps://code.djangoproject.com/ticket/12264#changeloghttps://code.djangoproject.com/ticket/12134
https://code.djangoproject.com/ticket/12134#12134: contrib.admin.RelatedFieldWidgetWrapper.__deepcopy__() should copy() the widget attrsTue, 03 Nov 2009 05:14:21 GMTJames Bennett<p>
Otherwise it ends up with a shallow copy which reuses the same attrs dict across separate widget instances, playing merry hell with form classes which want to change widget attrs on a per-(form)-instance basis.
</p>
Resultshttps://code.djangoproject.com/ticket/12134#changeloghttps://code.djangoproject.com/ticket/13339
https://code.djangoproject.com/ticket/13339#13339: Date(Time)Field.to_python() fails to parse localized month namesTue, 13 Apr 2010 22:03:28 GMTUlrich Petri<p>
Date(Time)Field.to_python() uses time.strptime to try and parse the input values.
</p>
<p>
If the input string contains a localized month name (e.g. "Dezember" for December in German) validation fails. This probably is due to strptime relying on the current locale to parse month names.
</p>
<p>
Test showing this behaviour is attached.
</p>
<p>
(N.B.: I'm not really clear on why the reverse operation in formats.localize_input() works correctly)
</p>
Resultshttps://code.djangoproject.com/ticket/13339#changeloghttps://code.djangoproject.com/ticket/12382
https://code.djangoproject.com/ticket/12382#12382: Deleting an inline can delete the whole inlined model instance recursivelyTue, 15 Dec 2009 16:05:57 GMTDirk Eschler<p>
A deleted inline can delete the whole inlined model (and all its related ForeignKeys) if the inlined model has a ForeignKey back to model it inlines. As this is best illustrated by an example, here's some code:
</p>
<p>
models.py:
</p>
<pre class="wiki">class Telephone(models.Model):
TELEPHONE_TYPES = ( ('WORK', 'Work'),
('HOME', 'Home'),
)
telephone_type = models.CharField(max_length=16, choices=TELEPHONE_TYPES)
number = models.CharField(max_length=100)
contact = models.ForeignKey('Contact')
# ...
class Contact(models.Model):
family_name = models.CharField(max_length=255, null=True, blank=True)
given_name = models.CharField(max_length=255, null=True, blank=True)
# ...
preferred_telephone = models.ForeignKey(Telephone, related_name='preferred_telephone', null=True, blank=True)
</pre><p>
admin.py:
</p>
<pre class="wiki">from
class TelephoneInline(admin.TabularInline):
model = Telephone
class TelephoneAdmin(admin.ModelAdmin):
# ...
class ContactAdmin(admin.ModelAdmin):
# ...
inlines = [
TelephoneInline,
]
</pre><p>
Steps:
</p>
<ul><li>Create a contact with a telephone number through the admin and save it
</li><li>Choose the new telephone number as preferred_telephone and save the contact
</li><li>Check the delete checkbox for the telephone number
</li><li>Save
</li></ul><p>
Expected:
</p>
<p>
The telephone number is deleted.
</p>
<p>
Result:
</p>
<p>
The contact is deleted recursively! In addition a 404 is raised that the contact doesn't exist, which is true.
</p>
<p>
If the Contact model had more relations, like a ForeignKey relation to an Address model for instance, all the addresses of the contact would have been deleted, too.
</p>
Resultshttps://code.djangoproject.com/ticket/12382#changeloghttps://code.djangoproject.com/ticket/12007
https://code.djangoproject.com/ticket/12007#12007: djangoadmin loaddata gives odd error if it runs out of memorySat, 10 Oct 2009 08:55:07 GMTchrisw<p>
Hi All,
</p>
<p>
I tried to import a 3.2GB xml file, partly to see if Django loads the whole file into memory when it's importing and partly to see how large pg client transactions work. Whichever caused the problem, I have a fair idea that even thought the machine has 4GB of memory, the process ran out of memory.
</p>
<p>
I'd expect a MemoryError if that were the case, what I actually got was:
</p>
<pre class="wiki"> File "django/core/management/__init__.py", line 362, in execute_manager
utility.execute()
File "/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "django/core/management/commands/loaddata.py", line 200, in handle
transaction.leave_transaction_management()
File "django/db/transaction.py", line 74, in leave_transaction_management
raise TransactionManagementError("This code isn't under transaction management")
django.db.transaction.TransactionManagementError: This code isn't under transaction management
</pre><p>
cheers,
</p>
<p>
Chris
</p>
Resultshttps://code.djangoproject.com/ticket/12007#changeloghttps://code.djangoproject.com/ticket/13327
https://code.djangoproject.com/ticket/13327#13327: FileField/ImageField accessor methods throw unnecessary exceptions when they are blank or null.Mon, 12 Apr 2010 15:30:55 GMTkevin.howerton@…<p>
Many of the accessor methods on the FileField call this method:
</p>
<pre class="wiki"> def _require_file(self):
if not self:
raise ValueError("The '%s' attribute has no file associated with it." % self.field.name)
</pre><p>
This method defeats the blank or null features, and has 0 benefit.
</p>
<p>
The preferred behavior should be that it raises an error if the field is set, but the file does not exist. However if you try to retrieve a URL or path from a file-field it should return None if the field is Null or <em> if the field is blank. Not sure what the reasoning behind throwing an error here, is but it seems extremely dis-advantageous in practice requiring every image or file-field that can be blank/null to have if/else statement wrapped around it in templates to prevent 500 errors.
</em></p>
Resultshttps://code.djangoproject.com/ticket/13327#changeloghttps://code.djangoproject.com/ticket/13314
https://code.djangoproject.com/ticket/13314#13314: "FileField" validation does not account for "upload_to" when counting charactersFri, 09 Apr 2010 21:42:24 GMTDenilson Figueiredo de Sá<p>
I have a model with a FileField object:
</p>
<pre class="wiki">def set_file (instance, filename):
return os.path.join("uploaded_files/my_obj_%d" % instance.my_obj_id, os.path.basename(filename))
class MyModel(models.Model):
my_file = models.FileField(upload_to=set_file, null=True)
</pre><p>
And I have a view that receives the POST and handles it to a trivial forms.ModelForm object. In that view I check for .is_valid().
</p>
<p>
Since the FileField creates a 100-char column at the database, any filename greater than 100 chars will be rejected, and the form instance will have a nice error message talking about this.
</p>
<p>
However, this comparison is broken, because the actual data stored at the database won't be the filename, but instead the return value of the "upload_to" callable. This returned value, in my case, has more characters than the actual filename.
</p>
<p>
Thus, in this case, filenames between 75 and 100 characters will be accepted by the form validation, but will be rejected by the database when the actual .save() occurs.
</p>
<p>
I'm not very sure about what is the best solution, but the forms.fields.FileField shouldn't rely just on the max_length parameter when validating the input.
</p>
Resultshttps://code.djangoproject.com/ticket/13314#changeloghttps://code.djangoproject.com/ticket/12157
https://code.djangoproject.com/ticket/12157#12157: FileSystemStorage does file I/O inefficiently, despite providing options to permit larger blocksizesWed, 04 Nov 2009 19:05:56 GMTalecmuffett<p>
FileSystemStorage contains the following:
</p>
<pre class="wiki"> def _open(self, name, mode='rb'):
return File(open(self.path(name), mode))
</pre><p>
..which is used to open files which are stored as FileFields in Django models.
</p>
<p>
If the programmer decides to hack through the file by using (for instance) the django.core.files.base.File.chunks() method:
</p>
<pre class="wiki"> def chunks(self, chunk_size=None):
"""
Read the file and yield chucks of ``chunk_size`` bytes (defaults to
``UploadedFile.DEFAULT_CHUNK_SIZE``).
"""
if not chunk_size:
chunk_size = self.__class__.DEFAULT_CHUNK_SIZE
if hasattr(self, 'seek'):
self.seek(0)
# Assume the pointer is at zero...
counter = self.size
while counter &gt; 0:
yield self.read(chunk_size)
counter -= chunk_size
</pre><p>
...the programmer would expect self.read() - which drops through to django.core.files.base.File.read() - to honour its arguments and for the I/O to occur in DEFAULT_CHUNK_SIZE blocks, currently 64k; however Dtrace shows otherwise:
</p>
<pre class="wiki">29830/0xaf465d0: open_nocancel("file.jpg\0", 0x0, 0x1B6) = 5 0
29830/0xaf465d0: fstat(0x5, 0xB007DB60, 0x1B6) = 0
29830/0xaf465d0: fstat64(0x5, 0xB007E1E4, 0x1B6) = 0 0
29830/0xaf465d0: lseek(0x5, 0x0, 0x1) = 0 0
29830/0xaf465d0: lseek(0x5, 0x0, 0x0) = 0 0
29830/0xaf465d0: stat("file.jpg\0", 0xB007DF7C, 0x0) = 0 0
29830/0xaf465d0: write_nocancel(0x1, "65536 113762\n\0", 0xD) = 13 0
29830/0xaf465d0: mmap(0x0, 0x11000, 0x3, 0x1002, 0x3000000, 0x0) = 0x7C5000 0
29830/0xaf465d0: read_nocancel(0x5, "\377\330\377\340\0", 0x1000) = 4096 0
29830/0xaf465d0: read_nocancel(0x5, "\333\035eS[\026+\360\215Q\361'I\304c`\352\v4M\272C\201\273\261\377\0", 0x1000) = 4096 0
...
...(many more 4kb reads elided)...
...
29830/0xaf465d0: sendto(0x4, 0x7C5014, 0x10000) = 65536 0
</pre><p>
...reading blocks in chunks of 4Kb (on OSX) and writing them in 64Kb blocks.
</p>
<p>
The reason this is occurring is because "open(self.path(name), mode)" is used to open the file, invoking the libc() stdio buffering which is much smaller than the 64kb requested by the programmer.
</p>
<p>
This can be kludged-around by hacking the open() statement:
</p>
<pre class="wiki"> def _open(self, name, mode='rb'):
return File(open(self.path(name), mode, 65536)) # use a larger buffer
</pre><p>
...or by not using the stdio file()/open() calls, instead using os.open()
</p>
<p>
In the meantime this means that Django is not handling FileSystemStorage reads efficiently.
</p>
<p>
It is not easy to determine whether this general stdio-buffer issue impacts other parts of Django's performance.
</p>
Resultshttps://code.djangoproject.com/ticket/12157#changeloghttps://code.djangoproject.com/ticket/11715
https://code.djangoproject.com/ticket/11715#11715: If change mutable list "inlines" in one admin options then it will change "inlines" for all admin options.Thu, 13 Aug 2009 22:35:05 GMTAlexander Ivanov<p>
Now attribute "inlines" is mutable and declared in the body of ModelAdmin class:
</p>
<pre class="wiki">class ModelAdmin(BaseModelAdmin):
...
inlines = []
...
</pre><p>
When we change this attribute in one sub-class, python will change it in all other sub-classes:
</p>
<pre class="wiki">from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
class Book(models.Model):
author = models.ForeignKey(Author)
title = models.CharField(max_length=100)
</pre><pre class="wiki">from django.contrib import admin
from models import *
class BookInline(admin.TabularInline):
model = Book
class AuthorAdmin(admin.ModelAdmin):
def __init__(self, *args, **kwds):
self.inlines.append(BookInline)
return super(AuthorAdmin, self).__init__(*args, **kwds)
class BookAdmin(admin.ModelAdmin):
pass
admin.site.register(Author, AuthorAdmin)
admin.site.register(Book, BookAdmin)
</pre><p>
This code will add BookInline to BookAdmin, too!
</p>
<p>
So, when we will go to admin and try to change Book, we will see exception:
</p>
<pre class="wiki">&lt;class 'test.models.Book'&gt; has no ForeignKey to &lt;class 'test.models.Book'&gt;
</pre><p>
We can fix it like this:
</p>
<pre class="wiki">--- django/contrib/admin/options.py
+++ django/contrib/admin/options.py
@@ -187,7 +187,7 @@ class ModelAdmin(BaseModelAdmin):
save_as = False
save_on_top = False
ordering = None
- inlines = []
+ inlines = None
# Custom templates (designed to be over-ridden in subclasses)
change_form_template = None
@@ -206,6 +206,8 @@ class ModelAdmin(BaseModelAdmin):
self.opts = model._meta
self.admin_site = admin_site
self.inline_instances = []
+ if self.inlines is None:
+ self.inlines = []
for inline_class in self.inlines:
inline_instance = inline_class(self.model, self.admin_site)
self.inline_instances.append(inline_instance)
--- django/contrib/admin/validation.py
+++ django/contrib/admin/validation.py
@@ -133,7 +133,7 @@ def validate(cls, model):
# inlines = []
- if hasattr(cls, 'inlines'):
+ if hasattr(cls, 'inlines') and cls.inlines is not None:
check_isseq(cls, 'inlines', cls.inlines)
for idx, inline in enumerate(cls.inlines):
if not issubclass(inline, BaseModelAdmin):
</pre><p>
But then our sample will raise:
</p>
<pre class="wiki">'NoneType' object has no attribute 'append'
</pre><p>
I think, we can do it like this:
</p>
<pre class="wiki">--- django/contrib/admin/options.py
+++ django/contrib/admin/options.py
@@ -187,7 +187,7 @@ class ModelAdmin(BaseModelAdmin):
save_as = False
save_on_top = False
ordering = None
- inlines = []
+ inlines = ()
# Custom templates (designed to be over-ridden in subclasses)
change_form_template = None
</pre><p>
It will fix logic with mutable attribute, but users will have to write:
</p>
<pre class="wiki"> from django.contrib import admin
from models import *
class BookInline(admin.TabularInline):
model = Book
class AuthorAdmin(admin.ModelAdmin):
+ inlines = []
def __init__(self, *args, **kwds):
self.inlines.append(BookInline)
return super(AuthorAdmin, self).__init__(*args, **kwds)
class BookAdmin(admin.ModelAdmin):
pass
admin.site.register(Author, AuthorAdmin)
admin.site.register(Book, BookAdmin)
</pre><p>
I believe, this will be more correct variant.
</p>
Resultshttps://code.djangoproject.com/ticket/11715#changeloghttps://code.djangoproject.com/ticket/12794
https://code.djangoproject.com/ticket/12794#12794: Interaction between sessions and django.views.i18n.set_language causes caching errorsFri, 05 Feb 2010 20:36:53 GMTalessandro.gudio+bugzilla@…<p>
The django.views.i18n.set_language view uses the session to store the language if it is available.
If a user has a session and tries to change the language, this change is reflected only in the variables inside the session storage. Since the headers of following requests won't change, the caching framework cannot detect such change and cached pages in the previous language will be returned.
</p>
<p>
I suggest always using cookies to store language.
</p>
Resultshttps://code.djangoproject.com/ticket/12794#changeloghttps://code.djangoproject.com/ticket/11929
https://code.djangoproject.com/ticket/11929#11929: manage.py dumpdata outputs YAML in unhelpful orderTue, 22 Sep 2009 16:28:43 GMTsampablokuper<p>
The <a class="ext-link" href="http://docs.djangoproject.com/en/dev/howto/initial-data/"><span class="icon">​</span>docs</a> suggest providing initial YAML data in the following format:
</p>
<pre class="wiki">- model: myapp.person
pk: 1
fields:
first_name: John
last_name: Lennon
</pre><p>
but the manage.py dumpdata outputs YAML in the following form:
</p>
<pre class="wiki">- fields: {first_name: John, last_name: Lennon}
model: myapp.person
pk: 1
</pre><p>
The fact that this is flow rather than block style YAML is the subject of <a class="ext-link" href="http://code.djangoproject.com/ticket/11927"><span class="icon">​</span>#11927</a>, but there's another problem, which is that rather than putting the model and PK first (which is most human-readable), dumpdata outputs the fields first.
</p>
Resultshttps://code.djangoproject.com/ticket/11929#changeloghttps://code.djangoproject.com/ticket/12238
https://code.djangoproject.com/ticket/12238#12238: ModelAdmin ignores dynamic fields of ModelFormWed, 18 Nov 2009 03:19:05 GMTanonymous<p>
If a ModelForm is created and then modified to programatically add fields (say, in <code>__init__</code>), ModelAdmin ignores these fields when rendering the form. If one of these fields is added to the ModelForm's <code>Meta</code>, the field shows up just fine.
</p>
<p>
I would expect the field to display without the coaxing in <code>Meta.fields</code>.
</p>
<ol><li>Create a ModelForm
</li><li>Add it to ModelAdmin
</li><li>View Form
</li><li>Update ModelForm's <code>__init__</code> to include <code>self.fields['xyz'] = forms.CharField(max_length=255, initial='keke')</code>
</li><li>View Form (note no change)
</li><li>Update ModelForm's <code>Meta.fields</code> to include "xyz"
</li><li>View Form (note the change)
</li></ol>Resultshttps://code.djangoproject.com/ticket/12238#changeloghttps://code.djangoproject.com/ticket/12096
https://code.djangoproject.com/ticket/12096#12096: Model fields are not accessible as attributes of the model classTue, 27 Oct 2009 15:45:45 GMTsejo<p>
When using attribute docstrings in my models they will never be picked up by doctools as the attributes disappear top level from the model.
This makes me to keep separate documentation and code for djagios.
</p>
Resultshttps://code.djangoproject.com/ticket/12096#changeloghttps://code.djangoproject.com/ticket/12938
https://code.djangoproject.com/ticket/12938#12938: not possible to validate a many-to-many at the modelMon, 22 Feb 2010 21:48:56 GMTryazwinski<p>
Reference ticket <a class="closed ticket" href="https://code.djangoproject.com/ticket/12065" title="#12065: Bug: URL clash between FlatPages causes middleware error (closed: fixed)">#12065</a> for genesis of this ticket.
</p>
<p>
It isn't currently possible to perform model-level validation of many-to-many relationships.
</p>
<p>
For example:
</p>
<pre class="wiki">class Test(models.Model):
f1 = models.CharField(max_length=100)
m2m = models.ManyToManyField(Other)
</pre><p>
It is not possible to ensure that the f1/m2m relationship is unique. Validation in the Test class cannot validate the m2m because Test won't have been saved yet.
</p>
Resultshttps://code.djangoproject.com/ticket/12938#changeloghttps://code.djangoproject.com/ticket/13296
https://code.djangoproject.com/ticket/13296#13296: order_with_respect_to fails to correctly track _order after deleting entriesThu, 08 Apr 2010 11:18:15 GMTChris<p>
When using a model that orders itself with respect to another entry the "_order" value is not set correctly after an entry has been deleted, and isn't set correct if the Foreign key is changed to point from one 'Question' to another (Question here the class with the foreighn key as in the django docs), this can result in incorrect ordering, and duplicate "_order" values for objects with the same foreign key id
</p>
<p>
To reproduce this problem is simple, use the admin interface to add one question and three answers (related to that question) into the db. These will have _order values of 0, 1 and 2 (correct). Now delete the first answer and add a new answer using the admin interface and the _order value for this new answer will be 2, resulting in the three answers having values of 1, 2 and 2 (where the duplication is clearly bad - this should either still be 0, 1 and 2 with multiple entries having been changed to accomodate, or should be 1, 2 and 3 - preserving the order). The value assigned to _order seems simply to be the number of entries related to that Question, however more intelligence is needed here.
</p>
<p>
The same issue occurs when moving an answer from one Question to another, in that the answer's _order value is unchanged, when it should probably change dependent on the list it is getting inserted into.
</p>
<pre class="wiki">class Question(models.Model):
q = models.CharField(max_length=200)
class Answer(models.Model):
question = models.ForeignKey(Question)
a = models.CharField(max_length=200)
class Meta:
order_with_respect_to = 'question'
</pre><p>
As I see it there are two ways to solve this:
</p>
<ul><li>when an Answer is saved to the db, it should get the first number larger than all current numbers
</li><li>or when an Answer is moved or deleted the remaining entries should be shuffled around so that there ordering is still complete
</li></ul><p>
Either way, _order and the fk should probably be unique together as this would enforce it
</p>
<p>
This testing was done using the admin interface to add and remove the classes on Django 1.1.1 with MYSQL
</p>
Resultshttps://code.djangoproject.com/ticket/13296#changeloghttps://code.djangoproject.com/ticket/11760
https://code.djangoproject.com/ticket/11760#11760: Placeholder for through value in ManyToManyField of abstract classFri, 21 Aug 2009 11:42:43 GMTMS<p>
If you have an abstract class with ManyToManyField it is possible to user %(class)s in related_name for generic related name. Same should be possible for through, to define a generic name for through tables.
</p>
<p>
Example:
</p>
<pre class="wiki">class ClassA(models.Model):
...
class AbstractClass(models.Model):
name = models.ManyToManyField(ClassA, related_name = '%(class)s_name', through = 'ClassA_%(class)s')
class MyClass(AbstractClass):
...
Class ClassA_MyClass(models.Model)
class_a=models.ForeignKey(ClassA)
my_class=models.ForeignKey(MyClass)
</pre><p>
The applied patch uses the same mechanism as used for related_name.
</p>
Resultshttps://code.djangoproject.com/ticket/11760#changeloghttps://code.djangoproject.com/ticket/12227
https://code.djangoproject.com/ticket/12227#12227: PREPEND_WWW breaks the test clientMon, 16 Nov 2009 19:40:40 GMTAndy Baker<p>
With PREPEND_WWW set to true the test client will always give a 301 status_code:
</p>
<pre class="wiki"> &gt;&gt;&gt; from django.test.client import Client
&gt;&gt;&gt; c = Client()
&gt;&gt;&gt; r = c.get('/admin/', follow=True)
&gt;&gt;&gt; r.status_code
301
&gt;&gt;&gt; r.redirect_chain
[('http://www.testserver/admin/', 301), ('http://www.testserver/admin/', 301)]
</pre>Resultshttps://code.djangoproject.com/ticket/12227#changeloghttps://code.djangoproject.com/ticket/12697
https://code.djangoproject.com/ticket/12697#12697: Prevent deletion of some rows in a formsetTue, 26 Jan 2010 17:46:03 GMTshadfc<p>
Original post to dev mailing list: <a class="ext-link" href="http://groups.google.com/group/django-developers/browse_frm/thread/5008b34e29c80417"><span class="icon">​</span>http://groups.google.com/group/django-developers/browse_frm/thread/5008b34e29c80417</a>
</p>
<p>
I need to prevent deletion of <strong>some</strong> of the rows on an inline modelformset.
</p>
<p>
At first I thought I could just do some validation in clean() and
attach errors to the "DELETE" (really the field mapped to
forms.formsets.DELETION_FIELD_NAME), but
<a class="ext-link" href="http://code.djangoproject.com/browser/django/trunk/django/forms/formsets.py?rev=#L216"><span class="icon">​</span>is_valid()</a>
on the formset ignores errors on forms when can_delete is True.
</p>
<p>
A few possible solutions:
</p>
<ol><li>Modify formset validation to ignore errors on the forms EXCEPT on the field referenced by forms.formsets.DELETION_FIELD_NAME ("DELETE" normally).
</li></ol><ol start="2"><li>Make the behavior of ignoring validation errors when can_delete is True explicit. Add a parameter such as "ignore_validation_on_delete" which defaults to True for backward compatibility. When False, formset validation fails on any errors.
</li></ol><ol start="3"><li>Allow can_delete to be specified per form in a formset, perhaps in a way similar to initial -- an iterable of boolean values.
</li></ol><ol start="4"><li>Add a pre-delete hook on model forms which can be used to circumvent deletion.
</li></ol>Resultshttps://code.djangoproject.com/ticket/12697#changeloghttps://code.djangoproject.com/ticket/13117
https://code.djangoproject.com/ticket/13117#13117: Recenter OSMGeoAdmin widget with coordinatesMon, 15 Mar 2010 02:10:01 GMTanonymous<p>
By default, all mapplets that gets created by the contrib.gis.admin.GeoModelAdmin and contrib.gis.admin.OSMGeoAdmin classes are centered at 0,0, which makes it tedious to enter geographic data with that widget when you have the lattitude and longitude coordinates in numeric form.
</p>
<p>
There should be a textbox for centering the map to a set of coordinates.
</p>
Resultshttps://code.djangoproject.com/ticket/13117#changeloghttps://code.djangoproject.com/ticket/12978
https://code.djangoproject.com/ticket/12978#12978: Support in syndication framework for CSS stylesheet linksFri, 26 Feb 2010 19:36:07 GMTintrepidweb<p>
It would be very helpful to be able to add CSS stylesheets to feeds produced by the syndication framework. As far as I know, this is not possible now without overriding the write method of the feed class.
</p>
Resultshttps://code.djangoproject.com/ticket/12978#changeloghttps://code.djangoproject.com/ticket/11688
https://code.djangoproject.com/ticket/11688#11688: verbose_name should allow dynamical translation based on a numberTue, 11 Aug 2009 00:53:44 GMTMitar<p>
<code>verbose_name</code> of meta data for models should allow dynamical translation based on a number of elements through <code>ungettext</code> and not just two possibilities of <code>verbose_name</code> and <code>verbose_name_plural</code> which is not enough for languages with complex plural forms.
</p>
<p>
Django could check if <code>verbose_name</code> is a function and call it with a number of elements as a parameter. This would also be backwards compatible.
</p>
<p>
It should also allow a seconds parameter, a context, as I have described in <a class="closed ticket" href="https://code.djangoproject.com/ticket/11686" title="#11686: Support for gettext's contexts (closed: wontfix)">#11686</a>, because in some languages counting depends also on a context (like case of a counted noun). Probably it should be set to something like a view name by default (or something else which would correlate with grammatical context). Or at least it should be possible to specify it in a model definition to differentiate between different translations of the same word for model name and some other use of this word.
</p>
Resultshttps://code.djangoproject.com/ticket/11688#changelog