jlmadurga / django-telegram-bot

Django app to write Telegram bots. Just define commands and how to handle them.
BSD 3-Clause "New" or "Revised" License
142 stars 45 forks source link

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

Open scorchio opened 7 years ago

scorchio commented 7 years ago

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?

mrabedini commented 7 years ago

@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.

mrabedini commented 7 years ago

@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)