Allow to use strings for pk in DjangoResource
seocam opened this issue · 0 comments
seocam commented
Currently the urls method in the DjangoResource looks for urls using the pattern r'^(?P<pk>\d+)/$'
. The problem is that in some cases is ok to have string identifiers. One example would be to use UUIDs instead of integers (common if you want to use distributed database with replications).
Another example would be to use slugs on codes instead of the pk.
I see at least two possibilities here:
- Change the
r'^(?P<pk>\d+)/$'
tor'^(?P<pk>[\w-]+)/$'
- Add a parameters to the urls method allowing the user to override the regexp. Something like pk_re or pk_regexp.
If you (maintainers) agree I could implement either option.