Django template include context

2009-09-11 Thread jaap

I'm using django 1.0's templates on GAE.

I've got a for loop that outputs  elements. I update their
contents using ajax.
I want to reuse the part of the template that renders the content of
these  elements.

I have two handlers that handle /stufflist and /stuff/?
reload=ajax.
The first handler passes stufflist (a list of stuff objects) to the
stufflist.html template.
The second handler passes one stuff object to stuff.html template.

I wanted to reuse stuff.html inside the for loop, but it doesn't pass
the stuff variable into the included template...

Is there any way I can achive this?

{# FILE stufflist.html (used on /stufflist) #}
{% for stuff in stufflist %}
  
{% include "stuff.html" %}
  
{% endfor %}

{# FILE stuff.html #}
{# called by stufflist.html and used on /stuff/id?reload=ajax #}

{{stuff.name}}: {{stuff.description}} etc. etc.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request_finished signal not being called with Django 1.5.1 with uwsgi

2013-05-30 Thread jaap
I'm being hit by the same issue. I don't really understand why it worked 
with older versions of Django though? That seems to be a bug.

Op vrijdag 12 april 2013 01:28:42 UTC+2 schreef Lewis Sobotkiewicz het 
volgende:
>
> So figured it out.
>
> Apparently Ubuntu 12.04 packages uwsgi 1.0.3 in their apt repository, 
> which doesn't support calling close() on the WSGI application object 
> returned by Django. I had installed that uWsgi version, then installed a 
> more up-to-date version with pip. ie.
>
> pip install uwsgi==1.4.4
>
> Subsequently, running uwsgi from the command line gives the later version:
>
> $ uwsgi --version
> 1.4.4
>
> However, when starting uwsgi with /etc/init.d/uwsgi, it was using Ubuntu's 
> older, pre-packaged version. I assumed that pip would overwrite that 
> version. Silly me. Fixed by editing /etc/init.d/uwsgi to point 
> DAEMON=/usr/bin/uwsgi to the version installed by pip.
>
> On Wednesday, April 10, 2013 4:55:51 PM UTC-7, Lewis Sobotkiewicz wrote:
>>
>> Hi there,
>>
>> I'm noticing some strange behaviour with Django 1.5.1 and uwsgi - The 
>> builtin signal django.core.signals.request_finished isn't being triggered. 
>> I've tried various versions of uwsgi, and they all have the same behaviour.
>>
>> Also, when I downgrade to Django 1.4.5, the normal behaviour resumes.
>>
>> Any idea why this might be happening? It's causing my DB connections to 
>> remain open after a request.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: request_finished signal not being called with Django 1.5.1 with uwsgi

2013-05-31 Thread jaap
I've created a ticket https://code.djangoproject.com/ticket/20537

Not sure if this can be fixed in Django or a stern warning in the 
documentation can suffice.

Op donderdag 30 mei 2013 17:15:29 UTC+2 schreef ja...@eight.nl het volgende:
>
> I'm being hit by the same issue. I don't really understand why it worked 
> with older versions of Django though? That seems to be a bug.
>
> Op vrijdag 12 april 2013 01:28:42 UTC+2 schreef Lewis Sobotkiewicz het 
> volgende:
>>
>> So figured it out.
>>
>> Apparently Ubuntu 12.04 packages uwsgi 1.0.3 in their apt repository, 
>> which doesn't support calling close() on the WSGI application object 
>> returned by Django. I had installed that uWsgi version, then installed a 
>> more up-to-date version with pip. ie.
>>
>> pip install uwsgi==1.4.4
>>
>> Subsequently, running uwsgi from the command line gives the later version:
>>
>> $ uwsgi --version
>> 1.4.4
>>
>> However, when starting uwsgi with /etc/init.d/uwsgi, it was using 
>> Ubuntu's older, pre-packaged version. I assumed that pip would overwrite 
>> that version. Silly me. Fixed by editing /etc/init.d/uwsgi to point 
>> DAEMON=/usr/bin/uwsgi to the version installed by pip.
>>
>> On Wednesday, April 10, 2013 4:55:51 PM UTC-7, Lewis Sobotkiewicz wrote:
>>>
>>> Hi there,
>>>
>>> I'm noticing some strange behaviour with Django 1.5.1 and uwsgi - The 
>>> builtin signal django.core.signals.request_finished isn't being triggered. 
>>> I've tried various versions of uwsgi, and they all have the same behaviour.
>>>
>>> Also, when I downgrade to Django 1.4.5, the normal behaviour resumes.
>>>
>>> Any idea why this might be happening? It's causing my DB connections to 
>>> remain open after a request.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: request_finished signal not being called with Django 1.5.1 with uwsgi

2013-05-31 Thread jaap
The problem is mainly that the current LTS of Ubuntu ships this ancient version 
of uwsgi via apt. So it's very easy to end up with a system that's not capable 
of running Django 1.5 properly (sysadmins seem to prefer apt over pip). Seems 
sensible to at least specify the minimum uWSGI version in the docs, kind of 
like the minimum python version.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




sys.path vraag

2008-03-29 Thread Jaap

Path onder Windows XP Home is:
D:\Phyton25\;D:\Python25Scripts;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem

Als ik de interpreter in PyScripter gebruik, dan krijg ik:
>>> print sys.path
['C:\\Windows\\system32\\python25.zip', 'D:\\Python25\\Lib', 'D:\
\Python25\\DLLs', 'D:\\Python25\\Lib\\lib-tk', 'C:\\Documents and
Settings\\', 'D:\\Python25', 'D:\\Python25\\lib\\site-
packages', 'D:\\Python25\\lib\\site-packages\\PIL', 'D:\\Python25\\lib\
\site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\
\lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin']

Waarom zijn deze paden verschillend?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



sys.path question

2008-03-29 Thread Jaap

Path in Windows XP Home is:
D:\Phyton25\;D:\Python25Scripts;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem

When I use the interpreter in PyScripter, I see:
>>> print sys.path

['C:\\Windows\\system32\\python25.zip', 'D:\\Python25\\Lib', 'D:\
\Python25\\DLLs', 'D:\\Python25\\Lib\\lib-tk', 'C:\\Documents and
Settings\\', 'D:\\Python25', 'D:\\Python25\\lib\\site-
packages', 'D:\\Python25\\lib\\site-packages\\PIL', 'D:\\Python25\\lib
\
\site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\
\lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin']

Why are these paths different?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: sys.path question

2008-03-29 Thread Jaap

The name 'sys' is confusing. If it had been named 'python.path'
instead of 'sys.path' I would have known where to look... I will be
asking stupid questions for the next month or so - it's the fate of
the newbie.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



render_to_response syntax

2008-03-30 Thread Jaap

render_to_response('template', *args, **kwargs):
kwargs looks like a dictionary but if I refer to a dictionary, it is
ignored:

In
names = {}
names['my_name'] = "somename"
render_to_response('template.html', names)

names is equivalent to {'my_name': 'somename'}, so I would expect the
render_to_response to work - but it doesn't: why?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: render_to_response syntax

2008-03-31 Thread Jaap

Absolutely right - thanks!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



howto display table data in html?

2008-03-31 Thread Jaap

Probably another stupid question (sigh), but looking at views.py and
having read just about all the documentation I could find (including
the Django book), I still do not see how I can get data from a
database into a web page. The Django book explains how it is done
using the live interpreter - but not how it should be done in a view.
Where is the documentation I missed?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: howto display table data in html?

2008-03-31 Thread Jaap

I read there:
from django.shortcuts import render_to_response
from mysite.polls.model import Poll
def index(request):
latest_poll_list = Poll.objects.all()
   &c.

What is 'latest_poll_list'? I assume it is a list, but a list of what?
Records? Can I cycle through that list (for X in latest_poll_list...)
and are the items in the list then again lists that contain the field
data?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: howto display table data in html?

2008-03-31 Thread Jaap

"A model class represents a database table, and an instance of that
class represents a particular record in the database table." I'm
beginning to see some light.
What I try to achieve is telling the application that, depending on
the user's authority, he may not see some data, and/or may not change
some other data: all fields must have an attribute for
[visible,changeable], and the forms should be able to handle those
attributes. I bet that the generic forms cannot do that - so I'll have
to make different forms for all types of user. Is that right?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Database API reference:

2008-04-02 Thread Jaap

QuerySet methods that return new QuerySets:
values(*fields)

Could anyone please give an example of this, using view and template?
I have read the example using the interpreter, and cannot get it to
work in view/template. FYI: I use version 0.96.1, Windows XP.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database API reference:

2008-04-02 Thread Jaap

Still Greek to me... So far I did it like this:

[view]
def start(request):
group = Staff.objects.values('pnr', 'last_name')
return render_to_response('tlist.html', group)

[template]

{% for person in group %}

pnr
last_name

{% endfor %}


Where did I go wrong?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database API reference:

2008-04-02 Thread Jaap

Aaah, I missed another dict... Thanks for setting it right.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



cannot resolve keyword mmtype__eq into field

2008-04-14 Thread Jaap

django version 0.96.1 on windows xp home.

error is caused by statement in view:
pdata = myfile.objects.filter(mmtype__eq="W")

where the model is:

mxt = (
('N", 'Narrow'),
('W', 'Wide'),
)

class Example(models.Model):
name=models.Charfield(maxlength=30)
mmtype=models.Charfield(maxlength=1, choices=mxt)

What is the problem here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cannot resolve keyword mmtype__eq into field

2008-04-14 Thread Jaap

Thanks - that worked. I then tried
pdata=myfile.objects.filter(mmtype__in=["W", "X"])
and that worked too!

Question: where can I find the complete documentation of the filter
expressions? I've been reading a lot about Django and Python - and
don't know where to find this information in the pile anymore...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



/static/ 404

2012-10-09 Thread Jaap van Wingerde
settings.py:
"STATIC_URL = 'http://jaap.custard.shrl.nl:8000/static/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/home/jaap/data/development/workspace/django/liakoster.nl/static/',
)"

"jaap@jaap:~/data/development/workspace/django/liakoster.nl$ python 
manage.py runserver jaap.custard.shrl.nl:8000
Validating models...

0 errors found
Django version 1.4.1, using settings 'liakosternl.settings'
Development server is running at http://jaap.custard.shrl.nl:8000/
Quit the server with CONTROL-C.
[09/Oct/2012 17:08:23] "GET /admin/data/maker/add/ HTTP/1.1" 200 15449
[09/Oct/2012 17:08:23] "GET 
/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.8.18.custom.css 
HTTP/1.1" 404 2573
[09/Oct/2012 17:08:23] "GET /static/grappelli/stylesheets/screen.css 
HTTP/1.1" 404 2477
[09/Oct/2012 17:08:23] "GET 
/static/grappelli/stylesheets/mueller/grid/output.css HTTP/1.1" 404 2516
[09/Oct/2012 17:08:23] "GET /static/grappelli/jquery/jquery-1.7.2.min.js 
HTTP/1.1" 404 2489
[09/Oct/2012 17:08:24] "GET 
/static/grappelli/jquery/ui/js/jquery-ui-1.8.18.custom.min.js HTTP/1.1" 404 
2540
[09/Oct/2012 17:08:24] "GET /static/grappelli/js/grappelli.min.js HTTP/1.1" 
404 2468
[09/Oct/2012 17:08:24] "GET /static/admin/js/core.js HTTP/1.1" 404 2429
[09/Oct/2012 17:08:24] "GET /static/admin/js/admin/RelatedObjectLookups.js 
HTTP/1.1" 404 2495
[09/Oct/2012 17:08:24] "GET /static/admin/js/jquery.js HTTP/1.1" 404 2435
[09/Oct/2012 17:08:24] "GET /admin/jsi18n/ HTTP/1.1" 200 5439
[09/Oct/2012 17:08:24] "GET /static/admin/js/actions.js HTTP/1.1" 404 2438
[09/Oct/2012 17:08:24] "GET /static/admin/js/jquery.init.js HTTP/1.1" 404 
2450
[09/Oct/2012 17:08:24] "GET /static/admin/js/core.js HTTP/1.1" 404 2429
[09/Oct/2012 17:08:24] "GET /static/admin/js/admin/RelatedObjectLookups.js 
HTTP/1.1" 404 2495
[09/Oct/2012 17:08:24] "GET /static/admin/js/jquery.js HTTP/1.1" 404 2435
[09/Oct/2012 17:08:24] "GET /static/admin/js/jquery.init.js HTTP/1.1" 404 
2450
[09/Oct/2012 17:08:24] "GET /static/admin/js/actions.js HTTP/1.1" 404 2438"

What am I doing wrong?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/utmB9O2bMksJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: /static/ 404

2012-10-09 Thread Jaap van Wingerde
On Tue, 9 Oct 2012 16:31:18 +0100
Tom Evans  wrote:

> Assuming your question is "Why am I getting 404's for static content
> on my dev server, even though I set STATIC_URL?", have you included
> 'django.contrib.staticfiles' in INSTALLED_APPS?
Yes:
"INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli',
'filebrowser',
'grappelli.dashboard',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
#'south',
    'data',
)" 
> What does "python manage.py findstatic admin/js/core.js" return?
jaap@jaap:~$
"cd /home/jaap/data/development/workspace/django/liakoster.nl
jaap@jaap:~/data/development/workspace/django/liakoster.nl$ python
manage.py findstatic admin/js/core.js Found 'admin/js/core.js'
here: 
/home/jaap/data/development/workspace/django/liakoster.nl/static/admin/js/core.js
 /usr/local/lib/python2.7/dist-packages/grappelli/static/admin/js/core.js
  /usr/share/pyshared/django/contrib/admin/static/admin/js/core.js
jaap@jaap:~/data/development/workspace/django/liakoster.nl$"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: /static/ 404

2012-10-09 Thread Jaap van Wingerde
On Tue, 9 Oct 2012 11:33:36 -0400
Gladson Simplício Brito  wrote:

> # coding: utf-8DEBUG = False or True ?TEMPLATE_DEBUG = DEBUG
> 
> 
> if false, it has to serve files with apache, nginx, etc...
> if true, and to operate...
"DEBUG = True
TEMPLATE_DEBUG = DEBUG"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to deal with not translated strings in html

2015-03-03 Thread Jaap van Wingerde
../locale/en/LC_MESSAGES/django.po:

...
#: template.html:4
msgid "jaar"
msgstr "year"

#: templates.html:4
msgid "maand"
msgstr ""
...

../templates/template.html:

{% load i18n %}
...
{% trans "jaar" %}{% trans "maand" %}
...

resulting html:


...
yearmaand
...

better html:


...
yearmaand
...

How can i get the better html?

-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20150303174121.024af2be%40jaap.custard.shrl.nl.
For more options, visit https://groups.google.com/d/optout.


pgpNhowxKxJrb.pgp
Description: OpenPGP digital signature


Re: how to deal with not translated strings in html

2015-03-04 Thread Jaap van Wingerde
Op 2015-03-03T17:41:21 UTC schreef Jaap van Wingerde
 in the message ,
mid:20150303174121.024af...@jaap.custard.shrl.nl the following text. 

> ../locale/en/LC_MESSAGES/django.po:
> 
> ...
> #: template.html:4
> msgid "jaar"
> msgstr "year"
> 
> #: templates.html:4
> msgid "maand"
> msgstr ""
> ...
> 
> ../templates/template.html:
> 
> {% load i18n %} lang="{{ LANGUAGE_CODE }}">
> ...
> {% trans "jaar" %}{% trans "maand" %}
> ...
> 
> resulting html:
> 
>  lang="en">
> ...
> yearmaand
> ...
> 
> better html:
> 
>  lang="en">
> ...
> yearmaand
> ...
> 
> How can i get the better html?

A solution with handwork:
 
#: templates.html:4
msgid "maand"
msgstr "maand"

Can this be done automagical?



-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20150304145226.0615f5ff%40jaap.custard.shrl.nl.
For more options, visit https://groups.google.com/d/optout.


pgp5fhGuyf4YR.pgp
Description: OpenPGP digital signature


modification time in Python - Django

2014-03-03 Thread Jaap van Wingerde
views.py:
...
pwd = os.path.dirname(os.path.realpath(__file__ ))
home_lastmod =  
strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getmtime(pwd+'/templates/art_index.html')))
...

The template says: "2014-03-02T19:03:55Z".

...
jaap@liakoster:~$ python
Python 2.7.3 (default, Jan  2 2013, 13:56:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, time
>>> from time import
>>> gmtime
>>> time.strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getmtime('/var/django/test2/art/templates/art_index.html')))
'2014-03-02T19:03:55Z'
>>> quit()
jaap@liakoster:~$ ls --full-time /var/django/test2/art/templates/art_index.html
-rwxrwx--- 1 lia www-data 2456 2014-03-02 19:16:55.568139590
+ /var/django/test2/art/templates/art_index.html
jaap@liakoster:~$
...

Bash gives the right modification time. What is wrong?

-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20140302194930.6c75a15b%40jaap.custard.shrl.nl.
For more options, visit https://groups.google.com/groups/opt_out.


append language-code tot variable name

2017-05-23 Thread Jaap van Wingerde
In my templates I have variables as {{ artobject.title|safe|capfirst }}. I 
want the site in more languages.So in changed the model: title changed in 
title_nl, and I appended title_de, title_en, title_fr. This is more easy 
for me than po-files.

A template must work for all languages,so the variable above in the 
template must become {{ artobject.title_nl|safe|capfirst }} etc.There is a 
variable {{ LANGUAGE_CODE }}, but nesting the variables: {{ 
artobject.title_{{ LANGUAGE_CODE }}|safe|capfirst }} does not work. How can 
I solve this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5ed6725c-a77d-48c5-bdc2-4e5642b03919%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unicode problems in admin interface

2014-09-18 Thread Jaap van Wingerde
I have suddenly unicode problems with de admin interface:

"DjangoUnicodeDecodeError at /admin/art/photographextra/

'ascii' codec can't decode byte 0xc3 in position 32: ordinal not in
range(128). You passed in  ()
...
Unicode error hint

The string that could not be encoded/decoded was: l>Mus��e du"

The site itself is behaving well:
<http://glaskunst.liakoster.nl/expositie/medium-verre-21/>.

settings.py:
"...
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli.dashboard',
'grappelli',
  # Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'art',
'rosetta',
'dbgettext',
)
...
DEFAULT_CHARSET='utf-8'
FILE_CHARSET='utf-8'
DEFAULT_CONTENT_TYPE='text/html'
..."

"jaap@liakoster:/var/django/liakoster.nl/test2$ python -c "import
django; print(django.get_version())" 1.7
jaap@liakoster:/var/django/liakoster.nl/test2$ python -V
Python 2.7.3
jaap@liakoster:/var/django/liakoster.nl/test2$"



What is going on?


-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl



signature.asc
Description: PGP signature


Re: unicode problems in admin interface

2014-09-20 Thread Jaap van Wingerde
Op 2014-09-19T15:58:59 UTC schreef Collin Anderson
 in het bericht , ID: 
interface> het volgende. 

> Are you uploading a file using apache? It could be
> the /etc/apache2/envvars issue.

No, it is an issue with Django/admin.

> Are you ever using string formatting like "something %s something" % 
> something ? If so, use unicode_literals or change that to a unicode
> string: u"something %s something" % something

models.py:
"...
def img(self):
return format_html(u'http://glaskunst.liakoster.nl/media/img/height_80/{2}.jpg"/>',
self.id,self.photograph)
image.allow.tags = True
def __unicode__(self):
return self.photograph
..."

Coulld it be a bug in Django 1.7?


-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl



signature.asc
Description: PGP signature


Re: unicode problems in admin interface

2014-09-22 Thread Jaap van Wingerde
Op 2014-09-18T13:41:53 UTC schreef Jaap van Wingerde
 in het bericht , ID: <20140918134153.390fc...@jaap.custard.shrl.nl> het
