multi_db support for doctests? How to enable?

2010-08-04 Thread Reinout van Rees

Hi,

http://docs.djangoproject.com/en/dev/topics/testing/#multi-database-support 
tells me to add "multi_db = True" to my unittest TestCase class to get 
multi db support.


I'm using a doctest, however, and I can't figure out how to set that for 
my doctest.  Anyone know how to get that working?  My tests.py looks 
like this:


===
import doctest
import unittest


def suite():
"""Return test suite

This method is automatically called by django's test mechanism.

"""
suite = unittest.TestSuite()
doctests = doctest.DocFileSuite(
'USAGE.txt',
'models.txt',
module_relative=True,
optionflags=(doctest.NORMALIZE_WHITESPACE |
 doctest.ELLIPSIS |
 doctest.REPORT_NDIFF))
# Multi db hack, I cannot set the multi_db to true otherwise.
for test in doctests._tests:
test.multi_db = True
# End of hack, which doesn't work anyway...
suite.addTest(doctests)
return suite

=


Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: multi_db support for doctests? How to enable?

2010-08-04 Thread Reinout van Rees

On 08/04/2010 01:49 PM, Russell Keith-Magee wrote:


Doctests don't do any database flushing, so there is no analog for the
multi-db flag. Just make your calls on the database as you normally
would.


Ah, ok.

Then I'm doing something else wrong (I've only got doctests right now): 
my second database isn't created by the test mechanism.  I added a 
regular unittest with the multi_db=True, but that also didn't result in 
a second database.


The code *does* use the regular database (sqlite, if available), but it 
doesn't create a test database like it does for the default database.


The relevant part from my testsettings.py:

DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': 'test.db',
},
'fews-unblobbed': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'testunblobbed.db',
}
}

No special options, I'd say.  The test database *used* to get created 
when I last ran the tests a few weeks ago, now that I think about it. 
I'll have to do some more debugging.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: multi_db support for doctests? How to enable?

2010-08-04 Thread Reinout van Rees

On 08/04/2010 06:08 PM, Xavier Ordoquy wrote:


The second database should be created. Maybe you want to double check you setup 
a database router.


I *do* have a database router.  The router makes sure that 5 tables end 
up in the second database (and the others end up in the default database).



So far, the only issue I found with testing on multi database is that django 
1.2 expects all the tables are created on the second database which may not 
always be the case (bug reported, I just uploaded a patch for that).


Which patch/ticket is that?  With my router, the second database is 
definitively not filled with all tables: just the 5 that are supposed to 
be in there.


I'll do some experimenting with django versions.  I clearly remember 
adding code to my router to allow django to create those 5 tables in my 
second database, so it *did* work.  Perhaps 1.2.1 broke something that 
1.2betasomething did right?   Gotta drink wine with my wife now, I'll 
test tomorrow :-)



Thanks,

Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: multi_db support for doctests? How to enable?

2010-08-05 Thread Reinout van Rees

On 08/05/2010 07:27 AM, Xavier Ordoquy wrote:

I'll do some experimenting with django versions.  I clearly remember adding 
code to my router to allow django to create those 5 tables in my second 
database, so it *did* work.  Perhaps 1.2.1 broke something that 
1.2betasomething did right?   Gotta drink wine with my wife now, I'll test 
tomorrow :-)


Could it be that you weren't using doctest before and that there is some issue 
with doctest and multi db support ?
I must say I haven't used doctests with multidb yet.

Also I'm not sure I understood your issue correctly.
When you state that the second database isn't created, you mean the tables are 
not created right ?


Yes, the tables aren't created.

I found it, sigh.  I added the following lines to my settings.py 
according to one of those django-with-hudson-integration articles (like 
http://www.caktusgroup.com/blog/2010/03/08/django-and-hudson-ci-day-1/):


TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.run_tests'
TEST_OUTPUT_DESCRIPTIONS = True
TEST_OUTPUT_DIR = 'xmlrunner'

Apparently that test runner doesn't work with the multi db setup.  When 
I removed those lines, the tests would work again.  I really should have 
spotted that by running the tests before and after making that config 
change...


Ok, now I'll have to figure out a different way of getting xml output 
(for hudson) out of django's tests.



Thanks,

Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: importing models to script file

2010-08-05 Thread Reinout van Rees

On 08/04/2010 08:32 PM, Tony wrote:

Hi, Im trying to import my models to another python file that I am
making to use the database data.  The problem is, I can't import the
models for some reason.  It keeps saying "ImportError: Settings cannot
be imported, because environment variable DJANGO_SETTINGS_MODULE is
undefined."
The thing is, the script works on my home computer when I do it, but
when I do it on webfaction this seems to happen.  Anyone ever have a
similar problem?  And I have tried including various paths in the py
file with sys.path.append() but that hasnt worked.  Disregard my first
message, this is actually what the error is.


That environment variable DJANGO_SETTINGS_MODULE is probably defined on 
your home computer but not on webfaction.  You use it to point django at 
your "mysite/settings.py" file so that it knows which settings to use.


See 
http://docs.djangoproject.com/en/dev/topics/settings/#designating-the-settings



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Python Segfaults with Django 1.1

2010-08-05 Thread Reinout van Rees

On 08/05/2010 12:50 PM, Sven Broeckling wrote:


i have a problem on a debian lenny machine which is not easy to track
down. It started with Apache2 mod_wsgi crashes (segfault in libapr)
after the migration from mod_python. The server crashes sporadic and
everytime with another view called, but everytime after a while (2-7
Days, depending on traffic).


Probably not related, but you never know... I've seen this happen in ye 
olde days with a zope server that you'd start in daemon mode from the 
terminal.  After 2-4 days the terminal would die and suddenly the 
perfectly-running zope server would have nowhere to print its console 
output once an infrequent error occured. And it would die.


The wsgi stuff works differently, so this shouldn't be the problem. 
Mentioning it anyway, perhaps it rings some distant bell :-)



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Python Segfaults with Django 1.1

2010-08-05 Thread Reinout van Rees

On 08/05/2010 02:06 PM, Sven Broeckling wrote:


I got another clue, it seems that the python process runs out of file
handles. After 10k requests (via ab -c 1 -n 1) i got several "not
found" io exceptions like "/dev/urandom not found",


Some tempfile that isn't getting closed? Watch your /tmp size, for 
instance. Normally if you do it from views or so, the tempfile object 
gets garbage collected and closed.


Anyway, you probably already know where to look :-)


Reinout



--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Creating a html table...

2010-08-05 Thread Reinout van Rees

On 08/05/2010 02:00 PM, ROger wrote:

I want  to create a html table containing taking from database , this
table should be sortable and searchable..
How do i do that??


There are javascript libraries for showing so-called grids.  The more 
elaborate ones allow you to sort on various colums. And perhaps even a 
search function.


On the template side you often only have to create a html table and tell 
the javascript to do its job.




Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: django.views.static.serve issue

2010-08-05 Thread Reinout van Rees

On 08/05/2010 01:36 PM, bagheera wrote:

Hi, i set up static files for development purposes in following way:

urls.py:


