2014-03-04 4 views
3

참고 : 결국 버그를 발견하여 아래 텍스트가 아마도 나에게 가치가있었습니다. 짧은 대답 : 나는 이전에 @property-method으로 정의한 애트리뷰트에서 모델 필드를 생성하기로 결정했습니다. 내가 @property-method을 제거하지 않은 유일한 장소는 난초 모델에있었습니다. 일부 후 Django : 디버그 AttributeError : 속성을 설정할 수 없습니다.


는 불통과 내 코드에 파고, 갑자기이 오류를 얻을 : AttributeError: can't set attribute합니다. 나는 Orchid의 코드 중 하나를 변경하지 않은,하지만 지금은이 오류를 얻을 : 오키드

>>> orc = Orchid.objects.get(id=1) 
Traceback (most recent call last): 
    File "<input>", line 1, in <module> 
    File "/Users/cole/PycharmProjects/Sites/virtualenvs/orchidislandcapital.com/lib/python2.7/site-packages/django/db/models/manager.py", line 151, in get 
    return self.get_queryset().get(*args, **kwargs) 
    File "/Users/cole/PycharmProjects/Sites/virtualenvs/orchidislandcapital.com/lib/python2.7/site-packages/django/db/models/query.py", line 301, in get 
    num = len(clone) 
    File "/Users/cole/PycharmProjects/Sites/virtualenvs/orchidislandcapital.com/lib/python2.7/site-packages/django/db/models/query.py", line 77, in __len__ 
    self._fetch_all() 
    File "/Users/cole/PycharmProjects/Sites/virtualenvs/orchidislandcapital.com/lib/python2.7/site-packages/django/db/models/query.py", line 854, in _fetch_all 
    self._result_cache = list(self.iterator()) 
    File "/Users/cole/PycharmProjects/Sites/virtualenvs/orchidislandcapital.com/lib/python2.7/site-packages/django/db/models/query.py", line 230, in iterator 
    obj = model(*row_data) 
    File "/Users/cole/PycharmProjects/Sites/virtualenvs/orchidislandcapital.com/lib/python2.7/site-packages/django/db/models/base.py", line 347, in __init__ 
    setattr(self, field.attname, val) 
AttributeError: can't set attribute 

정의는 class Orchid(FinancialReturnMixin, PeerPerformance)입니다. 나는 누구의 코드 인 FinancialReturnMixin, 변경하지 않은 :

class FinancialReturnMixin(models.Model): 
    exclude_special_dividend = True 
    round_to = 4 

    shares_outstanding = models.FloatField(blank=True, null=True) 
    stock_price = models.FloatField(
     verbose_name='quarter-end stock price', 
     blank=True, null=True) 

    class Meta: 
     abstract = True 
     app_label = 'snippets' 

Orchid 클래스 정의의 두 번째 부분은 내가 만들었던 하나의 변화를 주석 한있는 PeerPerformance이다. PeerPerformance에 대한 정의는 class PeerPerformance(DividendBookValueMixin)이며 모델에 추가 필드 1 개를 추가했습니다. DividendBookValueMixin는 추상적 인 모델입니다.

난초 이동, datatable 및 관련 south_migrationhistory 항목을 삭제했습니다. class Orchid(models.Model)으로 Orchid 모델이 잘 설정됩니다. class Orchid(PeerPerformance)으로 난초 오류가 남아 있습니다. 내 모든 테스트는 PeerPerformance에 대해 실행됩니다. PeerPerformance 개체를 읽고 저장할 수 있습니다.

>>> from peer.models import PeerPerformance as PP 
>>> pp1 = PP.objects.get(id=1) 
>>> pp1.dividend = 0.135 
>>> pp1.save() 

DividendBookValueMixin

PeerPerformance의 상위 클래스입니다. class Orchid(DividendBookValueMixin)으로 오류가 남아 있습니다. 내 모든 시험이 다시 DividendBookValueMixin 실행.

어디에서 볼 수 있습니까?

답변

0

(Linux) 언젠가 이것은 프로젝트 디렉토리 나 virtualenv 디렉토리에 대한 읽기 쓰기 권한이 없을 때 발생합니다. 디렉토리에 대한 적절한 읽기 쓰기 권한이 있는지 확인하십시오.

관련 문제