jlmadurga/django-telegram-bot

Django REST Framework token authentication vs. django-telegram-bot clash

scorchio opened this issue · 2 comments

Hi,

I have a Django setup where I'm trying to provide an API and use it as a Telegram bot at the same time. (Not the best setup I know, but I wanted a light setup, possibly refactoring the bot into a separate service later when it's really necessary.)

I wanted to enable support for Django REST Framework's token authentication after I got started with django-telegram-bot. When I run python manage.py migrate, it fails and gives me this:

SystemCheckError: System check identified some issues:

ERRORS:
authtoken.Token.user: (fields.E304) Reverse accessor for 'Token.user' clashes with reverse accessor for 'AuthToken.user'.
	HINT: Add or change a related_name argument to the definition for 'Token.user' or 'AuthToken.user'.
authtoken.Token.user: (fields.E305) Reverse query name for 'Token.user' clashes with reverse query name for 'AuthToken.user'.
	HINT: Add or change a related_name argument to the definition for 'Token.user' or 'AuthToken.user'.
telegrambot.AuthToken.user: (fields.E304) Reverse accessor for 'AuthToken.user' clashes with reverse accessor for 'Token.user'.
	HINT: Add or change a related_name argument to the definition for 'AuthToken.user' or 'Token.user'.
telegrambot.AuthToken.user: (fields.E305) Reverse query name for 'AuthToken.user' clashes with reverse query name for 'Token.user'.
	HINT: Add or change a related_name argument to the definition for 'AuthToken.user' or 'Token.user'.

Is there a workaround for this?

@scorchio I have the same problem. If you don't need the 'rest_framework.authtoken' app, you could remove it from INSTALLED_APPS. Then the migration would succeed.
I would let you know if I came with another solution.

@scorchio In AutToken model if you change the related name of the user field the problem would be resolved. sth like this:
user = models.OneToOneField(AUTH_USER_MODEL, related_name='%(app_label)s_auth_token',
on_delete=models.CASCADE)