2014-04-11 2 views
-1

모델 수정에 도움주세요.숫자 필드를 사용하는 방법은 무엇입니까?

from django.db import models 
from sorl.thumbnail import ImageField 
from decimal import * 


class News (models.Model): 
CHOICES_inner_image_position = [ 
(Decimal ("10.5"), '10 .5% '), 
(Decimal ("17.5"), '17 .5% '), 
(Decimal (" 30") , '30 % ') 
(Decimal (" 33") , '33 % ') 
] 
          
title = models.CharField (u'Zagolovok ', max_length = 70) 
content = models.TextField (verbose_name = u'Soderzhanie ', max_length = 30000) 
date_time = models.DateTimeField() 
image = models.ImageField (upload_to = 'news/headimage /') 
public = models.BooleanField (verbose_name = u'Opublikovat news ? ', default = True) 
teaser_length = DecimalField (verbose_name = u'Kolichestvo characters in the teaser ', max_digits = 4 , decimal_places = 0) 
inner_image_position = like = forms.ChoiceField (choices = CHOICES_inner_image_position, widget = forms.RadioSelect()) 

class Meta: 
verbose_name = ' News ' 
verbose_name_plural = ' News ' 

나는 콘솔 명령 파이썬 manage.py의 syncdb를하고 다음과 같은 오류 메시지가 얻을 :

NameError: name 'DecimalField' is not defined 

django1.6

답변

8

당신은 당신의 DecimalField 앞에 models을 놓치고있다. 행은 다음과 같이 표시되어야합니다.

teaser_length = models.DecimalField(verbose_name = u'Kolichestvo characters in the teaser ', max_digits = 4, decimal_places = 0) 
관련 문제