django-admin

Django admin handling one to many relation

Dears I have a django model as following class Project(models.Model) name=models.CharField(max_length=200) class Application(models.Model) proj=models.ForeignKey(Project, null=True, blank=True) I need to modify the admin form of the project to be able to assign multiple applications to the project, so in the admin.py I ...

ModelAdmin thread-safety/caching issues

Ultimately, my goal is to extend Django's ModelAdmin to provide field-level permissions—that is, given properties of the request object and values of the fields of the object being edited, I would like to control whether or not the fields/inlines are visible to the user. I ultimately accomplished this by adding a can_view_field() method ...

Django: Make items in ManyToMany field unavailable once it is "used"?

if this is my models.py: class Category(models.Model): name = models.CharField(max_length=500) slug = models.SlugField(unique=True) def __unicode__(self): return self.name def get_absolute_url(self): return "%s" % self.slug class Item(models.Model): name = models.CharField(max_length...

Django AdminSite: Display only a subset in ManyToManyField depending on user

Howdy, I'm using the admin site in django. By default there are the user and group models. I enabled to select the groups when creating a new user and I now want to filter the set of assignable groups depending on the current user. E.g. if the user is a superuser he is able to assign all groups. If he's within a subgroup, he can only as...

Extending the Django change list view to include the object title it is related to

Hi, I am using the Django comments framework to allow commenting on articles in a blog. I want to display the title of the article that the comment(s) belongs to in the list view of the comments section where the comment name, content type, object id etc is. How do I do this? I know you can hook up actions into your admin.py list view...

How do I inline edit a django user profile in the admin interface?

If you want to store extra information about a user (django.contrib.auth.models.User) in Django you can use the nifty AUTH_PROFILE_MODULE to plug in a "profile" model. Each user then gets a profile. It's all described here: http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users http://www.djangoboo...

django adding a checkbox to a custom field

I'm trying to write a field for django admin that will have 2 widgets: a textinput and an associated checkbox. If the checkbox is checked it will return none, if not return the value of the field. But I can't get the notch of it. Here is how I tried(note I'm new to django): class FloatRangeField(models.FloatField): __metaclass__=models...

Display unescaped HTML String in Django Admin change list

Hey Guys! I am currently facing a serious problem. I use the standard django admin interface incl. change list to display one of my models. The model has got a field, which includes a link (e.g. in database: link). What I want now is that this string is rendered unescaped and displayed as link. I already tried the following in "change_...

Widget filling values in two fields

I know that if I need a custom "selector" for a field in django-admin I need to create a custom widget. But what if the widget have to produce two values, for example X and Y coordinates, how can I fill them in two different fields from the model? ...

Implementing workflows in Django Admin - Django

Hi folks, I have a nice admin panel setup so users can manage the data within the site. Problem is that I need to implement a workflow, so saved models can be approved from and to various stages, to then be finally published. As the model in question is just one, I thougth of adding a boolean 'approved_for_publishing' field and a 'a...

django executing common action for all the admin forms

I use fileSystem caching in my django application what I need is to clear the cache after any action(adding or editing or deleting) taken by the admin is there any way to get an action (clearing the cache) to be executed after all the submission of any form in the admin site? ...

Django development server - IE6 / IE7 cannot display page bug

Hey Guys! Here is one extremely anoying bug. I expirience this bug when sending a Post request on IE6/7 within the admin interface. E.g. when I select all items (shown on change_list page) and hit the "delete" action. The IEs just drop the connection. Firefox works fine. Here is a link which i think is related to this problem: http://...

Issue with change_view save redirect

I am attempting to change the redirected for the django admin save button. What I pasted below works on saving an already existing entry (updating) but not on saving a new one. Any thoughts? def change_view(self, request, object_id, extra_context=None): result = super(TodoAdmin, self).change_view(request, object_id, extra_context) ...

Django Admin: how to display fields from two different models in same view?

My site makes use of Django's User Authentication User model and a custom UserProfile model to store some additional data (birthday, etc.). Is there a way to create a view in Django admin that weaves together fields from both the User and UserProfile models? I suspect that this code snippet is not even close, but maybe it will help illu...

Django admin: deletion of linked elements

hi, in Django admin site when you decide to suppress an object, all the linked element (ie: elements pointed at by a foreign key) are also deleted. How do you dodge this, except making raw queries in the shell? Is it possible to tune the admin to have the choice? Thanks ...

How to display a verbose name for models in Django's admin

I registered an app to the django admin with: from django.contrib import admin from MyProject.myapp.models import Model1, Model2 class HyperlinkAdmin(admin.ModelAdmin): pass class Model2Admin(admin.ModelAdmin): pass admin.site.register(Hyperlink, HyperlinkAdmin) admin.site.register(Model2, Model2Admin) Model1= class Hyperlink...

Django drop all tables from database

How can I drop all tables from database using mannage.py and command line? Is there any way to do that executing manage.py with appropriate parameters so that to execute it from .NET application? ...

AttributeError - type object 'Services' has no attribute 'service_price'

Hi there, I'm trying to create something like an invoice program, to create invoices and calculate prices. I am still on the models part and I am trying to calculate all the services includes in a single invoice and update them in Invoices.subtotal. My problem is that I cannot pass the summary value of Services.service_price to Invoice...

Using contentType for raw_id_fields

In my application, i have a model definition like: class SomeModel(models.Model): someFK = Models.ForeignKey(SomeModel, null=True, blank=True) otherFK = Models.ForeignKey(OtherModel, null=True, blank=True) ... This model keep data about Logs, and there are more than 1 kind of model to be logged, so i place a FK for each re...

Hot to reuse table header sort feature of Django admin?

Is possible to reuse the table header sort feature of the admin forms in my own views and templates? ...