Hi Andréas,
Thanks for your response.

When I'm removing the lines you've talked about I'm having the following 
error:

django.core.exceptions.ImproperlyConfigured: Requested setting 
DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either 
define the environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings.

This is why I've added those settings in the first place.



On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>
> Hi Alex,
>
> You shouldn't have anything regarding the settings in models.py.
>
> Remove:
> import os
> import django
> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
> django.setup()
>
> from your models.py file. You should never have any settings in the 
> models.py file at all. Also, you should never reference the django project 
> folder (your first MY_DJANGO here) in the project. It always has that 
> folder anyway.
>
> In settings.py, your INSTALLED_APPS should look like this:
>
> INSTALLED_APPS = [
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
>     'django.contrib.sites',
>     'django.contrib.admindocs',
>
>     'my_django',
>
> ]
>
>
> Everything should then work as expected.
>
> Regards,
>
> Andréas
>
> 2018-01-05 13:07 GMT+01:00 alex Tarasiuk <alex...@gmail.com <javascript:>>
> :
>
>> Hi, I'm new to Django and having some trouble to configure it.
>> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes it 
>> will solve the issue) and Python 2.7.12 from virtualenv.
>>
>> Here is my project structure (Please pay attention to upper/lower case 
>> letters - it is intentionally):
>>
>> <my project>:
>>
>> module 1
>>
>> module 2
>>
>> ...
>>
>> ...
>>
>> MY_DJANGO:
>>
>> MY_DJANGO:
>>
>>             __init__.py
>>
>>             settings.py
>>
>>             urls.py
>>
>> wsgi.py
>>
>> my_django:
>>
>>             migrations
>>
>>             __init__.py
>>
>>             admin.py
>>
>>             apps.py
>>
>>             models.py
>>
>>             tests.py
>>
>>             views.py
>>
>> __init__.py
>>
>> manage.py
>>  
>> in models.py I've added:
>>
>> import os
>> import django
>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>> django.setup()
>>
>> before the models import from django.db.
>>
>> in manage.py, in the main
>>
>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")
>>
>> was auto generated by Django 
>>
>> in settings.py, in INSTALLED_APPS:
>>
>> INSTALLED_APPS = [
>>     'django.contrib.admin',
>>     'django.contrib.auth',
>>     'django.contrib.contenttypes',
>>     'django.contrib.sessions',
>>     'django.contrib.messages',
>>     'django.contrib.staticfiles',
>>     'django.contrib.sites',
>>     'django.contrib.admindocs',
>>
>>     ======>>>>'MY_DJANGO.my_django', or 'my_django', <<<<===== Here is 
>> the problem
>>
>> ]
>>
>>
>> Problem description:
>>
>> if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python 
>> manage.py check' command yields:
>>
>>  ImportError: No module named MY_DJANGO.settings
>>
>>
>>  
>>
>> and if I use 'my_django' in INSTALLED_APPS then I have an import error 
>> while importing models:
>>
>>  from MY_DJANGO.my_django import models (in some file) yields:
>>
>> ImportError: No module named my_django 
>>
>>
>> Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS, 
>> and it didn't helped.
>>
>> What am I doing wrong??
>>
>> Thanks in advance,
>> Alex.
>>
>>  
>>
>>
>>
>>
>>
>>
>>  
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/bb9251bb-7bce-4eec-b8ac-90b031db1284%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/bb9251bb-7bce-4eec-b8ac-90b031db1284%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/31d7a9d0-a861-4814-a4d5-9771ba828918%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to