Questions tagged [django-admin]

1

votes
1

answer
72

Views

How to make a django admin panel for a ready database?

how to make a django admin panel for a ready mysql database ? I have a mysql database with tables and records in it , i want to make an admin panel for it how can i do that ? i searched and there was no strict answer for it . any suggestions will be helpfull , thanks to this great community .
Moji.Michael
1

votes
1

answer
24

Views

Track django admin with Google Analytics

What is the fastest way to put all admin pages of a Django app under Google Analytics/TagManager? EDIT A possible solution is here, but actually my question is about evaluating and comparing all the possible solutions: Include google analytics tag to django admin without changing the template for ev...
Dos
1

votes
1

answer
1.2k

Views

django admin. Create parent with child in same form

I have two classes in my model.py class User(models.Model): name = models.CharField() phone = models.CharField() # Other common fields class Customer(User): payment = models.CharField() user__id = models.OneToOneField('User', db_column='id', primary_key=True) class Company(User): address = models.Ch...
jhrs21
1

votes
1

answer
865

Views

Overriding the clean method in a Django model breaks other validations?

Assume I have a simple model in models.py that is intended to be edited via Django Admin: class Range(models.Model): gt = models.IntegerField('Greater than') lt = models.IntegerField('Lesser than') def clean(self): if self.gt >= self.lt: raise ValidationError('Incorrect range') The problem: While th...
gaazkam
0

votes
0

answer
6

Views

Django JQuery Ajax events not triggered

