Opened 17 years ago

Closed 16 years ago

#6280 closed (fixed)

IntegerField member_name and PositiveIntegerField error

Reported by: bo@… Owned by: nobody
Component: contrib.admin Version: 0.96
Severity: Keywords: member_name PostitiveIntegerField
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Using raw_id_admin = True On a ForeignKey that is references to a PostitiveIntegerField causes a

__init__() got an unexpected keyword argument 'member_name'  on python2.5/django/utils/maxlength.py in inner, line 47

i.e.


--- Failure when editing Provider ---
class User(models.Model):
	uid = models.PositiveIntegerField(primary_key=True)
	login = models.CharField(max_length=150)

class Provider(models.Model):
	provider_id = models.PositiveIntegerField(primary_key = True)
	user = models.ForeignKey(User, db_column = 'uid', raw_id_admin = True)
--- Failure when editing Provider ---

--- OK editing Provider ---
class User(models.Model):
	uid = models.IntegerField(primary_key=True)
	login = models.CharField(max_length=150)

class Provider(models.Model):
	provider_id = models.PositiveIntegerField(primary_key = True)
	user = models.ForeignKey(User, db_column = 'uid', raw_id_admin = True)
--- OK editing Provider ---

Seems strange as most DB 'default' Primary Keys are in-fact PostitiveIntegerFields

This little issue crops up often when inspection of the DB for migration. Its not really a bug per-say.

Its just the optimal validator for 'raw_id_admin' should check for the ID < 0 case before asking the DB if such an ID exists.
And of course to take advantage of the UNSIGNED/indexing optimizations DB's have for such fields if one were to "syncdb" (which bears itself out when the dataset is huge)

Change History (7)

comment:1 by Jacob, 16 years ago

Do you only get this error when entering a negative number, or all the time?

(By the way, there's no need to explicitally use db_column in these definitions; Django's smart enough to know that you want to reference the other object's primary key.)

comment:2 by Jacob, 16 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Matthias Kestenholz, 16 years ago

Version: SVN0.96

I cannot reproduce this using current SVN (after the merge of newforms-admin). It seems this bug only concerns users of 0.96 now. I have no local installation of 0.96 to verify this, though.

comment:4 by magneto, 16 years ago

True, this error did go away, however, another bug has appeared when i did a test .. to be posted soon

comment:5 by magneto, 16 years ago

see #7398 for the current error in the 1.0-alpha set of things

comment:6 by magneto, 16 years ago

thats #7938 .. sheesh

comment:7 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

If it cannot be replicated on trunk (and since the example in question is for old-admin), let's mark it as fixed.

Note: See TracTickets for help on using tickets.
Back to Top