Question

Im Following a django tutorial but I triple checked everything and its no working for me this is what I get.... what did I do wrong.

python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/base.py", line 284, in execute
self.validate()
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/base.py", line 310, in validate
num_errors = get_validation_errors(s, app)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors
self._populate()
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _populate
self.load_app(app_name, True)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app
models = import_module('%s.models' % app_name)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/hn/stories/models.py", line 6, in <module>
(hackernews)
sweetmedia: /Volumes/SweetMedia/Development/Python/hackernews/hn                                                                                              ▸▸▸▹▹▹▹▹▹▹
→ 

This is what I have in DATABASES

 DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

This is models.py from the app stories maybe I have something in here im not picking up?

from urlparse import urlparse
from django.db import models
from django.contrib.auth.models import User

class Story(models.Model):    
    title = models.CharField(max_length=200)    
    url = models.URLField()    
    points = models.IntergerField()    
    moderator = models.ForeignKey(User)    
    created_at = models.DateTimeField(auto_now_add=True)    
    updated_at = models.DateTimeField(auto_now=True)    

    @property
    def domain(self):
    return urlparse(self.url).netloc    
Was it helpful?

Solution 2

In the moderators model I had:

points = models.IntergerField()

and "Inte(r)gerField" does not exist! lol I mistyped it. I corrected it to:

points = models.IntegerField()

OTHER TIPS

You haven't set the database ENGINE setting in settings.py

This will be created in the same directory than the one from which you run manage.py

'NAME': 'data.sqlite',

This will give file name and your location for db

'NAME': '/yourpath/mysite/data.sqlite',

The best one is to pass an absolute path as

import os

SETTINGS_DIR = os.path.dirname(os.path.abspath(__file__))

and NAME as

'NAME': os.path.join(SETTINGS_DIR, 'data.sqlite'),
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top