Hey Karen. I used manage.py validate. My model validated before I added the abstract class and changed the class signatures. But I probably did something silly. Here is a chunk of the code:
# will use this for subclassing into our item subtypes class AbstractType(models.Model): name = models.CharField(max_length=100) class Meta: abstract = True class Item(models.Model): """Item information for survey pages - pages will contain one or more of these""" sub_item = models.ForeignKey(AbstractType) order = models.IntegerField() class Admin: pass class Page(models.Model): """Page information for pages - surveys will contain one or more of these""" survey = models.ForeignKey(Survey) item = models.ForeignKey(Item) order = models.IntegerField() file_name = models.CharField(max_length=50) class Admin: pass class RadioBoxType(AbstractType): """A Radio Button object with its specific attributes""" question_text = models.CharField(max_length=100) question_sub_text = models.CharField(max_length=100) item_type = models.CharField(max_length=20) required = models.BooleanField() randomize = models.BooleanField() splitlist = models.BooleanField() include_other = models.BooleanField() other_prompt = models.CharField(max_length=100) other_maxlen = models.IntegerField() other_box_size = models.IntegerField() class Admin: pass Well there is some of the model code - thanks for taking a look - I think I need to spend a couple of weeks reading 24 hours a day to get up to speed on all this technology, But I have just escaped from dot niet and asp and sql server etc etc. Oh, what a feeling, what a rush! Cheers On May 6, 2:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Tue, May 6, 2008 at 2:25 PM, Peter Bailey <[EMAIL PROTECTED]> wrote: > > > Hey alen. I have tried implementing this and it makes good sense as > > far as I can see, but when I validate the model I always get an > > AttributeError: 'NoneType' object has no attribute 'name'. > > How are you validating the model? > > I have tried removing name from the definition of the class - same > > > message (not sure where it is getting 'name' from since I deleted it. > > I also looked around and saw that some other have had similar > > problems, and it seemed to be a string definition problem. So I put > > back 'name' and changed it to an IntegerField - same unhappy result. > > > Do you have any notion of what the problem is? The code looks right to > > me. > > It sounds like you have some code somewhere that is expecting to always be > handed an instance of your model, and thus be able to access the field > 'name', but it is in fact sometimes getting handed None. When handed None, > it still tries to access 'name', but since None has no attribute 'name', you > get the error. If you post the code someone could probably help pinpoint > the error more specifically. > > Karen > > > > > Thanks, > > > Peter > > > On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote: > > > Thanks very much for your solution and reply alen. I'm learning the > > > ins and outs of python and django at the same time - fun adventure - > > > so far python is blowing me away - I love it. Better than anything I > > > have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc > > > (guess I am dating myself lol - most people don't seem to even ever > > > have looked at assembler these days. I used to love it - 7 years of > > > that after university) Oh, and of course C was always the bomb too :-) > > > > Thanks again, > > > > Peter > > > > On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > > wrote: > > > > > Define a 'abstract' attribute of Meta inner class and set it to true > > > > like so: > > > > > class AbstractType(models.Model): > > > > name = models.CharField(max_length=100) > > > > > class Meta: > > > > abstract = True > > > > > class RadioBoxTypes(AbstractType): > > > > radio_lable = models.CharField(max_length=20) > > > > > Regards, > > > > -Alen > > > > > On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote: > > > > > > I have designed a small db model (on paper) and want to implement it > > > > > in my models.py file. So far, this has been pretty straight forward, > > > > > but I have a generic superclass and several subclasses, and I am > > > > > unsure how to implement this. > > > > > > My DB has page objects (webpages) with a few common attributes, and > > a > > > > > fk to an Item object. The item object is the generic superclass. It > > > > > could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all > > > > > have attributes specific to themselves. > > > > > > Anyway, I don't grok how to set up this type of relationship in my > > > > > models.py file. Is there a standard way of doing this, or does > > anyone > > > > > have an suggestions or can point me to some relevant info? > > > > > > e.g. Pages - pointed to by fk in Items > > > > > ---------- > > > > > > Items - has key to one of the below > > > > > -------- > > > > > > RadioBoxTypes CheckboxTypes VerbatimTypes etc > > > > > ----------------------- ----------------------- > > > > > --------------------- ---- > > > > > > Thanks very much. Sorry if this is a dumb question - always fun > > being > > > > > a newbie :-( > > > > > > Peter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---