Reverse for 'filer_folder_changelist' not found - django

I am deploying site to divio server with django and django-cms. I do R&D but not found much information about this.
Facing Error: Reverse for 'filer_folder_changelist' not found. 'filer_folder_changelist' is not a valid view function or pattern name.
Exception Type: NoReverseMatch Exception Value: Reverse for
'filer_folder_changelist' not found. 'filer_folder_changelist' is not
a valid view function or pattern name. Exception
Location: /virtualenv/lib/python3.5/site-packages/django/urls/resolvers.py
in _reverse_with_prefix, line 497 Python
Executable: /virtualenv/bin/uwsgi
{% cms_toolbar %}
**urls.py:**
] + aldryn_addons.urls.patterns() + i18n_patterns(
# test urls
url(r'^admin-cms/', include(admin.site.urls)), # NOQA
url(r'^django-cms/', include('cms.urls')),
url(r'^django-cms1/',include('aldryn_django_cms.urls')),
url(r'^test4/$',views.test4,),
# ends here ~ test urls
# add your own i18n patterns here
*aldryn_addons.urls.i18n_patterns() # MUST be the last entry!
)
cms_toolbar.py
def populate(self):
media_library = _('Media library')
admin_menu = self.toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER)
admin_menu.add_sideframe_item(
media_library,
url=reverse('admin:filer_folder_changelist'),
position=self.get_insert_position(admin_menu, media_library)
)

Did some research and found this:
Need to install django-admin-shortcuts
Add shortcut to your settings.py:
ADMIN_SHORTCUTS = [
{
'shortcuts': [
{
'url_name': 'admin:filer_folder_changelist',
'title': _('Files'),
},
]
},
]
You can check out similar implementation in here. Hope it helps!!

I fixed this error by change settings.py.. Add below things in installed app in settings.py:
INSTALLED_APPS.extend([
.....
'djangocms_text_ckeditor',
'filer',
'easy_thumbnails',
'djangocms_column',
'djangocms_file',
'djangocms_link',
'djangocms_picture',
'djangocms_style',
'djangocms_snippet',
'djangocms_googlemap',
'djangocms_video',
.....
)]

Related

Django Debug Toolbar BaseConnectionHandler.all() error

I am using docker and the debug toolbar gives the following error:
BaseConnectionHandler.all() got an unexpected keyword argument 'initialized_only'
I wrote the following code in the settings.py file :
if DEBUG:
MIDDLEWARE += [
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
INSTALLED_APPS += [
'debug_toolbar',
]
import os
import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "10.0.2.2"]
I wrote the following code in the urls.py file :
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
]
For some reason django-debug-toolbar==3.5.0 broke backward compatability with Django lower than 4.1b1.
In 3.5.0 next changes were added:
https://github.com/jazzband/django-debug-toolbar/commit/4b77ec74f2d326013d715453d7a2219e574c3f6a#diff-72ecd973e54107d746eff0947206cbdbe24cbb3c42216b00615e64d49ca70d73R216-R217
But those changes need this changes in Django 4.1b1 to work:
https://github.com/django/django/commit/4f92cf87b013801810226928ddd20097f6e4fccf#diff-dbe1d4538efcca9f9a6157d5d3de919e0844835a7ccc698bb8c5d4a9eb06e274R75-R81
Fix the version of django-debug-toolbar to 3.4.0 before issue is solved. Opened issue in github:
https://github.com/jazzband/django-debug-toolbar/issues/1645
UPD: Django 3.2.4+ will also work and thats probably better solution.

NoReverseMatch at /auth/password/reset/

