-1

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'
Bav
  • 139
  • 2
  • 3
  • 14
  • You must use `models.CharField` instead of `models.Charfield`. Be carful with letter casing. – Pyfisch Apr 17 '16 at 13:15
  • @Pyfisch 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 – Bav Apr 17 '16 at 13:18
  • Can you please edit your question and include this information, also please update the error message. You should take some care how to write up your problem. – Pyfisch Apr 17 '16 at 13:22
  • You have a typo in this field `author = models.CharField(max_lenght = 200)` the `max_lenght` should be `max_length` – User Rik Apr 17 '16 at 13:40
  • @user2410723 as Brian pointed out again a typo. You will get used to them. A dictionary and Google are your friends for fighting them. – Pyfisch Apr 17 '16 at 14:54
  • Trust me i googled a lot before i post this question but nothing happened i want to solve the upwards errors – Bav Apr 17 '16 at 18:34
  • I solved the problem thanks guys for your help it was in model.py i will be careful for the next time @Brian – Bav Apr 18 '16 at 08:31
  • I solved also the auto complete problem as i use pycharm with virtualenv I followed these steps http://stackoverflow.com/questions/28677670/why-isnt-pycharms-autocomplete-working-for-libraries-i-install – Bav Apr 18 '16 at 17:05

2 Answers2

4

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

Yash Mehrotra
  • 3,032
  • 1
  • 21
  • 24
-1

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) 
Bav
  • 139
  • 2
  • 3
  • 14