Admin Page in Django - django

I want to check about some field in Django if the DB Contains the same value for it before make ADDITION in the admin page . and if there is any field with the same value a message will be appear, then the admin will take a decision if he wants to add or not.
and i dont want to make these field UNIQUE.
is it possible?

Related

Django - Does the default Django User model have any unique fields?

I know I should be able to find this in the Django documentation but I was having a difficult time. In my application I need to query the default Django User model but I need to do it in a way that it will only ever return one result. For this to happen one of the fields need to be unique.
Does the Django User Model have any unique fields I can use?
Thanks.
Of course it does: username must be unique, otherwise there would be no way of logging in a specific user.
And, as agconti points out, all models have a pk field which must be unique by deifnition.

Want to make an action

I have an django site for new articles , in which multiple user write articles.
I want to make an action for selecting a user , so that If I choose a particular user , I can only see its updation/insertion in admin site.
If updation/insertion is part of a model that has an foreign key to USER model, then just write an admin-inlline to show a list of them in the user page below all other fields

Reflect changes in admin page Django

I have a model and originally it had these attributes
First Name
Last Name
Email
I altered the model to include an additional attribue : Address , now it looks like this
First Name
Last Name
Email
Address
I am using MySQL database and the changes are reflected in the table in the database , however the changes are not reflected in Django admin as the tables does not have a new column called Address.
I know it has something to do with overriding the admin template in Django but i cant seems to be able to do it , can someone guide me
Thanks
In your admin.py file in your app directory, there will be a subclass of ModelAdmin that is registered for this model. Make sure the address field is listed in either the fields or fieldsets property of this class, and make sure it is not listed in the exclude list on this class.
REF: https://docs.djangoproject.com/en/dev/ref/contrib/admin/

How to modify the way a ForeignKey field is rendered in a Django admin page to avoid browser crash?

I have a Customer model which contains a ForeignKey to a Contact model.
I have over 100,000 contacts in my DB and when I load the admin page for a specific customer, the dropdown menu for the contact is getting populated with ALL of the contacts in the database. This has recently, due to its shear length, started causing my Firefox to crash while the admin page is loading.
Is there a way to either:
replace the field with an integer
field I can manually modify to the
contact ID when necessary
replace the dropdown menu with some
alternative input method which won't
crash the browser
remove this input
from the Customer admin page
altogether
Thanks!
You can do any of the either of things you want to.
Simplest solution is the exclude the field from the admin. Just say so in the admin class.
You can change the field to be text input and display it's primary key rather than the item itself, by including it in the raw_id_fields of the admin class.
You can also replace the standard dropdown widget with the Auto complete text field input. Use the implemented widget, or other equivalents. - This is probably the solution you like the best.
You can also override the formfield_for_foreignkey method on the Admin model to customize the queryset that gets displayed in the foreign-key dropdown. You may want to checkout my implementation for displaying only the current User's (or subdomain's) added entities.
Sounds like specifying the contact field in raw_id_fields in your admin.py entry for the relevant model would sort you out. Docs are here.
PS. Surprised (but not that surprised) that FF gives out before your database server tanks...

Does Django admin provide group edit of models?

For instance, I have a model called Person, and it has a bool field called 'isAthlete'. I would like to be able to check off True for 50 of these Person records, and then hit submit, without having to go into each Person model record and make the change. Is there an easy or already provided way to set this up in Django?
you can do this using django admin actions, http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/