interface>volgende. 

> I have suddenly unicode problems with de admin interface:
> 
> "DjangoUnicodeDecodeError at /admin/art/photographextra/
> 
> 'ascii' codec can't decode byte 0xc3 in position 32: ordinal not in
> range(128). You passed in  ( 'art.models.exposition'>)
> ...
> Unicode error hint
> 
> The string that could not be encoded/decoded was: l>Mus��e du"
> 
> The site itself is behaving well:
> <http://glaskunst.liakoster.nl/expositie/medium-verre-21/>.
> 
> settings.py:
> "...
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'grappelli.dashboard',
> 'grappelli',
>   # Uncomment the next line to enable the admin:
> 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> 'django.contrib.admindocs',
> 'art',
> 'rosetta',
> 'dbgettext',
> )
> ...
> DEFAULT_CHARSET='utf-8'
> FILE_CHARSET='utf-8'
> DEFAULT_CONTENT_TYPE='text/html'
> ..."
> 
> "jaap@liakoster:/var/django/liakoster.nl/test2$ python -c "import
> django; print(django.get_version())" 1.7
> jaap@liakoster:/var/django/liakoster.nl/test2$ python -V
> Python 2.7.3
> jaap@liakoster:/var/django/liakoster.nl/test2$"
> 
> 
> 
> What is going on?

