Treebeard Administrator at Django

I installed Treebeard in Django and everything seems to have gone well. I tried to configure the admin system, and I see that my models are represented in the admin interface. However, when I try to add new data using the admin interface, I get the following error in my template. The code is still working fine and I checked my DB and the data seems to be inserted correctly. However, the view does not seem to load properly. Any idea what causes this?

The exception am get is:

Rendering exception showing: unsuccessful key search [request] in u '[{\' action_index \ ': 0, \ block \': ,,,]>}, {\ 'block \': ,,]> ,,, \ n \ '>,]>,]> ,,]> ,, \ n \'>> ,,,,,] →,]>, \ n \ '>]>}, {\' cl \ ':, \ 'root_path \': None, \ 'actions_on_bottom \': False, \ 'title \': u \ 'Select an album to modify \', \ 'has_add_permission \': True, \ 'media \' :, \ 'is_popup \ ': False, \' action_form \ ':, \' actions_on_top \ ': True, \ app_label \': \ 'gallery \'}, {\ 'MEDIA_URL \': \ '\'}, {\ 'LANGUAGES \ ': ((\' ar \ ', \' Arabic \ '), (\' bn \ ', \' Bengali \ '), (\ bg \', \ 'Bulgarian \'), (\ 'ca \' , \ 'Catalan \'), (\ cs \ ', \'Czech \ '), (\' cy \ ', \' Welsh \ '), (\ da' ', \' Danish \ '), (' de ', \' German \ '), (\' el \ ' , \ 'Greek \'), (\ 'en \', \ 'English \'), (\ 'es \', '' Spanish ''), ('et', '' Estonian ''), (\ es-ar \ '', '' Argentinean Spanish ''), ('' eu '', 'Basque' '), (\' fa \ ',' Persian '), (\' fi \ ', \' Finnish '), (\' fr \ ', \' French \ '), (\ ga \', \ 'Irish \'), (\ gl \ ', \' Galician \ '), (\ hu \, "Hungarian "), (" he "," Hebrew "\ '), (\ hi \', \ 'Hindi \'), (\ hr \ ', \' Croatian \ '), (\' is \ ',' ' Icelandic), (\ it \ ', \' Italian \ '),(\ 'ja \', \ 'Japanese \'), (\ 'ka \', \ 'Georgian \'), (\ ko \ ', \' Korean \ '), (\ km \', \ 'Khmer \ '), (\ kn \', \ 'Kannada \'), (\ lv \ ', \' Latvian \ '), (\ lt lt', "Lithuanian"), ("mk", "Macedonian") , ("nl", "Dutch"), ("no", "Norwegian") (\ 'pl \', \ 'Polish \'), (\ 'pt \', \ 'Portuguese \'), (\ 'pt-br \', \ 'Brazilian Portuguese' '), (\' ro \ '', '' Romanian ''), (\ 'ru \', \ 'Russian \'), (\ 'sk \' , \ 'Slovak \'), (\ 'sl \', \ 'Slovenian \'), (\ 'sr \', \ 'Serbian \'), ('sv \', \ 'Swedish \'), ( \ ta \ ', \' Tamil \ '), (\ te, \'Th \ ', \' Thai \ '), (\' tr \ ', \' Turkish \ '), (\' uk \ ', \' Ukrainian \ '), (\\' zh-cn \ ', \ 'simplified Chinese \')), (\ zh-tw \ ', \' Traditional Chinese \ ')), \ LANGUAGE_BIDI \': False, \ LANGUAGE_CODE \ ': \' en-us \ '}, {}, {\ 'perms \' :, \ 'messages \': [], \ 'user \':}, {}] '

, Django.

admin.py:

class MP_Album_Admin(TreeAdmin):
 pass

admin.site.register(Album,MP_Album_Admin)
+3
5

. 'django.core.context_processors.request' TEMPLATE_CONTEXT_PROCESSORS settings.py.

"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media"

.

+3

'django.core.context_processors.request' TEMPLATE_CONTEXT_PROCESSORS settings.py.

+2

, "treebeard" INSTALLED_APPS.

settings.py . PROJECT_PATH = os.path.dirname(os.path.abspath(__ file__)), TEMPLATE_DIRS :

TEMPLATE_DIRS = (
    PROJECT_PATH + '/templates',
)
+1

.., ... . .

.py .. TEMPLATE_DIRS = (   # , "/home/html/django_templates" "C:/www/django/templates".   # Windows.   # , .    "//MYPROJ/",    "//MYPROJ//",),

My views.py .. def index ():   return render_to_response ('index.html')

Postmortem , "/Projects/myProj/templates" , settings.py index.html.

0

. TreeAdmin Adjacency .

: [] u '[{\' block\':,,,] > }, {\' block\':,,] > ,,,\n\' > ,] > ,] > ,,] > ,,\n \' > ,,,,,],] > ,\n\ > ] > }, {\ 'cl \':,\'root_path \': None,\'actions_on_bottom \': False,\'title \': u\' " ", "\", has_add_permission\': True,\media \':, 'is_popup \': False,\'action_form \':,\'actions_on_top \': True,\app_label\': \' nested\'}, {\'MEDIA_URL \':\'\'}, {\ 'LANGUAGES \': ((\ 'ar \',\'Arabic \'), (\ bn\', \' Bengali\'), (\ 'bg \',\'Bulgarian \'), (\ 'ca \',\'Catalan \'), (\ cs\', \' Czech\'), (\' cy\', \' Welsh (\ 'da \',\' \'), ('de',\'German \'), (\ 'el \',\'Greek \'), (\ en\', \' English\'), (\' es\',' 'Spanish' '), (' et ',' 'Estonian' '), (\' es-ar\', \' Argentinean ), (\ 'eu \', 'Basque \'), (\ 'fa \',\'Persian \'), (\ 'fi \',\'Finnish \'), (\ fr\', \' French\'), (\ ga \',\'Irish \'), (\ gl\', \' \'), (\ hu \',\'Hungarian\'), (\' he\', \' Hebrew\'), (\ 'hi \',\'Hindi \'), (\ hr\', \' Croatian\'), (\',\')', (\ it it ', \' Italian\'), (\' ja\', \' Japanese\'), (\' ka\', \' Georgian\'), (\ ko \',\'Korean \'), (\ km\', \' Khmer\'), (\' kn\', \' Kannada\'), (\ lv \',\'Latvian \'), (\ 'lt \',\'Lithuanian \'), (\ mk\', \' \'), (\nl \',\'Dutch \'), (\ 'no \',\'Norwegian \'), (\ pl \, "" ), ( "pt", "" ), ( "pt-br", " " ), ( "ro", "" ) '), (\' ru\', \' Russian\'), (\' sk\', \' Slovak\'), (\ sl \',\'Slovenian \'), (\ sr\',' '), (\' sv\', \' Swedish\'), (' ta\',' 'Tamil' '), (\ te \',\'Telugu \'), (\ 'th \',\'Thai \'), (\ 'tr \',\'Turkish \'), (\ 'uk \',\'Ukrainian \'), (\ zh-cn\', \' \'), (\ zh-tw \',\'Traditional Chinese \')),\LANGUAGE_BIDI\': False,\LANGUAGE_CODE \':\'en-us \'}, {}, {\ 'perms \':,\'messages \': [],\'user \':}, {}] '

Model for nested sets:

from django.db import models
from treebeard.ns_tree import NS_Node

class Category(NS_Node):
    name  = models.CharField(max_length=255)

    def get_absolute_url(self):
        return ('node-view', ('ns', str(self.id),))

    def __unicode__(self):
        return u'NS_Post %d: %s' % (self.id, self.name)

class Meta:
    verbose_name = 'Nested Set Tree Post'

    # when adding a custom Meta class to a NS model, the ordering must be
    # set again
    ordering = ['tree_id', 'lft']

Contact List Model:

from django.db import models
from treebeard.al_tree import AL_Node

class Category(AL_Node):
    name  = models.CharField(max_length=255)
    parent = models.ForeignKey('self',related_name='children_set',null=True,blank=True,db_index=True)
    node_order_by = ['name']

    @models.permalink
    def get_absolute_url(self):
       return ('node-view', ('al', str(self.id),))

    def __unicode__(self):
        return self.name

I tried to fix it with

TEMPLATE_CONTEXT_PROCESSORS = 'django.core.context_processors.request'

in settings.py, like ml, it was suggested on March 27 at 23:16. Now i have an error

Exception Type:     ValueError
Exception Value:    Empty module name
0
source

Source: https://habr.com/ru/post/1738430/


All Articles