Questions tagged [django-modeladmin]
132 questions
0
votes
1 answer
Make some elements of choice array readonly in Django?
I have a model:
class myLimit(models.Model):
limit = models.PositiveSmallIntegerField(help_text="The upper limit of the number of points that can be used.")
TYPES_OF_LIMITS = [('perday','Limit Per Day'),('lifetime', 'Lifetime…

Aekansh Dixit
- 513
- 1
- 9
- 20
0
votes
2 answers
How can i use csrf token in customised django model admin?
I am working in a simple Django project, and i want to add a button for every model object in admin and i am able to create it by using this:
in admin.py
class RegistrationAdmin(admin.ModelAdmin):
def button(self, obj):
…

vkswhy
- 78
- 8
0
votes
0 answers
CHECKBOXES instead radio buttons at DJANGO ADMIN?
If you are looking for a way to put radio buttons in Django using MODELS you only need do something like this (e.g):
in models.py
class MonitoringPointsClass( models.Model ):
monitoring_has_power = models.BooleanField(
null = True,…

Fernando Cesar
- 131
- 2
- 6
0
votes
1 answer
How to resolve IntegrityError which caused Foreign Key constraint failed
I encountered this error when trying to update/add/delete users in the Admin.
I don't really know what is referencing my model, that has caused the Foreign key constraint to fail.
Below is the model.py, forms.py, and admin.py
Error
IntegrityError at…
0
votes
1 answer
Django ManyToManyField inline list values
I have two Django models related by a ManyToManyField relationship. Everything works fine except for the inline add dropdown which lists ugly automatically created object names instead of allowing me to format it. How can I specify…

rubmz
- 1,947
- 5
- 27
- 49
0
votes
1 answer
Django Query values_list getting last value
Lets say I have a blog and a class user in a model. Furthermore I have a class comment connected with a foreign key.
class User(models.Model):
UserName = models.CharField(max_length=50, blank=True)
UserCountry =…

kingbrain
- 116
- 12
0
votes
1 answer
Overriding django form in Forms.modelAdmin
I have a problem when I want to override a field in my form
The class looks like below
class UserCreationForm(forms.ModelForm):
class Meta:
model = User
fields = ['password', 'services', 'project', 'email', 'name', 'first_name',…

reda
- 5
- 3
0
votes
1 answer
Django ModelAdmin - custom name of items in drop down list
I want to change a names of items (users) in drop down list in Django Admin Model. I want to do it without any changes in basic models.
I just want to field 'user'(admin.py) refers to 'user' in Worker model(office.py) through username (just…

dzierzak
- 79
- 10
0
votes
1 answer
How to introduce a model class method in Django admin
I have a model that has class methods. In testing the class methods work and alter the model instances according to my needs. The issue is using this class method in the admin. When an application cannot pay a late payment fee is applied creating…

max89
- 443
- 5
- 18
0
votes
1 answer
How to add multiple foreign key in Django
I am beginner in Django.
I am having two models
class Employee(models.Model):
full_name = models.CharField(max_length=120,default=None)
designation = models.CharField(max_length=80,default=None)
class Leave(models.Model):
employee =…

sourabhah
- 424
- 4
- 16
0
votes
0 answers
django modelAdmin with different TabInline class
I have been picking up Django for a month or two and don't have a strong education in programming, so bear with me. It may be easier than I've found it.
My project is extending the Polls app from the tutorial with a variety of different question…

Atcrank
- 439
- 3
- 11
0
votes
0 answers
Django admin - Extended User model
My requirement is to create 2 types of user in Django.
1. Student
2. Faculty
I have extended the Django user model by creating a MyProfile model:
class MyProfile(models.Model):
user = models.OneToOneField(User,…

Shashank Sachan
- 520
- 1
- 8
- 20
0
votes
2 answers
Cannot register simple-history if already using ModelAdmin customization?
register() only takes 3 positional arguments ("self" being passed implicitly. If already using a ModelAdmin class to customize the appearance of the model in Django Admin, my registration would look like:
admin.site.register(AttorneyGroup,…

Nicole Marie
- 159
- 2
- 12
0
votes
1 answer
For a Charfield with choices, how to use the human readable name in list_display through a foreignkey?
Let's assume I have the following :
models.py :
VALUE_CHOICES = (('0', 'ZERO'),
('1', 'ONE'))
class ModelA(models.Model):
def val(self):
return self.model_b.value or ''
class ModelB(models.Model):
modela =…

vmonteco
- 14,136
- 15
- 55
- 86
0
votes
1 answer
Django - Switch between boolean and integer in TabularInline
I have some models in Django like this:
class Object(models.Model):
...
class ObjectFeatures(models.Model):
class Meta:
unique_together = (('object', 'feature'),)
count = models.PositiveSmallIntegerField()
object =…

Olivier Van Bulck
- 751
- 1
- 8
- 22