2313: Base64Field requires an AutoField key to operate
- WontFix
- Review Board
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
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
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.
Here is the error trace: http://paste2.org/p/1688251
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?
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.
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.
I have tried creating an instant and calling .save() on it, with the same results.