Fix setting app_label correctly for typeclass
This commit is contained in:
parent
a721760da6
commit
e8b99175ad
3 changed files with 16 additions and 4 deletions
|
|
@ -88,6 +88,7 @@ class AccountForm(forms.ModelForm):
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
model = AccountDB
|
model = AccountDB
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
app_label = "accounts"
|
||||||
|
|
||||||
db_key = forms.RegexField(
|
db_key = forms.RegexField(
|
||||||
label="Username",
|
label="Username",
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,8 @@ class AccountDB(TypedObject, AbstractUser):
|
||||||
__applabel__ = "accounts"
|
__applabel__ = "accounts"
|
||||||
__settingsclasspath__ = settings.BASE_SCRIPT_TYPECLASS
|
__settingsclasspath__ = settings.BASE_SCRIPT_TYPECLASS
|
||||||
|
|
||||||
class Meta(object):
|
# class Meta:
|
||||||
verbose_name = "Account"
|
# verbose_name = "Account"
|
||||||
|
|
||||||
# cmdset_storage property
|
# cmdset_storage property
|
||||||
# This seems very sensitive to caching, so leaving it be for now /Griatch
|
# This seems very sensitive to caching, so leaving it be for now /Griatch
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,20 @@ class TypeclassBase(SharedMemoryModelBase):
|
||||||
attrs["path"] = "%s.%s" % (attrs["__module__"], name)
|
attrs["path"] = "%s.%s" % (attrs["__module__"], name)
|
||||||
|
|
||||||
# typeclass proxy setup
|
# typeclass proxy setup
|
||||||
if "Meta" not in attrs:
|
app_label = None
|
||||||
|
# first check explicit __applabel__ on the typeclass
|
||||||
|
if "__applabel__" not in attrs:
|
||||||
|
# find the app-label in one of the bases, usually the dbmodel
|
||||||
|
for base in bases:
|
||||||
|
try:
|
||||||
|
attrs["__applabel__"] = base.__applabel__
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
class Meta(object):
|
if "Meta" not in attrs:
|
||||||
|
class Meta:
|
||||||
proxy = True
|
proxy = True
|
||||||
app_label = attrs.get("__applabel__", "typeclasses")
|
app_label = attrs.get("__applabel__", "typeclasses")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue