Kifsif
Kifsif

Reputation: 3843

Django: No module named blog

Well, pardon for asking such a question. But searching didn't help me.

I did:

django-admin.py startproject mysite
./manage.py startapp blog

Well, now I can see:

michael@ubuntu:~/PycharmProjects/mysite$ ls -l
total 12
drwxrwxr-x 2 michael michael 4096 Oct  2 08:22 blog
-rwxr-xr-x 1 michael michael  249 Oct  2 08:14 manage.py
drwxrwxr-x 2 michael michael 4096 Oct  2 08:26 mysite

In settings.py I added my blog:

INSTALLED_APPS = (

    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mysite.blog',

Then mentioned SQlite:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/var/db/django.db',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

Then I edited models.py

from django.db import models:

class BlogPost(models.Model):
    title = models.CharField(max_length = 150)
    body = models.TextField()
    timestamp = models.DateTimeField()

Well, when I do:

./manage.py syncdb

I get:

Error: No module named blog

Could you help me cope with this?

Upvotes: 0

Views: 3620

Answers (3)

Dean Elbaz
Dean Elbaz

Reputation: 2450

sqlite3.OperationalError: unable to open database file

indicates a permission problem. make sure you have necessary permissions in /var/db/

Upvotes: 0

Rohan
Rohan

Reputation: 53326

In INSTALLED_APPS add blog instead of 'mysite.blog'.

Upvotes: 4

Dean Elbaz
Dean Elbaz

Reputation: 2450

In INSTALLED_APPS, you need to have just 'blog' instead of 'mysite.blog'. That should fix your problem.

Upvotes: 3

Related Questions