Re: edit_view() missing 1 required positional argument: 'id'

2021-09-14 Thread Kasper Laudrup

On 14/09/2021 12.20, Vikram J wrote:


I got this error how can I fixed it, plz help me out,



You edit path is missing an argument. Change this:


 path('edit/', views.edit_view)


to something like this:

path('edit/', views.edit_view)

That ought to fix it.

Kind regards,

Kasper Laudrup

--
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/d35382fd-fb17-fd07-0fe3-eeb8deb05d17%40stacktrace.dk.


RE: edit_view() missing 1 required positional argument: 'id'

2021-09-14 Thread Vikram J
Good Day,

I got this error how can I fixed it, plz help me out,

views.py

 def edit_view(request, id , *args, **kwargs):
d1 = data.objects.get(id=id)
if request.method == 'POST':
form = dataForm(request.POST, instance=d1)
if form.is_valid():
form.save()
return redirect('/homepage')
return render(request, 'edit.html', {'d1': d1 })

urls.py

  urlpatterns = [
path('admin/', admin.site.urls),
path('homepage/', views.select_view),
path('new/', views.create_view),
path('delete/', views.delete_view),
path('edit/', views.edit_view),

-- 
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/f2121622-43cb-4b38-8470-1098792c2879n%40googlegroups.com.