On Thu, Oct 16, 2008 at 11:46 AM, nostradamnit <[EMAIL PROTECTED]>wrote:

>
> Nope, doesn't work?!? I've tried every possible combination that I can
> think of. Is there a known method of inheriting/using/appropriating an
> existing model in a new model.py? My code works with an independent
> Country model, but I don't want a new Country table, I want to use the
> existing one... There must be a way to do this.
>

First, the problem you are having with the import is that you want to import
from *models*.

from satchmo.l10n.models import Country

However, you can't just extend a Django model and add to the object. Not
like you are thinking anyway.  What you want to do is to make a new model,
and link the one you want to "extend" with a OneToOne field.  Here's an
example from tieredpricing.  I wanted to extend the
satchmo.contrib.auth.models.Group object to give discounts to people in
certain groups.

class PricingTier(models.Model):
    """A specific pricing tier, such as "trade customers"
    """
    group = models.OneToOneField(Group, help_text=_('The user group that
will receive the discount'))
    title = models.CharField(_('Title'), max_length=50)
    discount_percent = models.DecimalField(_("Discount Percent"), null=True,
blank=True,
        max_digits=5, decimal_places=2,
        help_text=_("This is the discount that will be applied to every
product if no explicit Tiered Price exists for that product.  Leave as 0 if
you don't want any automatic discount in that case."))

Please refer to
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.OneToOneFieldfor
quite usable and understandable documentation about how this works.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to