I found a way around by removing 'artobjects' from list_filter:
"#list_filter = 
('expositions','galleries','creators','objectseries','artobjects',)
list_filter = ('expositions','galleries','creators','objectseries',)"

This problem is like the following bugs:
<https://github.com/darklow/django-suit/pull/162> and
<https://github.com/darklow/django-suit/issues/46>. However, I do not
use django-suite.


-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl



signature.asc
Description: PGP signature


Re: How to populate DB from PDF extracted data

2018-03-09 Thread Jaap van Wingerde
Use 'pdftohtml - xml' to convert the pdf in an xml-file and use per
line in de xml-file regulair expressions to extract the data.

[pdftohtml]
https://www.sourceforge.net/projects/pdftohtml/

Op Fri, 9 Mar 2018 00:00:39 -0800
Shazia Nusrat  schreef:

> Hi,
> 
> I am trying to work around with PDF's where user uploads PDF in image
> or filefield and then way to extract it for Django and finally update
> DB table based on it. Following are the models:
> 
> class StudentFee(models.Model):
>class_name = models.CharField(choices=CLASSES, max_lenght=200)
>fee_deposit_slip = models.ImageField(upload_to="students/")
> 
>def __unicode__(self):
>  return unicode(self.class_name)
> 
> All I need is to design a view where I can extract data from the PDF
> uploaded in the model below:
> 
> class StudentInfo(models.Model):
> first_name = models.CharField(max_length=200)
> last_name = models.CharField(max_length=200)
> email=models.EmailField()
> phone = PhoneField() #using phoneField custom field
> def __unicode__(self):
>return unicode(self.first_name)
> 
> All the fields in second model does exist in the PDF. In my Views.py
> 
> class StudentPDFReader(FormView):
>   template_name = 'pdfdata.html'
>   form_class = PDFForm
>   success_url = '/success/'
> 
>   def form_valid(self, form):
># here I need to extract and add entries to modelform
>   return super(StudentPDFReader, self).form_valid(form)
> 
> Looking for kind help.
> 
> Regards,
> Shazia
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20180309151249.0ebddf92%40jaap.custard.shrl.nl.
For more options, visit https://groups.google.com/d/optout.