if settings.DEBUG:
urlpatterns += patterns('',(r'^site_media/(?P.*)$',
'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),)

settings.py:

MEDIA_ROOT = '/home/bagheera/NetBeansProjects/nml-src/storage'
MEDIA_URL = 'http://localhost:8000/site_media/'

index.html template:



WHY i had to add "site_media" string, when it IS already included in
MEDIA_URL ?
If i use

dev server gives output:
/images/clock.gif/ HTTP/1.1" 404 2155

Full path to this file is:
'/home/bagheera/NetBeansProjects/nml-src/storage/images/clock.gif'


Probably MEDIA_URL isn't set at all in that template.  If even the 
"localhost:8000" isn't showing up...


I saw that problem once, too.  The reason was that the template is 
rendered without the proper context.  You'll need to pass along a 
RequestContext:



from django.template import RequestContext

def your_view(request):
...
return render_to_response(
your_template,
    {'some': 'parameter'},
context_instance=RequestContext(request))


Reinout





--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Linkedin Search

2010-08-06 Thread Reinout van Rees

On 08/05/2010 05:22 PM, kostia wrote:

Yes, Linkedin mostly is written on Java.

Did you see its menu and the search to the right? People, Jobs,
Answers, Groups.

I would like to add something similar to this on my site.


In the end, it are all just database queries.  So java or python doesn't 
really matter.  Grab all persons having the same company names as I 
have: just a database query.


Search?  Well, again database queries.  In the linkedin example they're 
mostly looking for exact matches, so that's relatively straightforward. 
 If you need more "fuzzy" searching: there are specialized databases 
for that.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: portable apps problem

2010-08-06 Thread Reinout van Rees

On 08/05/2010 09:34 PM, bax...@gretschpages.com wrote:

I try to make my apps portable between the various sites/projects that
use them, but I'm running into some problems doing so. I'm hoping
there's some good way to handle this I just don't understand or know
about.

In a nutshell, I've got multiple sites/projects, and I'd like them to
all use the same articles app. Problem is, the articles app was
originally written for site A,and has at least one M2M relationship
with another app that site B does not have, need, or really want. So,
how do I give site A what it needs without cluttering up Site B with a
bunch of unwanted extras, while using the same app?


Can you write the articles app without the functionality needed by A but 
not B?  You could have site A handle the M2M relationship to that other 
app, probably.


The M2M relation probably results in a couple of extra links in the web 
interface, right?  Have a generic template in the articles app and 
override it in site A.  Could work.


Another thing to think of: the view method for the articles?  Allow a 
couple of optional keyword arguments ("extra_relation=other_app_thingy") 
for things that need customizing for the various sites.


Have you seen the "reusable apps" talk by James Bennett? 
http://www.youtube.com/watch?v=A-S0tqpPga4   If not: 45 minutes of 
highly recommended information that'll give you lots of ideas :-)



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: django comments problem

2010-08-06 Thread Reinout van Rees

On 08/06/2010 01:15 AM, ignacio.arriaga wrote:


Hello,

I have a problem with django.contrib comments application. I have
installed the applicacion and made the synchronization with the
database. I create a comment form in this way:

{% render_comment_form for project %}

When I push either preview or submit I get a 403 error related with
csrf protection. I have the Csrf middleware activated.

I am using django 1.2 with python 2.6.


You're probably missing the csrf_token tag in your form.

From http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ :

  In any template that uses a POST form, use the csrf_token tag
  inside the  element if the form is for an internal URL, e.g.:

  {% csrf_token %}


So just add that csrf_token tag and you're probably done.


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Deploying application media files

2010-08-06 Thread Reinout van Rees

On 08/06/2010 09:54 AM, Alessandro Ronchi wrote:

I have always used a symbolic link to deploy with apache all my django
libraries media files.
But now I need a more solid way to deploy those files, without
concerning about symlinks I need to make after libraries install.

What solution do you use? Apache aliases?
As far as I know, it's not possible to serve static files from inside
an egg file. It would be very nice to pack a library (like, for
example, filebrowser), and have python unpack it on cache and serve
also javascript and image files.

Is it possible?


Yes, it is :-)  Django-staticfiles is an application that can do it for 
you.  In DEBUG mode, django-staticfiles handles those files for you 
directly.  DEBUG=False, so in production: the "manage.py build_static" 
grabs all your media files and puts them in a directory, ready for 
apache to serve.


Behind the scenes, you have to have a /media directory in your 
applications, just like that /template directory that's already there. 
It basically works in the same way.


I've written a blog entry about it with some setup code and an example 
apache config: 
http://reinout.vanrees.org/weblog/2010/05/19/django-css-javascript-files.html 
 (http://tinyurl.com/377g9l9).  Read it and you'll know if 
django-staticfiles is what you're looking for.



Note: at djangocon.eu in Berlin, there were voices to make this 
django-staticfiles solution standard in django 1.3.




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: extends templates with the same name

2010-08-06 Thread Reinout van Rees

On 08/06/2010 12:22 PM, Alessandro Ronchi wrote:

It's useful to have some templates with the same name of another one,
like you can do with YOURPROJECT/templates/admin/base_site.html that
override the base site django default.
but If I want to add a word in the title of my base_site.html I need
to copy the entire content of the base_site.html I am overriding, and
I cannot extend it to avoid that with am {% extend
"admin/templates/base_site.html" %}
or an {% extend super %}


I'm not sure if it's what you want, but...  I've got a base ui 
application with a ui/base.html.  Several blocks for the title, logo, 
the sidebar, footer, javascript, etc.


Several applications extend that base template.  But multiple sites also 
want to extend it to change the global logo and footer... The sites 
effectively have to override the base template.



The solution: in my ui project I have a ui/realbase.html that is 
extended by ui/base.html.  The only code in ui/base.html is the 
"extends" line!  So overriding that one is inexpensive.


The other applications can happily extend ui/base.html and fill in the 
blocks that are really from ui/realbase.html.  And my site can override 
ui/base.html and fill in the logo block and the footer block (which are 
normally not touched by the applications).



I hope I'm clear enough without a code example.  The code, should you 
want to take a look, is at http://pypi.python.org/pypi/lizard-ui




Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Multipart and Content-Type

2010-08-06 Thread Reinout van Rees

On 08/06/2010 07:54 AM, Henrique Teófilo wrote:

Dear all,

I'm posting a multipart/mixed message to Django 1.1.1 using the
development web server (a binary file and a textual part -- it's not a
Form) and I need to get the Content-Type of the textual part. How do I
accomplish this??

I was trying to get it from request.raw_post_data but it is coming
empty...


I've seen cases where you cannot grab data from the request after you've 
already grabbed it.  So if that raw_post_data is called after the 
"regular" grab...


I totally don't know how this works in Django, but I've seen this happen 
once elsewhere, so it might have bitten you too.




Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Beautiful popup windows

2010-08-06 Thread Reinout van Rees

On 08/06/2010 03:13 PM, kostia wrote:

Do we know some alternatives for using popups in python/django?

Here is the SqueezeBox from Mootools JS library - 
http://digitarald.de/project/squeezebox/
I used it in Joomla / php.

I would like to create a great popup form to prevent the user from
redirecting to the new page. It will be awesome.


Basically all the external javascript goodie libraries.  Django is 
javascript-library-agnostic, so take your pick.


Personally, I'm using "jquery tools" for the overlay: 
http://flowplayer.org/tools/overlay/index.html


Note that Plone (big python CMS) also uses jquery tools because it 
doesn't have its own css: the UI library doesn't fight your existing 
css.  That's a big difference with for instance jqueryui (which I also 
use and like, btw :-)



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: 'module' object has no attribute 'instancemethod' error

2010-08-11 Thread Reinout van Rees

On 08/10/2010 09:53 PM, Wim Feijen wrote:

Exception Type: ViewDoesNotExist at /
Exception Value: Tried book in module book.address.views. Error was:
'module' object has no attribute 'instancemethod'


It *looks* like you're using 'instancemethod' in that views.py, but that 
it isn't available in views.py.  Perhaps a missing import?



Tip: "easy_install pyflakes" and call "pyflakes views.py", it'll report 
on missing (or extraneous) imports or variables.


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



geodjango: windows installer for geos dependency?

2010-08-17 Thread Reinout van Rees

Hi,

(I also mailed the mapnik user list with this problem, not sure what the 
best place is)


I have to install my geodjango app on a windows server for a specific 
customer.  After one day, I've almost got it working.


Remaining problem: the geo database is oracle, so apparently I need the 
"geos" library. The error I'm getting is:


ImproperlyConfigured: Could not import user-defined GEOMETRY_BACKEND "geos".

Well, I didn't install the geos library yet, so that could be it. But I 
cannot find a windows installer for that. Either I'm blind or nobody 
uses oracle+geo stuff on windows :-)


a) Do I really need that geos library? Or could there be something wrong 
with the oracle installation (like missing geo templates whatever).


b) Where can I grab a windows installer for GEOS? I only see mentions of 
binary packages for osx and linux, none for windows.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: geodjango: windows installer for geos dependency?

2010-08-18 Thread Reinout van Rees

On 08/18/2010 08:16 AM, Sam Lai wrote:

Quick Google tells me that PostGIS contains GEOS 3.2.0. I know you're
not using PostgreSQL, but installing that might do the trick, or if
you don't want to pollute your server, you can probably extract it
from the setup somehow.

http://postgis.refractions.net/download/windows/#windbinaries


On #geodjango I got a similar hint: use the geodjango windows installer 
even though I don't use the django part of it.  That one also includes 
the geos .so file (which they again grabbed from postgis) :-)


I'll test it once I get to work (don't have access to the win2008 box 
from home).



Thanks,

Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: deserializing json

2010-08-20 Thread Reinout van Rees

On 08/20/2010 02:16 PM, irum wrote:

Hi,
I am trying to parse json, loop through it and access its data.
At first I tried this:

for obj in serializers.deserialize("json", p):
 a=2
 response = HttpResponse()
 response.status_code = 200
 return response


One small thing to try:
response = HttpResponse('')
instead of:
response = HttpResponse()

So: feed it an empty string.

As it complains about being unreadable, perhaps you should stuff 
something into it.  Just a pretty wild guess...




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: installing DB engine

2010-08-22 Thread Reinout van Rees

On 08/22/2010 04:54 PM, matches wrote:

I'm trying to install the mySQL db adapter. Do I really need to
compile it before I can get it to work? Is there an easier way?


You ought to be able to grab an installer for your OS.  So
"aptitude install python-mysqldb" for ubuntu, for instance. I'm sure 
windows also has a clicky-clicky installer.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: ANN: nosedjango 0.8.1

2010-08-23 Thread Reinout van Rees

On 08/23/2010 08:54 AM, Jyrki Pulliainen wrote:

Hi there,

I'm pleased to announce new version of Django testing plugin for nose:
nosedjango version 0.8.1.


What are the differences with http://pypi.python.org/pypi/django-nose?
I just got my test + hudson setup more or less working, so I'm 
interested in alternatives :-)



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: manage.py syncdb not working

2010-08-24 Thread Reinout van Rees

On 08/24/2010 04:17 PM, Sithembewena Lloyd Dube wrote:

Hi all,

I have been working on some models and tried to run the manage.py syncdb
command. It says there are no fixtures found even after I just added a
field to a model.


No fixtures found: it means to tell you that it didn't find any 
special-named "initial_data" fixtures.


Regular fixtures must/can be loaded with "manage.py loaddata fixturename".


A solution has been to drop the table in MySQL before running syncdb.
This doesn't seem feasible all the time. What could I be doing wrong?


It is a (sensible) restriction of syncdb: it only creates missing 
tables.  If you modified a table, the table is still there, so it won't 
re-add it.  Doing so would mean potential data corruption.


So if you added fields to a model, you'll have to add that field by hand 
to the table.


An alternative is for instance South (http://south.aeracode.org/) which 
*can* do the database migration for you, also in the case of added fields.




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



apache, mod_wsgi, windows: config hints?

2010-08-25 Thread Reinout van Rees

Hi all,

I normally deploy everything on linux, but a customer requires windows. 
 I have a working setup with apache and mod_wsgi, but I wonder about 
the efficiency.


I see hints like "mod_wsgi, daemon mode" including "but that doesn't 
work on windows".  Similarly with other apache settings like the worker 
you have to chose.  The best one isn't available on windows.


=> Could someone give me a pointer on how to best set up apache and 
mod_wsgi+django on windows?  My google skills seem to let me down a bit. 
 I'm probably overlooking something obvious.


Alternatives are fine, too.  But it has to be windows :-)


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Caching JSON in Django

2010-08-25 Thread Reinout van Rees

On 08/24/2010 11:15 PM, buddhasystem wrote:


I'm trying to use native caching in Django as per
http://docs.djangoproject.com/en/dev/topics/cache/

