I am developing a web with django, and in my model I need to superclass
all model classes with a superclass that add some methods.
The problem is django-admin.py create a dummy table not needed for this
superclass. I know that multiple-inheritance can be useful here, but I
can consider some times that multiple-inheritance doesn't works (for
example, I wanted to change __metaclass__ of several classes in my
model).
I patched django for permit abstract classes in a model. My syntax maybe
doesn't like to someone...
Here are a model example of use:
class FooSuperclass(models.Model):
__abstract__ = True
def oneFunction(self, x, y):
...
class FooClass(FooSuperclass):
age = models.IntegerField()
--
Manuel Saelices
[EMAIL PROTECTED]
ICS Yaco S.L.
http://www.yaco.es/
Tlfno. +34 954 50 00 57
Fax +34 954 50 09 29
C/ Sierpes, 48
Sevilla
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---
Index: django/db/models/base.py
===================================================================
--- django/db/models/base.py (revisión: 3641)
+++ django/db/models/base.py (copia de trabajo)
@@ -23,6 +23,9 @@
# If this isn't a subclass of Model, don't do anything special.
if not bases or bases == (object,):
return type.__new__(cls, name, bases, attrs)
+ # If __abstract__ attribute declared, don't do anything more
+ if '__abstract__' in attrs:
+ return type.__new__(cls, name, bases, attrs)
# Create the class.
new_class = type.__new__(cls, name, bases, {'__module__': attrs.pop('__module__')})