#419 closed enhancement (duplicate)
Create meta.AbstractModel
Reported by: | Adrian Holovaty | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Metasystem | Version: | |
Severity: | enhancement | Keywords: | |
Cc: | eric@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
class BaseModel(meta.Model): foo = meta.CharField(maxlength=200) class FirstChild(BaseModel): bar = meta.CharField(maxlength=10) class SecondChild(BaseModel): bar = meta.CharField(maxlength=10)
In this example, BaseModel
only exists as an "abstract class" -- its only purpose is to be extended. We don't want to install SQL for it, and we don't want it to be available via the API. So we could introduce a meta.AbstractModel
for models that serve this purpose.
Attachments (1)
Change History (5)
comment:1 by , 19 years ago
priority: | normal → low |
---|---|
Type: | defect → enhancement |
comment:2 by , 19 years ago
Cc: | added |
---|
by , 19 years ago
Attachment: | django-core-meta-__init__.py.diff added |
---|
Proposed "no_table" patch to django/core/meta/init.py
comment:3 by , 19 years ago
I am using the no_table-patch in my project and it works fine. It's quite useful, I think it would be no mistake to include this in the trunk.
comment:4 by , 19 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This will be fixed in magic-removal with mixins.
Note:
See TracTickets
for help on using tickets.
Here's a proposed patch that acheives the same result, but without creating a meta.AbstractModel. It passes the django unit tests existing as of today.
To summarize, it modifies django/core/meta/init.py to:
The result is that the model isn't included in other functions that
operate on meta.MODEL classes while still allowing inheritance.
I've only tested it lightly, with the existing unit tests and my simple
"experiment" classes.
If you like the fix, please tell me how you like your patch submissions
formatted and/or what other test(s) you'd like to see. I'll then clean
it up and write unit tests like the existing ones that generate the
model example documentation.
Eric.
[ewalstad@pasauran django_src]$ python tests/runtests.py
Running tests with database 'postgresql'
All tests passed.
experiment.py file:
[ewalstad@pasauran django_src]$ django-admin.py sql experiment
Mailing list posting: http://groups.google.com/group/django-users/browse_frm/thread/75aebf82055172cf/c0cea4033973f7c8?q=no_table&rnum=1#c0cea4033973f7c8