Skip to content

Tag: django

How to Get all post data from a request in Django?

Is there any way get all the form names from a request in Django ? Html request in the above I can get only from the name I know, what I need is to get all names of the django request and later parse it and get data. Answer Try use this: But if you need print a dynamic POST

Catch IntegrityError in Django Admin

Working with Django 1.4 I would like to catch an Integrity Error when a user does enter a duplicate value. At this moment the application just shows the default Django error page. (debug = True) model admin form At this moment I get an error page showing a ValidationError instead of an IntegrityError. (Which …

Django percentage field

I’m trying to create a percentage field in Django, where the user just fills in 40 for 40%. There will be a percentage sign on the right of the input box so that they know they should fill in a percentage. 0.4 must be stored in the DB. So far I’ve tried the following: It works, but the problem is,

Django download a file

I’m quite new to using Django and I am trying to develop a website where the user is able to upload a number of excel files, these files are then stored in a media folder Webproject/project/media. The document is then displayed in a list along with any other document they have uploaded, which you can cl…

Django admin is_staff based on group

Is it possible to have is_staff selected by choosing a group? Let’s say there are two groups: users, admins When a new user is in the users group he is not staff, but if he is in the admins group he is staff. Answer I managed to make it work by extending the UserAdmin class and in the get_form function

get mongodb “_id” in django template

My question is related to this question. I am trying to display all the _id of mongo database in django template from last 2 days but unable to get it. This is the error: This is the code I am trying: views.py product.html Though, I tried changing the name to static, cache etc, but still no luck. Answer templ…