+ : 'dict'및 'int'에 대해 Django TypeError 지원되지 않는 피연산자 유형

Bayman

m2m 필드에 주문 필드를 추가 할 수 있도록 관통 모델을 만들었지 만 아래 def number ()를 통해 주문 필드를 자동으로 증가시키는 데 문제가 있습니다. 객체를 추가 할 때 + : 'dict'및 'int'에 대해 TypeError 지원되지 않는 피연산자 유형이 표시되고 그 이유를 모르겠습니다. 어떤 아이디어?

models.py :

class Playlist(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
    name = models.CharField(max_length=50)
    tracks = models.ManyToManyField(Track, through='PlaylistTrack')

    def __str__(self):
        return self.name

class PlaylistTrack(models.Model):

    def number():
        last_order = PlaylistTrack.objects.all().aggregate(Max('order'))
        if last_order == None:
            return 1
        else:
            return last_order + 1

    track = models.ForeignKey(Track)
    playlist = models.ForeignKey(Playlist)
    order = models.PositiveIntegerField(default=number)

    class Meta:
        ordering = ['order']
JRodDynamite

문서에서 언급했듯이 aggregate()dict 객체를 반환합니다. 따라서 변수 last_order는 실제로 dict이고 dict에 숫자를 추가하려고합니다.

dict에서 값을 얻은 다음 추가해야합니다.

return last_order['order__max'] + 1

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Python : TypeError : + : 'NoneType'및 'int'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : + =에 대해 지원되지 않는 피연산자 유형 : 'int'및 'list'with Pygame

분류에서Dev

TypeError : %에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'int'

분류에서Dev

TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'int'및 'str'값

분류에서Dev

TypeError : * : 'int'및 'NoneType'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : + : 'int'및 'instance'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

지원되지 않는 피연산자 유형 'int'및 'list'에 대한 TypeError

분류에서Dev

사전 병합시 TypeError : | : 'dict'및 'dict'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : ** 또는 pow ()에 대해 지원되지 않는 피연산자 유형 : '함수'및 'int'확률 계산기

분류에서Dev

Python 3 TypeError : ** 또는 pow ()에 대해 지원되지 않는 피연산자 유형 : 'str'및 'int'

분류에서Dev

TensorFlow 1.x : TypeError : / : 'NoneType'및 'int'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

영화 예약 프로그램 : TypeError :-: 'list'및 'int'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

builtins.TypeError : + : 'int'및 'list'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : +에 대해 지원되지 않는 피연산자 유형 : while 루프의 'NoneType'및 'int'

분류에서Dev

TypeError : /에 대해 지원되지 않는 피연산자 유형 : extract_image_patches의 경우 'NoneType'및 'int'

분류에서Dev

TypeError : /에 대해 지원되지 않는 피연산자 유형 : 'str'및 'str'django setting.py

분류에서Dev

+에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'str'및 'int'

분류에서Dev

TypeError :-에 대해 지원되지 않는 피연산자 유형 : 'Position'및 'Position'

분류에서Dev

TypeError :-: 'Approximate'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'list'

분류에서Dev

TypeError : % : 'Text'및 'tuple'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : | : 'list'및 'list'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError :-: 'float'및 'method'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError :-: 'instance'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError :-: 'tuple'및 'tuple'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : + : 'Timestamp'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

python & mysql :-: 'int'및 'tuple'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

+에 대해 지원되지 않는 피연산자 유형 : 'int'및 'classobj'

분류에서Dev

/에 대해 지원되지 않는 피연산자 유형 : 'instance'및 'int'

Related 관련 기사

  1. 1

    Python : TypeError : + : 'NoneType'및 'int'에 대해 지원되지 않는 피연산자 유형

  2. 2

    TypeError : + =에 대해 지원되지 않는 피연산자 유형 : 'int'및 'list'with Pygame

  3. 3

    TypeError : %에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'int'

  4. 4

    TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'int'및 'str'값

  5. 5

    TypeError : * : 'int'및 'NoneType'에 대해 지원되지 않는 피연산자 유형

  6. 6

    TypeError : + : 'int'및 'instance'에 대해 지원되지 않는 피연산자 유형

  7. 7

    지원되지 않는 피연산자 유형 'int'및 'list'에 대한 TypeError

  8. 8

    사전 병합시 TypeError : | : 'dict'및 'dict'에 대해 지원되지 않는 피연산자 유형

  9. 9

    TypeError : ** 또는 pow ()에 대해 지원되지 않는 피연산자 유형 : '함수'및 'int'확률 계산기

  10. 10

    Python 3 TypeError : ** 또는 pow ()에 대해 지원되지 않는 피연산자 유형 : 'str'및 'int'

  11. 11

    TensorFlow 1.x : TypeError : / : 'NoneType'및 'int'에 대해 지원되지 않는 피연산자 유형

  12. 12

    영화 예약 프로그램 : TypeError :-: 'list'및 'int'에 대해 지원되지 않는 피연산자 유형

  13. 13

    builtins.TypeError : + : 'int'및 'list'에 대해 지원되지 않는 피연산자 유형

  14. 14

    TypeError : +에 대해 지원되지 않는 피연산자 유형 : while 루프의 'NoneType'및 'int'

  15. 15

    TypeError : /에 대해 지원되지 않는 피연산자 유형 : extract_image_patches의 경우 'NoneType'및 'int'

  16. 16

    TypeError : /에 대해 지원되지 않는 피연산자 유형 : 'str'및 'str'django setting.py

  17. 17

    +에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'str'및 'int'

  18. 18

    TypeError :-에 대해 지원되지 않는 피연산자 유형 : 'Position'및 'Position'

  19. 19

    TypeError :-: 'Approximate'및 'float'에 대해 지원되지 않는 피연산자 유형

  20. 20

    TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'list'

  21. 21

    TypeError : % : 'Text'및 'tuple'에 대해 지원되지 않는 피연산자 유형

  22. 22

    TypeError : | : 'list'및 'list'에 대해 지원되지 않는 피연산자 유형

  23. 23

    TypeError :-: 'float'및 'method'에 대해 지원되지 않는 피연산자 유형

  24. 24

    TypeError :-: 'instance'및 'float'에 대해 지원되지 않는 피연산자 유형

  25. 25

    TypeError :-: 'tuple'및 'tuple'에 대해 지원되지 않는 피연산자 유형

  26. 26

    TypeError : + : 'Timestamp'및 'float'에 대해 지원되지 않는 피연산자 유형

  27. 27

    python & mysql :-: 'int'및 'tuple'에 대해 지원되지 않는 피연산자 유형

  28. 28

    +에 대해 지원되지 않는 피연산자 유형 : 'int'및 'classobj'

  29. 29

    /에 대해 지원되지 않는 피연산자 유형 : 'instance'및 'int'

뜨겁다태그

보관