I followed the setup procedure to the tee (it's not hard, of course). What I
observe is that my app caches only views that deliver HTML. Since my
application is heavily AJAX, that's not what I want -- I want to cache JSON
-- but it doesn't work!

Any hints how I can make it work?


Quick guess: difference in RequestContext between regular html pages and 
ajax views?



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Help with Geodjango+Postgres to find a Point, variance in decimal places

2010-08-25 Thread Reinout van Rees

On 08/25/2010 02:57 AM, Sam Walters wrote:

Hi fellow Django developers

I have Lat/Lng points stored in my db:

class Airfield(models.Model):
 point = models.PointField(srid=4326)

I noticed when i query on my development server with postgresql i DONT
have to have the EXACT number of decimal places to find that point.
(what i want)
However on the production server if i ask for a point then i have to
give the exact same number with the same number of decimal places.
(undesired)

Production server is postgresql-8.3 where as my development server is
postgresql-8.4

Obviously the db backend is behaving differently.

8.4:
-32.67 == -32.6667
8.3:
-32.67 !=  -32.6667


Obviously, this is a problem.

But: do you need to *have* the problem?  I mean, why would you look up 
the airfield in the DB, grab x/y and then try to grab the same one back 
again with the exact coordinates?


Normally, searching by coordinates would mean clicking on a map which 
results in a DB query with a location plus a margin around that location.


=> Can you work with a "search radius" in your query?


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: command python not recognized with syncdb

2010-08-25 Thread Reinout van Rees

On 08/25/2010 10:21 AM, yotta wrote:

Hi
i am new on Djagon and i was fellowing the tutorial (part1); but i had
some trouble to execute this command "python manage.py syncdb" and i
got error message like what the command python is not recognized as an
internal command.
the 'mysite' directory is inside the django-121 directory and my
python directory is in C:\.
i am using windows XP.


Try "python.exe" instead of just "python.

Alternatively, use the full path to the python.exe inside your python 
directory.


A third alternative: check whether your python path is in your windows' 
path.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Help with Geodjango+Postgres to find a Point, variance in decimal places

2010-08-25 Thread Reinout van Rees

On 08/25/2010 02:19 PM, Sam Walters wrote:

I would need the answer evaluated as quickly as possible, radius
calculation would be slower (how much slower depends on the algorithm
used and other variables).


One of my colleagues tells me the database-internal (so: 
postgresql+postgis and so) calculations are lightning fast.  Indexes 
optimized for it.  So if you can keep the calculation inside the DB it 
ought to be fast enough.


I agree however that it's best not to have to work around this issue. 
So your fix-it-with-javascript idea might be best.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Caching JSON in Django

2010-08-25 Thread Reinout van Rees

On 08/25/2010 02:23 PM, Jirka Vejrazka wrote:

I think that might be the case... I do extract parameters from GET.

Am I out of luck?


Well, nothing can stop your from doing the caching manually so you can
tune it exactlly to your needs. It's actually not that difficult:

from django.core.cache import cache

def my_view(request):
 # some way to determine exact instaned of JSON data needed
 cache_key = 'some_way_to_uniquely_identify_json_data'
 json_data = cache.get(cache_key)
 if not json_data:
# get the response data the hard way
json_data = get_json_data()
cache.set(cache_key, json_data)
 return HttpResponse(json_data)


Good example.


Small addition:

If you replace "if not json_data:"  with "if json_data is not None", you 
can also cache empty values.  Otherwise you might do an expensive 
calculation for [] over and over again without caching it :-)



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Django Database problems

2010-08-25 Thread Reinout van Rees

On 08/25/2010 05:03 PM, Robbington wrote:


I've been using Django for about a month now, with no real problem on
my linode vps with ubuntu. For some reason now everytime I start a new
project I cant sync the database. I get a "Need to fill in the
database name' message even though it clearly filled in. Even if I can
get past that bit and can sync everything, going to /admin I get the
cant access database error. The paths are right, I have changed the
database permission to be able to write to them I just dont know what
the prob is.

I really dont want to have to re-install my who system as I have a few
web projects running from it all ready, so if anyone has come across
this or has a fix, please let me know


Could you paste the database part of your config (with user/password 
obfuscated, of course)?



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Django Database problems

2010-08-25 Thread Reinout van Rees

On 08/25/2010 05:51 PM, Xavier Ordoquy wrote:

Hi,

You may have several django versions in your path.
The settings under apears to be django 1.1
In your project, try:
$ python manage.py shell

import django
print django.__file__
print django.VERSION


Yeah, and also do an "import sys" followed by a "print sys.path". 
That'll tell you where python is looking for code.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: apache, mod_wsgi, windows: config hints?

2010-08-26 Thread Reinout van Rees

On 08/26/2010 05:01 AM, Sam Lai wrote:

On 25 August 2010 20:09, Reinout van Rees  wrote:


I normally deploy everything on linux, but a customer requires windows.  I
have a working setup with apache and mod_wsgi, but I wonder about the
efficiency.

I see hints like "mod_wsgi, daemon mode" including "but that doesn't work on
windows".  Similarly with other apache settings like the worker you have to
chose.  The best one isn't available on windows.

=>  Could someone give me a pointer on how to best set up apache and
mod_wsgi+django on windows?  My google skills seem to let me down a bit.
  I'm probably overlooking something obvious.


I'd stick with IIS on Windows - much better supported than Apache, not
to mention easier to manage on a Windows box, particularly if you only
have Windows sysadmins.


I doubt one of those windows-is-easier-for-us sysadmins is willing to 
give me a working IIS configuration :-)  So I'll have to figure that out 
myself.



Here's a pretty good overview of your options -
http://jasonmbaker.wordpress.com/2009/06/04/windows-for-python-programmers-iis/


Good link.  That's pretty convincing that apache might really not be a 
good idea.  Bit of a shame as I'm suddenly down to 0 knowledge on how to 
set up a webserver :-)



ISAPI-WSGI would be the best option.
http://code.google.com/p/isapi-wsgi/


I'll look at that, thanks.


Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: how to turn off CSRF in django 1.2?

2010-08-27 Thread Reinout van Rees

On 08/26/2010 05:33 PM, Alan wrote:

Ops, sorry, but I don't have this line
django.middleware.csrf.CsrfViewMiddleware, as I said, it's a project
done in 1.0.2. and I want it to run on my django 1.2 but without any
reference to Csrf, since the server where the portal is runs 1.0.2
yet.


You could also attempt it the other way around.

If I remember correctly, they added a "dummy" {% csrf %} tag to 1.1.x 
that doesn't really do anything.  So a form that works with 1.2 also 
works with 1.1 without throwing errors.


You could see if that's available/portable for 1.0, too.  Otherwise, a 
template tag that hacks this is quick to make yourself, I'd guess.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: order of middleware

2010-08-27 Thread Reinout van Rees

On 08/26/2010 07:08 PM, Alessandro Ronchi wrote:

Is this middleware classes correctly ordered for performance?
thanks in advance,

MIDDLEWARE_CLASSES = (


"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.middleware.doc.XViewMiddleware",
'django.middleware.gzip.GZipMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'pagination.middleware.PaginationMiddleware',
"django.contrib.flatpages.middleware.FlatpageFallbackMiddleware",
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',


I don't know about performance, but at least the GZipMiddleware 
documentation says it has to be right at the top to prevent errors.  It 
mucks about with the content-length, that's why.


By the way: have you already optimised the non-django-view parts of your 
application?  Combined js; combined css; static hosting of media files 
by apache/ngnix; perhaps a varnish cache; etc.


Optimizing *there* might bring more returns than a heaping amount of 
middleware.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Template not found

2010-08-27 Thread Reinout van Rees

On 08/26/2010 09:11 PM, Bradley Hintze wrote:

Got it!


You're keeping us all in suspense :-)

Next time, could you add a one-line summary of the eventual solution? 
There will be people with similar problems that google your post in 
2012.  They'll want more than a "got it" :-)



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Problems loading static files on runserver (I mean images and css)

2010-08-27 Thread Reinout van Rees

On 08/27/2010 08:58 AM, Karim Gorjux wrote:


My doubt is in these 3 variables. How I have to use they?

MEDIA_ROOT = ''
MEDIA_URL = ''
ADMIN_MEDIA_PREFIX = '/media/'


A bit of copy/paste from my settings.py:

# Absolute path to the directory that holds user-uploaded media.
MEDIA_ROOT = '/path/to/your/media/dir'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
MEDIA_URL = '/media/'


Another question. In the template how I have to refer to the files? I
have just 2: "style.css" and "header.jpg" that are located in
"/Users/karim/Projects/simplesite/template/media"


That'd have to be the value of MEDIA_ROOT, then.  The MEDIA_URL is 
traditionally /media/, but you can really pick anything.



Is these code right?






I'd put a slash in front of "media".

Even better would be:



(Note the lack of a slash after {{ MEDIA_URL }}, btw).

For those {{ MEDIA_URL }}-like urls to work you need to use the 
RequestContext, see http://tinyurl.com/yllym5h




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: order of middleware

2010-08-27 Thread Reinout van Rees

On 08/27/2010 12:43 PM, Alessandro Ronchi wrote:



2010/8/27 Reinout van Rees mailto:rein...@vanrees.org>>


I don't know about performance, but at least the GZipMiddleware
documentation says it has to be right at the top to prevent errors.
  It mucks about with the content-length, that's why.


So, I should put it before commonMiddleware?


At the top is at the top :-)  See the docs:

http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.gzip


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: What replaced mod_python

2010-08-27 Thread Reinout van Rees

On 08/28/2010 01:35 AM, Jesse wrote:

I'm trying to load django/python 27/apache onto Windows XP.  I'm
following the instructions that recommends mod_python.  Mod_python is
no longer available.  What is it's replacement?  Will apache work
without it?


mod_wsgi.

(wsgi = web service gateway interface, normally pronounced "wiskey"...)

