I'm having the same problem as this question. However, on my local machine, the password prompt is displayed, but when I push to my development server on Openshift, the password prompt is not displayed. Instead, only this is displayed:
Coming soon...
This is not yet available to the public.
Again, as the linked question states, it seems like the form context variable is not passed to the template. I have not changed anything in lockdown. Furthermore, this used to work. I've gone through the history of my settings.py and no smoking gun. What's irritating is that this works on my local machine. Here's the lockdown related variables in my settings.py:
USE_LOCKDOWN = True
if USE_LOCKDOWN:
INSTALLED_APPS += ('lockdown',)
MIDDLEWARE_CLASSES += ('lockdown.middleware.LockdownMiddleware',)
LOCKDOWN_PASSWORD = ('mypassword')
LOCKDOWN_URL_EXCEPTIONS = (r'^/admin',)
LOCKDOWN_FORM = 'lockdown.forms.LockdownForm'
Found the problem.
When I had initially installed lockdown using pip on my local machine, pypi only had version 0.1.1, which uses LOCKDOWN_PASSWORD. In my settings.py, I used a string for the password, not a tuple. In the question I had linked to in my original post, the answers mentioned passing a tuple instead of string. I tried that, and that did not work.
When you push code onto OpenShift and don't specify the version in setup.py, it downloads the latest version of the package. In the latest version of lockdown, LOCKDOWN_PASSWORDS is used instead and that expects a tuple. I updated my settings.py file accordingly, and now a password prompt is displayed.
Related
I am trying to setup translations for emails with django-allauth.
I have rewritten my templates, translated my .po files and complied them.
The html translations work fine but for some reason just the emails don't get translated.
I have properly configured translations following the django tutorial
https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#how-django-discovers-language-preference
The related question doesn't help:
How does email translation work with django allauth?
Package versions:
Django==1.10
django-allauth==0.27.0
I had the same problem with django-allauth==0.32.0 and Django==1.11.1. Translations that are shipped with allauth are simply outdated or incomplete. In my project, for example, an email with a link to reset the password was always in English (in default language LANGUAGE_CODE = 'en') although the user set the language to Czech.
In .po file for Czech translations: https://github.com/pennersr/django-allauth/blob/master/allauth/locale/cs/LC_MESSAGES/django.po#L408 is this e-mail translation marked as fuzzy – so translations are not used. The same applies to other languages I've checked (de, es...).
The reason is explained in this comment from the author of allauth:
The allauth templates are merely meant as a starting point, something
to get you going quickly. Hence, I do not treat issues in the
translations as blocking for release, which can result in translations
getting left behind. Feel free to submit pull requests to fill in the
gaps.
Source: https://github.com/pennersr/django-allauth/issues/1113#issuecomment-141189606
I think there are two ways to solve this issue:
Fix/update translations on https://www.transifex.com/django-allauth/django-allauth/, submit pull request on Github and wait for a new release.
My recommendation: copy all templates from allauth to your project, make your own *.po files and ignore all default translations/templates. Do not forget that e-mail templates are in *.txt so you must call makemessages this way: python manage.py makemessages ... --extension html,txt,py.
I've installed Aldryn-boilerplates, using Configuration block's advices from github (https://github.com/aldryn/aldryn-boilerplates#configuration).
But when I make python manage.py runserver I recieve a message:
/home/stp/env/local/lib/python2.7/site-packages/django/template/loader.py:110: UserWarning: Your TEMPLATE_LOADERS setting includes'aldryn_boilerplates.template_loaders.AppDirectoriesLoader', but your Python installation doesn't support that type of template loading. Consider removing that line from TEMPLATE_LOADERS.
warnings.warn("Your TEMPLATE_LOADERS setting includes %r, but your Python installation doesn't support that type of template loading. Consider removing that line from TEMPLATE_LOADERS." % loader)
The web page loads normally (without any template or style).
Also a question, where to put line ALDRYN_BOILERPLATE_NAME = 'bootstrap3'? I've placed it in the bottom of my project's settings.py file.
Anyone knows how to fix that? Or maybe there are another framework with much more detailed description about installation and configuration, which fits for beginners?
I got the some error with django 1.8 and a custom template loader. I had overridden the Loader class out of django.templates.loaders.base. To get rid of this error I also had to the set the class variable is_usable to true
class Myloader(Loader):
is_usable = True
So maybe you can solve your issue with subclassing the 'aldryn_boilerplates.template_loaders.AppDirectoriesLoader' and only change the class variable as shown above.
You have placed the ALDRYN_BOILERPLATE_NAME = 'bootstrap3' at the right place. Please mention the versions of python and django-cms you are using. If you want to try another blogging platform for python, then http://mezzanine.jupo.org/ is helpful for beginners, because it's very easy to setup.
I'm trying to run a django website on my local computer. It works fine on an external server, but I didn't set it up and right now I don't have access to all the specs.
The issue I have is when I try to log in the web site as a user, which has been defined. Running in debug mode I get a detailed error page containing on top the message:
UnicodeDecodeError at /accounts/login/
'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
Looking down I can see that the error occurs in crypto.py, function salted_hmac at the line
key = hashlib.sha1((key_salt + secret).encode('utf-8')).digest()
and displaying the local variables I see
key_salt u'django.contrib.sessionsSessionStore'
secret '\xe2\x80\x9cXXX"'
value '{}'
where XXX is a 50 character string identical to the SECRET_KEY defined in my configuration file. Variable secret is assigned in the function through:
if secret is None:
secret = settings.SECRET_KEY
and I know that secret is None at this point since it is a third parameter in salted_hmac not used by the caller. I strongly suspect that the error occurs because python can not handle the unicode characters at the beginning of the variable secret.
So I have a few questions:
1) Why is setting.SECRET_KEY different from the SECRET_KEY I defined in the configuration file? Is it how it should be? And if it is do I have any control over what it should be?
2) Could something in my environment be responsible for this?
A few notes: As I mentioned it works on a server, running ubuntu 1.6, python 2.7. However I can not right now obtain the info on the versions for the other packages. But even if I could I still want to know why it doesn't work on my installation. I have tested with django 1.6.1, python 2.7 on lubuntu 14.04, opensuse 13.2, with identical results.
Thanks for any help or hint.
a
Problem solved: the secret key in my configuration file started with an (unicode) opening quote, instead of a regular double quote, probably a result of copying and pasting the original file that had been written with an editor that uses these "smarter" quotes.
I know, I know, the first thing you are thinking is to check all of the instructions online and on dajaxproject.com
Well I have checked and checked and rerun this installation and I cannot figure out what the problem is. I assume it has something to do with the version of Dajaxice I am using and the version the installation instructions are, but those details are usually missing.
At this point in the process, I have everything setup to accomplish a very simple task. Load a webpage from the IP:8000 (ie 1.2.3.4:8000) and have that page load a simple html form button. Once that button is pressed, the page should then send a mesage (using dajaxice) to the server, and once it returns an alert box will pop up, proving that the dajaxice install is working.
So, I have:
Installed Dajaxice (and dajax for that matter), by getting the zip from here: github [dot] com/jorgebastida/django-dajaxice/
Changed everything in a basic Django project to follow the details in this tutorial: http://django-dajaxice.readthedocs.org/en/latest/installation.html
I have setup all of the details of ajax.py, and index.html to work with this example: django-dajaxice [dot] readthedocs [dot] org/en/latest/quickstart.html
PS Sorry for the "[dot]"s, but being a new registered user they limit you to 2 per post, so I tried to give you the best links clickable.
I am stumped. I have been trying many different things, but the documentation available seems so sporadic. It's gotta be something simple I am messing up, but I cannot seem to find it.
Currently, the "Say Hello!" button shows up on the screen, but nothing happens when you press it. Any ideas?
Here is a link to the zip file of the Django project I am working with here: https://docs.google.com/open?id=0B5rzYk6W5HlrYk9veVRfM3JkTGc
The way I have it all organized, DjangoAjax is just the folder containing the Django project. ajax_prac is the project, and practice is an app. Also you'll see a folder called django_media...that's pretty self explanatory, it just holds all the "media" for my Django projects, including jquery.js and jquery.dajax.core.js
If there are some details that I have smudged in the code, contrary to the installation guide, I apologize. I have been working through so many iterations of this, that it is likely I could've forgotten to change something back when making this post.
Can anyone help?
All the documentation weirdness is probably related with the new release I made yesterday (8 hours ago). Probably you was using an old version of dajaxice reading the new documentation.
I've release django-dajaxice (0.5) and django-dajax (0.9.1), both fully compatible with the last version of Django (1.4.1).
django-dajaxice: http://pypi.python.org/pypi/django-dajaxice
django-dajax: http://pypi.python.org/pypi/django-dajax
For this release I've also rewrite both documentations and hosted them on readthedocs. Also, http://dajaxproject.com code is now opensource so everybody can read the code and see how dajaxice works in production.
django-dajaxice: http://django-dajaxice.readthedocs.org/en/latest/
django-dajax: http://django-dajax.readthedocs.org/en/latest/
example project: https://github.com/jorgebastida/dajaxproject.com
Could you please upgrade to django-dajaxice (0.5) follow the new installation steps (quite similar http://django-dajaxice.readthedocs.org/en/latest/installation.html) and post here any traceback/issue you could have?
Thanks
In your example code ( DjangoAjax / ajax_prac / templatedirectory / practice / index.html):
<input type="button" value="Send message to server!"
onclick="Dajaxice.ajax.sayhello(my_js_callback);">
Should be:
<input type="button" value="Send message to server!"
onclick="Dajaxice.ajax_prac.practice.views.sayhello(my_js_callback);">
I.e. It must reference a Python module that contains your registered Dajaxice view. And according to your sample code, ajax_prac.practice.views exists while ajax.sayhello does not.
Also the Python module must be prefaced with "Dajaxice" (which is probably a significant source of confusion).
Where should DATETIME_FORMAT be placed for it to have effect
on the display of date-time in the Django admin site
(Django’s automatic admin interface)?
Documentation for DATETIME_FORMAT, on page
http://docs.djangoproject.com/en/1.0/ref/settings/, says:
"The default formatting to use for datetime fields on
Django admin change-list pages -- and, possibly, by
other parts of the system."
Update 1: DATETIME_FORMAT is broken (the value of it is
ignored), despite the documentation. Many years ago it
worked, but since then the Django implementations have been
broken wrt. this feature. It seems the Django community
can't decide how to fix it (but in the meantime I think they
should remove DATETIME_FORMAT from the documentation or add
a note about this problem to it).
I have put these lines into file "settings.py" of the
website/project (not the app), but it does not seem to have
any effect (after restarting the development server):
DATETIME_FORMAT = 'Y-m-d H:i:sO'
DATE_FORMAT = 'Y-m-d'
As an example "June 29, 2009, 7:30 p.m." is displayed when
using Django admin site.
Django version is 1.0.2 final and Python version is 2.6.2
(64 bit). Platform: Windows XP 64 bit.
Stack Overflow question European date input in Django Admin seems to be about the exact opposite problem (and thus an apparent
contradiction).
The full path to file "settings.py" is
"D:\dproj\MSQall\website\GoogleCodeHost\settings.py". I now
start the development server this way (in a Windows command
line window):
cd D:\dproj\MSQall\website\GoogleCodeHost
set DJANGO_SETTINGS_MODULE=GoogleCodeHost.settings
python manage.py runserver 6800
There is no difference. Besides these are positively read
from file "settings.py":
DATABASE_NAME
INSTALLED_APPS
TEMPLATE_DIRS
MIDDLEWARE_CLASSES
"django-admin.py startproject XYZ" does not create file
"settings.py" containing DATETIME_FORMAT or DATE_FORMAT.
Perhaps there is a reason for that?
The sequence "d:", "cd D:\dproj\MSQall\website\GoogleCodeHost",
"python manage.py
shell", "from django.conf import settings",
"settings.DATE_FORMAT", "settings.DATETIME_FORMAT" outputs
(as expected):
'Y-m-d H:i:sO'
'Y-m-d'
So the content of file "settings.py" is being read, but does
not take effect in the Django Admin interface.
With:
USE_L10N = False
DATE_TIME takes effect, since the localization of l10n overrides DATETIME_FORMAT and DATE_FORMAT as documented at: https://docs.djangoproject.com/en/1.9/ref/settings/#date-format
As Ciro Santilli told, localization format overrides DATETIME_FORMAT in settings when USE_L10N = True. But you can still override DATETIME_FORMAT and other date/time formats by creating custom format files as described in Django documentation.
See detailed answer here.
You can override DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT and other date/time formats when USE_L10N = True by creating custom format files as described in Django documentation.
In summary:
Set FORMAT_MODULE_PATH = 'yourproject.formats' in settings.py
Create directory structure yourproject/formats/en (replacing en with the corresponding ISO 639-1 locale code if you are using other locale than English) and add __init__.py files to all directories to make it a valid Python module
Add formats.py to the leaf directory, containing the format definitions you want to override, e.g. DATE_FORMAT = 'j. F Y'.
Example from an actual project here.
This will solve the particular problem that is not possible
with DATETIME_FORMAT (as it is ignored in the current Django
implementations despite the documentation), is dirty too and
is similar to ayaz's answer (less global - will only affect
the admin site list view):
Right after the line
(date_format, datetime_format,time_format) = get_date_formats()
in file (Django is usually in folder Lib/site-packages in
the Python installation)
django/contrib/admin/templatetags/admin_list.py
overwrite the value of datetime_format (for a
models.DateTimeField in the model):
datetime_format = 'Y-m-d H:i:sO'
And for date-only fields:
date_format = 'Y-m-d'
Restart of the web-server (e.g. development server) or
logging out of the admin interface is NOT necessary for
this change to take effect. A simple refresh in the web-browser
is all what is required.
The two setting directives should be defined in settings.py. Could you ensure that the same settings.py that you are editing is being read when you start the development server?
You could always drop to the Python interactive shell by running python manage.py shell, and run these commands to ensure whether the date/time format values are getting through fine:
from django.conf import settings
settings.DATE_FORMAT
settings.DATETIME_FORMAT
Ok, I forgot to look it up, but ticket #2203 deals with this. Unfortunately, the ticket remains in pending state.
I remember that for a project that used a certain trunk revision of the 0.97 branch of Django, I worked around that by overwriting the date_format and datetime_format values in the get_date_formats() function inside django/utils/translation/trans_real.py. It was dirty, but I had already been using a custom Django of sorts for that project, so didn't see anything going wrong in hacking it trifle more.