Reverse for 'modification' with no arguments not found issue

2019-08-22 Thread Ali IMRANE
Hello everyone,

I know I may ask this question for another time for some of you but after 
an hour of research, I'm still stuck with this issue of "No Reverse Match".

Here is my problem :

   - First, I using forms to put information in my DB (tickets) ;
   - I want to be able to edit those informations (check if a ticket has 
   been handled) ;
   - When I'm trying to call again my form to edit my information, even if 
   I give a specific ID, no way to reach it.


lire.html
...
{{ req.name }}
Soumis par moi le {{ req.fromd|date:"DATE_FORMAT" }}
  ID : {{ req.id }}
  Type de test : {{ req.typeOfTest }}
  Nom : {{ req.name }}
  Date de la requête : {{ req.fromd }}
  Périmètre : {{ req.perimetre }}
  Owner : {{ req.owner }}
Indice de compromission :{{ req.iocs|linebreaks 
}}
  Message à l'utilisateur :{{ 
req.messageToUser|linebreaks }}
  BAL Folder :{{ req.balFolder|linebreaks }}
  Note :{{ req.note|linebreaks }}
  Requête finie : {{ req.handled|linebreaks }}
  
  Editer larequête
...

views.py
def view_modif(request, id):
# Construit le formulaire, soit avec les données postées,
# soit vide si l'user accède pour la première fois à la page.
req = get_object_or_404(Requete, id=id)
form_m = RequeteFormEdit(instance=req)
# Verif que les données envoyées sont valides.
# Cette méthode renvoie False s'il n'y a pas de
# donnée dans le form ou qu'il contient des erreurs.
if form_m.is_valid():
# Ici, on traite les données du form
form_m.typeOfTest = form_m.cleaned_data['typeOfTest']
form_m.name = form_m.cleaned_data['name']
form_m.tod = timezone.now
form_m.perimetre = form_m.cleaned_data['perimetre']
form_m.owner = form_m.cleaned_data['owner']
form_m.iocs = form_m.cleaned_data['iocs']
form_m.messageToUser = form_m.cleaned_data['messageToUser']
form_m.balFolder = form_m.cleaned_data['balFolder']
# form_m.pj = form_m.cleaned_data['pj']
form_m.handler = form_m.cleaned_data['handler']
form_m.note = form_m.cleaned_data['handled']
form_m.handled = form_m.cleaned_data['note']

form_m.save()

# Nous pourrions ici envoyer l'e-mail grâce aux données
# que nous venons de récupérer
envoi = True
redirect(home)

# Quoiqu'il arrive, on affiche la page du formulaire.
return render(request, 'insertion/modification.html', locals())

urls.py
from django.urls import path
from . import views

urlpatterns = [
path('', views.home, name='home'),
path('liste', views.liste, name='liste'),
path('requete/', views.print_req, name='voir_req'),
path('insertion/', views.view_insert, name='insertion'),
path('edit/', views.view_modif, name='modification'),
path('connexion/', views.connexion, name='connexion'),
path('deconnexion/', views.deconnexion, name='deconnexion')
]

error :
NoReverseMatch at /edit/1

Reverse for 'modification' with no arguments not found. 1 pattern(s) tried: 
['edit/(?P[0-9]+)$']

Request Method: GET
Request URL: http://127.0.0.1:8000/edit/1
Django Version: 2.0
Exception Type: NoReverseMatch
Exception Value: 

Reverse for 'modification' with no arguments not found. 1 pattern(s) tried: 
['edit/(?P[0-9]+)$']

Exception Location: /usr/lib/python3.7/site-packages/django/urls/resolvers.py 
in _reverse_with_prefix, line 632
Python Executable: /usr/bin/python


I'm in a hurry and hope I could have the help I need thanks to you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/04ba18e5-46af-49d3-a13f-67fd95ecd1ee%40googlegroups.com.


Re: Reverse for 'modification' with no arguments not found issue

2019-08-28 Thread Ali IMRANE
Thanks James for your help.

Indeed, I tought about that problem but I already managed to see an number 
on an other page, as well as using that ID to read information behind my 
informations (as you can see in the third line I gave on "lire.html"). A 
number is printed. How can I know that it is an *int* and not a *string* 
use in there ?

