0
I do not work long with Django but I come here turning around + now I fall into this problem I am not able to solve, so I ask for help from those who can.
I have my application working in perfect development, but when I deploy for production presents the following msg:
"Reverse for 'geracontratocompravenda' not found. 'geracontratocompravenda' is not a Valid view Function or Pattern name.
The fact is that in development I am using python 3.5 with Django 2.0.1 on the production server is python 3.6 with Django 2.0.8.
I have distrust that may be version problem because developing works.
Since I thank,
João Neto
py.
url(r'geracontratocompravenda/(?P<pk>[0-9]+)/$',
views.GeraContratoCompraVenda.as_view(),name='geracontratocompravenda'),
py views.
class General Contratocompravenda(Customview):
permission_codename = 'change_pedidovenda'
def get(self, request, *args, **kwargs):
venda_id = kwargs.get('pk', None)
instance = PedidoVenda.objects.get(id=venda_id)
instance.status = '2'
instance.save()
return redirect(reverse_lazy('vendas:editarpedidovendaview', kwargs={'pk': instance.id}))
In my html
href="{% url 'sales:geracontratocompraven' Object.id %}"
Traceback
Environment:
Django Version: 2.0.8 Python Version: 3.6.2 Installed Applications: ['Django.contrib.admin', 'Django.contrib.auth', 'Django.contrib.contenttypes', 'Django.contrib.Sessions', 'Django.contrib.messages', 'Django.contrib.staticfiles', 'stock.apps.base', 'stock.apps.login', 'stock.apps.cadastre', 'stock.apps.sales', 'stock.apps.shopping', 'stock.apps.fiscal', 'financial stock.apps.', 'stock.apps.stock'] Installed Middleware: ['Django.middleware.security.Securitymiddleware', 'Django.contrib.Sessions.middleware.Sessionmiddleware', 'Django.middleware.common.Commonmiddleware', 'Django.middleware.csrf.Csrfviewmiddleware', 'Django.contrib.auth.middleware.Authenticationmiddleware', 'Django.contrib.messages.middleware.Messagemiddleware', 'Django.middleware.clickjacking.Xframeoptionsmiddleware', 'stock.middleware.Loginrequiredmiddleware']
Template error: In template /home/handson/apps_wsgi/fortcar/templates/base/base.html, error at line 0 Reverse for 'geracontratocompravenda' not found. 'geracontratocompravenda' is not a Valid view Function or Pattern name. 1 : 2 : 3 : 4 : 5 : {%load staticfiles %} 6 : 7 : 8 : 9 : 10 :
Traceback:
File "/home/handson/. local/lib/python3.6/site-Packages/Django/core/handlers/Exception.py" in Inner 35. Answer = get_response(request)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/core/handlers/base.py" in _get_response 158. Sponse = self.process_exception_by_middleware(e, request)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/core/handlers/base.py" in _get_response 156. Answer = Answer.()
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/Response.py" in render 106. self.content = self.rendered_content
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/Response.py" in rendered_content 83. content = template.render(context, self. _request)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/backends/Django.py" in render 61. Return self.template.render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in render 175. self. _render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in _render 167. Return self.nodelist.render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in render 943. bit = Node.render_annotated(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in render_annotated 910. Return self.render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/loader_tags.py" in render 155. Return compiled_parent. _render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in _render 167. Return self.nodelist.render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in render 943. bit = Node.render_annotated(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in render_annotated 910. Return self.render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/loader_tags.py" in render 67. result = block.nodelist.render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in render 943. bit = Node.render_annotated(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/base.py" in render_annotated 910. Return self.render(context)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/template/defaulttags.py" in render 447. url = Reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File "/home/handson/. local/lib/python3.6/site-Packages/Django/urls/base.py" in Reverse 90. Return iri_to_uri(resolve. _reverse_with_prefix(view, prefix, *args, **kwargs))
File "/home/handson/. local/lib/python3.6/site-Packages/Django/urls/resolvers.py" in _reverse_with_prefix 634. raise Noreversematch(msg)
Exception Type: Noreversematch at /sales/pedidovenda/edit/2/ Exception Value: Reverse for 'geracontratocompravenda' not found. 'geracontratocompravenda' is not a Valid view Function or Pattern name.
It hasn’t made any sense for years to use different versions of Python and biblitecs for development and production - look for documentation on
virtualenv
which allows an isolated environment of Python co but libraries in the version you choose, andpyenv
which allows you to choose the desired version of Python, independent of the operating system.– jsbueno
All right it was done with the same versions yet not working some other tip?
– João Netto