I was thinking that django admin is an utility to provide trusted administrators of the site, full access to the site's data model.
However, after going through django admin in detail, I understand that it is very powerful set of views and templates that one can use to create an entire application.
How often do you create an entire app...
I'm new to Django and so far I like it a lot but I've come to a bit of a roadblock and I'm not sure if it is in the admin that I can change this, or in my models. I have a relationship that looks like this: Unfortunately due to circumstances I can't link the actual code
class A:
class B:
a = models.ForeignKey(A)
class C:
a = m...
I've tried various methods to achieve this.
I decided against overriding formfield_for_dbfield as it's doesn't get a copy of the request object and I was hoping to avoid the thread_locals hack.
I settled on overriding get_form in my ModelAdmin class and tried the following:
class PageOptions(admin.ModelAdmin):
def get_form(self, r...
I know the link template to reach an object is like following:
"{{ domain }}/{{ admin_dir }}/{{ appname }}/{{ modelname }}/{{ pk }}"
Is there a way built-in to get a permalink for an object?
from django.contrib import admin
def get_admin_permalink(instance, admin_site=admin.site):
# returns admin URL for instance change page
...
Before Django 1.0 there was an easy way to get the admin url of an object, and I had written a small filter that I'd use like this: <a href="{{ object|admin_url }}" .... > ... </a>
Basically I was using the url reverse function with the view name being 'django.contrib.admin.views.main.change_stage'
reverse( 'django.contrib.admin.views....
Hi,
I've got a set of models that look like this:
class Page(models.Model):
title = models.CharField(max_length=255)
class LinkSection(models.Model):
page = models.ForeignKey(Page)
title = models.CharField(max_length=255)
class Link(models.Model):
linksection = models.ForeignKey(LinkSection)
text = models.CharFiel...
Hi all,
in my Django app i have a Newsletter model. Now I'd like to be able to send the newsletter (and even resend it) from Django Admin.
I could do this with a hook on the Model.save() method but is there another way that is not tied to the Model?
Thanks
...
I've added a method 'highlight_link' to my model's admin.py class:
class RadioGridAdmin(admin.ModelAdmin):
list_display = ('start_time', highlight_link)
def highlight_link(self):
return ('some custom link')
admin.site.register(RadioGrid, RadioGridAdmin)
It returns a custom link for (I've left out highlight_link.short_...
I'm working on a Django app for hosting media (specifically audio and images). I have image galleries and photos separate in my model, and have them linked with a ForeignKey (not sure if that's correct, but still learning). What I need is for the Album class's __unicode__ to return the album owner's username.
class Album(models.Model):
...
I need to generate external links in admin interface grid column, but they shows as html code:
<a href="http://www.site.com/">site</a>
Admin interface translates my links as html-entities and they doesn't shows as right links.
Is it possible to show external links there, not html code?
I think list_display_links doesn't work...
Is there any way to group the models in django admin interface?
I currently have an app called requests with the following models showing in the admin site:
**Requests**
Divisions
Hardware Requests
Hardware Types
Requests
Software Requests
Software Types
I would like the divisions, Software Requests and Hardware Requests to be groupe...
Ok, so here's the skinny:
# models.py
class Article( models.Model ):
title = models.CharField( max_length = 255 )
author = models.ForeignKey( User )
published_at = models.DateTimeField( auto_now_add = True )
body = models.TextField( )
def __unicode__( self ):
return self.titl...
Suppose I have a model:
class SomeModel(models.Model):
id = models.AutoField(primary_key=True)
a = models.CharField(max_length=10)
b = models.CharField(max_length=7)
Currently I am using the defauly admin to create/edit objects of this type.
How do I remove the field b from the admin so that each object cannot be created w...
I have a Django website in which I want site administrators to be able to edit rich content.
Suppose we're talking about an organizational info page, which might include some pictures, and some links, where the page is not as structured as a news page (which updates with news pieces every few days), but still needs the ability to be easi...
How do I get Django admin to display groups horizontally? If I have 3 adjacent datetime fields, I'd rather them take up 1 row, not 3.
...
I have an admin view which contains four foreign keys each with a few thousand entries. It is slow to appear in the browser.
If I change the django model to eliminate the select boxes by adding raw_id_fields things become nice and snappy. So the slowness is due to the population of the select drop downs and also this is a known issue s...
I have model for example like this:
class Meeting(models.Model):
date = models.DateTimeField(default=datetime.datetime.now)
team = models.CharField(max_length=100)
class Meta:
verbose_name_plural = u'Meetings'
ordering = ['-date', 'team']
def __unicode__(self):
return u'%s %s' % (self.date, self...
I have the following models:
class Category(models.Model):
name = models.CharField(max_length=40)
class Item(models.Model):
name = models.CharField(max_length=40)
category = models.ForeignKey(Category)
class Demo(models.Model):
name = models.CharField(max_length=40)
category = models.ForeignKey(Category)
item =...
I'm using Photologue in my application, and I really like the ManyToManyField selector that appears in the admin app (two multi-select boxes with arrows for moving items between the selected and non-selected states, along with "Choose All" and "Clear All" options).
I'm using very similar code in my own model, but my ManyToManyField sele...
I'm having trouble overriding a modelform save method. This is the error I'm receiving:
Exception Type: TypeError
Exception Value:
save() got an unexpected keyword argument 'commit'
My intentions are to have a form submit many values for 3 fields, to then create an object for each combination of those fields, and to save each of th...