Here's my best attempt:
urlpatterns = patterns('',
url(r'^$', 'django.views.generic.simple.direct_to_template',
{'template': 'main.html', 'login_required': 'True'}),
)
What am I missing?
An explanation of what you expect to happen and what is actually
happening for a start, along with any error message.
How are your trying to use login_required in your template? Your initial
paragraph says you are trying to use the login_required *decorator*, but
that is something that applies to Python code, not inside a template.
Regards,
Malcolm
I'm sorry, my terminology was probably improper. I think should have
said I'm trying to use login_required as an argument for a generic
view.
What I'm trying to do is have a URL that uses direct_to_template to
send people to my application's main page. I want to require login to
view this page.
If I were doing it with a regular view, I'd just put the
login_required decorator above it. Since the page has no logic that
requires a view to be written, direct_to_template will work nicely.
The documentation says that CRUD generic views take an optional
argument of login_required.
from django.contrib.auth.decorators import login_required
from django.views.generic.simple import direct_to_template
urlpatterns = patterns('',
(r'^someurl/', login_required(direct_to_template), { 'template':
'template.html', }),
)
- whiteinge
That did it perfectly - thanks!