#7713: newforms-admin has issues with model inheritance
----------------------------------------------+-----------------------------
 Reporter:  zobbo                             |       Owner:  nobody        
   Status:  new                               |   Milestone:                
Component:  Admin interface                   |     Version:  newforms-admin
 Keywords:  newforms-admin model inheritance  |       Stage:  Unreviewed    
Has_patch:  0                                 |  
----------------------------------------------+-----------------------------
 You'll need to apply the patch in #7588 to test this, otherwise you'll
 just get a python traceback

 Take the following class:
 {{{
 from django.db import models

 # Create your models here.

 from django.db import models
 import datetime

 class BaseModel(models.Model):
     """Abstract class used for some common fields"""
     created_at = models.DateTimeField(blank=True,
 default=datetime.datetime.now)
     modified_at = models.DateTimeField(blank=True,
 default=datetime.datetime.now)
     class Meta:
         abstract = True

 class Item(BaseModel):
     """Everything in the system - multi table inheritance"""
     code = models.CharField(blank=True, max_length=15) # A shortname
     description = models.CharField(blank=True, max_length=50)

 class ValuedItem(Item):
     """This is an abstract base class for stuff with a value"""
     value = models.FloatField(default=0.0)
     class Meta:
         abstract = True

 class PlayableItem(ValuedItem):
     """Inheriting from our abstract ValuedItem class"""
     funfactor = models.IntegerField(blank=True, null=True) # Amount of fun

     class Admin:
         pass

 /* The admin stuff, normally in admin.py */

 from django.contrib import admin
 from django.contrib.admin.sites import AlreadyRegistered

 class PlayableItemAdmin(admin.ModelAdmin) :
     model = PlayableItem
     list_display = ('code','description',)
     list_filter = ('code',)
     search_fields=('code','description')

 try:
     admin.site.register(PlayableItem, PlayableItemAdmin)
 except AlreadyRegistered:
     pass
 }}}
 Now try and add a playable item through the admin interface. By default
 the item ptr appears and won't let you save the record until it's been
 filled in. And of course, you can't fill it in, because the item it needs
 to point to is not saved yet. I'd assume these ptr fields should be
 automatically hidden and filled in by the admin mechanism. Attached
 graphic of the form behaviour.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7713>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to