Code

Opened 15 months ago

Closed 15 months ago

Last modified 7 months ago

#19701 closed Uncategorized (worksforme)

error500 default view don't include STATIC_URL

Reported by: hugo.arregui@… Owned by: nobody
Component: Generic views Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

i was playing with this behaviour when I found this:

https://github.com/django/django/blob/master/django/views/defaults.py#L41

error500 is the only default view which doesn't use RequestContext, then, STATIC_URL is not included.

Is there a reason for that?

Thanks.

Attachments (0)

Change History (3)

comment:1 Changed 15 months ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

A friend point me to: https://code.djangoproject.com/ticket/5617

But this is a problem.. maybe the default view could insert STATIC_URL from settings without RequestContext?

comment:2 Changed 15 months ago by mlavin

  • Resolution set to worksforme
  • Status changed from new to closed

The reason why it does not use a RequestContext is already documented https://docs.djangoproject.com/en/1.4/topics/http/views/#the-500-server-error-view

The default 500 view passes no variables to this template and is rendered with an empty Context to lessen the chance of additional errors.

You can still use the get_static_prefix https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#get-static-prefix or static https://docs.djangoproject.com/en/1.4/howto/static-files/#with-a-template-tag to reference static files without a RequestContext.

comment:3 Changed 7 months ago by mlissner

Is it just me, or should we try to document this better? Maybe add it as part of the static configuration page? It's a big gotcha for somebody that's made their 500 page, and has it depend on their base template, where the {{ STATIC_URL }} will work the rest of the time.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.