(I'm having to install django on windows for the first time these weeks. 
Asked a question about it.  mod_wsgi + apache will work, but I got the 
tip of running it under IIS instead: there's a wsgi module for IIS, too. 
 I still have to follow up on that tip: that'll be on monday.).



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: GeoDjango: default 4326 SRID doesn't work for transform()

2010-08-30 Thread Reinout van Rees

On 08/29/2010 07:45 PM, kyleduncan wrote:

Hi all,

I am trying to do obtain the distance between two users on my site,
using code I found in this group. We already have geoDjango installed,
though i'm wondering if my problem comes from being on an old version
(i dont know which version we're using - if somebody could tell me how
to check that would be great). We are running Django 1.1


Well, then you're using the geodjango bundled with django 1.1.  I don't 
remember seeing big changes in django 1.2's changelog regarding 
geodjango.  So you ought to be OK with that.



the code i am using is:

from django.contrib.gis.geos import Point
from django.contrib.gis.measure import D

my_location = request.user.get_profile().location
 their_location = other_user.get_profile().location

 my_location.transform(4326)
 their_location.transform(4326)
 distance = my_location.distance(their_location)

 if request.user.get_profile().get_preferences().use_metric
== 1:
 distance_result =
round(D(m=my_location.distance(their_location)).km, 1)
 else:
 distance_result =
round(D(m=my_location.distance(their_location)).mi, 1)

the last section is just a check to see whether the user wants the
result in miles or km. the bit that's troubles me is the transform()
section. if i put in 4326, i just get 0.0 as the result. if i put in
nothing so it's just transform() (which i understand should use 4326),
i get this django Error:

TypeError at /members/GayHopHelper/

transform() takes at least 2 arguments (1 given)

the only thing that works so far is using SRID 32140, which is for
south texas. the results seem ok but definitely a bit inaccurate,
which is to be expected.


I only recently started using geodjango, so I'll just spit out a few 
brainstormy ideas without any real solution:


- What's the coordinate system of your user's location data?

- Why transforming before grabbing the distance? Can't you transform 
afterwards?


- If you're using the google projection somewhere: did you add it to 
your geo database?  There's a note somewhere in geodjango's doc about 
that 900973 projection.  Not having it could throw off a calculation.


- There's also a hint in that doc about a NULL projection that you need 
to add to your proj4 or whatever files to enable proper transformations.



Just a brainstorm to get you started ;-)

Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: GeoDjango: default 4326 SRID doesn't work for transform()

2010-09-01 Thread Reinout van Rees

On 08/30/2010 04:14 PM, kyleduncan wrote:

Hi,

thanks for the tips! to answer your questions:

1. our model doesnt specify a coordinate system, it just saves the lat
and lng that are returned from google maps.
2. i thought transforming had to be done to make a lat/lng point
"spatial" before distance was calculated. have i got that wrong?
3. i'm not actually sure we even have a "geodatabase". all we have are
pointfields in the model for users, which save the lat/lng points from
google.


Those PointFields are what make it a geo database (well, that's how I 
use the terminology anyway).


So your_object.your_point_field.distance(another.your_point_field) ought 
to give you a distance alright.


I don't know from the top of my head which unit that distance is in. 
I've only had to pick the closest one till now :-)



i'm not really capable enough to know how to proceed on my own from
your points, but for now i'll try removing the transform() (and also
placing it after) and i'll also specify the transform SRID of 900973
(is that the SRID for google or are you talking about something else
with that number?)


Oopsie, that's 900913 instead of 900973 (google written in characters 
that look a bit similar).



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Surreptitious caching of JS in Django

2010-09-01 Thread Reinout van Rees

On 08/30/2010 07:52 PM, buddhasystem wrote:


Hello,
with the generous help of many of you, I easily set up JSON caching feature
in my Django app, in a few views.

The problem I'm now facing is that according to what I observe, Django also
caches Javascript code in its memcached backend.


That's probably something you configured yourself.

Anyway, in development you can uncomment any CACHE_BACKEND in your 
settings.py and no caching will happen.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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 files

2010-09-01 Thread Reinout van Rees

On 08/30/2010 09:26 PM, Bradley Hintze wrote:

base.html
...


   


That "media/xyz.gif" means that if you've got a
http://example.com/subdir/test.html page, the image looked up is
http://example.com/subdir/media/ajax-loader.gif

You probably want "/media/ajax-loader.gif".

And: you're apparently not using {{ MEDIA_URL }} in your template, which 
is intended precisely to get the url right (and absolute).



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



multiple oracle database queries in one request problem

2010-09-01 Thread Reinout van Rees

Hi,

I'm deploying a site on windows with oracle (and I don't know either of 
them well).  Simple apache+wsgi setup for now.


Problem: one specific page kills off the mod_wsgi/django part. The rest 
of apache keeps working. "Kill off" meaning "it doesn't react anymore 
and takes quite some time for apache to kill it when I close apache.


The only error message I can find is an
"errno 10054" "existing connection was forcibly closed".  I can only 
guess that the remote database server closed something.



The specific page is the only one that fires off queries to both 
databases, so within the same request.  Anyone got any hints on where to 
look?  How to debug?   How to fix it?



Reinout (who dislikes the amount of handy debug info he's got...)


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: multiple oracle database queries in one request problem

2010-09-01 Thread Reinout van Rees

On 09/01/2010 02:00 PM, Reinout van Rees wrote:

Hi,

I'm deploying a site on windows with oracle (and I don't know either of
them well). Simple apache+wsgi setup for now.


I'll have to test it out tomorrow when I'm near the windows machine 
again, but I might have found the solution in an existing bug report: 
http://code.djangoproject.com/ticket/13351


In a threaded situation (which you always have with mod_wsgi on 
windows), you apparently need to pass the cx_oracle database driver a 
threaded=True option (which is off by default).


So I added the following to my database config and I'm hoping I'll be 
happy tomorrow morning...


'OPTIONS': {'threaded': True}


I'll update the ticket when it helps.


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: multiple oracle database queries in one request problem

2010-09-02 Thread Reinout van Rees

On 09/01/2010 11:54 PM, Reinout van Rees wrote:

On 09/01/2010 02:00 PM, Reinout van Rees wrote:

Hi,

I'm deploying a site on windows with oracle (and I don't know either of
them well). Simple apache+wsgi setup for now.


I'll have to test it out tomorrow when I'm near the windows machine
again, but I might have found the solution in an existing bug report:
http://code.djangoproject.com/ticket/13351

In a threaded situation (which you always have with mod_wsgi on
windows), you apparently need to pass the cx_oracle database driver a
threaded=True option (which is off by default).

So I added the following to my database config and I'm hoping I'll be
happy tomorrow morning...

'OPTIONS': {'threaded': True}


That did not help... If anything, it crashes earlier.

Some things I know for (reasonably) sure:

- It occurs when running with threads: mod_wsgi on windows.

- It occurs when talking to the oracle database.

- It occurs when I talk to two databases on the same oracle server 
(well, that's database in django speak, oracle calls it a schema: it is 
in the same physical oracle-speak database).




So I'm desperately trying to figure out how to tell mod_wsgi to run in 
single threaded mode for the time being.  The problem is that only 
WSGIDaemonProcess has the required "threads=1" option and exactly that 
WSGIDaemonProcess isn't available on windows!  Catch 22.




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-03 Thread Reinout van Rees

On 09/02/2010 11:46 PM, Jesse wrote:

Hello Graham,

I have the c:/public/apache/apache_django_wsgi.conf working now, at
least apache restarts.  Do you know if mod_wsgi has a problem with
these versions:
python 2.7 and apache 2.2, and postgres 8.4, psycopg 2.2.2

My server error is:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
'django.db.backends.postgresql_psycopg2' isn't an available database
backend.
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using
django.db.backends.XXX, where XXX is one of:
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] 'dummy',
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was:
cannot import name utils


I got the same error with python 2.6, mod_wsgi, windows.  Even though 
psycopg2 was installed perfectly.  Just half a minute earlier my 
"manage.py syncdb" created the database :-)  And "runserver" works fine, 
only when running it under apache does this error crop up.


Graham has an article on the differences in running runserver versus 
django's own wsgi handling:

http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

I haven't figured out yet what's wrong.  I'm using buildout's 
djangorecipe to set it all up and djangorecipe's wsgi file does most of 
the tricks that Graham's improved wsgi script does.



Weird error.


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-03 Thread Reinout van Rees

On 09/03/2010 12:34 PM, Graham Dumpleton wrote:



On Sep 3, 7:46 am, Jesse  wrote:

My server error is:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
'django.db.backends.postgresql_psycopg2' isn't an available database
backend.
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using
django.db.backends.XXX, where XXX is one of:
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] 'dummy',
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was:
cannot import name utils


Provide the full traceback.

Sounds a bit like:

   http://code.djangoproject.com/ticket/12730


A settings.py that imports from other django applications... Ok, so 
that's dangerous.


Hm. I also have two or three of those lines in my settings.py.  I'm by 
now convinced that "settings.py only gets loaded once so that's a nice 
place to put it" is wrong.  So I'm probably better off adding lines I 
want run only once to one of my django applications' __init__py?  I *do* 
want to be sure they're called before my site starts answering requests.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: mod_wsgi, apache, windows XP

2010-09-05 Thread Reinout van Rees

On 09/03/2010 05:38 PM, Anna Leslie wrote:

This is in my settings file:
 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

And it works fine with the local django server.  The entire application
works fine with the local django server, but I need to get it into
production mode.  I've tried 'ENGINE': 'django.postgresql_psycopg2',
# Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
And get the opposite error under Apache saying I need to do
'django.db.backends.postgresql_psycopg2'.  I don't have the deseb statement
in my settings file, so that shouldn't be a problem.  I was going to try
downgrading to python 26, but it seems that a similar problem occurs with
it.  I don't think I can get the downgraded version of psycopg2 now, anyway.

Now I seem to have a utils problem??


Sorry, no solution.  Frustrated rant below, perhaps it helps yo uto know 
that you're not alone... :-)



Windows, I guess?  I have never ever seen this problem under linux.  But 
I've been bashing my head on a windows install problem for a full week. 
(Well, a 80 hour week instead of the regular 40 hour week).


I could not solve the postgres problem. Paths all seemed OK.  The 
relevant postres stuff is installed globally.  So both apache (mod_wsgi) 
and "runserver" should be able to find it.  But apache fails to find it. 
 No way to debug as I've got no windows experience.  Everything looks 
right.


