[Answer]-Navigating from admin site to one of my apps in same project

1👍

define a method in your model:

def get_absolute_url(self):
   return "An url computed with resolve() for example"

A button will appear on top right of the admin side.

Example

def get_absolute_url(self):
   return resolve('home_page')

will send you to the page named (in urls.py) ‘home_page’.

See https://docs.djangoproject.com/en/dev/ref/models/instances/#get-absolute-url

[EDIT]

This is not well documented in the django documentation. You have to search in the Django source tree.

First create a template with this path (assuming templates is your templates default root directory):

templates/admin/index.html

Which contains:

{%extends 'admin/base_site.html'%}
{%block content%}
<style>
    a.btn { display: inline-block; padding: 5px; margin-right: 10px; border: 1px solid black; border-radius: 5px; line-height: 50px; }
</style>
<div><a href="/admin/app1/model1/" class="btn">Your first app with the model1</a></div>
<div><a href="/admin/app1/model2/" class="btn">Your first app with the model2</a></div>
<div><a href="/admin/app2/model/" class="btn">Your second app with a model</a></div>
{% endblock %}

This is a very basic sample and it will completly override the standard presentation. You can add buttons with a little bit of CSS.

To add a entry you can add:

<div><a href="/admin/app1/model1/add/">Add a new entry in app1/model1</a></div>

All the Django admin templates are in this path. It can be very helpful to understand it :

[DJANGO_ROOT]/contrib/admin/templates/

I think it’s what you want.

Cheers

Leave a comment