<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
import osimport djangoos.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"django.setup()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")
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
]
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
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',
]
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@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/bb9251bb-7bce-4eec-b8ac-90b031db1284%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import osimport djangoos.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"django.setup()
INSTALLED_APPS = [...
======>>>>'MY_DJANGO.my_django', or 'my_django', <<<<===== Here is the problem
]
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@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.
Here are the steps of how I created the project:
1. django-admin startproject MY_DGANGO
2. python manage.py startapp my_django
3. edited the models.py
4. python manage.py makemigrations my_django
5. python manage.py sqlmigrate my_django 0001
6. python manage.py migrate
Now after the tables in the DB was created, I want to use it (add/remove/update date) from my project.
7. So from my project I’m importing models so I’ll be able to use the classes I’ve created to extract and add information to/from the DB.
For example:
· In models.py:
Class Person(models.Model):
first_name = models.CharField(max_length=100, null=False)
last_name = models.CharField(max_length=100, null=False)
phone_number = models.CharField(max_length=100, null=False)
…
· In some file in my project:
from MY_DGANGO.my_django import models
….
def add_person(first_name, last_name, phone_number):
…
person = models.Person(first_name= first_name, last_name= last_name,
phone_number= phone_number)
person.save()
…
…
…
def get_person_by_phone_number(phone_number):
…
person = models.Person.objects.filter(phone_number= phone_number)
…
Med vänliga hälsningar,Andréas
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@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/5e97c0b6-51de-4503-8a89-a0ad4e3269d6%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@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/5e97c0b6-51de-4503-8a89-a0ad4e3269d6%40googlegroups.com.
Regards,Andréas
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCeR1sqF1dKNnARvu7chOAJOmDRLX4wmUWas3DHB8sDkWw%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@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/c09c5b64-8244-4f4d-9d43-acc091919fce%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHn91ofk%3DbcyVuPB9rUpO_Tkv%3Dbbbfsos8bHgvrxwdA4RJ7eJg%40mail.gmail.com.