Re: Who can help me?

2020-08-23 Thread Jaap van Wingerde
This is the first result with Google:
https://stackoverflow.com/questions/55831728/what-is-statreloader-while-running-django

Hella thor  schreef op August 21, 2020 9:23:22 AM 
UTC:
>Hey guys: 
>
>My python version is 3.7.1
>Django version is 3.1
>
>When I started the project
>
>[image: 9.png]
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/f6364ce8-2d3e-401b-9d00-010c95322f42n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/BA0C7E31-1955-47FD-97C6-9BA76CDD94C6%40vanwingerde.net.


Re: creating a website with django

2020-08-29 Thread Jaap van Wingerde
https://www.djangoproject.com/start/

Kamini Shukla  schreef op August 28, 2020 9:09:24 AM 
UTC:
>i want to create a website with the help of django. pls some one help
>of 
>that.
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/2fd61f31-8604-422a-b091-e46cd9bc25d0n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3D87DD9C-7B89-45E7-ADF3-2F612A711BF4%40vanwingerde.net.


Invalid filter: 'unlocalize' (Django 3.1.7, Python 3.7.3)

2021-03-19 Thread Jaap van Wingerde
I try to use the filter 'localize'
<https://docs.djangoproject.com/en/3.1/topics/i18n/formatting/#std:templatefilter-localize>
in a template.

