django-admin

Admin generic inlines for multi-table subclassed models broken --- any alternatives?

Here's what I'm trying to do, and failing... I have a File model which has a generic-relation to other objects: class File(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey() file = models.FileField(upload_to='files/%Y/%m/%d'...

Django Admin Interface Does Not Use Subclass's __unicode__()

Hello, (Django 1.x, Python 2.6.x) I have models to the tune of: class Animal(models.Model): pass class Cat(Animal): def __unicode__(self): return "This is a cat" class Dog(Animal): def __unicode__(self): return "This is a dog" class AnimalHome(models.Model): animal = models.ForeignKey(Animal) I have instantiated n...

Django Foreign Keys Read Only

Hi, I have two models one is Employee and other is Asset, with Many to one relation between Asset and Employee. And Asset is added as StackedInline field to Employee Admin interface, Is there anyway I can make Asset as read only field in the Employee Admin. My intention was to show all the assets the employee is currently holding in t...

Django Admin's "view on site" points to example.com instead of my domain.

I added a get_absolute_url function to one of my models. def get_absolute_url(self): return '/foo/bar' The admin site picks it up and adds a "view on site" link to the detail page for that object (when I put a real URL there instead of "/foo/bar"). The problem is instead of going to http://localhost:8000/foo/bar, it goes to http:...

Can you change a field label in the Django Admin application?

As the title suggests. I want to be able to change the label of a single field in the admin application. I'm aware of the Form.field attribute, but how do I get my Model or ModelAdmin to pass along that information? ...

Ordering admin.ModelAdmin objects in Django Admin

Let's say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this: PizzaApp - Toppings >>>>>>>>>> Add / Change Pizzas >>>>>>>>>> Add / Change But I want them like this: PizzaApp - Pizzas >>>>>>>>>> Add / Change Toppings >>>>>>>>>> Add / Change ...

Djang-Admin: CharField as TextArea

I have class Cab(models.Model): name = models.CharField( max_length=20 ) descr = models.CharField( max_length=2000 ) class Cab_Admin(admin.ModelAdmin): ordering = ('name',) list_display = ('name','descr', ) # what to write here to make descr using TextArea? admin.site.register( Cab, Cab_Admin ) how to assig...

How do I add a custom inline admin widget in Django?

This is easy for non-inlines. Just override the following in the your admin.py AdminOptions: def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'photo': kwargs['widget'] = AdminImageWidget() return db_field.formfield(**kwargs) return super(NewsOptions,self).formfield_for_dbfield(db_field,**k...

Django - Custom virtual model field with companion stored field

I would like to have a ConfirmationField field type. I want this field to work like a boolean field. I don't need to store this information on database instead I would like to store the date of confirmation on a seperate field. class MyModel(models.Model): confirmation = ConfirmationField() m = MyModel() m.confirmation # False m.c...

What is the best approach to implement configuration app with Django?

I need to program kind of configuration registry for Django-based application. Requirements: Most likely param_name : param_value structure Editable via admin interface Has to work with syncdb. How to deal with a situation in which other apps depend on configuration model and the model itself has not been initialized yet in DB? Let's...

How do I override Django's administrative change password page?

I'd like to override Django's administrative "Change Password" page (change_password.html). As such, I've placed Django's "/contrib/admin/templates/registration/password_change_form.html" in my project's "/templates/admin/registration/password_change_form.html" directory. Unfortunately, this doesn't seem to do the trick. At this point...

Is it dangerous to leave your Django admin directory under the default url of admin?

Is it dangerous to have your admin interface in a Django app accessible by using just a plain old admin url? For security should it be hidden under an obfuscated url that is like a 64 bit unique uuid? Also, if you create such an obfuscated link to your admin interface, how can you avoid having anyone find out where it is? Does the goo...

How to make a model instance read-only after saving it once?

One of the functionalities in a Django project I am writing is sending a newsletter. I have a model, Newsletter and a function, send_newsletter, which I have registered to listen to Newsletter's post_save signal. When the newsletter object is saved via the admin interface, send_newsletter checks if created is True, and if yes it actually...

Customizing an Admin form in Django while also using autodiscover

I want to modify a few tiny details of Django's built-in django.contrib.auth module. Specifically, I want a different form that makes username an email field (and email an alternate email address. (I'd rather not modify auth any more than necessary -- a simple form change seems to be all that's needed.) When I use autodiscover with a...

Adding reports to Django's admin

I'm looking to add an extra set of pages to my auto-generated admin site. I want to generate reports off my models and some logs surrounding it. The actual generating isn't the issue. How do I: Make the report output look like it's an admin page, with breadcrumbs, similarly formatted table, etc? Register the view so it shows up on the...

Django Admin app or roll my own?

I'm just starting to use Django for a personal project. What are the pros and cons of using the built-in Admin application versus integrating my administrative functions into the app itself (by checking request.user.is_staff)? This is a community wiki because it could be considered a poll. ...

Valid use case for django admin?

I want to build a django site where a certain group of trusted users can edit their profile information. Does it make sense to have each trusted user go through the django admin interface? I'd only want them to be able to see and edit their own information (obviously). It doesn't seem like this fits the way the django people define "trus...

Is there a way to auto-increment a Django field with respect to a foreign key?

I'm currently coding a site in Django (because you can never learn too many frameworks!), and am wondering if there's a way to auto-increment an object with respect to a related object. So for instance, say I have an Entry model and an EntryVersion model: Entry - title - slug EntryVersion - entry (foreign key) - version_number - conte...

How would you populate a field based on another field

From the admin panel I want to populate a slug field based on a certain text field eg. Title: My Awesome Page would automaticaly populate Slug: my_awesome_page ...

Django - How to preopopluate admin form fields

I know that you can prepopulate admin form fields based on other fields. For example, I have a slug field that is automatically populated based on the title field. However, I would also like to make other automatic prepopulations based on the date. For example, I have an URL field, and I want it to automatically be set to http://www.mys...