You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
str returned non-string (type NoneType)
when choosing to enter another language in admin.
Step to reproduce:
In admin you can select one of the language tabs: If you fill in one then save - No problems /Errors. When you then go back into the entry to add another language it causes the no string type error.
Model
class MainMenu(MPTTModel, TranslatableModel):
"""
Model defines the main menu for the application
"""
id = models.UUIDField(
primary_key=True,
default=uuid.uuid4,
editable=False
)
parent = TreeForeignKey(
"self",
on_delete=models.CASCADE,
null=True,
blank=True,
related_name='child'
)
translations = TranslatedFields(
name=models.CharField(
max_length=50,
help_text="Enter the display name",
verbose_name="name",
blank=True,
null=True
),
slug=models.SlugField(
max_length=200,
db_index=True),
)
icon = models.CharField(
max_length=40,
help_text="Enter the icon name",
verbose_name="Display Icon"
)
url = models.CharField(
max_length=255,
help_text="Enter the url name",
verbose_name="Url"
)
order = models.IntegerField(
verbose_name="Menu order",
help_text="Choose menu order",
)
class MPTTMeta:
order_insertion_by = ['order']
class Meta:
verbose_name = "Menu item"
def __str__(self):
return self.safe_translation_getter('name', any_language=True)
objects = NavigationManager()
Manager:
class NavigationQuerySet(TranslatableQuerySet, TreeQuerySet):
def as_manager(cls):
# make sure creating managers from querysets works.
manager = NavigationManager.from_queryset(cls)()
manager._built_with_as_manager = True
return manager
as_manager.queryset_only = True
as_manager = classmethod(as_manager)
class NavigationManager(TreeManager, TranslatableManager):
_queryset_class = NavigationQuerySet
Admin:
class NavigationAdminForm(MPTTAdminForm, TranslatableModelForm):
pass
class NavigationAdmin(TranslatableAdmin, MPTTModelAdmin):
form = NavigationAdminForm
def get_prepopulated_fields(self, request, obj=None):
return {'slug': ('name',)} # needed for translated fields
admin.site.register(MainMenu, NavigationAdmin)
The text was updated successfully, but these errors were encountered:
str returned non-string (type NoneType)
when choosing to enter another language in admin.
Step to reproduce:
In admin you can select one of the language tabs: If you fill in one then save - No problems /Errors. When you then go back into the entry to add another language it causes the no string type error.
Model
Manager:
Admin:
The text was updated successfully, but these errors were encountered: