apragacz / django-rest-registration

User-related REST API based on the awesome Django REST Framework
https://django-rest-registration.readthedocs.io/
MIT License
545 stars 84 forks source link

*_VERIFICATION_EMAIL_TEMPLATES is invalid #77

Closed ruslankrivoshein closed 5 years ago

ruslankrivoshein commented 5 years ago

I try to use the package without any TEMPLATES option. I've added in settings minimal REST_REGISTRATION config, but get REGISTEREMAIL/REGISTERVERIFICATION/RESET_PASSWORD_VERIFICATION_EMAIL_TEMPLATES is invalid (3 SystemCheck errors). Also I've tried to set this options in {}, '', None, but unsuccessfully. Minimal config to launch server:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'APP_DIRS': True,
    },
]

Do I something wrong understand with using the package or Django..?

apragacz commented 5 years ago

Hi @ruslankrivoshein

  1. Can your send your REST_REGISTRATION dictionary from your settings? In other words, what this section:

    REST_REGISTRATION = {
    ...
    }

    looks in your settings.py? Even better, you could paste your whole settings.py (with secret information removed, of course).

  2. Can you send what specific system checks you get (you mentioned three)? You can copy and paste so we don't miss anything here.

ruslankrivoshein commented 5 years ago

Nothing unusual. I use minimal settings of django-rest-registration and don't use TEMPLATE setting of Django. So, if I get right, if I wanna use only endpoints with data, without any templates, I don't need TEMPLATE setting.

Anyway, just start a new DRF project, delete TEMPLATE setting and try to launch...

apragacz commented 5 years ago

Nothing unusual. I use minimal settings of django-rest-registration and don't use TEMPLATE setting of Django.

OK, but what about the system check errors you mentioned? what is the actual problem?

So, if I get right, if I wanna use only endpoints with data, without any templates, I don't need TEMPLATE setting.

To be sincere we don't test that case (settings.py without TEMPLATES) as the django-admin startproject command usually generates a settings file with that setting (at least it used to do that). I don't think that having the TEMPLATES unset should cause any problems, but I can't say that for sure. I would need to write additonal test for that but I consider this case pretty esoteric (in other words, value/cost is pretty low here).

ruslankrivoshein commented 5 years ago

OK, but what about the system check errors you mentioned? what is the actual problem?

Problem that I can't use django-rest-registration without any template settings)

apragacz commented 5 years ago

I can't use django-rest-registration without any template settings

Please be more specific. What errors are you getting?

Also, I'm still not getting why have you explicitly removed the TEMPLATES setting from you Django settings. I'm saying that because I just checked and django-admin startproject sets up TEMPLATES by default.

apragacz commented 5 years ago

BTW: this is the default TEMPLATES setting generated by django-admin startproject:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
ruslankrivoshein commented 5 years ago

As I said,

REGISTEREMAIL/REGISTERVERIFICATION/RESET_PASSWORD_VERIFICATION_EMAIL_TEMPLATES is invalid (3 SystemCheck errors).

When I delete totally TEMPLATE setting, I get errors only from the package... So, as far as I understand now, the package contains some templates, without which it doesn't work. And question is now: can I disable all package templates and build my RESTful API without any template? :)

apragacz commented 5 years ago

Thanks for the clarification. I still think this is a fringe use case, as I didn't got the answer why you can't have the TEMPLATES setting in your Django setup.

Anyway, I decided to relax the system checks in case no verification is used - as it is the only case when the templates are not needed (they are used for generating the email messages which are sent to the users as a verification). In other words, you should be able to have a Django settings without TEMPLATES setting, as long your Django-REST-Registration setup looks like this:

REST_REGISTRATION = {
    'REGISTER_VERIFICATION_ENABLED': False,
    'RESET_PASSWORD_VERIFICATION_ENABLED': False,
    'REGISTER_EMAIL_VERIFICATION_ENABLED': False,
    ...
}

I will release this change in next version (0.5.2).