Problem with abstract model class

22 views
Skip to first unread message

Legioneer

unread,
May 16, 2008, 9:33:57 AM5/16/08
to Django users
Hi All,

Got a problem when trying to define an abstract class. Below there is
an examle:

class PaymentData(models.Model):
owner = models.ForeignKey(Customer,
related_name="%s(class)s_related" )

class Meta:
abstract = True

When running 'python manage.py validate' receive an error:

....
.......
File "/usr/lib/python2.3/site-packages/django/db/models/base.py",
line 89, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/lib/python2.3/site-packages/django/db/models/options.py",
line 70, in contribute_to_class
raise TypeError, "'class Meta' got invalid attribute(s): %s" %
','.join(meta_attrs.keys())
TypeError: 'class Meta' got invalid attribute(s): abstract

What can be the problem?

Julien

unread,
May 16, 2008, 10:25:13 AM5/16/08
to Django users
Hi,

I think it should be %(class)s, not %s(class)s (take out the first
's')

Julien

Legioneer

unread,
May 16, 2008, 5:51:42 PM5/16/08
to Django users
It looks that this is not the case. The problem seems to be more
general. When I add abstract=True to ANY model I receive the same
error. Example:

class OrderItem(models.Model):
num = models.IntegerField(default=1)
timestamp = models.DateTimeField(auto_now=True)

class Meta:
abstract = True

Matthias Kestenholz

unread,
May 17, 2008, 2:50:57 AM5/17/08
to django...@googlegroups.com
On Fri, 2008-05-16 at 14:51 -0700, Legioneer wrote:
> It looks that this is not the case. The problem seems to be more
> general. When I add abstract=True to ANY model I receive the same
> error. Example:
>
> class OrderItem(models.Model):
> num = models.IntegerField(default=1)
> timestamp = models.DateTimeField(auto_now=True)
>
> class Meta:
> abstract = True
>

%s(class)s will not do what you want:

>>> '%s(class)s' % {'class': 'WhatEver'}
"{'class': 'WhatEver'}(class)s"
>>> '%(class)s' % {'class': 'WhatEver'}
'WhatEver'


Are you sure your django version is recent enough? The queryset-refactor
branch merge did not happen a long time ago, an old subversion checkout
or even a released django version (f.e. 0.96.1) won't do.


--
http://spinlock.ch/blog/

Reply all
Reply to author
Forward
0 new messages