"Luckily" the oracle driver (it was supposed to connect to an oracle db 
after all) did work OK.  At least, until you talked to a certain 
database in multi-treaded mode.  Telling (via OPTIONS={'threaded':True} 
in the database settings) it to run in multi-treaded mode didn't help. 
Something somewhere (no error messages) kept crashing.  I dived into 
a couple of the python libraries (pdb and so), but I couldn't check 
every detail.  And the c-level libraries were beyond me.


In the end I got it working (that is, "not actively dying") by telling 
apache to run with just one single thread... That's some solution...



This is the first time that a hard problem took more than 1.5 day to 
fix.  Effectively, this is 2 full work weeks.  And still no real solution.





Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Python Restarting After Every Request, MaxRequests Per Child is High

2010-10-04 Thread Reinout van Rees

On 10/03/2010 07:54 PM, Koobz wrote:

I'm getting about 0.5 requests per second using apache, and about 60
using the development server so something is definitely wrong :)

After every requests I see:

[Sun Oct 03 11:48:52 2010] [info] mod_wsgi (pid=27761): Python has
shutdown.
[Sun Oct 03 10:49:09 2010] [info] mod_wsgi (pid=27767): Destroying
interpreters.


My guess would be that there's something wrong in your django.wsgi file. 
 It looks like that doesn't start up some wsgi process but instead only 
processes one request.


Perhaps try and add some logging at the start and the end of the main 
call in your django.wsgi?


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Empty Response

2010-11-02 Thread Reinout van Rees

On 11/02/2010 09:29 PM, Eric wrote:

I am returning a json structure in one of my views after the user
performs a search when I only run Django's built in server. Following
the asynchronous GET  I get a response with the expected json
structure which I can then use to populate the page.

However, when I have Apache in front, the response is empty. And this
appears to be only when I make an AJAX request since all of the other
requests and responses produce the expected results.

I don't know how to go about troubleshooting this.

Does anybody know what is going on here? Or, how to troubleshoot this?


Some random tips:

Take a hard look at what's actually being returned.  Empty response, 
apparently.  But what about the http status code?  200 OK or 500 
AARGH_ERROR?  Or something that's just not parsed as valid json?  Or 
perhaps an invalid mimetype?


Useful tools: firebug (lets you inspect the headers).  Or just "wget" in 
a pretty verbose mode.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Do Fixtures have a limit?

2010-11-22 Thread Reinout van Rees

On 11/22/2010 03:16 PM, Ryno in Stereo wrote:

I'm trying to create around 32,000 rows in a table via a json fixture
and although Django confirms via the commandline that it's worked
(Installed 32423 object(s) from 1 fixture(s)
), I can only ever see 20,149 records in my MySQl database.

I can't any mention of an upper limit for fixtures and this really has
me stumped.

Any ideas?


Duplicate primary keys is the only thing I can think off right now.  So: 
it added 32k objects, but 12k of them were duplicates.  Worth a quick check.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: ajax and django

2010-11-22 Thread Reinout van Rees

On 11/22/2010 11:48 PM, owidjaya wrote:

What is the best way to go about handling ajax request per
application?

I currently have a middleware that implements "process_request"
function.
the function acts as a relay to call "serve_ajax(request)" function
that is implemented in the application class that wants to respond to
ajax request. The application object that will respond to the ajax
request is indicated by a GET variable "object". while every other
variables to be passed to the application is passed with POST
variable.


Having one process_request function is not best practice.  It is better 
to design good URLs for your application.  Instead of:


http://example.com/do_something?object=library_book12&action=loan

something like a POST to the following URL is better:

http://example.com/library/book12/loan


So: allow django to do its job of "URL dispatching".  This frees your 
method to just do their actual job instead of also having to figure out 
on which object to do their work.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Hosting multiple projects

2010-11-23 Thread Reinout van Rees

On 11/22/2010 10:42 PM, Todd Wilson wrote:

I teach a course in which I have students developing unrelated Django
projects on servers of their own choice.  As we near the end of the
semester, I would like to set up a single server where I can host all
of these student projects together.  I will obviously create a new
user, as well as a new mysql account and database, on this server for
each project, and ask the student teams to upload their project files
into the home directories of these accounts.  But what else will I
have to do to make this work?

I suppose I'll have to install the union of all the python libraries
used by the individual projects, but each project will have its own
settings and "local" URL structure, and I'm not sure how all of this
should be coordinated, or what changes I'll have to ask the teams to
make to their own projects to allow this coordination.  (The server is
Apache/mod_wsgi.)

Any recommendations?


Probably handiest: provide isolation between the various projects.  So 
virtualenv or buildout.


What I'd do is to give every student a project skeleton with a pre-made 
buildout config including an apache config.  Theoretically you should 
then only have to run the buildouts and symlink the various apache 
configs into your /etc/apache2/sites-available/.


Anyhow, make sure their projects look a bit similar.  A setup.py and an 
apache config, for instance.  Hook it up with virtualenv or buildout.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: How do I get tracebacks printed to terminal?

2010-11-24 Thread Reinout van Rees

On 11/23/2010 09:48 PM, Markus Barth wrote:

I am using quite a lot of asynchronous calls for updating a page. The
problem is that this way you never see a traceback. In turbogears the
development server prints all tracebacks to the terminal. Is there any
way to get a similar behaviour with django?


You'll have to enable that yourself with some middleware, strangely.

In your app/site, add a "middleware.py":


import logging

logger = logging.getLogger(__name__)


class TracebackLoggingMiddleware(object):
"""Middleware that logs exceptions.

See http://djangosnippets.org/snippets/421/.

To enable it, add
'yourapp.middleware.TracebackLoggingMiddleware' to
your setting.py's MIDDLEWARE_CLASSES.

"""

def process_exception(self, request, exception):
logger.exception(repr(request))



And do the MIDDLEWARE_CLASSES thingy in the docstring.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Got Django and Buildout working, but what about PIL and Postgres?

2010-01-06 Thread Reinout van Rees

On 01/06/2010 04:23 PM, littlejim84 wrote:


Can anyone help me to reliably get PIL and Postgres working with my
Buildout? Thank you so much in advance... Everything I've tried so far just
throws up all sorts of errors.


Add the lines marked with '<<<' behind them to your buildout to 
*probably* solve the PIL issue.


* The find-links line points at a specially-stripped PIL download used 
by for instance Plone.  It is stripped of the 'tk' stuff, which helps a 
lot with the common PIL compilation errors.


* The versions lines are needed to pin PIL to 1.1.6 as 1.1.7 is just 
out: this has several problems, at least in buildouts I saw.



[buildout]
parts = python django
develop = .
eggs = myproject
find-links = http://dist.repoze.org/   <<<
versions = versions<<<

[versions] <<<
PIL = 1.1.6<<<

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

[django]
recipe = djangorecipe
version = 1.1.1
project = myproject
projectegg = myproject
settings = testsettings
test = myproject
eggs = ${buildout:eggs}



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer/advisor at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python based web reporting tool?

2010-01-07 Thread Reinout van Rees

On 01/07/2010 04:20 PM, Mark Freeman wrote:

I have a question for those of you doing web work with python. Is
anyone familiar with a python based reporting tool?  I am about to
start on a pretty big web app and will need the ability to do some end
user reporting (invoices, revenue reports, etc). It can be an existing
django app or anything python based so I can hook into it. Thanks!


You can use reportlab for creating pdf. And you can look at 
http://www.zopyx.de/blog/smartprintng-state-of-the-art-web-to-print-with 
(despite the first paragraph: usable outside of plone) for some inspiration.


Several projects are using open office: define a template in open office 
and use the python bindings to fill the documents with your data. Also 
apparently works "headless", so on the server without opening the UI.


Depends on your usecase :-) These ought to at least give you some more 
google inspiration.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer/advisor at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Why there are so few open-source business applications in django?

2010-01-07 Thread Reinout van Rees

On 01/08/2010 12:26 AM, Ray wrote:

On Jan 8, 9:35 am, Mohammad Tayseer  wrote:

I know that there are applications written in django for everything, but why 
there are so few open-source business application in django? I mean 
applications like warehouse management systems, HR systems, etc. The existing 
ones are out of date.


I think you can say the same thing about Python in general.


There's one positive python exception I know of: OpenERP 
http://en.wikipedia.org/wiki/OpenERP . (The web part uses turbogears 
instead of django, btw). It is, from what I heard, booming business.


There's not too much room in open source land for such elaborate 
full-fledged business apps. I'm happy one of them is in python, at least :-)


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer/advisor at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Splitting tests.py

2010-01-18 Thread Reinout van Rees

On 01/18/2010 08:40 PM, Olivier Guilyardi wrote:

Hi,

I'm trying to split tests.py into individual files into a tests/ subfolder, but
that doesn't work.

I correctly import everything from within tests/__init__.py, as previously said
on this mailing list:
http://groups.google.com/group/django-users/browse_frm/thread/10cfd65e398360d2/dae3a7226dccdc5f

But that doesn't work. I tested on Django 1.0.2 and SVN r12255, same thing.


Wild guess: place the test code in normal python test files inside the 
tests/ folder instead of in the __init__.py?  (I tend to keep that one 
virtually empty anyway).


Again: pretty wild guess ;-)

Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer/advisor at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: eurodjangocon?

2010-01-20 Thread Reinout van Rees

On 01/20/2010 08:41 AM, Alex_Gaynor wrote:


http://djangocon.eu/ is the official website for djangocon.eu (the new
name).


Please mention the old eurodjango name somewhere on that page so that 
google can find it.  I was also searching in vain :-)



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer/advisor at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: "Pro Django" book still up to date

2010-01-27 Thread Reinout van Rees

On 01/27/2010 05:55 PM, Achim Domma wrote:

Hi,

I'm interested in buying the "Pro Django" book. I could not find any
hint about what version it's written for. As it covers mostly
internals and the ideas behind Django, it should not be outdated as
quickly as other books. Has anybody read that book and can give some
feedback about how useful it is for the current version of Django?


Written for 1.0, at least the version I bought 2 weeks ago :-)

I haven't read it in full yet, but I've got the same impression as you 
have: it won't be outdated so quickly.