Django says 'TemplateSyntaxError':
TemplateSyntaxError at /beelden-en-glas/zomergeluid/
Invalid filter: 'unlocalize'
Request Method: GET
Request URL:
https://glaskunst-3.liakoster.nl/beelden-en-glas/zomergeluid/?beelden-en-glas-te-koop
Django Version: 3.1.7 Exception Type:
TemplateSyntaxError Exception Value:
Invalid filter: 'unlocalize'
Exception
Location: 
/var/django/liakoster.nl/glaskunst-3/lib/python3.7/site-packages/django/template/base.py,
line 569, in find_filter Python Executable: /usr/bin/python3
Python Version: 3.7.3 
...
Error during template rendering

In
template 
/var/django/liakoster.nl/glaskunst-3/art/templates/art_artobject.json-ld,
error at line 30 Invalid filter: 'unlocalize'
...
30 "price": "{{ art_artobject.price|unlocalize }}", "priceCurrency":
"EUR",{% endif %}
...

Am I doing something wrong?

-- 

Jaap van Wingerde
e-mail: j...@vanwingerde.nl

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20210319225601.059bbada%40jaap.artio.shrl.nl.


pgpCp84wUApuW.pgp
Description: OpenPGP digitale ondertekening


Announcing DjHTML: A Django template indender

