Well, if I understand you correctly, you should have any trouble, as long as a parent relationship actually exists. From the code given, you aren't creating explicit relationships inside your CustomCategory class, so I assume you're falling back on Satchmo's category relationships. If you subclassed CustomCategory from Category, it now has all the attributes of a CustomCategory AND a Category.
So, if I have: c = CustomCategory.objecst.select_related().get(id=2) Then I should be able to access the 'code' for c as: print c.code For the parent (I'm not certain how Satchmo structures these right now as I don't use categories): print c.parent_category.code Just replace parent_category with whatever field Satchmo's Category model uses to point to the immediate parent. On Thu, Mar 19, 2009 at 2:09 AM, welyou <[email protected]> wrote: > > yes. > > addition question, if i have > class CustomCategory(Category): > code = models.CharField(_("Code"), max_length=20) > > and i save two instance CustomCategory category: > (1)Parent > (2)Child > > then i get by id instance of second "(2)Child" - child_cat > > child_cat.parent - returns CustomCategory instance? (without my > "code") it's right? > > How i can get "code" of "parent" from child instance? > > Mar 19, 9:10 am, Bob Waycott <[email protected]> wrote: > > if you defined your class like this: > > class CustomCategory(Category): > > # special fields > > > > You get all categories the traditional Satchmo way, via Category: > > > > Category.objects.all() > > > > You get all your custom categories like so: > > > > CustomCategory.objects.all() > > > > That will only return those categories that are also defined in the > > CustomCategory table. > > > > Make sense? > > > > On Wed, Mar 18, 2009 at 9:41 PM, welyou <[email protected]> wrote: > > > > > Thanks, Bob! > > > > > category.child.all() (for my CustomCategory) returns Category objects > > > (not CustomCategory) > > > > > if i want get, in this case, CustomCategory, what i do need? It is > > > possible? > > > > > On Mar 18, 8:49 pm, Bob Waycott <[email protected]> wrote: > > > > I'd recommend subclassing Category and create your own custom > > > CustomCategory > > > > class. > > > > You will have minimal impact on Satchmo operations, will ensure that > a > > > > Satchmo category is saved/updated each time a CustomCategory is > > > > saved/updated, and will have a model that you can define any methods > you > > > > need for without affecting Satchmo and breaking your upgrade path. > > > > > > On Wed, Mar 18, 2009 at 3:07 AM, welyou <[email protected]> > wrote: > > > > > > > We develophttp://code.google.com/p/django-satchmo-tuning/" - > "Tuning > > > > > Satchmo for wholesale store" > > > > > > > We tuning Satchmo for web presentation of data stored in accounting > > > > > system. > > > > > > > And have problem, how to correct extend Category (subclass/inherit > or > > > > > create one-to-one relation with addition entity)? > > > > > > > Every hour data from account system will be uploaded/updated into > site > > > > > shop data base. > > > > > > > In accounting system category have code and name attributes, for > > > > > ability sync operation between site and accounting system i must > have > > > > > "code". > > > > > > > Addition "active" attribute we needed for hide some category from > > > > > category catalog. > > > > > > > How do this more correct? > > > > > > > Help, please :)! > > > > > > > P.S. > > > > > Maybe Satchmo developers add "code,active" into class Category > source > > > > > satchmo? > > > > > > > Needing of "active" attribute for Category already discussed. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Satchmo users" 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/satchmo-users?hl=en -~----------~----~----~----~------~----~------~--~---