For me, the core value is that the book explains all the various django 
details (forms, templates, views, models) in depth and explains how they 
really work (so: with background information) and how they're supposed 
to be used.


Reading it is giving me a good clue on what is possible with django. If 
I later need to apply it, I can look it up again in the book or, perhaps 
more likely, I can google for it in the django documentation.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer/advisor at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: sqlite3 error

2012-02-12 Thread Reinout van Rees

On 12-02-12 15:31, Marcus Maximus wrote:

I tried to change the setting.py on line  'ENGINE': 'sqlite3', but
this seems ok in my eyes...

so whats wrong?


Try the full dotted path, so including django.db.backends:

'ENGINE': 'django.db.backends.sqlite3',

Just "sqlite3" by itself was fine in older django versions, so you might 
have picked up an example from there.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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 Context problem

2012-02-19 Thread Reinout van Rees

On 19-02-12 14:16, dummyman dummyman wrote:

I am getting the following eror on posting the form

CSRF verification failed. Request aborted.

Reason given for failure:
 CSRF token missing or incorrect.


It is already on the first go into your view that Django complains about 
a missing CSRF token. It won't even hit your "else add csrf token" code.


The solution is simple: just add a {{ csrf_token }} somewhere in your 
form. That ought to do it.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Weird stacktrace coming from manage.py test

2012-03-23 Thread Reinout van Rees

On 22-03-12 17:34, Jeff Heard wrote:

Has anyone seen this before?  Am I missing something?  This hasn't even
gotten to my code yet.  I'm using this in my settings.py:

TEST_RUNNER = 'django.contrib.gis.tests.GeoDjangoTestSuiteRunner'

I have a template PostGIS database setup properly.  And I'm running the
stable release of Django 1.3.

---

Traceback (most recent call last):

...

self.connection.connection.autocommit = True
psycopg2.ProgrammingError: autocommit cannot be used inside a transaction


For me, this normally means the database definition is not quite right.

In your geodjango case, do you perhaps miss django.contrib.gis in your 
INSTALLED_APPS list?



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Django-1.4c2 logging issue on Snow Leopard

2012-03-23 Thread Reinout van Rees

On 22-03-12 21:09, Jeff Heard wrote:

   File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py",
line 562, in configure
 'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': Cannot
resolve 'django.utils.log.RequireDebugFalse': No module named
RequireDebugFalse

I'm using virtualenv and the system python.


Guess: You have django installed both in your virtualenv and in your 
system python and they're probably interfering. Look in your manage.py 
script if you spot something wrong with sys.path or so. Or the `#!` 
python line at the top.




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Django log lines spamming syslog

2012-03-23 Thread Reinout van Rees

On 23-03-12 14:49, Scott Gould wrote:


Our syslog has been filling up for some time with this stuff and we
only just noticed due to logrotate breaking on us. For what appears to
be every django request across all virtual hosts, we are getting a
pair of lines, like so (blank lines inserted by me):

Jan 27 14:48:52 cloweb01 apache2: SessionMiddleware.process_request -
id 0x7f6dabfb35d0 - cookie None - session
915ffaa7831b5de78876abb7746dfc1f - path /serverstatus/api/v1/status/
Jan 27 14:48:52 cloweb01 apache2: WSGIHandler.__call__ - id
0x7f6dabfb35d0 - cookie None - session
879f844cb6ea0213b445f60e11b22978 - path /serverstatus/api/v1/status/


I looked at django/contrib/sessions/middleware.py and there's no logging 
or printing happening there.


That the syslog ends up with this info probably means that django prints 
it out on the console, which would normally end up in your apache's 
error log. Probably you configured apache to send it to the syslog instead.


Printing on the console means "print ..." or a logger that's configured 
to print to the console. Did you do the latter?



My guess: someone put a print statement in 
django/contrib/sessions/middleware.py for debug purposes. So check the 
django that your site is using and see if you have to beat someone with 
a stout stick.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Pip install matplotlib error with virtualenv

2012-03-23 Thread Reinout van Rees

On 23-03-12 16:59, Tom Evans wrote:

* Do Linux distros still do this? I use FreeBSD, so am not affected by
this madness. Why would an OS install a binary library and not install
the headers, the very thing that allow you to use the library
yourself. Madness.


At least ubuntu still does this.

Only reason I can think of is that it might be safer on the server or 
something like that.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Pip install matplotlib error with virtualenv

2012-03-23 Thread Reinout van Rees

On 23-03-12 18:51, darwin_tech wrote:

the weird thing is that matplotlib works fine on my system. If I have a
Django project running outside of virtualenv, there is no problem and
matplotlib is on the pythonpath.


One of virtualenv's options is to isolate you *completely* from the 
system python. "virtualenv -s" or something like that.


Perhaps you passed along that option? In that case, nothing in your 
virtualenv can find the system python's matplotlib.




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Pip install matplotlib error with virtualenv

2012-03-23 Thread Reinout van Rees

On 23-03-12 21:37, Reinout van Rees wrote:

On 23-03-12 18:51, darwin_tech wrote:

the weird thing is that matplotlib works fine on my system. If I have a
Django project running outside of virtualenv, there is no problem and
matplotlib is on the pythonpath.


One of virtualenv's options is to isolate you *completely* from the
system python. "virtualenv -s" or something like that.


I checked, it is '--no-site-packages'.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Accessing objects from a dictionary in templates

2012-03-23 Thread Reinout van Rees

On 23-03-12 20:56, gowtham wrote:


But, in template, rather than iterating over the dictionary (using for
and items)  i would like to access them using keys.


You can, can't you?  {{ my_dict.some_key }}.

You're using numerical keys, which might not work as well.
But you can try something like {{ my_dict.42 }}.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Accessing objects from a dictionary in templates

2012-03-23 Thread Reinout van Rees

On 23-03-12 22:00, gowtham wrote:


But, i could not get it.  It prints the primary key of the stored object
rather than the object itself.


Well, I don't know what's in the stored object. How are you supposed to 
print it?


Something like {{ my_object.name }}{{ my_object.description }} or so?



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Pip install matplotlib error with virtualenv

2012-03-26 Thread Reinout van Rees

On 23-03-12 22:01, darwin_tech wrote:

Yes, that is true. I set the virtualenv with --no-site-packages as I
want a reproducible environment for my Django project. This should not
mean that I cannot install matplotlib within the virtualenv though, surely?



You can install matplotlib just fine in your virtualenv, but with one 
prerequisite: all necessary libraries and header files must be available 
for pip to be able to compile matplotlib.


This compiling-and-grabbing-headers stuff is already handled for you by 
your OS and now you'll have to do it yourself. Which is fine, but it 
*does* mean you must have all xyz-devel packages installed.



An alternative is to keep your global python clean and only install 
specific packages with your OS that are best handled by the OS. Don't 
"pip install" other stuff by hand.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: philosophy behind sites and applications in Django

2012-03-26 Thread Reinout van Rees

On 26-03-12 02:21, Jojo wrote:

Hi guys, I'm new in Django (I started with the 1.3 and now I'm playing
with the 1.4) and I'd like to understand better the phylosophy behind
the concepts of sites and applications.
Ok a site can contain multiple applications and an application can live
in many sites, that's simple.

Now.

For me a site is like a "container" of applications and every
application accomplish a particular job just like manage polls, articles
and so on. But a site must have its own graphic style, and in particular
common parts, just like user management.

How do you handle these "trasversal" (common) components?
For example, is it possible to define a css at site level? How to deal
with user management and other commont funcionalities?


You're right, a site is a container of applications and an application 
should do one thing and one thing only.


Normally, you don't want your site to contain applications and at the 
same time have those applications inherit from your site's main template 
or so.



But... django sticks all the templates/ and static/ directories of all 
apps and sites together. So nothing stops you from sticking a very basic 
base template in every app ("yourapp/templates/base.html") with just a 
sidebar and main content block or so. You can have your apps use that.


In your site, you provide the real "yoursite/templates/base.html", which 
will win because your site is higher up in the INSTALLED_APPS list. 
Stuff that one full with the real layout and css, but keep providing the 
sidebar and content block (or whatever you need).



Alternative: just make templates in the apps and customize them in the 
site. Not as nice imho.



ALternative: start a base UI app that just provides a layout. Use that 
in the apps.




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: myproject/wsgi.py vs. myproject.wsgi?

2012-03-26 Thread Reinout van Rees

On 25-03-12 08:04, Micky Hulse wrote:

Hello,

This is is probably a silly question, but...

I just installed a fresh copy ofDjango 1.4 (mod_wsgi 3.3/Python 2.7)
on my WebFaction server.

In 1.3, the command startproject (IIRC) generated a myproject.wsgi
that lived next to myporject folder.

In the 1.4 installer, the wsgi file is no longer generated and there's
the new myproject/wsgi.py file.

I have read the docs (and Googled around a little bit) but I don't
fully understand wsgi.py does.


In 1.3, there was no wsgi file. So either you added it yourself or 
webfaction automatically adds it.


1.4 started adding that wsgi.py file. It should be a drop-in replacement 
for the one you have now, basically.


(Only thing to watch out for: wsgi.py hardcodes settings.py, so if you 
want to use a productionsettings.py or so you should take a good hard look).




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: TestCase Client.login() fails

2012-03-28 Thread Reinout van Rees

On 28-03-12 08:05, jondbaker wrote:


def test_login(self):
user = User.objects.create_user('test', 't...@test.com', 't3stp@s$')
response = self.client.login(username=user.username, password=user.password)
self.assertTrue(response)

After creating the user, I can verify that user.is_active is in fact
True, but unfortunately response returns False. Both
'django.contrib.auth.middleware.AuthenticationMiddleware' and
'django.contrib.auth' are declared in settings.py.

Any thoughts?


Yes: You have to call user.save() after creating it. Otherwise the user 
object exists, but it isn't saved to the database yet. And 
"self.client.login()" queries the database, not user objects local to 
the test.



Creating model objects in tests and testing them afterwards is something 
that needs a bit of care. I've made several mistakes with them already 
:-) Look at [1] for an example error.



Reinout

