简体   繁体   中英

django and python ./manage.py makemigrations execution error

thats my code in modeles.py

from django.db import models
from django.utils import timezone
   class Book(models.Model):
title = models.CharField(max_length = 200)
author = models.CharField(max_lenght = 200)
description = models.TextField()
publish_date = models.DateField(Default= timezone.now)

that is when i type ./manage.py makemigrations execution error
that is what i see in shh still error there is no control space to know when i pointer to mouse to django it appears unresolved reference 'django' while i installed it pip install django==1.8 and i run every time sudo pip install --ignore-installed virtualenvwrapper because when i use workon bookstore-django it does not execute until i run sudo pip install --ignore-installed virtualenvwrapper i am too beginner in this field

 (bookstore-django) bavlys-Mac:bookstore bavlymorcos$ ./manage.py makemigrations store
  Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
  File "/Users/bavlymorcos/.virtualenvs/bookstore-django/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
 File "/Users/bavlymorcos/.virtualenvs/bookstore-django/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
 File "/Users/bavlymorcos/.virtualenvs/bookstore-django/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
 File "/Users/bavlymorcos/.virtualenvs/bookstore-django/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
 File "/Users/bavlymorcos/.virtualenvs/bookstore-django/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
 File "/Users/bavlymorcos/Desktop/development/bookstore/store/models.py", line 6, in <module>
class Book(models.Model):
 File "/Users/bavlymorcos/Desktop/development/bookstore/store/models.py", line 10, in Book
publish_date = models.DateField(Default=timezone.now)
 File "/Users/bavlymorcos/.virtualenvs/bookstore-django/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1201, in __init__
super(DateField, self).__init__(verbose_name, name, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'Default'

The Charfield part should be CharField .

In /Users/bavlymorcos/Desktop/development/bookstore/store/models.py, line no. 6,

it should be

title = models.CharField(max_length = 200)

ie. F in field should be Capital. (CharField instead of Charfield)

Docs: https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.CharField

I solved the problem thanks guys

the problem was in model.py I changed it to like that

 from django.db import models

 from django.utils import timezone


class Book(models.Model):
   title = models.CharField(max_length=200)
   author = models.CharField(max_length=200)
   description = models.TextField()
   publish_date = models.DateField(default=timezone.now) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM