django-settings

G Suite and Django for SMTP

梦想的初衷 提交于 2020-03-18 06:28:11
问题 I'm in the process of getting G Suite to work with my django site so that it will replace the SMTP server of my host. I configured my domain within my webhost's config panel. As a result, when I send an email to support@mysite.com, I can see that it successfully comes though to the Google Account, which is great. My application is setup to send out a confirmation email after someone tries to register. I've completed what I believe to be all of the required steps to setup G Suite with my

G Suite and Django for SMTP

大兔子大兔子 提交于 2020-03-18 06:27:30
问题 I'm in the process of getting G Suite to work with my django site so that it will replace the SMTP server of my host. I configured my domain within my webhost's config panel. As a result, when I send an email to support@mysite.com, I can see that it successfully comes though to the Google Account, which is great. My application is setup to send out a confirmation email after someone tries to register. I've completed what I believe to be all of the required steps to setup G Suite with my

Is there a function for generating settings.SECRET_KEY in django?

依然范特西╮ 提交于 2020-03-16 02:51:09
问题 I wrote an ansible-role for openwisp2 to ease its deployment, it's a series of django apps. To ease the deployment as much as possible, I wrote a simple (probably trivial) SECRET_KEY generator script which is called by ansible to generate the secret key the first time the ansible playbook is run. Now, that works fine BUT I think it defeats the built-in security measures Django has in generating a strong key which is also very hard to guess. At the time I looked at other ways of doing it but

Django ALLOWED_HOSTS IPs range

不问归期 提交于 2020-02-17 06:00:27
问题 Is there a way to set a range of ALLOWED_HOSTS IPs in django? Something like this: ALLOWED_HOSTS = ['172.17.*.*'] 回答1: I posted a ticket on Django however I was shown this could be achieved by doing the following from socket import gethostname, gethostbyname ALLOWED_HOSTS = [ gethostname(), gethostbyname(gethostname()), ] https://code.djangoproject.com/ticket/27485 回答2: No, this is not currently possible. According to the docs, the following syntax is supported: ['www.example.com'] # Fully

django local_settings import error

别来无恙 提交于 2020-02-01 06:33:48
问题 I would like to import a local_settings.py file (which is not in my VCS system) for overriding the DATABASES settings from settings.py For this purpose I added those lines at the very end of my settings.py file. try: from local_settings import * except ImportError: print('Unable to load local_settings.py:') When I use a python manage.py diffsettings I see that the DATABASES settings from settings.py is not changed and I get the message Unable to load local_settings.py: I would like to know

Django @override_settings does not allow dictionary?

♀尐吖头ヾ 提交于 2020-01-30 04:32:48
问题 I am new to Python decorators so perhaps I am missing something simple, here is my situation: This works for me: def test_something(self): settings.SETTING_DICT['key'] = True #no error ... But this throws a "SyntaxError: keyword can't be an expression": @override_settings(SETTING_DICT['key'] = True) #error def test_something(self): ... Just to be clear, normal use of override settings works: @override_settings(SETTING_VAR = True) #no error def test_something(self): ... Is there a way to use

How do I reference a Django settings variable in my models.py?

喜夏-厌秋 提交于 2020-01-20 12:29:29
问题 This is a very beginner question. But I'm stumped. How do I reference a Django settings variable in my model.py? NameError: name 'PRIVATE_DIR' is not defined Also tried a lot of other stuff including settings.PRIVATE_DIR settings.py: PRIVATE_DIR = '/home/me/django_projects/myproject/storage_dir' models.py: # Problem is here. from django.core.files.storage import FileSystemStorage fs = FileSystemStorage(location=PRIVATE_DIR) class Customer(models.Model): lastName = models.CharField(max_length

How do I reference a Django settings variable in my models.py?

不想你离开。 提交于 2020-01-20 12:28:41
问题 This is a very beginner question. But I'm stumped. How do I reference a Django settings variable in my model.py? NameError: name 'PRIVATE_DIR' is not defined Also tried a lot of other stuff including settings.PRIVATE_DIR settings.py: PRIVATE_DIR = '/home/me/django_projects/myproject/storage_dir' models.py: # Problem is here. from django.core.files.storage import FileSystemStorage fs = FileSystemStorage(location=PRIVATE_DIR) class Customer(models.Model): lastName = models.CharField(max_length

How do I reference a Django settings variable in my models.py?

こ雲淡風輕ζ 提交于 2020-01-20 12:28:26
问题 This is a very beginner question. But I'm stumped. How do I reference a Django settings variable in my model.py? NameError: name 'PRIVATE_DIR' is not defined Also tried a lot of other stuff including settings.PRIVATE_DIR settings.py: PRIVATE_DIR = '/home/me/django_projects/myproject/storage_dir' models.py: # Problem is here. from django.core.files.storage import FileSystemStorage fs = FileSystemStorage(location=PRIVATE_DIR) class Customer(models.Model): lastName = models.CharField(max_length

Django SECRET KEY error

放肆的年华 提交于 2020-01-15 07:25:27
问题 I'm building a little Django REST API. I've configured a separate settings module for local and production but I'm having an annoying error which is: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty. This error doesn't make sense because I have the SECRET_KEY variable set. Here are my base.py (which is my base settings for the API) and the local.py. Also, here are my wsgi.py and manage.py. base.py """ https://docs.djangoproject.com/en/2.0/ref/settings/ """