django-errors

My Ajax request throws an error in django, how do I find what it is?

爷,独闯天下 提交于 2019-12-11 04:02:20
问题 How do I get more information about the errors in my Ajax requests? When error occurs in Django during a normal HTTP request , Django shows a descriptive error page with exception details. However, when error occurs during an AJAX request , I just know the HTTP error code and that's it. I'd like to know as much details as I learn from a Django error page. 回答1: Your web server's error log will contain additional information about any uncaught exceptions. 回答2: Handle errors within your ajax

changing the field name django uses when display form error messages

久未见 提交于 2019-12-11 02:54:58
问题 Okay so I have a form and then in the template, I have this code: {% if form.errors %} { form.errors %} {% endif %} Now, suppose I have a username field in my form which is required and I purposely do not fill it out. It would say username -This field is required How do I change the word "username" which it displays when telling what field the error message is for? I'm guessing it is taking the name from the Model I created because in the model (which I then made a form of) I had written

Cause of Django duplicate entry error (1062)?

蹲街弑〆低调 提交于 2019-12-10 11:27:45
问题 I updated the info below to reference a different model/view that is giving me the same error. Its a simpler model so there are less variables to take into account... I have the following model: class Imaging_order(Order): order_description = models.ForeignKey(Imaging_test, limit_choices_to = {'active': 1}, null=True, blank=True) orders = models.ManyToManyField(Imaging_test, limit_choices_to = {'active': 1}, related_name='orders') ... I have the following views (basically the generic django

Django custom 500 error template not displaying request.user

流过昼夜 提交于 2019-12-07 06:07:17
问题 I'm implementing custom 404 and 500 templates, but while the 404.html template seems to return request.user.is_authenticated fine, the 500.html template fails to return anything. I also checked for request.user and it's just blank on the 500 page. This is very strange, because when I trigger the 500 error, I receive the expected error report e-mail, and it clearly has USER properly defined in the request breakdown. Here's the code I'm using in views.py: def handler404(request): response =

In Django, when I call User.objects.create_user(username, email, password) - why does post_save get called twice?

倖福魔咒の 提交于 2019-12-06 11:42:22
In views.py I have the following view which gets called when a new user account is registered. All it does is get the username, email, and password from the request, then try to create a user with those credentials. In the code below, "A" gets printed, but "B" does not, because it crashes: views.py def register(request): if request.method == 'POST': query_dict = request.POST username = query_dict['username'] email = query_dict['user_email'] password = query_dict['password'] role = query_dict['role'] print "A" user = User.objects.create_user(username, email, password) # the handler is called

Django error email is too long. How do I truncate it?

只愿长相守 提交于 2019-12-06 05:43:41
问题 It seems like the error emails in Django 1.9 are much longer than they were previously. There's a whole section for "settings" which I think is superfluous and potentially too revealing. What is the best way to edit the error email that Django sends? edit: I am not just trying to hide sensitive information. There is a lot more content in the email in Django 1.9 and I want to change the format of the email to be shorter. I liked it the old way. 回答1: There's a django template variable TECHNICAL

Django: Field Error Unknown fields

喜夏-厌秋 提交于 2019-12-05 15:02:35
问题 I just installed OS X Lion, so I had to reinstall everything for Python2.7. In doing that I upgraded my Django to 1.3 from 1.2.3. When I try and runserver, I get an odd field error that I'm having a tough time deciphering. FieldError at / Unknown field(s) (a, m, s, e, g) specified for Note Here is that Model & Form: class Note(models.Model): pub_date = models.DateTimeField(default=datetime.now, auto_now_add=True, db_index=True) user = models.ForeignKey(User, null=True, blank=True, related

Make django templates strict

痴心易碎 提交于 2019-12-04 18:37:30
问题 In a django template, a call to {{ var }} will silently fail if var is undefined. That makes templates hard to debug. Is there a setting I can switch so django will throw an exception in this case? The only hint at a solution I've found online is http://groups.google.com/group/google-appengine/browse_thread/thread/86a5b12ff868038d and that sounds awfully hacky. 回答1: Django<=1.9 Set TEMPLATE_STRING_IF_INVALID = 'DEBUG WARNING: undefined template variable [%s] not found' in your settings.py .

Django error email is too long. How do I truncate it?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 09:32:33
It seems like the error emails in Django 1.9 are much longer than they were previously. There's a whole section for "settings" which I think is superfluous and potentially too revealing. What is the best way to edit the error email that Django sends? edit: I am not just trying to hide sensitive information. There is a lot more content in the email in Django 1.9 and I want to change the format of the email to be shorter. I liked it the old way. There's a django template variable TECHNICAL_500_TEMPLATE / TECHNICAL_500_TEXT_TEMPLATE in the django debug view that controls what's visible in the

Django Error Reporting - How to know which user triggered the error?

…衆ロ難τιáo~ 提交于 2019-12-04 03:02:04
Is there a way I can customize Django error reporting so when it emails me it lets me know which user triggered the error? I'm in Django 1.2 if it matters. Much Thanks in advance! If you don't want to use sentry you can use this simple middleware to attache the user-infos to the error mail: # source: https://gist.github.com/646372 class ExceptionUserInfoMiddleware(object): """ Adds user details to request context on receiving an exception, so that they show up in the error emails. Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on top if possible). This allows it to catch