Questions tagged [django-modeladmin]

132 questions
1
vote
1 answer

Django admin list page takes forever to load after overriding get_queryset method

I have this model admin - class NewsAdmin(ImageWidgetAdmin): image_fields = ['featured_image'] list_per_page = 20 list_display = ('heading', 'category', 'status', 'is_active', 'created_at', 'published_at', …
1
vote
1 answer

Django- Display columns depending on chosen filter in ModelAdmin (list_display)

I'm trying to show different columns(in list_display) depending on chosen filter. Here is my code: # Filter: class FilterNameFilter(admin.SimpleListFilter): title = ('FilterName') parameter_name = 'FilterName' def lookups(self, request,…
Fortelll
  • 15
  • 6
1
vote
1 answer

Django - Custom ModelAdmin form not overriding default models

I have a model defined class subnet(models.Model): subnet_id = models.AutoField(primary_key=True) subnet_pod = models.ForeignKey(pod, null=True, on_delete=models.SET_NULL, verbose_name='Select Pod') subnet_number =…
Sindhujit
  • 51
  • 9
1
vote
1 answer

Custom model form on admin tabular inline gives Integrity Error

I have made a custom model form so that I can change the header text: forms.py class AddRoomAddRoomExtrasForm(ModelForm): roomextrafields = forms.ModelChoiceField(queryset=RoomExtra.objects.all(), label=_('Room Extras')) class Meta: …
Itergator
  • 299
  • 3
  • 16
1
vote
1 answer

Specific Queryset for Input on Django ModelAdmin Change Form

I've got a 'Registration' object in place that users can create on the front end without issue. It looks like this: class Registration(models.Model): person = models.ForeignKey(Person, on_delete=models.PROTECT) course_detail =…
Hanny
  • 580
  • 3
  • 16
  • 44
1
vote
2 answers

How to limit number of choices of a ManyToManyField to a specific number of choices

I am trying to build a multiple choice quizzes Django app. I have a model named Answer, and another model named Question. Here are the contents of Answer: class Answer(models.Model): text = models.CharField(max_length=255) and this is…
Ambitions
  • 2,369
  • 3
  • 13
  • 24
1
vote
2 answers

django multitable inheritance in django modeladmin

I have to models class Parent(object): text_field = models.TextField() boolean_field = models.BooleanField() class Child(Parent): another_text_field = models.TextField() With the following ModelAdmin class…
ezdazuzena
  • 6,120
  • 6
  • 41
  • 71
1
vote
2 answers

How to check image width & height in Django admin class?

I have registered a class like below to have an admin panel to upload images: android_dashboard.register(Banner, BannerAdmin) The banner model is as below: class Banner(models.Model): image = ImageField( _('Image'),…
Alireza
  • 6,497
  • 13
  • 59
  • 132
1
vote
3 answers

Override default text label for any external packages in Django admin

It's the classic way to describe Modules in Django Admin, and it works great! at bookshelf/apps.py from django.apps import AppConfig class BOOKConfig(AppConfig): name = 'bookshelf' verbose_name = "Your Book" at…
1
vote
2 answers

How to prevent Django ModelAdmin from stripping whitespaces?

so I've defined readonly_fields in Django ModelAdmin with a callable which looks like this: class TestAdmin(admin.ModelAdmin): readonly_fields = ("test_field_with_whitespace",) def test_field_with_whitespace(self, obj): return ' …
RaideR
  • 869
  • 1
  • 12
  • 33
1
vote
2 answers

Django - Displaying model having content type in admin panel

I am new to Django and I am facing a problem. I have multiple model that require address and phone number against address. And only phone number can be associated with some of models. So, I have made polymorphic relation for "Addresses" and…
1
vote
1 answer

How to CRUD ContentType in Django admin site?

I'm reading a book about Django and I'm trying to reinterpret some content. (I'm using Django 2.1 and Python 3.6) In the book different types of contents are associated with a module, like this: class Module(models.Model): course =…
1
vote
1 answer

Advance queryset in django ModelAdmin. AttributeError: 'dict' object has no attribute '_meta'

I writing an app that has one Model User, with different roles. So assign role I added a field in User model "user_type". below is my User model. class User(models.Model): name = models.CharField(max_length=30) password =…
1
vote
1 answer

Calling api without knowing ip address in django

I have a post request http://localhost:8000/api/orders/shipment what i want to do is i dont want to pass domain/ip address and access the api something like Django admin console give "172.18.0.1 - - [08/Sep/2017 14:30:29] "POST…
1
vote
0 answers

Wagtail ModelAdmin not showing fields when editing one object, but does show fields when showing all

I'm using Wagtail, and I'm also using django-inspectional-registration. I'm trying to set it up so that approving users can be done in the CMS, and not the django admin. To do this I've created a ModelAdmin, as seen here: wagtail_hooks.py from…
sham
  • 1,214
  • 10
  • 16
1 2 3
8 9