2021-05-24 Thread Jaap Joris Vens
Dear all,

I would like to take this opportunity to announce my side project to
the Django community. It's a Django template indenter called DjHTML.
It's Black for Django templates!

https://github.com/rtts/djhtml/

Over the past year I have fallen in love with Black and pre-commit to
automatically format code upon each commit. However, I could not find
any tool that would do the same for HTML files and so I decided to
write one myself. Take for instance the following template:

{% block content %}
 1 %}
class="extra"
{% endif %}
>
{% localize on %}
{% if clickable %}

{% endif %}
Blog post {{ nr }}
{% if clickable %}

{% endif %}
{% endlocalize %}

{% endblock %}

This is what it looks like after processing by DjHTML:

{% block content %}
 1 %}
class="extra"
{% endif %}
>
{% localize on %}
{% if clickable %}

{% endif %}
Blog post {{ nr }}
{% if clickable %}

{% endif %}
{% endlocalize %}

{% endblock %}

Currently, DjHTML is able to parse DTL, HTML, CSS, Javascript and any
combinations of these inside the same template. The indentation rules
are similar to Emacs' web-mode.el but with better handling of some
edge cases.

The difference with Black is that DjHTML is an indenter and not a
formatter: It will only add/remove whitespace and not insert newlines
or any other characters. The goal is to indent already well-structured
templates but not to fix broken ones. Also, unlike Black, the tabwidth
is configurable :-)

I am hoping that some of you will give it a try and hopefully provide
me with some feedback, test cases, and bug reports that will help me
improve this tool.

Greetings,
Jaap Joris Vens

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/YKug2AoTDvcMSLz4%40logos.


DoesNotExist at /admin/blog/blog/add/: blog matching query does not exist

2022-09-13 Thread Jaap van Wingerde
te-packages/django/db/models/base.py",
line 831, in save self.save_base( File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/base.py",
line 882, in save_base updated = self._save_table( File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/base.py",
line 1025, in _save_table results = self._do_insert( File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/base.py",
line 1066, in _do_insert return manager._insert( File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/manager.py",
line 85, in manager_method return getattr(self.get_queryset(),
name)(*args, **kwargs) File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/query.py",
line 1790, in _insert return
query.get_compiler(using=using).execute_sql(returning_fields) File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/sql/compiler.py",
line 1656, in execute_sql for sql, params in self.as_sql(): File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/sql/compiler.py",
line 1580, in as_sql value_rows = [ File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/sql/compiler.py",
line 1581, in  [ File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/sql/compiler.py",
line 1582, in  self.prepare_value(field,
self.pre_save_val(field, obj)) File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/sql/compiler.py",
line 1530, in pre_save_val return field.pre_save(obj, add=True) File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/fields/__init__.py",
line 1548, in pre_save return super().pre_save(model_instance, add)
File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/fields/__init__.py",
line 1411, in pre_save return super().pre_save(model_instance, add)
File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/fields/__init__.py",
line 905, in pre_save return getattr(model_instance, self.attname) File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/query_utils.py",
line 178, in __get__ instance.refresh_from_db(fields=[field_name]) File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/base.py",
line 741, in refresh_from_db db_instance = db_instance_qs.get() File
"/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/query.py",
line 650, in get raise self.model.DoesNotExist(

Exception Type: DoesNotExist at /admin/blog/blog/add/
Exception Value: blog matching query does not exist.


-- 

Jaap van Wingerde
e-mail: j...@vanwingerde.nl

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20220913115704.461e97f4%40jaap.artio.shrl.nl.


pgpFPjHedQ3R4.pgp
Description: OpenPGP digitale ondertekening