-1

I have next task and dont know how to make it.

Web page shows to user list of objects. Every object has 2 button with urls like function_detail and function_change_history. First url need open the page about details of the object and the second url need to open the page about change history. I used get_absolute_url to make second url but dont know how to create first url cause I need to use get_absolute_url again.

models.py:

@reversion.register()
class Function(models.Model):
    ***FIELDS***

    def get_absolute_url(self):
        return reverse('project:function_change_history', args=[self.project_id, self.code])

urls.py:

url(r'^(?P<project_code>[0-9a-f-]+)/(?P<function_code>[0-9a-f-]+)/change_history/$',
        function_change_history,
        name='function_change_history'),

url(r'^(?P<project_code>[0-9a-f-]+)/(?P<function_code>[0-9a-f-]+)/detail/$',
        function_detail,
        name='function_detail'),

Is it possible to set 2 url in get_absolute_url?

Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193

1 Answers1

0

Finally I found the decision. For function_detail I use get_absolute_url and for function_change_history I use in template {% url 'function_change_history' project_code=project.code function_code=function.code %}

Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193