In page edit object links

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function django_admin_links_div() {
    // Update these variables for your site
    var admin_url = '/admin/';
    var div_title = 'Admin';
    var div_style = 'position: fixed; top: 0; right: 0; border: solid #008999 1px; padding: 3px 5px 3px 5px; text-align: center; color: #000; background: #EEDEBC; font-size: 11px; z-index:999;';
    // end variables to update
    if(typeof ActiveXObject != 'undefined') {
       var x = new ActiveXObject('Microsoft.XMLHTTP');
    }
    else if(typeof XMLHttpRequest != 'undefined') {
       var x = new XMLHttpRequest();
    }
    else {
       return;
    }
    x.open('GET', location.href, false);
    x.send(null);
    try {
       var type = x.getResponseHeader('x-object-type');
       var id = x.getResponseHeader('x-object-id');
    }
    catch(e) {
       return;
    }
    var div = document.createElement('div');
    div.style.cssText = div_style;
    div.innerHTML = '<b><a href="'+admin_url+'">'+div_title+'</a></b><br /><a href="'+admin_url + type.split('.').join('/') + '/' + id + '/">Edit '+type.split('.')[1]+'</a> &nbsp; <a href="'+admin_url+'logout/">Logout</a>';
    document.body.appendChild(div);
}
django_admin_links_div();

More like this

  1. Handling choices the right way by mallipeddi 5 years, 6 months ago
  2. Manager introspecting attached model by ubernostrum 5 years, 2 months ago
  3. Command Line Script Launcher by dakrauth 4 years, 10 months ago
  4. Use django-admin.py instead of manage.py by whiteinge 4 years, 11 months ago
  5. Model field choices as a namedtuple by whiteinge 2 years, 1 month ago

Comments

(Forgotten your password?)