[1]: 
http://reinout.vanrees.org/weblog/2011/11/18/django_unicodedecodeerror.html


--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: TestCase Client.login() fails

2012-03-28 Thread Reinout van Rees

On 28-03-12 11:17, Alexey Kinyov wrote:

Yes: You have to call user.save() after creating it. Otherwise the user
>  object exists, but it isn't saved to the database yet.

That' wrong.

Documentation says:

 create_user(username, email=None, password=None)

 Creates, saves and returns a User.


You're right, I was wrong :-)  I overlooked that create_user is a 
special call and thought it was just a generic create statement.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Django Book

2012-04-21 Thread Reinout van Rees

On 12-04-12 09:44, Timothy Makobu wrote:

The Django book is the best source of understanding Django I have found
http://www.djangobook.com/en/2.0/

However, it's three years old now. Is the info on it still valid?

Is there a plan to update it?


Well, I'm writing a book on Django for the pragmatic programmers: 
http://pragprog.com/book/rvrdj/solid-django :-)


There's not much to see there now as I'm still writing it, but at least 
you can click on the "progress" link and get a visualization of the 
progress.


See http://reinout.vanrees.org/weblog/tags/book.html


Most available books are quite old, so I'm doing my best to get this one 
out so that there's a current book. I'm targetting Django 1.4 so that's 
pretty current :-)



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Loading static files from a dev environment

2012-04-29 Thread Reinout van Rees

On 23-04-12 12:56, gnesher wrote:

I'm having an odd problem with my test Django environment.

It seems that static filles I've collected from different apps using
the collectstatic command works fine, while other static files I
placed in myself result in 404 error. This can happen from the same
directory (where a png that was collected will load, but a png i just
drop in will fail).


In development mode, staticfiles will just serve the files directly from 
your app's static/ directories without using the directory where 
collectstatic places them. That's proper behaviour for development.


The directory that collectstatic fills is just for your production 
environment where you've got a proper webserver to serve that directory.


So... it is by design :-)


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: buildout development vs. deployment

2012-04-29 Thread Reinout van Rees

On 25-04-12 12:21, Reikje wrote:

Hi, I am looking into buildout to deploy a django webapp and all it's
dependencies. I find it quite useful even during development because it
forces you to keep track of your dependencies. A question regarding some
best practices. Lets say I have buildout.cfg and setup.py in my project
root and checked in into SCM. My webapp is listed under develop in
buildout.cfg. While this is great, during deployment this is probably
not what you want because you wanna lock the version of your source
code. I want to do a git revision checkout to archive this. So i guess I
need to maintain two different buildout.cfg files, one for development
and one for deployment. How can this be organized to avoid DRY?


I have a production.cfg that extends buildout.cfg. I can then add extra 
parts ("set up a supervisord to run gunicorn") of modify settings in 
existing ones ("use port 10026 instead of 8000").


I get to keep it pretty DRY that way.

Note that I make proper packages out of my development apps and stick 
them somewhere that buildout can find them. You could try to use the 
mr.developer add-on to check out tags of your stuff.


For hints on getting your own packages up on a pypi of your own:
http://reinout.vanrees.org/weblog/2009/11/09/eggproxy-plus-private-packages.html
That ought to give you some hints.


On a side note, what are the alternatives to buildout. Maybe there is
something even better :)


Buildout provides two things:

- Installation + isolation of python packages, just like the 
pip+virtualenv environment. With the note that buildout works just fine 
on windows and that pip won't install binary windows eggs. Otherwise the 
effect is mostly the same, though I like buildout's version handling 
better as it is impossible to forget it (unlike forgetting to pass pip a 
requirements.txt file).


- Add-on recipes for extra automation. Great for deployment. Generating 
nginx/apache config files, setting up a cron job, creating 
your_site_dir/var/log directories and so on.


=> for handling everything *within* your project directory, nothing 
beats the functionality of buildout. And it combines fine with tools 
like fabric that can handle everything outside of the project directory.



Reinout


--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Unable to get result using distance query

2012-04-29 Thread Reinout van Rees

On 26-04-12 00:02, vishy wrote:

I am using PointField to store longitude and latitude with SRID 4326.
All my places are in USA. Now, given a reference point, I do

lat = "41.881944"
lng = "-87.627778"

 ref_pnt = fromstr("POINT(%s %s)" % (lng, lat))


You have probably mixed up latitude and longitude. First pass lat, then lng.


DatabaseError: Coordinate values are out of range [-180 -90,
180 90] for GEOGRAHY type


Only thing that springs to mind is that web-mercator coordinates 
(="google") don't work from latitude 85 upwards and -85 downwards (so, 
on the two poles). And as you swapped lat/lon, the 87 value ends up as 
latitude. Long shot...


Another wild guess: print the value of ref_pnt. So what comes out of 
fromstr(). Is that really the correct value? Is there some 
number-formatting mishap that treats points differently?


Wild guesses...



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: outdated django book

2012-04-29 Thread Reinout van Rees

On 29-04-12 21:24, knowledge_seeker wrote:

On Friday, April 27, 2012 7:09:32 PM UTC-7, knowledge_seeker wrote:

My Django book (from the university library) said to add the label
"@login_required" to views that I wish to restrict user access on.
Django 1.4 does not allow this; obviously the book is dated! Is there
a more modern way to get the same effect?


Perhaps your @login_required error was also an forgot-to-import-it 
error. But it also might be because you're using a class based view.


If so, look for the 'decorators' heading in the following link:
http://www.caktusgroup.com/blog/2011/12/29/class-based-views-django-13/

You need to decorate the dispatch() method in the class-based-view case.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: @login_required do nothing

2012-04-29 Thread Reinout van Rees

On 28-04-12 21:00, marcelo nicolet wrote:

Following the on-line docs (
https://docs.djangoproject.com/en/1.4/topics/auth/ ) I decorated my
"index" view with @login_required, but nothing happens. In other words,
it'supossed I would be redirected to a login page, else an exception
migth raise. But the whole thing keeps doing as always.
What am I doing the wrong way?


Are you using a function as a view or a new class based one?
In the latter case, the decorator won't work if you place it on the class:
http://www.caktusgroup.com/blog/2011/12/29/class-based-views-django-13/


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: buildout development vs. deployment

2012-04-30 Thread Reinout van Rees

On 30-04-12 13:08, Reikje wrote:

Are you using a setup.py file with buildout? Currently I am not using
one. My buildout.cfg lists all the dependencies


Yes, I use a setup.py. For me, a setup.py is for listing hard 
dependencies of the code, especially for packages you include in your 
buildout. That way you can also reuse them and be sure that everything 
you need is included.


The core point is that setup.py's are "recursive" where buildouts are not.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: How to get caller function from a function

2012-05-04 Thread Reinout van Rees

On 04-05-12 05:30, cj wrote:

def myfunc():
 blah blah blah

and then in views.py

def myview1():
 myfunc()

def myview2():
myfunc()


What you probably want:

def myview1():
return myfunc()


So you might be missing the 'return'. Otherwise you're only calling the 
helper function, not returning its results.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: template logic vs AJAX newbie seeks advice

2012-05-04 Thread Reinout van Rees

On 04-05-12 15:17, Sells, Fred wrote:

Up to now, I’ve been using Flex for my client side and having Django
return xml for the last 2 years. With Adobe’s policy changes regarding
Flex support, I need to shift future efforts to HTML5. I’m seeking some
general advice from the group on basic technology/techniques. My
specific question is…


Swapping xml output from Django for JSON output should be pretty 
straightforward, I guess. And you can feed the JSON to your brand new 
html5+javascript front-end. If you're comfortable with javascript, this 
could be pretty similar in nature to your current setup.



When looking at the Django templating features vs using a tool like
CS5.5 or expression blend, what advice would you offer deciding how much
to put into the template logic and how much to do via
AJAX/Javascript/Jquery? My applications are generally 10 to 30 pages and
I have a 10% commonality between applications.


I blogged about the ajax/template split regarding Django a couple of 
days ago and got some helpful comments. Perhaps some of them give you 
some additional feel for the matter:


http://reinout.vanrees.org/weblog/2012/04/30/django-vs-ajax-how-far.html



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: template logic vs AJAX newbie seeks advice

2012-05-05 Thread Reinout van Rees

On 04-05-12 19:15, Etienne B. Roesch wrote:

Thanks for the link to your post Reinout!

So, have you made a decision about the way to go for your application?


For the near future we're sticking with templates, but with javascript 
for the spots where we need it (we'll use backbone to clean up on part 
of the UI).



I like the idea of using two different systems from the backend and the
frontend. I am new to django (a month+), but I don't think there was
ever a doubt in mind that my frontend would be .js based, and I liked
that django dev let /static to be dealt with by say plain Apache,
instead of enforcing python for that too.


And... with django's staticfiles handling you can even bundle 
js/css/images per app and Django'll combine it all together. Works great.



As I said, I am new to django, but I have done some experiments (wrote
my own little hello world app, moved on to deploying mezzanine to
dotcloud), and as I understand django is meant to be a flexible system
to handle data, and was never meant to be a flexible frontend, right?


Django has always been frontend-agnostic. There's only the admin 
interface, for the rest you have to build everything yourself.



Now, even though I do like the proper tools for the proper jobs, the
perspective of maintaining two systems built on different technologies
raises red flags. What do people think?


Well, if the separation is clean enough, it is fine. Just make sure you 
don't tie them together too much.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: template logic vs AJAX newbie seeks advice

2012-05-05 Thread Reinout van Rees

On 05-05-12 22:34, M Hussain wrote:

I think I'm in the same situation of considering Django for developing a
webapp or knowing Django features to develop UI. Is that possible to
develop UI like a desktop application, features like, tab, Buttons,
Checkboxes, lists, ploting graphs based on the data read from DB.


Well, if you want the full desktop-like experience in a web page, you 
ought to look at extjs: http://www.sencha.com/products/extjs/


Full windows-like buttons, tabs, etc stuff.

It won't be usable on a mobile phone, but if a heavy js interface (it 
*is* quite big) is no problem: take a look.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: How to serve staticfiles with full URL for local development?

