Opened 7 years ago

Closed 7 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: UI/UX:

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 Changed 7 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 7 years ago by mk

  • Version changed from SVN to 0.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 Changed 7 years ago by magneto

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

comment:5 Changed 7 years ago by magneto

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

comment:6 Changed 7 years ago by magneto

thats #7938 .. sheesh

comment:7 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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