Edit Profile When I click on the lin" /> Edit Profile When I click on the lin" /> Edit Profile When I click on the lin"/>

<int:pk> url mapping error , <int:pk> not passing

522 Views Asked by At

Here is my html link from where I want to use <int:pk>

<a href= "/main/profile/edit/{{ user.myprofile.id }}" >Edit Profile</a>

When I click on the link I get a url mapping error

Page not found (404)
Request Method: GET
Request URL:    http://127.0.0.1:8000/main/profile/edit/
Using the URLconf defined in lunarcodes.urls, Django tried these URL patterns, in this order:

  main/ home/
  main/ profile/
  main/ feed/
  main/ profile/edit/<int:pk>

here is my urls.py,

urlpatterns = [ 

path('profile/edit/<int:pk>', views.MyProfileUpdateView.as_view(success_url="/main/profile")),

    ]

this is my views.py,

@method_decorator(login_required, name="dispatch")    
class MyProfileUpdateView(UpdateView):
model = MyProfile
fields = ["name", "description", "pic"]     

this is my models.py,

class MyProfile(models.Model):
name = models.CharField(max_length = 100)
user = models.OneToOneField(to=User, on_delete=CASCADE)
description = models.TextField(null=True, blank=True)
pic= models.ImageField(upload_to = "images\\", null=True)
def __str__(self):
    return "%s" % self.user

I myself couldn't understand the problem properly as I am beginner.

0

There are 0 best solutions below