Mit Python 2.7 und Django 1.9.9 Ich erhalte den folgenden Fehler, wenn ich eine App einschließe, die ich gerade entwickle mein INSTALLED_APSNeue App, die AttributeError verursacht: 'str' -Objekt hat kein Attribut '_meta' in Python/Django App
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 398, in execute
self.check()
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 1180, in check
errors.extend(cls._check_long_column_names())
File "/var/www/cltc/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 1631, in _check_long_column_names
for m2m in f.remote_field.through._meta.local_fields:
AttributeError: 'str' object has no attribute '_meta'
Das ist, glaube ich durch etwas verursacht wird falsch in models.py, die wie folgt aussieht:
from django.db import models
from django.contrib.auth.models import User
from django.conf import settings
import datetime
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
class Category(models.Model):
name = models.CharField('Category', max_length=30)
age = models.IntegerField('Member age at start of Subscription', default=18)
class Subscription(models.Model):
name = models.CharField('Subscription', max_length=30)
cost = models.DecimalField('Price', max_digits=6, decimal_places=2, default=0.00)
start = models.DateField('Start Date')
end = models.DateField('End Date')
category = models.ManyToManyField(
Category,
through = 'SubscritptionCategory',
related_name = 'category',
verbose_name = 'Membership Category',
help_text = 'Membership Categories included in the Subscription'
)
def __unicode__(self):
return u'%s' % (self.name)
def clean (self):
if self.start > self.end:
raise ValidationError(
_("Start Date must be earlier than End Date"),
)
def is_live(self):
if self.end >= datetime.datetime.now().date():
return True
else:
return False
class SubscriptionCategory (models.Model):
subscription = models.ForeignKey(
Subscription,
verbose_name = 'Subscription',
help_text = 'A class of membership (which could include several members, eg Family).',
)
category = models.ForeignKey(
Category,
verbose_name = 'Category',
help_text = 'A class of member (eg adult)',
)
Jede Hilfe sehr willkommen
Zwei Stunden und ich konnte das nicht sehen! Vielen Dank – HenryM