2012-05-05 Thread Reinout van Rees

On 05-05-12 15:34, e.generalov wrote:

There was a snippet to display a content of response in browser during
debugginghttp://miniblog.glezos.com/post/3388080372/tests-browser  .

"One of the first issues you might face is seeing a style-less page.
This happens becuase the test server isn’t really a web server, and
you’re probably serving static files from something relative such as
'/
site_media'. The solution is simple: Run a separate Django server and
tweak your development-only static URL to something like:

STATIC_URL = 'http://localhost:8000/site_media/
"

but this doesn't works anymore, because django.contrib.staticfiles
doesn't serve static when STATIC_URL contains full URL.


I don't have any problems with static stuff. The solution is probably 
simply to not include any hostname. What I have (on the server and 
locally on my development box):


STATIC_URL = '/static_media/'


In case it still doesn't work: you probably use something else than the 
standard runserver. In that case,

https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#django.contrib.staticfiles.templatetags.staticfiles.django.contrib.staticfiles.urls.staticfiles_urlpatterns
applies. You have to add that to your urls.py. But normally, you don't 
have to.




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: How to serve staticfiles with full URL for local development?

2012-05-14 Thread Reinout van Rees

On 11-05-12 08:48, e.generalov wrote:

ps: but why these restrictions are needed in the tool, which should
assist in the development?


I think you're using it in a strange way, as I (nor anyone I know that 
uses django-staticfiles) has any problem in development.


You said in a reply to one of my messages something about "needing a 
full path name '/tmp/' for saved pages". What did you mean by that? 
Such a full path is different from a proper localhost:8000 url.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: JSONField: which app to choose ?

2012-07-10 Thread Reinout van Rees

On 09-07-12 20:52, Michael Palumbo wrote:

Hi,

I have found several implementations of a Django JSON Field.
Have you ever tried one ? Which one do you recommend ?


I'm using the 'django-jsonfield' on pypi:
http://pypi.python.org/pypi/django-jsonfield/

It is https://bitbucket.org/schinckel/django-jsonfield/ on bitbucket.
I looked at it with a colleague and it seemed to have a bit more 
validation than some others. Little things.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"



--
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: Release considerations

2012-07-10 Thread Reinout van Rees

On 10-07-12 08:24, Jon Black wrote:

I've been working on a task management project and am at a point where
I'm happy to make my first release. The idea is that people can install
the project on their own server (at home, at work, wherever) and use it
to manage their tasks.

What should I consider doing before making the code available to both
make life easier for the users/keep private information out of the
repository?


First you have to get the basics right like a proper setup.py, a README, 
a changelog, that sort of stuff.


If you're looking at how-to-package-a-django-site examples, I'd look at 
sentry. I liked the way they packaged it. Install it in a virtualenv and 
it'll set up a django site for you. A custom settings file is installed 
in some ~/.sentry directory, with defaults imported from a sentry 
default settings file. Works fine. Pretty clear.


Make sure you've got example configurations on how to integrate it with 
a webserver (apache/nginx).



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"



--
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: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-15 Thread Reinout van Rees

On 15-10-12 14:50, Zheng Li wrote:

get_or_create shouldn't give duplicate entry error


Perhaps you have existing data that violates your unique-together 
constraint? Data that existed before that constraint was in place?


Check it directly in your database by searching for that a=a, b=b entry.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: problem with a grph image in template

2011-08-18 Thread Reinout van Rees

On 17-08-11 21:32, smartaz wrote:


if I call this view for an url: (r $' ^plot / image.png ', 'contact ')
which comes from a form where I put
  {% csrf_token %}
the graph is correctly displayed as picture in a page html
http: // 127.0.0.1:8000 / graphs / contact / image.png


That url doesn't seem to match the url you gave above. That makes it 
hard to guess what goes wrong.



If I pass by another view to show picture in a template Django,
I have an Internal Server Error 500 systematically


So: what is the error? Getting an error 500 can mean anything from "disk 
full" to "python syntax error".


Perhaps there's a difference that your first example is a POST to that 
image? And  means a GET request?



by putting in the
template a simple tag  in the template


That src attribute again doesn't seem to match your original url.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: 'dict' object has no attribute 'META'

2011-08-18 Thread Reinout van Rees

On 18-08-11 17:44, MikeKJ wrote:

'dict' object has no attribute 'META'

...

 ▶ Local vars
 /var/www/django/eco/django/core/context_processors.py in debug
 if settings.DEBUG and request.META.get('REMOTE_ADDR') in
settings.INTERNAL_IPS: ...


Apparently the request is now a 'dict' object instead of a real django 
request object.


Do you have some middleware or so that does something to the request? 
Does your view modify the request, inadvertently modifying it into a dict?


Just brainstorming about possible causes :-)



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Anyone use mod_security with Django?

2011-08-18 Thread Reinout van Rees

On 18-08-11 18:35, KC LEE wrote:

  Hi,

  I am running a website built with Django.

  For security, I am going to install mod_security on my web server.

  Anyone use mod_security with Django? Is mod_security useful?

  I heard that Django can defend many attacks (like csrf, XSS, SQL
Injection... and so on...)


The way django is build prevents those common attacks. You won't need 
protection against sql injection, for instance, as it is simply not a 
problem with django.


mod_security looks like something that needs both care and knowledge to 
set up properly. So you yourself will need to gain knowledge on what 
mod_security actually does and how to configure it.


Personally, I've never heard of anyone using it for Django and I'd be 
surprised if it is needed.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Anyone use mod_security with Django?

2011-08-18 Thread Reinout van Rees

On 18-08-11 22:42, Shawn Milochik wrote:

This was actually discussed in a talk by Adam Baldwin at DjangoCon 2010:
http://www.ngenuity-is.com/blog/2010/sep/10/pony-pwning-djangocon-2010/


Ah, that's useful!


I don't believe it's a good idea at all to disregard something like
mod_security just because we're using Django, because mod_security isn't
limited to duplicating what Django protects against by default.


You're probably right. I don't know the full range of what mod_security 
protects against.


My reaction was more the other side of the coin: don't feel secure 
"just" because you put mod_security in front if you don't fully know 
what that protects against and what actually needs protecting in Django.
Otherwise you're just installing mod_security because it protects 
against crsf and because that sounds secure even though Django protects 
against that just fine ;-)




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: problem with a graph image in template

2011-08-19 Thread Reinout van Rees

On 19-08-11 04:03, smartaz wrote:

I think the error is in image.png GET, a python syntax error but I can
not think where (I do not know how to retrieve the trace of a 500
error in django, I installed django debug toolbar) it seems that
python can not write the file with the image ..the content type? ..I
don't understand, .this second view works when i ask an httpresponse
instead of the template


Ah! You're getting the 500 on the image, so you can't easily see the 
full 500 traceback in your browser as the html renders just fine.


Two options:

- Just go directly to the url of the image instead of to the html page 
that contains the img tag. Then you'll see the 500 traceback of your 
image itself. (Assuming DEBUG=True in your settings.py).


- Install firebug (or use chrome's/safari's build-in developer tools) 
and look at the various responses. There you can normally directly see 
the 500 error text.



Seeing the traceback ought to show you the problem.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Django admin site and DEBUG flag.

2011-08-19 Thread Reinout van Rees

On 19-08-11 05:28, KC LEE wrote:

When I set DEBUG flag true, Django admin site works fine.

But when I change it to false, it throws me the page not found in
Django admin site (except main page of admin site, Groups page, and
Users page)


This sounds like your urls.py has an "if settings.DEBUG:" around where 
the admin site is mounted in your urls.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Django admin site and DEBUG flag.

2011-08-19 Thread Reinout van Rees

On 19-08-11 10:27, KC LEE wrote:

urlpatterns = patterns('',

 (r'^$', 'accounts.views.front_page'),
 url(r'social/', include('social_auth.urls')),

 (r'^admin/', include(admin.site.urls)),

 (r'^regions/', include('region.urls')),

 (r'^messages/', include('pimfy_messages.urls')),
 (r'^accounts/', include('accounts.urls')),
 (r'^issue/', include('issue.urls')),
 (r'^notification/', include('notification.urls')),



Looks alright. Only noticeable thing: that 'social/' one is the only one 
called with url(). Might be worth a try to remove that url() call around 
it to let it match the rest. Shouldn't matter, but... ;-)



You said that admin/* and admin/users/* and admin/groups/* *did* work? 
Which ones don't? If it is for instance /admin/issues/*, look at that 
issues app and see if there's an 'if settings.DEBUG' somewhere in there.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Django 1.3 logging not working as I'd expect

2011-08-22 Thread Reinout van Rees

On 20-08-11 06:51, Scott Danzig wrote:


I have a simple Django app in development that uses a dictConfig setting
simpler than the default in settings.py:

LOGGING = {

[snip]

}

Then later in code that I know is run... (I tried in my app's views.py
and also the backend).. I put something like this:

import logging
logger = logging.getLogger('testlogger')
logger.warn('hello')
logger.info('please appear')

And I just don't see it, neither in the console, nor the file.


Probably all your logging statements are executed right at file import 
time before the logging is actually configured.


Just as a simple test, put such a logging statement inside one of your 
view methods and hit it in your browser. Just to make sure your logging 
setup as such works.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: why can't I access a dictionary with an initial form field value from my django template?

2011-08-23 Thread Reinout van Rees

On 23-08-11 21:16, Tony Schmidt wrote:

I thought this should be the proper syntax in my template:

{{ MYDICT.myform.somefield.value }}

But I get a "can't parse remainder error."

Just putting {{ myform.somefield.value }} gives me "3" and {{ MYDICT.
3 }} gives me the dictionary value I want.

Am I missing something?


MYDICT.myform looks up an 'myform' attribute on MYDICT or the 'myform' 
key in the MYDICT dictionary. Which doesn't exist.


There's no way the template language can know that it first has to look 
up the last three items and then apply that to the first item. That's 
the basic problem.


Best solution probably: just do the MYDICT[myform.somefield.value] in 
your view and pass the value to the template?



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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.



  1   2   >