i extended my django-admin detail site with some javascript magic..., before an ajax requests gets sent, i want to manipulate it with global ajax beforeSend handler, my setup: {% extends 'admin/change_form.html' %} {% block submit_buttons_bottom %} django.jQuery(document).ready(function() { console....
Creative crypter
1

votes
1

answer
10

Views

Django admin multiple querysets on one page

How to have multiple tables(queryset) on one page in django admin. For example: When i go to the company page, i can see the list of departments in the company, i can also see the list of employees in the company.
bituze
1

votes
2

answer
602

Views

Django Admin URL reverse to admin users

I would like to know How I can redirect admin users logged in my Django application (Django 2.0) to the user admin webpage ? In my menu, I have : Administration But How I could redirect to /admin/auth/user ? I tried : Utilisateurs or Utilisateurs But I don't overcome to redirect to user admin page...
Essex
1

votes
2

answer
577

Views

Reorder app and models in Django admin

I want to reorder my apps in my Django admin panel, I saw some responses from another similar question here in SO, so I go for install this method: django-modeladmin-reorder I follow all the steps and it's not working. Here's my actual Django panel #settings.py INSTALLED_APPS = [ 'django.contrib.adm...
Pilar Figueroa
1

votes
1

answer
600

Views

Django: how to change manytomany inline text with no intermediate table?

When you have what I call 'intermediate' ManyToMany tables, it's easy, like that: class Interrogation(models.Model): phrases = models.ManyToManyField(Phrase, blank=True, through='InterrogationPhrase', symmetrical=False, related_name='phrase') class InterrogationPhrase(models.Model): interrogation =...
Olivier Pons
1

votes
2

answer
731

Views

MemoryError at … No exception message supplied

I have a very simple ManyToMany relationship: @python_2_unicode_compatible class Mot(BaseModel): groupes_categories = models.ManyToManyField(GroupeCategories, blank=True, through='MotGroupeCategories', symmetrical=False, related_name='mot') texte = models.CharField(max_length=150) def __str__(self):...
Olivier Pons
1

votes
1

answer
40

Views

Django: I have to login to admin site before the application [closed]

I have a weird problem with my Django application and I have no idea where to look to fix it. Whenever I run my application, before I can login to the application and do stuff on it I have to login to the admin site or else it throws a 'Page not found (404)' error when I try to login to the applicat...
TyCharm
1

votes
1

answer
426

Views

django: automatically detect CRUD changes done on database

I'm building an application(log) which stores the CRUD operations done on database.Is there any way to detect the CRUD operations directly?
Manjunath Gk
1

votes
1

answer
106

Views

Assigning the model field values to a custom field in django?

I have created a custom field in django admin using its admin class.Now I have a model field which is has corresponding database values in it.I want the custom field that i created using admin.py to have values of this model field .Is it possible to assign the model field values to a custom fields i...
user18683
1

votes
1

answer
2.1k

Views

Importing django.contrib.auth.urls does not play well with existing admin templates

I've been trying to follow documentation on using builtin Django templates to login/logout nonstaff users on a Django (1.9) site. In particular, I modified the urlconf by adding url('^', include('django.contrib.auth.urls')) which brings in /login and /logout endpoints and views with default templat...
rschwieb
1

votes
1

answer
853

Views

Use of “class Meta” in Django's admin.py

Can someone please explain why we use nested meta class here? I understood why we use Meta class in model.py from 'https://docs.djangoproject.com/en/1.9/topics/db/models/#meta-options' but I can't understand why we use it in admin.py and forms.py classes as shown below: from django.contrib import ad...
1

votes
1

answer
465

Views

Change verbose_name for is_superuser Django

I have a custom User model class User(AbstractBaseUser, PermissionsMixin): ... Field is_superuser inherited from PermissionsMixin. Is there a possibility to change verbose_name and help_text for is_superuser to my own text without changing Django sources?
Flowneee
1

votes
1

answer
397

Views

Triggering Custom Functionality in Django Admin

I'm new to Django, and Django Admin, so I'm still not 100% with the correct names for things. I want to add a 'Download All' button/link/action to the list view when using the Admin app for a Model. Ideally just like the 'Add' button. I tried a custom action, which almost got me there, but it is ins...
Kong
1

votes
1

answer
16

Views

Django admin show who submitted the entry

I've a database of doctors. I want to be able to see in the admin panel under doctors who created a particular doctor entry. I've the following in my admin.py class CustomUserAdmin(UserAdmin): filter_horizontal = ('user_permissions', 'groups') save_on_top = True list_display = ('username', 'email',...
James L.
1

votes
1

answer
815

Views

Remove or edit object name in admin.TabularInline

My tabular inline in the admin looks like this : How do I get rid of the DateDeCotisation_adherents object phrase ? For bonus points, why are there three empty lines at the bottom ? admin.py class DatesDeCotisationInline(admin.TabularInline): model = DateDeCotisation.adherents.through readonly_field...
Brachamul
1

votes
1

answer
182

Views

How turn {{ fieldset.fields }} in Django template into a string?

What does Django return with using {{ fieldset.fields }}? How can I make it a string? In my template, I have this: {% for fieldset in adminform %} {{ fieldset.fields }} {% if 'nanoadded' in fieldset.fields %} nanoadded is here {% else %} nanoadded is NOT here {% endif %} {% endfor %} Her...
Sandra
1

votes
1

answer
178

Views

Django count today's logged in users

I want to show on my admin interface the count of the users those did log in today. My admin interface looks like following: When I print from my view count = User.objects.filter(last_login=timezone.now()).count() it gives me 0 as both the date/time format are different. i.e. 2016-06-01 14:58:29.07...
Thinker
1

votes
1

answer
428

Views

Upgrading from 1.8 to 1.9 Django Admin get_urls not working

I am using the Django admin and have just upgraded from 1.8 to 1.9. In 1.8, I added a click button to the change_form that takes me to another html template using the get_urls override. Like this: def get_urls(self): urls = super(arunAdmin, self).get_urls() my_urls = patterns('', (r'(\d+)/tarrespgra...
Sandra
1

votes
1

answer
185

Views

Django: manage.py works fine but django-admin fails

I've been starting up a new django project (django 1.8.13, python 3.4) and everything is working fine. However, I just noticed, django-admin returns these errors if I use it instead of manage.py It's reporting there is no module named mysite (name of working project). It's no big deal as the site is...
Fish
1

votes
1

answer
426

Views

Showing validation error from m2m_changed signal in django admin

I am trying to validate that the variable foo is the same for MyModel and Item before adding it as a m2m. I want to raise a ValidationError in the admin if it is not. models.py class Item(models.Model): foo = models.CharField(max_length=200) class MyModel(models.Model): foo = models.CharField(ma...
Maxim
1

votes
1

answer
379

Views

Django Admin - customize use jquery inside and custom fields

I want to implement in Django Admin a jquery plugin that 'adjust' and image(http://guillotine.js.org/), them get the coordinates with ImageKit and save the new image. I need some tutorials and advises how to do it.
user3541631
1

votes
1

answer
994

Views

RemovedInDjango110Warning: The context_instance argument of render_to_string is deprecated

For one of the apps, I'm overloading the 'delete selected objects' method in a Django 1.9.x project which uses the Admin panel. For that, I have a code similar to this: from django.contrib.admin import helpers from django.http import HttpResponseRedirect from django.shortcuts import render_to_respon...
nKn
1

votes
1

answer
1.3k

Views

Django Admin not saving data to the Database

I am trying to save data from my Django Admin to my database but somehow it is not happening. I have created a form in one of my apps which my admin uses.I am new to Django and any help would be greatly appreciated. Below is the relevant code: models.py from __future__ import unicode_literals from...
karan nayak
1

votes
1

answer
845

Views

Django import-export choices field

I have a model with choices list (models.py): class Product(models.Model): ... UNITS_L = 1 UNITS_SL = 2 UNITS_XL = 3 PRODUCT_SIZE_CHOICES = ( (UNITS_L, _('L')), (UNITS_SL, _('SL')), (UNITS_XL), _('XL'), ) product_size = models.IntegerField(choices=PRODUCT_SIZE_CHOICES) ... Also I added a new class f...
Serko
1

votes
1

answer
437

Views

How to populate django admin form from model property?

I have model which among other fields contains price property which is calculated dynamically. I want to display this property in model admin page. So I've created custom ModelForm: class ShipmentForm(forms.ModelForm): price = forms.IntegerField() class Meta: model = models.Shipment fields = [ 'titl...
dimazubrik
1

votes
1

answer
36

Views

Django Static Inlines

I have a model Student with lots of fields and a model Document with a ForeignKey to Student. I'm using an inline to edit Students' associated Documents. models.py: class Document(models.Model): def media_path(instance, filename): return '{0}/{1}'.format(instance.Student.Id, filename) File = models....
AnDrOiD
1

votes
1

answer
260

Views

Trouble overriding save method on Django model with ManyToManyField

I'm having trouble overriding the save method on a Django model to check a restriction on a many-to-many field. Say I have the following models: class Person(models.Model): name = models.CharField() class ClothingItem(models.Model): description = models.CharField() owner = models.ForeignKey(Person)...
8one6
1

votes
2

answer
1.3k

Views

missing 1 required positional argument: 'queryset'

I am attempting to update an extended user model profile in admin.py actions. I have been researching this for a couple hours now and have come up short. I am receiving a pc_add_1() missing 1 required positional argument: 'queryset' error, please help. class ProfileAdminInLine(admin.StackedInline):...
Kerosive
1

votes
1

answer
231

Views

How to display many to many relationship fields (if the many to many relationship is using 'through') in the Django Admin Area?

I know it is easy to display fields for foreign keys in the admin area, but how do I display fields for many to many relationships if through is used? Models.py: class Pizza(models.Model): toppings = models.ManyToManyField(Topping, through='PizzaTopping') class Topping(models.Model): topping = model...
Tom Brock
1

votes
2

answer
38

Views

I'm having trouble deciding between using a foreign key, many-to-many field, or choicefield

edit: Code has been updated with working solution I'm building a video game library and I'm having some trouble structuring my models. I'm not sure if I should use a many-to-many, foreign key, or choices field to do the following: There are game consoles (PC, Playstation 4, etc) and video games (Roc...
NoahLE
1

votes
1

answer
44

Views

Django Faking Required Fields

I'd like to know if there's any to way to make a nullable (null=True) field be required when creating models (or saving)? As a superuser, I'd like to be able to leave certain fields with null while other staff members won't be able to. Is there any way to do something like that? Thanks in advance. E...
AnDrOiD
1

votes
1

answer
1.3k

Views

How to use Django-autocomplete-light for foreign key in the admin

I've been struggling to add an autocomplete to django admin fk fields, I've come across this third party app, Django-autocomplete-light, but its docs are very confusing for beginner like me. So, I have my model, and how could I add an autocomplete for the fk fields. Class Order(models.Models) Client...
Goun2
1

votes
1

answer
448

Views

Django can't download file via admin

I'm using Django version 1.10.5 to build a website with the following apps installed: django.contrib.admin django.contrib.auth django.contrib.contenttypes django.contrib.sessions django.contrib.messages django.contrib.staticfiles bootstrap3 myapp storages In the models.py I defined the following cl...
Nkls155
1

votes
1

answer
39

Views

Getting AttributeError while registering my model to Django admin?

What i am trying to do: Trying to registering my model to django admin What problem do i get: I am getting the following error: My Code: admin.py: from django.contrib import admin from .models import UserProfile, Post admin.site.register(UserProfile,Post) model.py: from django.contrib.auth.models i...
Ahtisham
1

votes
1

answer
342

Views

make django not insert certain fields

I have a Django model against a postgresql database table where I want Django to not insert field_3 during object creation as its a timestamp field that DB is supposed to fill in. class AbcModel: model_id = models.AutoField(primary_key=True) field_1 = models.BigIntegerField() field_2 = models.TextFi...
comiventor
1

votes
1

answer
263

Views

Django Group Permissions-like Field

I would like to know how what is the name of the field and how to use it in django admin groups permissions as I attach in the image below. It looks like a ManytoManyField but it is a lot more user freindly.
Stavros Avramidis

View additional questions