Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API support for model primary key not named id #357

Open
SamuelJennings opened this issue Nov 18, 2021 · 0 comments
Open

API support for model primary key not named id #357

SamuelJennings opened this issue Nov 18, 2021 · 0 comments

Comments

@SamuelJennings
Copy link

Hi,

Just started using this app and I think it's great so far! I really want to switch to the API backend but doing so requires a primary key field named id. I know this is pretty standard for most django models but unfortunately not for me.

Trying to load comments through the API at the moment gives the following error:

'MyModel' object has no attribute 'id'

The problem occurs in lines 87-92 of api/frontend.py:

        "list_url": _reverse('comments-xtd-api-list',
                             kwargs={'content_type': ctype_slug,
                                     'object_pk': obj.id}),
        "count_url": _reverse('comments-xtd-api-count',
                              kwargs={'content_type': ctype_slug,
                                      'object_pk': obj.id}),

Unless I'm missing something, switching references of obj.id to obj.pk should be a simple fix.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant