Django中的类别和子类别

时间:2018-02-08 16:43:16

标签: python django

我有点问题。我为类别和帖子创建了一个模型。在我的项目中,我使用了categories->子类别模型。当我完成创建超级用户并登录管理面板时,我会显示字段'类别'和'帖子'。当我想添加一个新类别作为父类时,我需要添加子项。我添加了1条记录'Biznes'和Child'WłasnaFirma'。我点击了下一步添加,那一刻管理员面板思考,思考而不回应。我无法添加帖子,删除或编辑类别。这是我的  的 models.py

from django.contrib import admin
from .models import Kategoria, Firma

class KategoriaAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')
    prepopulated_fields = {'slug' :('name',)}

admin.site.register(Kategoria, KategoriaAdmin)
admin.site.register(Firma)

admin.py

(myvenv) λ python manage.py runserver
> d:\django\firmy\ogloszenia\models.py(5)<module>()
-> class Kategoria(models.Model):
(Pdb) n
> d:\django\firmy\ogloszenia\models.py(25)<module>()
-> class Firma(models.Model):
(Pdb) n
--Return--
> d:\django\firmy\ogloszenia\models.py(25)<module>()->None
-> class Firma(models.Model):
(Pdb) n
--Return--
> <frozen importlib._bootstrap>(219)_call_with_frames_removed()->None
(Pdb) n
--Return--
> <frozen importlib._bootstrap_external>(678)exec_module()->None
(Pdb) n
--Call--
> <frozen importlib._bootstrap>(318)__exit__()
(Pdb) n
> <frozen importlib._bootstrap>(319)__exit__()
(Pdb) n
> <frozen importlib._bootstrap>(320)__exit__()
(Pdb) n
> <frozen importlib._bootstrap>(321)__exit__()
(Pdb) n
> <frozen importlib._bootstrap>(327)__exit__()
(Pdb) n
> <frozen importlib._bootstrap>(329)__exit__()
(Pdb) n
--Return--
> <frozen importlib._bootstrap>(329)__exit__()->None
(Pdb) n
> <frozen importlib._bootstrap>(670)_load_unlocked()
(Pdb) n
--Return--
> <frozen importlib._bootstrap>(670)_load_unlocked()-><module 'oglo...a\\models.py'>
(Pdb) n
> <frozen importlib._bootstrap>(956)_find_and_load_unlocked()
(Pdb) n
> <frozen importlib._bootstrap>(958)_find_and_load_unlocked()
(Pdb) n
> <frozen importlib._bootstrap>(959)_find_and_load_unlocked()
(Pdb) n
> <frozen importlib._bootstrap>(960)_find_and_load_unlocked()
(Pdb) n
--Return--
> <frozen importlib._bootstrap>(960)_find_and_load_unlocked()-><module 'oglo...a\\models.py'>
(Pdb) n
--Call--
> <frozen importlib._bootstrap>(151)__exit__()
(Pdb) n
> <frozen importlib._bootstrap>(152)__exit__()
(Pdb) n
--Return--
> <frozen importlib._bootstrap>(152)__exit__()->None
(Pdb) n
--Return--
> <frozen importlib._bootstrap>(971)_find_and_load()-><module 'oglo...a\\models.py'>
(Pdb) n
--Return--
> <frozen importlib._bootstrap>(994)_gcd_import()-><module 'oglo...a\\models.py'>
(Pdb) n
--Return--
> c:\python36\lib\importlib\__init__.py(126)import_module()-><module 'oglo...a\\models.py'>
-> return _bootstrap._gcd_import(name[level:], package, level)
(Pdb) n
--Return--
> d:\django\myvenv\lib\site-packages\django\apps\config.py(198)import_models()->None
-> self.models_module = import_module(models_module_name)
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(111)populate()
-> for app_config in self.app_configs.values():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(114)populate()
-> self.clear_cache()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(116)populate()
-> self.models_ready = True
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(120)populate()
-> app_config.ready()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(120)populate()
-> app_config.ready()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(120)populate()
-> app_config.ready()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(120)populate()
-> app_config.ready()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(120)populate()
-> app_config.ready()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(120)populate()
-> app_config.ready()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(120)populate()
-> app_config.ready()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(119)populate()
-> for app_config in self.get_app_configs():
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(122)populate()
-> self.ready = True
(Pdb) n
--Return--
> d:\django\myvenv\lib\site-packages\django\apps\registry.py(122)populate()->None
-> self.ready = True
(Pdb) n
--Return--
> d:\django\myvenv\lib\site-packages\django\__init__.py(24)setup()->None
-> apps.populate(settings.INSTALLED_APPS)
(Pdb) n
--Return--
> d:\django\myvenv\lib\site-packages\django\utils\autoreload.py(225)wrapper()->None
-> fn(*args, **kwargs)
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\core\management\__init__.py(349)execute()
-> self.autocomplete()
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\core\management\__init__.py(351)execute()
-> if subcommand == 'help':
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\core\management\__init__.py(360)execute()
-> elif subcommand == 'version' or self.argv[1:] == ['--version']:
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\core\management\__init__.py(362)execute()
-> elif self.argv[1:] in (['--help'], ['-h']):
(Pdb) n
> d:\django\myvenv\lib\site-packages\django\core\management\__init__.py(365)execute()
-> self.fetch_command(subcommand).run_from_argv(self.argv)

编辑: 当我使用调试器时,我收到了一个日志:

df
   people_emotions_anger  people_emotions_joy  people_emotions_surprise  foo  \
0                      1                    2                         3    4   

   bar  
0    5  

df[[x for x in df.columns if x.startswith('people_emotions')]]
   people_emotions_anger  people_emotions_joy  people_emotions_surprise
0                      1                    2                         3

0 个答案:

没有答案