As per the docs,it expects this file in a folder named 'registration' in templates directory.I tried that ,but I am getting a templateNotFound exception.
I have configured the registration template location like
from django.conf.urls.defaults import *
urlpatterns=patterns('django.contrib.auth.views',....)
urlpatterns+=patterns('registration.views',
url(r'^register/$','register',{'template_name':'myapp/registration_form.html'},name='myapp_register'),
)
Is there some place I can configure the location for activation_email.txt template ? When I submit the registration form ,the user is created in db ,but django searches all over python path for the activation_email.txt template
Why is it that all other templates are found with out any problem while this template is not found?
Look at your TEMPLATE_DIRECTORIES setting. The template paths are relative to any of the TEMPLATE_DIRECTORIES.
If template_name is myapp/registration_form.html, then you should create a dir "myapp" in one of the TEMPLATE_DIRECTORIES, and put registration_form.html in there.
To double check TEMPLATE_DIRECTORIES, run manage.py shell and in there from django.conf import settings; print settings.TEMPLATE_DIRECTORIES.
Related
I have a django app and a view for the home page where I want to use a static html file for the homepage. My file structure is like this:
project/
stats (this is my app)/
urls.py
views.py
stats.html
(other files here)
In my views.py I have the following code:
from django.shortcuts import render_to_response
def index(request):
return render_to_response('stats.html')
When I run the urls, I just have the index page. I go to the stats page and I receive a TemplateDoesNotExist Error. Looking for an answer I tried to put stats/stats.html instead for the path, but I still get the same error. What is the correct way of doing this?
In your project directory, add a directory called 'templates' and inside the templates directory, create 'stats' directory. Put your HTML file in the stats directory.
Then change your settings file at the bottom from
TEMPLATE_DIRS = (
os.path.join(SETTINGS_PATH, 'templates'),
)
To
TEMPLATE_DIRS = (
os.path.join(BASE_PATH, 'templates'),
)
You can arrange your project like this
project/
stats (this is my app)/
urls.py
views.py
stats.html
templates/
stats/
stats.html
In your views.py, write this:
def index(request):
return render_to_response('stats/stats.html')
make sure there is 'stats' in the INSTALLED_APPS list in the settings.py.
I am new to django..
When I was working before 2 days..it was working properly..
Now django index page shows ..
ViewDoesNotExist at /
Could not import mysite.views.home. Parent module mysite.views does not exist.
my url.py contain
url(r'^$', 'mysite.views.home', name='home'),
please help me.
Where I did mistake??
Is the views.py that you are referring to in the project root? Error message says it can't find that file so check the path. If you moved the home view into an app folder, make sure you configured your settings file to include the app and point to the app folder as app_folder.views.home
Seems like a mistake in your views.py. Could you add the home view code?
I want to use django's password change/reset views so for example for the view
django.contrib.auth.views.password_change
I need create a template named
registration/password_change_form.html
the problem is that even though I have this template implemented in my project, django still shows the password-change page of the admin website, the only way I can make django use my template is by renaming it to something different - like registration/password_change_form_1.html and then pass the name
url(r'^password/change/$',
auth_views.password_change,
{'template_name': 'registration/password_change_form_1.html',
'password_change_form': MyPasswordChangeForm},
name='password_change'),
Am I missing something here? why won't django use my template when I use the default name?
I think because your app is under django.contribute.admin in the INSTALLED_APP.
Django automatically generates the admin template with the default name, so, if you use the admin, you must specify a different template name.
It simply fails to find your template, since it is overiden by the generated one.
Add in settings
INSTALLED_APPS = (
...
'registration',
)
After
TEMPLATE_DIRS = (
...
"/home/user/templates",
)
Add in directory templates "registration"
base.html that will contain the template and other templates
run in django==1.5
I am trying to edit some things in django and am running into a few problems as I am quite new to it.
I am working off an existing django configuration with templates that currently work, but I don't really understand how to create new templates. If I create a new .html file in my templates folder in "myprojects" and then declare the new template under cms_templates = (...) in settings.py nothing happens. Am I missing a step to get the template to upload and appear in my cms?
I also had a problem with an existing template, when I try to go to the contact page I am told that the template does not exist: http://paul.evansoderberg.com/en/contact/
The template is declared under "cms_templates", the file exists in the templates folder, and the page is created in django cms yet I get this error message.
Help would be greatly appreciated, thank you.
In settings I have :
CMS_TEMPLATES = (
('index.html', 'index'),
('contact.html', 'contact'),
('main.html', 'main'),
('about.html', 'about'),
('cv.html', 'cv'),
)
The template field in admin is set to "contact"
I've gotten userena successfully installed and I've copied the entire userena template directory over to my app (which is not named userena but rather accounts, so the directory the templates are in is /accounts/templates/accounts/ ) but simply editing them reflects no changes. When I point my urls.py to
url(r'^accounts/signout/$', userena_views.signout, {'template_name': 'accounts/signout.html'})
It works, but only for that one file. Is there a way to have the entire app automatically refer to this templates directory? I thought about using TEMPLATE_DIRS but that would apply to the entire site and not this one app. Any solutions? Thanks for your help.
The view that calls this template:
def signout(request, next_page=userena_settings.USERENA_REDIRECT_ON_SIGNOUT,
template_name='userena/signout.html', *args, **kwargs):
Put all userena templates in accounts/templates/userena instead of accounts/templates/accounts.
That should work.