pythondjangolinesyncdb

manage.py syncdb not working


DJANGO@linux-l94a:~/Desktop/myblog> ./manage.py syncdb

Traceback (most recent call last):

File "./manage.py", line 10, in

execute_from_command_line(sys.argv)

File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line

utility.execute()

File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv

self.execute(*args, **options.__dict__)

File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 231, in execute

self.validate()

File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate

num_errors = get_validation_errors(s, app)

File "/usr/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors

for (app_name, error) in get_app_errors().items():

File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors

self._populate()

File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 64, in _populate

self.load_app(app_name, True)

File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app models = import_module('.models', app_name)

File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module

__import__(name)

File "/home/DJANGO/Desktop/myblog/blog/models.py", line 4, in

class Post(models.Model):

File "/home/DJANGO/Desktop/myblog/blog/models.py", line 5, in Post

title = modles.CharField(max_lenght=100)

NameError: name 'modles' is not defined

models.py

from django.db import models

from taggit.managers import TaggableManager

class Post(models.Model): title = modles.CharField(max_lenght=100)

body = modles.TextField()

created = models.DateTimeField()

tags = TaggableManager()

def __unicode__(self):
    return self.title

urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('', # Examples: # url(r'^$', 'myblog.views.home', name='home'),

# url(r'^myblog/', include('myblog.foo.urls')),


url(r'^admin/', include(admin.site.urls)),

)

admin.py

from django.contrib import admin

from blog.models import Post

admin.site.register(Post)

settings.py

INSTALLED_APPS = (

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.sites',

'django.contrib.messages',

'django.contrib.staticfiles',

# Uncomment the next line to enable the admin:

'django.contrib.admin',

'taggit',

'blog',

# Uncomment the next line to enable admin documentation:

# 'django.contrib.admindocs',

)

Solution

  • You have a typo in your models.py, at line 5:

    title = modles.CharField(max_lenght=100)
    

    This should be updated to be

    title = models.CharField(max_length=100)