1👍
I just asked my colleagues who have some experience in Django. The answer is very simple.
you just need to create this function in “models.py” :
def get_absolute_url(self):
return "/viewguides/detail/%s/" %(self.id)
and then you can call it in the html by:
<a href="{{obj.get_absolute_url}}edit" class="btn">EDIT</a>
Every time you click the btn EDIT, it will take you to the following edit page with the given id (id that contains the forms/models of the user).
0👍
You must use the url tag in your template, something like this:
<a href="{% url update guide.id %}">EDIT</a>
Where “update” is the name
found in urls.py and “guide” the instance you want to update.
- Custom validation in django admin breaks datetime widget
- Django Unique model for every user
- Django – AttributeError at /prescription/ 'PrescriptionView' object has no attribute 'object_list'
Source:stackexchange.com