Questions tagged [django-admin-actions]

Django Admin Actions django-admin comes by default with django installation and it is one of strongest feature of django. So there are many actions that can be taken by django like add user, change their permissions, change their access levels and many more.

113 questions
32
votes
5 answers

How to add the custom button which executes a Django admin action to change form page?

I have already defined a custom admin action for my model which works perfectly as expected. I also looked at multiple ways of adding a button to the admin change form page here on SO. The only step that I am missing is how do I make a button in the…
dsalaj
  • 2,857
  • 4
  • 34
  • 43
28
votes
4 answers

make django model field read only or disable in admin while saving the object first time

I want to disable the few fields from model in django admin while saving initially. "" like this. My model is: class Blogmodel(models.Model): tag =…
Wagh
  • 4,202
  • 5
  • 39
  • 62
22
votes
5 answers

Custom actions in Django Admin

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…
Lorenzo
  • 4,558
  • 11
  • 44
  • 54
7
votes
1 answer

django-admin startapp v/s python manage.py startapp

What is the difference between django-admin startapp and python manage.py startapp? They both create apps and the files are also same so what's the difference between these two?
7
votes
2 answers

Differences between Stacked inline and Tabular inline

This is my models.py file from django.db import models # Create your models here. class Item(models.Model): name=models.CharField(max_length=250) description = model.TextField() class Meta: oredering['name'] def…
user7671217
7
votes
5 answers

Permissions to Django Admin Actions

I have written some custom actions for my django project, however cannot work out how to make them available to only superusers. I have tried putting an if statement round the actions line with Users.is_superuser but it keeps giving me an error…
Gary
  • 107
  • 2
  • 6
6
votes
3 answers

How to add a function after a record inserted in database using django admin?

I want to execute a function after a record inserted to database using django-admin panel . I have a product table , i want to send notification to users when a record inserted in database by django admin panel . i know how to send notification to…
5
votes
1 answer

How to put a button on List page for each row in django admin page

I want to add a button for each row as shown in the picture on the button place which shall give a popup of a field content of the same modal or whatever i insert for it to show.
5
votes
3 answers

Django Admin - Allow models to be shown for is_staff users

I need to make some Django models available for is_staff=True users in the Django admin interface. I do not want to go for each user and assign them permissions or group permissions to the staff users. Which method do I need to override in…
SiddharthG
  • 166
  • 1
  • 5
5
votes
2 answers

redirect from django admin action intermediate page to change form page

I am trying to build an admin action 'download_selected' which will download selected models. When the action is selected, I redirect to an intermediate page so that users can select a download format. When a user selects a download format and…
ac11
  • 927
  • 2
  • 11
  • 18
4
votes
3 answers

How to get the inline objects in the save method in models.py

I have the class Invoice, which (simplified) has the following attributes: class Invoice(models.Model) number = models.CharField(verbose_name="Number", max_length=16) issue_date = models.DateTimeField(verbose_name="Issue date",…
4
votes
2 answers

Hide action in django admin if they don't have permission

I added an action in my admin pages that allows user to export selected records to an excel sheet. Now I need to be able to only allow some users to be able to export data. I have a UserProfile model that has a can_export boolean field. How can I…
Austin
  • 4,296
  • 6
  • 40
  • 52
3
votes
1 answer

How can I create a button for a django admin action?

I have a django admin action say "refresh", I want to add a refresh button for each row in the admin list view. I can create button using format_html but how can I invoke "refresh" action when it is pressed?
Ravi Kumar
  • 445
  • 4
  • 13
3
votes
1 answer

Testing Django Admin Action (redirecting/auth issue)

I'm trying to write tests for an Admin action in the change_list view. I referred to this question but couldn't get the test to work. Here's my code and issue: class StatusChangeTestCase(TestCase): """ Test case for batch changing 'status' to 'Show'…
Thomas Jiang
  • 1,303
  • 11
  • 16
3
votes
2 answers

Adding dynamic fields to Django's export_as_csv action in admin

I'm trying to customize the export_as_csv action that appears in the admin menu, so that I can add dynamic fields to the exported CSV file. This is through the use of django-adminactions which provides the Export as CSV action. So far I have the…
Frankline
  • 40,277
  • 8
  • 44
  • 75
1
2 3 4 5 6 7 8