0

I learn Django. And now I try to make new database table. I have done the structure of the files, as in the book, which I learn. My app is named - "books":

Structure of the files

Then, I must add the line ‘mysite.books’ to field INSTALLED_APPS, in settings.py, isn`t it? Also, in the book, written, that I must comment out next lines in the file "settings.py":

 MIDDLEWARE_CLASSES = (
 # ‘django.middleware.common.CommonMiddleware’,
 # ‘django.contrib.sessions.middleware.SessionMiddleware’,
 # ‘django.contrib.auth.middleware.AuthenticationMiddleware’,
)
INSTALLED_APPS = (
 # ‘django.contrib.auth’,
 # ‘django.contrib.contenttypes’,
 # ‘django.contrib.sessions’,
 # ‘django.contrib.sites’,
 ‘mysite.books’,
)

But, the book about Django, is for 1.1 version of Django, and I use the 1.8 version of Django. So, I have some another fields "MIDDLEWARE_CLASSES" and "INSTALLED_APPS":

INSTALLED_APPS = (
    #'django.contrib.admin',
    #'django.contrib.auth',
    #'django.contrib.contenttypes',
    #'django.contrib.sessions',
    #'django.contrib.messages',
    #'django.contrib.staticfiles',
    'mysite.books',
)

MIDDLEWARE_CLASSES = (
    #'django.contrib.sessions.middleware.SessionMiddleware',
    #'django.middleware.common.CommonMiddleware',
    #'django.middleware.csrf.CsrfViewMiddleware',
    #'django.contrib.auth.middleware.AuthenticationMiddleware',
    #'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    #'django.contrib.messages.middleware.MessageMiddleware',
    #'django.middleware.clickjacking.XFrameOptionsMiddleware',
    #'django.middleware.security.SecurityMiddleware',
)

And, if I run the command "python manage.py validate", i see the error: "ImportError: No module named 'mysite.books'"

What I do wrong? Or, maybe it is the problem with different versions of Django? What I must doing?

5
  • 1
    What happens if you put the app in installed apps as 'books'? Commented May 23, 2015 at 14:10
  • 2
    You might find it easier if you use a more recent book. Django 1.1 was released in 2009, a lot has changed since then. Commented May 23, 2015 at 14:13
  • 2
    Note that Django 1.1 is almost six years old -- really really ancient. You're probably better off doing the official Django tutorial for 1.8. Commented May 23, 2015 at 14:14
  • I understand, that Django 1.1 is very old, by I have not any another book about Django at this momment. Commented May 23, 2015 at 14:18
  • also keep note that you need not have to comment the other INSTALLED_APPS. Putting 'books' instead of 'mysite.books' should work. Commented May 23, 2015 at 14:31

2 Answers 2

2

Try to put books without the prefix mysite.

Sign up to request clarification or add additional context in comments.

4 Comments

Oh, thanks. Validate work super. result:'System check identified no issues (0 silenced).'.. But next I must run command "python manage.py sqlall books". And it cause: "CommandError: App 'books' has migrations. Only the sqlmigrate and sqlflush commands can be used when an app has migrations." What is it?
I think your doc reference is outdated. Please refer to the Django1.8
Ok, I will try to read the official documentation. But, what I do wrong?
@Q-bart: migrations are a new feature introduced in Django 1.7. You should disable migrations for your model if you want to use sqlall and friends.
2

The default Django project layout changed in Django 1.4.

For the directory layout you have shown you should use books instead of mysite.books in your INSTALLED_APPS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.