2313: Base64Field requires an AutoField key to operate

dru***@gmai***** (Google Code) (Is this you? Claim this profile.)
Dec. 24, 2012
What version are you running?
Master branch of Djblets

What steps will reproduce the problem?
1. Create a model without an auto incrementing primary key "id".
2. Add a Base64Field to the model.
3. Create an instance of the model.

What is the expected output? What do you see instead?
Expect the model to be created. Instead, a base64 conversion "padding" exception is thrown.

Please provide any additional information below.
This exists in djblets/util/fields.py
chipx86
#1 chipx86
Can you build a test case for this?

Are you saying you're specifically turning off "id" for the model, or you just aren't including the field specifically in your model?

Can you show the exception in its entirety?
  • +NeedInfo
  • +Djblets
#2 dru***@gmai***** (Google Code) (Is this you? Claim this profile.)
Turning off "id" completely. Specifically, I was using a CharField as the primary key.
I will build a test case and get the specific error.
#3 dru***@gmai***** (Google Code) (Is this you? Claim this profile.)
Here is the error trace: http://paste2.org/p/1688251
chipx86
#4 chipx86
Hmm, I'm confused. That's a traceback with Review Board. Why would "id" be off?
david
#5 david
Christian, this is in David's diff-storage changes
chipx86
#6 chipx86
Oh hah. That makes sense. The username is cut off so I didn't associate it.

Okay, same question though. Why would "id" be explicitly turned off? And how are you even doing that?
chipx86
#7 chipx86
I think what's actually happening is that the wrong sort of data is going into that field.

Maybe it just can't be used with defaults=. Try setting it explicitly on the object.
#8 dru***@gmai***** (Google Code) (Is this you? Claim this profile.)
From the Django docs: "If you'd like to specify a custom primary key, just specify primary_key=True on one of your fields. If Django sees you've explicitly set Field.primary_key, it won't add the automatic id column."

Yes, this is a modification of the diff-storage posted; the only difference being primary_key=True on the hash id.
#9 dru***@gmai***** (Google Code) (Is this you? Claim this profile.)
I have tried creating an instant and calling .save() on it, with the same results.
david
#10 david
  • -NeedInfo
    +New
david
#11 david
I'm going to close this for now, since I think it's not blocking any work.
  • -New
    +WontFix