gettext is not defined - js error in admin calendar.js

3,682 views
Skip to first unread message

justin...@gmail.com

unread,
Aug 19, 2008, 12:28:48 PM8/19/08
to Django users
Hello,

I'm trying to use the datetime picker widget from the admin widgets.

My form is displaying, but the datetime picker is not. When I check
the error console, I see the message:

Error: gettext is not defined
Source File: http://localhost:8001/media/js/calendar.js
Line: 26

And another in DateTimeShortcuts.

Searching this group I found:
http://groups.google.com/group/django-users/browse_thread/thread/f0abe54d2d1e0313/3f975ec982c4cacc?lnk=gst&q=gettext#3f975ec982c4cacc

But I'm running the latest update from the trunk.

In my HTML output I see:

<script type="text/javascript" src="/media/js/core.js"></script>
<script type="text/javascript" src="/media/js/calendar.js"></script>
<script type="text/javascript" src="/media/js/admin/
DateTimeShortcuts.js"></script>

The second two lines are coming from the media property of my form
object, and I inserted the first to quiet another JS error.

I've searched all the JS in my Django check out and I can't find
gettext described there. I turned internationalization off in my
settings file. Any one have any ideas?

-Justin

Daniel Roseman

unread,
Aug 19, 2008, 3:09:33 PM8/19/08
to Django users
On Aug 19, 5:28 pm, "justin.don...@gmail.com"
<justin.don...@gmail.com> wrote:
> Hello,
>
> I'm trying to use the datetime picker widget from the admin widgets.
>
> My form is displaying, but the datetime picker is not. When I check
> the error console, I see the message:
>
> Error: gettext is not defined
> Source File:http://localhost:8001/media/js/calendar.js
> Line: 26
>
> And another in DateTimeShortcuts.
>
> Searching this group I found:http://groups.google.com/group/django-users/browse_thread/thread/f0ab...
>
> But I'm running the latest update from the trunk.
>
> In my HTML output I see:
>
>  <script type="text/javascript" src="/media/js/core.js"></script>
>   <script type="text/javascript" src="/media/js/calendar.js"></script>
> <script type="text/javascript" src="/media/js/admin/
> DateTimeShortcuts.js"></script>
>
> The second two lines are coming from the media property of my form
> object, and I inserted the first to quiet another JS error.
>
> I've searched all the JS in my Django check out and I can't find
> gettext described there. I turned internationalization off in my
> settings file. Any one have any ideas?
>
> -Justin

The admin templates have this extra line:
<script type="text/javascript" src="../../../jsi18n/"></script>
which refers to an actual Django admin view which renders Javascript,
rather than an included JS file. I think if you resolve the path it
ends up as /admin/jsi18n/ - would definitely be worth including that
before your other script tags and see if that helps.

--
DR.

justin...@gmail.com

unread,
Aug 19, 2008, 4:38:55 PM8/19/08
to Django users
That did it. Many Thanks!

On Aug 19, 3:09 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:

ykb

unread,
Sep 8, 2008, 8:37:38 AM9/8/08
to Django users
Could you please let us know in a little more detail on how to set the
jsi18n path.
Where is "/admin/jsi18n/" referring to?

Thanks,
Yadu.

On Aug 20, 1:38 am, "justin.don...@gmail.com"

Natim

unread,
Oct 13, 2008, 2:52:39 AM10/13/08
to Django users
You have to do like that :

<script type="text/javascript" src="/jsi18n/"></script>

And define in you urls.py

(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages':
'django.conf'}),

Let me know if it does works :)

Natim

unread,
Oct 13, 2008, 3:26:43 AM10/13/08
to Django users
I did it :D

Here are my <head> information :

<link rel="stylesheet" href="/media/css/widgets.css" type="text/
css" />
<script type="text/javascript" src="/jsi18n/"></script>
<script type="text/javascript" src="/media/js/core.js"></script>
<script type="text/javascript" src="/media/js/admin/
RelatedObjectLookups.js"></script>
<script type="text/javascript" src="/media/js/calendar.js"></script>
<script type="text/javascript" src="/media/js/admin/
DateTimeShortcuts.js"></script>

Here is my Form.Field definition :

dob = forms.DateField(label="Date of birth", input_formats=['%Y-%m-
%d'], widget=forms.DateTimeInput(attrs={'class':'vDateField'}))

And that's it :D
Reply all
Reply to author
Forward
0 new messages