Hi Kaloian,

Ah - you've just fired a neuron in my brain… This is a known issue, and
it's not just the permission_required decorator.

See ticket #14881.

I don't remember the permission_required decorator itself being a problem
at that time (not saying it isn't -- just that it wasn't reported as such,
or I don't recall it being reported as such) -- the issues that were being
reported were with admin URLs for User objects, and for password reset
tokens.

So - the short answer is that yes, non-integer primary keys will cause some
problems with custom User objects. This is something we should probably
document as a limitation. I've just added a note to this effect in the docs.

This doesn't mean you have to give up having the api_key as a unique
identifier; you just need to have the api_key *in addition* to the integer
primary key; Django's internals will use the integer primary key, and your
code can do lookups based on the API key.

Of course, we're also open to patches to fix the situation :-)

Yours,
Russ Magee %-)

On Fri, Feb 15, 2013 at 9:48 PM, Kaloian <kaloian.min...@gmail.com> wrote:

>
> Hi Russel I got into another small issue related to the character primary
> key of the user model.
> When I try to use the permission_required decorator on that model I got
> the following error.
>
> Exception Value:
>
> invalid literal for int() with base 10: 
> '3DDz0Vi7zonFDq9JfByKkeparghaWwupVwbMCbL7JHo'
>
>  Exception Location: 
> /usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py
> in get_prep_value, line 554
> Here is the latest definition of my model:
>
> class Merchant(AbstractBaseUser,PermissionsMixin):
>     """User with app settings."""
>     id = models.CharField(max_length=256, primary_key=True)
>     email = models.EmailField(unique=True, db_index=True)
>
>     company_name = models.CharField(max_length=256)
>     website = models.URLField()
>     description = models.TextField(blank=True)
>     #api_key = models.CharField(blank=True, max_length=256,
> primary_key=True)
>
>     USERNAME_FIELD = 'email'
>     REQUIRED_FIELDS = ['company_name','website']
>
>     objects = MerchantManager()
>
>
>     class Meta:
>         verbose_name = _('Merchant')
>         verbose_name_plural = _('Merchants')
>
>
>
>
> I can easily find workaround for that problem by writing custom decorator for 
> example but I am not sure this is supposed to be this way. Or may be I am 
> missing something here ?
>
> Thanks,
> Kaloian
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to