-1

models.py を更新したところ、エラーが発生しました。これがスローされたエラーです。

モデルを検証しています...

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x9eb5dec>>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 91, in inner_run
    self.validate(display_num_errors=True)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors
    self._populate()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
    self.load_app(app_name, True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
    models = import_module('.models', app_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/vaibhav/TRAC/bright-coupons/brightCoupons/brightCouponsApp/models.py", line 75, in <module>
    admin.site.register(couponVotes, couponVotesAdmin)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py", line 74, in register
    for model in model_or_iterable:
TypeError: 'classobj' object is not iterable

python manage.py runserver を実行しようとするたびに

そして、これは私のmodels.pyです:

from django.db import models
from django.contrib import admin

#------------------------------------------------------------------------------ 

class store(models.Model):

    storeName = models.CharField(max_length=30)          # Store Name


class coupon(models.Model):    

    couponDescription = models.TextField()               # Coupon Description
    active =  models.BooleanField(default=True)
    couponCode = models.CharField(max_length=30)
    couponStore = models.CharField(max_length=30)        # Store Name
    featured =  models.BooleanField(default=False)
    couponTitle = models.CharField(max_length=100)       # Coupon Title
    updatedAt = models.DateTimeField(auto_now=True)
    createdAt = models.DateTimeField(auto_now=True)
    lastTested = models.DateField(auto_now_add=True)     # When was the coupon last tested
    localCouponId = models.CharField(max_length=30,primary_key=True)


class commentCoupons(models.Model):
    couponId = models.CharField(max_length=20)                        # CouponId form couponRestApiApp

    class Meta:
        """Meta class to control display Behavior of the Model name """
        verbose_name_plural = "commentCoupons"

    def __unicode__(self):
        """Method to display string correctly"""
        return unicode(self.couponId)


class couponVotes():
    success = models.IntegerField()                      # Count of the number of times people have made it work
    failure = models.IntegerField()                      # Count of the number of times this has failed    
    couponid = models.OneToOneField(commentCoupons)

class comments(models.Model):

    comment = models.TextField()
    addedOn = models.DateField(auto_now=True)
    userName = models.CharField(max_length=30)
    commentCoupon = models.ForeignKey(commentCoupons)   

    class Meta:
        """Meta class to control display Behavior of the Model name """
        verbose_name_plural = "comments"

    def __unicode__(self):
        """Method to display string correctly"""
        return unicode(self.comment)


class commentCouponsAdmin(admin.ModelAdmin):
    list_display = ('couponId',)

class commentsAdmin(admin.ModelAdmin):
    list_display = ('comment','addedOn','userName','commentCoupon',)

class couponAdmin(admin.ModelAdmin):
    list_display = ('couponTitle','couponDescription','couponCode',
                    'couponStore','updatedAt',
                    'createdAt','localCouponId','active','featured')

class couponVotesAdmin(admin.ModelAdmin):
    list_display = ('success','failure',)

admin.site.register(coupon,couponAdmin)
admin.site.register(comments, commentsAdmin)
admin.site.register(couponVotes, couponVotesAdmin)
admin.site.register(commentCoupons,commentCouponsAdmin)

#------------------------------------------------------------------------------

何が起こったのか理解できませんでしたが、新しいモデルcouponVotesを追加したところエラーが発生しましたが、なぜですか?

4

1 に答える 1

10

あなたのクラスcouponVotesは継承しませんmodels.Model

于 2013-05-02T12:58:00.270 に答える