On local machine with "runserver" the app is running without any problem. Problems occur on the staging server, Gunicorn + Nginx, where I got 'Reverse for 'tag_owner_lost' not found. 'tag_owner_lost' is not a valid view function or pattern name.' Any ideas where to look into?

the view

class TagOwnerLostView(LoginRequiredMixin, CreateView):
    template_name = 'tag_owner/tag_owner_lost.html'
    title = 'Inregistrare TAG pierdut'

    def get(self, request ):
        if request.user.is_owner:
            form = TagOwnerLostForm(request.user)
            if len(form["tag"]) == 1:
                messages.warning(
                    request,
                    _('Nu aveti TAG-uri asociate acestui cont')
                )
            args = {
                'form': form, 
                'title': self.title
                }
            return render(request, self.template_name, args )
        else:
            return redirect('general:home')

    def post(self, request ):
        if request.user.is_authenticated:
            form = TagOwnerLostForm(request.POST, request.user)
            if form.is_valid():
*
*
        else:
            return redirect('accounts:login')


    def get_absolute_url(self):
        return reverse('owner:tag_owner_lost')

urls.py

app_name = 'owner'
urlpatterns = [
    # path('', TagListView.as_view(), name='tag_list'),
    path('inregistrare-tag/', TagOwnerRegisteringView.as_view(), name='tag_owner_registered'),
    path('pierdut/', TagOwnerLostView.as_view(), name='tag_owner_lost'),
]

Menu link:

<a class="nav-link" href="{% url 'owner:tag_owner_lost' %}">am Pierdut<span class="sr-only"></span></a>

Thanks!

Late edit

Like many other simple things, a simple server reboot fix the problem.

1 Answers

0
Alpaslan Aykovan On

how about using reverse_lazy

reverse_lazy('owner:tag_owner_lost')