Le jeudi 22 août 2019 18:27:48 UTC+2, Ali IMRANE a écrit :
>
> Hello everyone,
>
> I know I may ask this question for another time for some of you but after 
> an hour of research, I'm still stuck with this issue of "No Reverse Match".
>
> Here is my problem :
>
>- First, I using forms to put information in my DB (tickets) ;
>- I want to be able to edit those informations (check if a ticket has 
>been handled) ;
>- When I'm trying to call again my form to edit my information, even 
>if I give a specific ID, no way to reach it.
>
>
> lire.html
> ...
> {{ req.name }}
> Soumis par moi le {{ req.fromd|date:"DATE_FORMAT" }}
>   ID : {{ req.id }}
>   Type de test : {{ req.typeOfTest }}
>   Nom : {{ req.name }}
>   Date de la requête : {{ req.fromd }}
>   Périmètre : {{ req.perimetre }}
>   Owner : {{ req.owner }}
> Indice de compromission :{{ req.iocs|linebreaks 
> }}
>   Message à l'utilisateur :{{ 
> req.messageToUser|linebreaks }}
>   BAL Folder :{{ req.balFolder|linebreaks }}
>   Note :{{ req.note|linebreaks }}
>   Requête finie : {{ req.handled|linebreaks }}
>   
>type="button">Editer larequête
> ...
>
> views.py
> def view_modif(request, id):
> # Construit le formulaire, soit avec les données postées,
> # soit vide si l'user accède pour la première fois à la page.
> req = get_object_or_404(Requete, id=id)
> form_m = RequeteFormEdit(instance=req)
> # Verif que les données envoyées sont valides.
> # Cette méthode renvoie False s'il n'y a pas de
> # donnée dans le form ou qu'il contient des erreurs.
> if form_m.is_valid():
> # Ici, on traite les données du form
> form_m.typeOfTest = form_m.cleaned_data['typeOfTest']
> form_m.name = form_m.cleaned_data['name']
> form_m.tod = timezone.now
> form_m.perimetre = form_m.cleaned_data['perimetre']
> form_m.owner = form_m.cleaned_data['owner']
> form_m.iocs = form_m.cleaned_data['iocs']
> form_m.messageToUser = form_m.cleaned_data['messageToUser']
> form_m.balFolder = form_m.cleaned_data['balFolder']
> # form_m.pj = form_m.cleaned_data['pj']
> form_m.handler = form_m.cleaned_data['handler']
> form_m.note = form_m.cleaned_data['handled']
> form_m.handled = form_m.cleaned_data['note']
> 
> form_m.save()
>
> # Nous pourrions ici envoyer l'e-mail grâce aux données
> # que nous venons de récupérer
> envoi = True
> redirect(home)
>
> # Quoiqu'il arrive, on affiche la page du formulaire.
> return render(request, 'insertion/modification.html', locals())
>
> urls.py
> from django.urls import path
> from . import views
>
> urlpatterns = [
> path('', views.home, name='home'),
> path('liste', views.liste, name='liste'),
> path('requete/', views.print_req, name='voir_req'),
> path('insertion/', views.view_insert, name='insertion'),
> path('edit/', views.view_modif, name='modification'),
> path('connexion/', views.connexion, name='connexion'),
> path('deconnexion/', views.deconnexion, name='deconnexion')
> ]
>
> error :
> NoReverseMatch at /edit/1
>
> Reverse for 'modification' with no arguments not found. 1 pattern(s) tried: 
> ['edit/(?P[0-9]+)$']
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/edit/1
> Django Version: 2.0
> Exception Type: NoReverseMatch
> Exception Value: 
>
> Reverse for 'modification' with no arguments not found. 1 pattern(s) tried: 
> ['edit/(?P[0-9]+)$']
>
> Exception Location: /usr/lib/python3.7/site-packages/django/urls/resolvers.py 
> in _reverse_with_prefix, line 632
> Python Executable: /usr/bin/python
>
>
> I'm in a hurry and hope I could have the help I need thanks to you.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bf830ec3-b68d-4f56-9fb0-515586bbe900%40googlegroups.com.


Re: Reverse for 'modification' with no arguments not found issue

2019-08-29 Thread Ali IMRANE
My "home" variable is defined with a view :

def home(request):
""" Acceuil du site qui recense toutes nos requêtes pour le moment """
return render(request, 'insertion/accueil.html', locals())

Which redirect to my homepage.

The line with a problem is that one

return render(request, 'insertion/modification.html', locals())



And I really can't figure it out why, according the fact that "locals()" 
contains my variable and even if I send directly my variable instead, I get 
the same !



Le jeudi 29 août 2019 03:55:52 UTC+2, James Schneider a écrit :
>
>
>
> On Wed, Aug 28, 2019, 2:00 AM Ali IMRANE > 
> wrote:
>
>> Thanks James for your help.
>>
>> Indeed, I tought about that problem but I already managed to see an 
>> number on an other page, as well as using that ID to read information 
>> behind my informations (as you can see in the third line I gave on 
>> "lire.html"). A number is printed. How can I know that it is an *int* 
>> and not a *string* use in there ?
>>
>
> In the template it won't matter whether it is an int or a string, it gets 
> implicitly converted to a string for the regex match anyway.
>
>
>
>>> # Nous pourrions ici envoyer l'e-mail grâce aux données
>>> # que nous venons de récupérer
>>> envoi = True
>>> redirect(home)
>>>
>>>
> What is the home variable in the redirect statement above? It isn't 
> defined in your view. I think that will need an extra argument. What line 
> is the traceback actually complaining about?
>
> -James
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e7167ae-5519-4b9a-8bad-2310e5cc5217%40googlegroups.com.