hey guys, im trying to internationalize my site, so i have the django cms multilingual middleware class in my settings.py , when viewed from brasil, the url changes to
www.ashtangayogavideo.com/pt/ash/homepage/ resulting in a 404, because my site is in www.ashtangayogavideo.com/ash/en/homepage, how can i configure the middleware, or settings.py, so that the language code is added after the /ash/ ? .
Sounds like you need to modify your urls.py, not your settings or middleware.
Related
I'm a Django newbie and looking at Mezzanine CMS and looked at all URLs, can somebody point where http://127.0.0.1:8000/about/ is defined, what urls.py, I'm guessing it is
urlpatterns = [
url("^(?P<slug>.*)%s$" % ("/" if settings.APPEND_SLASH else ""),
views.page, name="page"),
]
is that correct?
That is correct. Mezzanine page urls are not defined explicitly in a urls.py, but are stored in the database in the Page model's slug field. You can navigate to the "about" page and the admin and modify its slug field there.
Note that in practice, page views are always intercepted and returned by mezzanine.pages.middleware.PageMiddleware, which could be relevant for debugging purposes.
I'm writing some API functionality for my project using Python 3.4 and Django 1.6.
All functionality works fine, but I want execute one function for all that kind of requests.
For Example: I have following urls.py file in my API application in Django project
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^getposts', 'Postigs.views.get_posts', name='getPosts'),
url(r'^addpost', 'Postigs.views.add_post', name='addPost'),
url(r'^addcomment', 'Postigs.views.add_comment', name='addComment'),
)
And views.py for that URL requests handling.
So is it possible to execute some function for Example:
def pre_execute(request):
do_something_before_view_function()
I've worked before with many PHP frameworks , there are always some pre_execute() function ... also I've worked with ASP.NET MVC , Node.js Express.js , and all have that function which is firing before request action.
I don't believe that Django didn't have it , but I can't find how implement that functionality.
Thanks.
Middlewares are what you want: https://docs.djangoproject.com/en/dev/topics/http/middleware/
example middleware: https://github.com/django/django/blob/master/django/middleware/common.py
Like iskorum mentioned above, Middlewares is the answer. Or there is also a chance that you are looking for View Decorators. Here is the link https://docs.djangoproject.com/en/dev/topics/http/decorators/
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 trying to add to my project django log object to my django project
I followed these steps
1)pip install django-object-log
2)copied the object_log folder into your Django project.
3)Add "object_log" to INSTALLED_APPS
4)Run ./manage.py syncdb
5)add this url to my project urls ....url(r'yasmina', include('object_log.urls')),
But i don't know what to do next so any help plz ??
and this is one of the urls in url.py of the django object log ...url(r'^user/(?P\d+)/actions/?$', 'list_user_actions', name="user-object_log-actions"),
when i runned the server and added this url to my browser http://localhost:8000/yasmina/user/2/actions/
I got error this url doesnt match
Looks like your Url pattern matches
http://localhost:8000/user/2/actions/.