I am using dj-rest-auth package to do auth related functions, installed the package and added to installed apps and included it in main url as follows
path('auth/', include('dj_rest_auth.urls')),
it works for login, logout etc, but when I do password reset it throws the error
http://127.0.0.1:8000/auth/password/reset/
Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name
NoReverseMatch at /auth/password/reset/
Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name.
Request Method: POST
Request URL: http://127.0.0.1:8000/auth/password/reset/
Django Version: 3.2
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name.
Exception Location: /home/biju/Desktop/reporting-system/lib/python3.8/site-packages/django/urls/resolvers.py, line 694, in _reverse_with_prefix
Python Executable: /home/biju/Desktop/reporting-system/bin/python
Python Version: 3.8.10
Python Path:
['/home/biju/Desktop/reporting-system',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/biju/Desktop/reporting-system/lib/python3.8/site-packages']
Server time: Fri, 01 Apr 2022 16:01:18 +0000
the urlpattern in https://github.com/iMerica/dj-rest-auth/blob/master/dj_rest_auth/urls.py:
...
path('password/reset/confirm/', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
...
so you need to change 'password_reset_confirm' to 'rest_password_reset_confirm' in your html url tag or in django function call like reverse()
update:
see https://dj-rest-auth.readthedocs.io/en/latest/faq.html
"You need to add password_reset_confirm url into your urls.py (at the top of any other included urls). Please check the urls.py module inside demo app example for more details."
the package expects something like:
path('password/reset/confirm/<uidb64>/<token>',TemplateView.as_view(template_name="password_reset_confirm.html"),
name='password_reset_confirm'),
path('auth/', include('dj_rest_auth.urls')),
see the demo urls.py: https://github.com/iMerica/dj-rest-auth/blob/24678437b3cdf3fa663880ab66a42aa0992b1d39/demo/demo/urls.py
strange for me that it is mentioned only in the FAQ - looks to me like a bug in the confirm email generation where they use the wrong urlpattern name without the "rest" prefix
.

Stuck two days on this NoReverseMatch thing

Coded in Pycharm
Django version 3.2.6
Project hw_v2
app
aftersales
...
Templates
Project URL
urlpatterns = [
path('', include(('index.urls', 'index'), namespace='index')),
path('admin/', admin.site.urls),
path('mkt/', include(('marketing.urls', 'marketing'), namespace='mkt')),
path('com/', include(('commercial.urls', 'comercial'), namespace='com')),
path('aft/', include(('aftersales.urls', 'aft'), namespace='aft')),
path('gen/', include(('general.urls', 'general'), namespace='gen')),
path('user/',include(('user.urls','user'),namespace='user')),
path('bootstrapTable/',include('bootstrapTable.urls')),]
App/aftersales URL:
urlpatterns = [
path('', views.aft,name='afti'),
path('edit/<int:id>',views.aft_edit,name='aft_edit'),
path('view/<int:id>',views.aft_view,name='aft_view'),]
Error Page HTML:
<td>
</td>
Error:
NoReverseMatch at /aft/view/1
Reverse for 'aft' not found. 'aft' is not a valid view function or pattern name.
Request Method: GET
Request URL: http://127.0.0.1:8000/aft/view/1
Django Version: 3.2.6
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'aft' not found. 'aft' is not a valid view function or pattern name.
Exception Location: D:\0 PROJECTS\14 django_website_ali\hw_v2\venv\lib\site-packages\django\urls\resolvers.py, line 694, in _reverse_with_prefix
Python Executable: D:\0 PROJECTS\14 django_website_ali\hw_v2\venv\Scripts\python.exe
Python Version: 3.9.2
Python Path: [WindowsPath('D:/0 PROJECTS/14 django_website_ali/hw_v2'),
'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\app',
'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2',
'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2',
'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\app',
'D:\\Program Files\\JetBrains\\PyCharm '
'2020.1\\plugins\\python\\helpers\\pycharm_display',
'D:\\Program Files\\Python39\\python39.zip',
'D:\\Program Files\\Python39\\DLLs',
'D:\\Program Files\\Python39\\lib',
'D:\\Program Files\\Python39',
'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\venv',
'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\venv\\lib\\site-packages',
'D:\\Program Files\\JetBrains\\PyCharm '
'2020.1\\plugins\\python\\helpers\\pycharm_matplotlib_backend']
Server time: Fri, 20 Aug 2021 09:01:56 +0800
app/aftersales/views:
def aft_edit(request, id):
item = FFREntry.objects.get(pk=id)
if request.method == "GET":
print(item)
return render(request, 'aft_edit.html', locals())
elif request.method == "POST":
keys = ['engineer', 'date', 'complaint', 'client', 'e_code', 'inv_type', 'inv_model', 'sn', 'region', 'state',
'f_type', 'f_type_d', 'solution', 'is_warr', 'compl', 'remark', 'img', 'video'
]
for key in keys:
if request.POST.get(key):
dict={key:request.POST.get(key)}
FFREntry.objects.filter(id=id).update(**dict)
FFREntry.save
return redirect('aft_view',id=id)
def aft_view(request, id):
item = FFREntry.objects.get(pk=id)
return render(request, 'aft_view.html', locals())
I've been stuck here for two days.
The error came out of nowhere.
One sec ago, it was all ok. Then, the error jumped out.
I am not a programmer. Coding is just a hobby. I have no one I can consult with.
So please please please, save me.
LATEST UPDATES
The project is working now. It is totally creepy and strange. Below is what I did:
In #app/aftersales/url.py
path('', views.aft,name='aft'),
path('aft/edit/<int:id>',views.aft_edit,name='aft_edit'),
path('view/<int:id>',views.aft_view,name='aft_view'),
]
I added 'aft/' in the second path(). Totally out of desperation.
obviously, it's wrong. And error popped.
I deleted the 'aft/'.
Then everything goes back to normal.
I have no idea what happened.
Thanks to everyone who gave me advice! Deeply!
Without seeing your views I can't be sure, but the issue is likely in your template due to the way arguments are being passed into your template tag.
<td>
</td>
Remove the key / equals sign and simply pass the argument value. Assuming the context you're passing the template includes itm this should render the links correctly and the reverse match error will go away.
Before: id=itm.id
After: itm.id
Note that I tested this on one of my own templates by adding the arguments as key value pairs like in your example and got the same error.

Problems with {% URL %} tag

I've been trying to implement hyper links into my Django application, where a list of items are displayed, clicking on each item will take you to a page detailing more information about the item.
I've been wrestling with the {% URL %} tag and despite searching over here, the internet and books on the matter, I've yet to get it working.
In views.py:
def Link(request):
return render_to_response('Search_Page.html')
In Urls.py:
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ParkManager.views.home', name='home'),
# url(r'^ParkManager/', include('ParkManager.foo.urls')),
url(r'^test/', Search_Page),
url(r'^search/', Search),
url(r'^details/', Details_Main),
url(r'^Link/(d+}/$', Link),
url(r'^$', 'Parks.views.Link', name="home"),
in my template:
test
Thanks for your time :)
EDIT
error:
The page loads however the link only takes you to 127 .0 .0 .1 /8000
when I add: test
I get:
NoReverseMatch at /search/
Reverse for 'name' with arguments '(u'North West Thrill Centre',)' and keyword arguments '{}' not found.
Request Method:
GET
Request URL:
http://127.0.0.1:8000/search/?search=a&type=parks&submit=Search
Django Version:
1.4.2
Exception Type:
NoReverseMatch
Exception Value:
Reverse for 'name' with arguments '(u'North West Thrill Centre',)' and keyword arguments '{}' not found.
Exception Location:
C:\Python27\lib\site-packages\django\template\defaulttags.py in render, line 424
Python Executable:
C:\Python27\python.exe
Python Version:
2.7.3
Python Path:
['C:\\Users\\User\\Documents\\Django\\ParkManager',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages']
Server time:
Mon, 4 Feb 2013 16:05:30 +0000
Error during template rendering
In template C:\Users\User\Documents\Django\ParkManager\Templates\Details_Main.html, error at line 23
Reverse for 'name' with arguments '(u'North West Thrill Centre',)' and keyword arguments '{}' not found.
A clue:
Exception Location:
C:\Python27\lib\re.py in _compile, line 242
Your issue is not related to the url tag. It is a mal-formed regex in your urls.py.
urls.py
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ParkManager.views.home', name='home'),
# url(r'^ParkManager/', include('ParkManager.foo.urls')),
url(r'^test/', Search_Page),
url(r'^search/', Search),
url(r'^details/', Details_Main),
# LINE BELOW has an open parentheses and not a closed parentheses.
url(r'^Link/(d+}/$', Link),
#url(r'^Link/(d+)/$', Link), #line fixed
url(r'^$', 'Parks.views.Link', name="home"),
unbalanced parenthesis is problem at this line:
url(r'^Link/(d+}/$', Link),
You have forgotten to close the parenthesis.
If you are using {% url %} tag in Django < 1.5, use it this way:
{% load url from future %}
{% url 'namespace:viewname' arg1, arg2 %}
{% url 'namespace:viewname' kwarg1=val, kwarg2=val2 %}
If you are using Django 1.5, you don't have to load the special url tag. If you are not using namespaces (good if you are using general view names like list, detail etc. and you want to distinguish between apps, e.g.: author:list or book:list) use only the view name. Check the documentation, there is a good section about the url tag - https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#url

Django include url causes rendering error?

I have a working django project. I wrote a small app - pm - and I tried to include its urls.py in the active project:
urlpatterns = patterns('',
# ... some urls here
url(r'^$', views.home, name='vw_home'),
# I added the following line:
(r'^pm/', include('pm.urls')),
Once I access the main web page, I receive the following error:
TemplateSyntaxError at /
Caught error while rendering: syntax error
and the debug shows the problem in the following line:
Home
If I remove the last url pattern (the include()), the page renders without any problem.
How can this be fixed?
EDIT:
Adding the urls.py of the pm app:
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns("pm.views",
url(r'^inbox/$', 'inbox', {'folder': 'inbox'}, name='vw_inbox'),
url(r'^sent/$', 'inbox', {'folder': 'sent'}, name='vw_sent'),
url(r'^message/(?<message_id>\w+)/$', 'read_message', name='vw_read_message'),
url(r'^compose/(?P<profile_id>\w+)/$', 'compose_message', name='vw_compose_message'),
url(r'^reply/(?P<message_id>\w+)/$', 'compose_message', name='vw_reply_message'),
)
url(r'^message/(?<message_id>\w+)/$', 'read_message', name='vw_read_message'),
You missed ?P