Which apps/solutions are most appropriate for model based search in Django?

2009-10-21 Thread chefsmart

This is on stackoverflow.com also, but I guess not all Django users
visit that site so I am posting this here also: -

I have a Django app where most of the search is driven by foreign
keys. For example, assuming Student, School, State, and
EducationalQualification are Django models, the user would search for
Students by specifying search criteria by selecting from lists of
Schools, States, Degrees, Diplomas etc. That is, a search on students
is essentially an answer to the question "Show students that belong to
the following schools, and who belong to the following states, and who
have the following degrees / diplomas".

My Django app is purely database driven - there are no documents or
webpages to search.

In this case where searching for Django models are guided mostly by
the foreign keys that model has, what search apps/solutions are most
appropriate? The ones I have taken a look at all talk a lot about full
text search, I may be wrong but I don't think that is appropriate in
my case.

I am currently searching using Peter Herndon's approach (http://
www.slideshare.net/tpherndon/django-search-presentation). But this is
expected to be a high-traffic site and I am worried about speed and
performance.

Regards,
CM.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ANNOUNCE:- ibm_db_django-0.1.4 IBM Dataservers backend support for Django 1.1 Released

2009-10-21 Thread Tarun Pasrija

IBM_DB_DJANGO-0.1.4
---
IBM_DB_DJANGO adaptor enables access to IBM databases from Django
applications http://www.djangoproject.com/. The adaptor is developed
and maintained by IBM.

What's New?

We are pleased to announce the release of ibm_db_django-0.1.4 to
support Django 1.1 and 1.0.x. We have kept the backward compatibility
so that users who have not migrated from 1.0.x to 1.1 can still use
the same adaptor.

Note:- Updation from from ibm_db_django-0.1.0 to ibm_db_django-0.1.4
---
--
The name of the adaptor (in Django terminology, the DATABASE_ENGINE)
has been changed to 'ibm_db_django' from this version onwards (in
earlier versions it was 'db2'). For your existing apps please
remember
to change this once you upgrade to ibm_db_django-0.1.4
The 'DATABASE_ENGINE' field in settings.py should as below when using
ibm_db_django-0.1.2
   DATABASE_ENGINE= 'ibm_db_django'
(In version 0.1.0, it is "DATABASE_ENGINE= 'db2' " )

SVN access to the source
---
http://code.google.com/p/ibm-db/source/browse/trunk/IBM_DB/ibm_db_django/

Installation

$ easy_install ibm_db_django

Feedback/Suggestions/Issues

You can provide us feedback/suggestions, or report a bug/defect, or
ask for help by using any of the following channels:
1. Mailing us at open...@us.ibm.com
2. Opening a new issue at http://code.google.com/p/ibm-db/issues/list.
3. By opening new discussion at http://groups.google.co.in/group/ibm_db.
For prerequisites, installation steps and help details, visit -
http://code.google.com/p/ibm-db/wiki/ibm_db_django_README
Try this out and let us know you valuable feedback. Have fun.

Cheers,
Tarun Pasrija
Open Source Application Development
IBM India Software Labs

DB2 Cobra is now available. Download Express-C for free, go to:
---
-
https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=swg-db2expressc_CMP=ECDDWW01_TACT=ACDB206
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



django-bbcode

2009-10-21 Thread Jonas Obrist

Hi django-users

I wrote a django app called 'django-bbcode' which parses bbcode (or any 
whatever you want it to) into html (or whatever you want it to). The 
code is hosted on http://bitbucket.org/ojii/django-bbcode/wiki/Home for 
all those who are interested.

I also wondered if there is any site where I can post my app (some sort 
of django addons list), since the only one I knew (djangopluggables) is 
down.

- ojii

--~--~-~--~~~---~--~~
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: Does anyone know what happened to djangopluggables.com?

2009-10-21 Thread Andy McKay

> I've been seeing that for a few months now when trying to visit the site.

Before djangopluggables has been dead for many months. Before it went
offline, I spidered everything into http://djangozen.com/, its been growing
slowly since then.

--
Andy McKay

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



SSL Redirect on apache.

2009-10-21 Thread Sonal Breed

Hi all,

In my application, I need to have https on sign-in, sign-up pages and
any page that user visits after log in.

I am running my django app on apache 2.2.14 server.

I made use of following snippet

http://www.djangosnippets.org/snippets/880/

along with many others like 80, 240, 1760

But I cannot get it working. Do I have modify apache config file with
respect to Redirect?
Am I missing anything?


Thanks,
Sincerely,
Sonal.
--~--~-~--~~~---~--~~
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: syncdb fails to update Not NULL property in PostgreSQL 8.4

2009-10-21 Thread Tomasz Zieliński


On 21 Paź, 19:20, "Thomas B. Higgins" 
wrote:
> Using the SVN trunk version of Django, I have observed that if a model
> IntegerField or FloatField is changed by adding "null=True" syncdb
> does not update the Not NULL property of the column using PostgeSQL
> 8.4. Is this correct behavior, or a bug? The two easy workarounds are
> (1) drop the table using pgAdmin III and follow with a syncdb creating
> a new table which will have the correct Not NULL status, or (2)
> manually change the Not Null property value for the column using
> pgAdmin III. Obviously the first method is a bit extreme.

There is also method (3) - use migration app, I suggest you take
a look at South: http://south.aeracode.org - it's very easy to pickup
up.

--
Tomasz Zielinski,
http://pyconsultant.eu
--~--~-~--~~~---~--~~
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: admin actions bar in django 1.1

2009-10-21 Thread kkerbel

it doesn't appear to be working for any apps.  everything else on the
admin page shows fine to my knowledge...just not the admin actions
bar.

On Oct 21, 4:47 pm, kkerbel  wrote:
> within the templates folder for my app (events in this case)...I just
> have a folder named events containing templates for the pages...I do
> not have any admin template mods.
>
> On Oct 21, 12:47 pm, Peter Bengtsson  wrote:
>
>
>
> > What customizations have your done in the templates/admin/ folder of
> > the app that isn't working?
>
> > On 21 Oct, 17:22, kkerbel  wrote:
>
> > > i upgraded django 1.0.2 to 1.1 stable and I cannot see the admin
> > > actions bar in one of my apps...or any of them for that matter.  My
> > > fresh install of 1.1 has the bar, however, I can't seem to find the
> > > discrepancy between the two installs.  Have any of you experienced
> > > this?  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin actions bar in django 1.1

2009-10-21 Thread kkerbel

within the templates folder for my app (events in this case)...I just
have a folder named events containing templates for the pages...I do
not have any admin template mods.

On Oct 21, 12:47 pm, Peter Bengtsson  wrote:
> What customizations have your done in the templates/admin/ folder of
> the app that isn't working?
>
> On 21 Oct, 17:22, kkerbel  wrote:
>
>
>
> > i upgraded django 1.0.2 to 1.1 stable and I cannot see the admin
> > actions bar in one of my apps...or any of them for that matter.  My
> > fresh install of 1.1 has the bar, however, I can't seem to find the
> > discrepancy between the two installs.  Have any of you experienced
> > this?  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does anyone know what happened to djangopluggables.com?

2009-10-21 Thread James Bennett

If anyone knew what had happened to it, it's likely they'd have
responded in one of the multiple other threads asking this question.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



nginx, apache, and odd admin error

2009-10-21 Thread rd-london

Hi,
Wonder if someone can help.This issue is all with a local dev
situation, so this isn't live.

I have nginx running on port 81 e.g. http://127.0.0.1:81/ and serving
static media - which in turn proxies through to Apache running on port
96. All works fine (apart from the issue I outline below) - so I can
browse my content no problem.

The issues relate to the admin interface.

If I request the admin interface at http://127.0.0.1:81/admin/, the
admin login window appears but on "log in", I am taken to  
http://127.0.0.1/admin/
- which of course 404's i.e. doesn't work (there appears to be some
kind of redirect going on).

Once I've got this 404, if I then request http://127.0.0.1:81/admin/
again, the full "logged in" interface now comes up - i.e. I am now
*not* redirected and am now logged in.

Carrying on ... if I try to edit some content, all works fine until I
try to Save or Save and Continue ... at which point again I am
redirected to admin URL minus the port (incidentally the item is then
saved).

If I work directly on the Apache interface at http://127.0.0.1:96/ I
don't have this problem.

Anyone any suggestions as to what's going on and how to fix it?

Many thanks,
R
--~--~-~--~~~---~--~~
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: Does anyone know what happened to djangopluggables.com?

2009-10-21 Thread Wayne Koorts

>> It's been giving me a "502 Bad Gateway
>> nginx" for at least a couple weeks now.

I've been seeing that for a few months now when trying to visit the site.

Regards,
Wayne

--~--~-~--~~~---~--~~
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: Does anyone know what happened to djangopluggables.com?

2009-10-21 Thread Lemuel Formacil


On Oct 22, 2009, at 12:32 AM, Brian McKeever wrote:

>
> It's been giving me a "502 Bad Gateway
> nginx" for at least a couple weeks now.

Yeah, looks like it's down.

Here are the guys who made it:

http://sidebarcreative.com/

>
> Are there any other good sources of django plugins?

with some google-fu you can list all django apps in googlecode:

http://www.google.com/search?hl=en=site:code.google.com+inurl:/p/django-=10=N


-- 
Lemuel


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



edit fieldset.html template

2009-10-21 Thread onoxo

hi!
i have a model and I'm using it as inline in admin site. here is the
code:

models.py

class PhotoItem(models.Model):
order = models.IntegerField(blank = True, null = True)
itemset = models.ForeignKey('PhotoSet', related_name='photoset')
item = models.ForeignKey('Photo', related_name='photoitem')

admin.py

class PhotoItemInline(admin.StackedInline):
model = PhotoItem
ordering = ['order']
raw_id_fields = ['item']
extra = 5

i want to use value (item.image) from PhotoItem object (witch is a
string that represents s path to image) in "templates/admin/includes/
fieldset.html" template. the problem is that i dont know how to refer
to that attribute (item.image) when I'm in html.
since i'm designer i'll show you what i need, this is the picture of
field that i need to create in inlines (this is done in filebrowser
app):
http://vedran.webfactional.com/kontenjner/fb.png

 i've try to put this on many places:
item.image
but it's not working.

could someone please help me with this one?

--~--~-~--~~~---~--~~
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: Preview model before saving it

2009-10-21 Thread akonsu

hello,

anything is possible. you just need to decide how you are going to
store your changes before the model gets "really" saved so that the
preview functionality works. where would preview get the values from?
i propose a "published" boolean field in the model.

konstantin

On Oct 21, 3:41 pm, Aaron  wrote:
> I'm wanting to set up model previews in the admin. I've been following
> this guide:
>
> http://latherrinserepeat.org/2008/7/28/stupid-simple-django-admin-pre...
>
> However, that guide seems to only apply to models that have already
> been saved (how is it different from "View on site"?). I wish to be
> able to make changes to my model, click on "Preview", and see what my
> model page will look like *before* saving it in the admin. Is this
> possible?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



order_by date_trunc ?

2009-10-21 Thread akonsu

hello,

i have a datetime field in my model. is there a way to order a query
set by this field truncated to the given precision?

even worse. i have another field in the model that specifies the
precision ('year', 'day', etc), i need to order the query set by the
datetime field truncated using the corresponding precision field.

thanks
konstantin
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Does anyone know what happened to djangopluggables.com?

2009-10-21 Thread Brian McKeever

It's been giving me a "502 Bad Gateway
nginx" for at least a couple weeks now.

Are there any other good sources of django plugins?

I know of the official python packages:
http://pypi.python.org/pypi?%3Aaction=browse

and django snippets:
http://www.djangosnippets.org/


--~--~-~--~~~---~--~~
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: 500.html does not load

2009-10-21 Thread akonsu

hello,

there is a setting in settings.py that controls where django searches
for templates.

konstantin

On Oct 21, 2:50 pm, NoviceSortOf  wrote:
> Although I have 500.html in my
> site-packages/django/contrib/admin/templates folder 500.html does not
> appear when it should, below see my errors (I've included the
> traceback items below).
>
> Is there something else I need to configure to get 500.html to load?
>
> Mod_python error: "PythonHandler django.core.handlers.modpython"
> 
> 
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
> 299, in HandlerDispatch
>     result = object(req)
>
>   File "/usr/lib/python2.3/site-packages/django/core/handlers/
> modpython.py", line 222, in handler
>     return ModPythonHandler()(req)
>
>   File "/usr/lib/python2.3/site-packages/django/core/handlers/
> modpython.py", line 195, in __call__
>     response = self.get_response(request)
>
>   File "/usr/lib/python2.3/site-packages/django/core/handlers/
> base.py", line 116, in get_response
>     return self.handle_uncaught_exception(request, resolver,
> sys.exc_info())
>
>   File "/usr/lib/python2.3/site-packages/django/core/handlers/
> base.py", line 160, in handle_uncaught_exception
>     return callback(request, **param_dict)
>
>   File "/usr/lib/python2.3/site-packages/django/views/defaults.py",
> line 88, in server_error
>     t = loader.get_template(template_name) # You need to create a
> 500.html template.
>
>   File "/usr/lib/python2.3/site-packages/django/template/loader.py",
> line 80, in get_template
>     source, origin = find_template_source(template_name)
>
>   File "/usr/lib/python2.3/site-packages/django/template/loader.py",
> line 73, in find_template_source
>     raise TemplateDoesNotExist, name
>
> TemplateDoesNotExist: 500.html
--~--~-~--~~~---~--~~
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: "can't adapt" - mod_python, multiple interpreters, psycopg2

2009-10-21 Thread Antoni Aloy

2008/3/5 Pigletto :
>
>> > Problem is possibly with multiple interpreters and psycopg2 again,
>>
>> Why do you say that? The thread you refer to above doesn't talk about
>> mod_python, so do you have any extra evidence that support this claim?
> There was a bug in psycopg2 with Decimal data type that sometimes
> caused
> error like that:
> unsupported operand type(s) for *: 'Decimal' and 'Decimal'
>
> It was discussed on the list:
> http://groups.google.com/group/django-users/browse_thread/thread/091aa6c088f6c090
>
> Similarly to "can't adapt" it was raised sometimes, after apache was
> running for few days, etc.. When error appears, restarting apache
> causes everything to work fine but only for some time and then again,
> errors are appearing. It was said that Decimal problem is caused by
> running psycopg2 with multiple interpreters, so thats why I think
> "can't adapt" might be the same thing.
> Exactly same place, same data entered in the form and after submit
> sometimes I get "can't adapt" and sometimes (after apache restart)
> everything works.
>

Sorry for opening an old thread but this is exactly the problem we
have had today with an application that has been running for nearly
two years. We're using mod_python and we run two different sites. We
have the can't adapt error at random basis. Once is produced in one
site the other site gives the same error.

I don't know if is related or not, but the only thing we have done is
to update to the security patch of 1.0 version. Actually we have
updated to the 1.1.2 version but the error still happens.

Restarting Apache makes everythink running again, but after some time
the error appears. The request involves making a query that Django
converts to a Decimal number (a request between 0 and 9), I
have refactored to make a different query so It seems this kind of
error is not solved.

Traceback follows:

Traceback (most recent call last):

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/handlers/base.py",
line 92, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/var/pywww/trobacasaweb/trobacasa/views.py", line 502, in buscar
resultado['page'] = paginator.page(actual_page)

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 37, in page
number = self.validate_number(number)

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 28, in validate_number
if number > self.num_pages:

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 60, in _get_num_pages
if self.count == 0 and not self.allow_empty_first_page:

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/core/paginator.py",
line 48, in _get_count
self._count = self.object_list.count()

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/query.py",
line 292, in count
return self.query.get_count()

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 376, in get_count
number = obj.get_aggregation()[None]

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 348, in get_aggregation
result = query.execute_sql(SINGLE)

  File 
"/usr/local/virtualenvs/trobacasa/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 2369, in execute_sql
cursor.execute(sql, params)

ProgrammingError: can't adapt



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Preview model before saving it

2009-10-21 Thread Aaron

I'm wanting to set up model previews in the admin. I've been following
this guide:

http://latherrinserepeat.org/2008/7/28/stupid-simple-django-admin-previews/

However, that guide seems to only apply to models that have already
been saved (how is it different from "View on site"?). I wish to be
able to make changes to my model, click on "Preview", and see what my
model page will look like *before* saving it in the admin. Is this
possible?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



500.html does not load

2009-10-21 Thread NoviceSortOf


Although I have 500.html in my
site-packages/django/contrib/admin/templates folder 500.html does not
appear when it should, below see my errors (I've included the
traceback items below).

Is there something else I need to configure to get 500.html to load?

Mod_python error: "PythonHandler django.core.handlers.modpython"


Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

  File "/usr/lib/python2.3/site-packages/django/core/handlers/
modpython.py", line 222, in handler
return ModPythonHandler()(req)

  File "/usr/lib/python2.3/site-packages/django/core/handlers/
modpython.py", line 195, in __call__
response = self.get_response(request)

  File "/usr/lib/python2.3/site-packages/django/core/handlers/
base.py", line 116, in get_response
return self.handle_uncaught_exception(request, resolver,
sys.exc_info())

  File "/usr/lib/python2.3/site-packages/django/core/handlers/
base.py", line 160, in handle_uncaught_exception
return callback(request, **param_dict)

  File "/usr/lib/python2.3/site-packages/django/views/defaults.py",
line 88, in server_error
t = loader.get_template(template_name) # You need to create a
500.html template.

  File "/usr/lib/python2.3/site-packages/django/template/loader.py",
line 80, in get_template
source, origin = find_template_source(template_name)

  File "/usr/lib/python2.3/site-packages/django/template/loader.py",
line 73, in find_template_source
raise TemplateDoesNotExist, name

TemplateDoesNotExist: 500.html

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



Restricting date_hierarchy

2009-10-21 Thread Manfre

I am working against a legacy database with over 25 years of
historical data. I really like the functionality provided by
date_hierarchy, but having all 25 years appear above the list is quite
ugly. My users will only ever need the past 2-3 years. Is there a way
of restricting the year links shown in the date drill down?

--
Michael Manfre
--~--~-~--~~~---~--~~
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: Do I have to pass the httprequest object to render_to_response every time?

2009-10-21 Thread Andrew Ingram

jul wrote:
> hi,
>
> in my base.html template I've got a header which needs httprequest
> (request.path, request.user.is_authenticated...).
> In all my views I'm passing the request object to render_to_response.
> Is there any better way to do that?
>
> thanks
> jul

Hi jul,

There is a context processor that comes as part of django that gives you 
access to the request object:

http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request

as long as you have it specified in your settings.py, it will 
automatically become available if you use render_to_response

Regards,
Andrew Ingram

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



Do I have to pass the httprequest object to render_to_response every time?

2009-10-21 Thread jul

hi,

in my base.html template I've got a header which needs httprequest
(request.path, request.user.is_authenticated...).
In all my views I'm passing the request object to render_to_response.
Is there any better way to do that?

thanks
jul

--~--~-~--~~~---~--~~
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: admin actions bar in django 1.1

2009-10-21 Thread Peter Bengtsson

What customizations have your done in the templates/admin/ folder of
the app that isn't working?

On 21 Oct, 17:22, kkerbel  wrote:
> i upgraded django 1.0.2 to 1.1 stable and I cannot see the admin
> actions bar in one of my apps...or any of them for that matter.  My
> fresh install of 1.1 has the bar, however, I can't seem to find the
> discrepancy between the two installs.  Have any of you experienced
> this?  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Authenticate returns None when it should validate... what I am I doing wrong here?

2009-10-21 Thread Social Network in DJango

Just tested it on my deployment environment. It still works there. Why
is it failing on my development machine??

Deployment environment:
Python 2.5.4 (r254:67916, Aug  5 2009, 12:42:40)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.auth import authenticate
>>> from django.contrib.auth.models import User
>>> user = 
>>> User.objects.create_user('johnlennon','len...@beatles.com','johnpassword')
>>> user.save()
>>> newuser= authenticate(username='johnlennon', password='johnpassword')
>>> print newuser
johnlennon
>>>

On Oct 21, 1:35 pm, Social Network in DJango 
wrote:
> My django program will not log in on one of my development machines,
> yet it works fine in my
> deployment environment. I managed to isolate the bug to the following
> code:
>
> Any help is greatly appreciated.
>
> Jonathan
>
> (Python Shell)>>> from django.contrib.auth import authenticate
> >>> from django.contrib.auth import login
> >>> from django.contrib.auth import logout
> >>> from django.contrib.auth.models import User
>
> >>> user = 
> >>> User.objects.create_user('johnlennon','len...@beatles.com','johnpassword')
> >>> user.save()
> >>> newuser= authenticate(username='johnlennon', password='johnpassword')
> >>> newuser
> >>> print newuser
>
> None
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Authenticate returns None when it should validate... what I am I doing wrong here?

2009-10-21 Thread Social Network in DJango

My django program will not log in on one of my development machines,
yet it works fine in my
deployment environment. I managed to isolate the bug to the following
code:

Any help is greatly appreciated.

Jonathan

(Python Shell)
>>> from django.contrib.auth import authenticate
>>> from django.contrib.auth import login
>>> from django.contrib.auth import logout
>>> from django.contrib.auth.models import User
>>>
>>> user = 
>>> User.objects.create_user('johnlennon','len...@beatles.com','johnpassword')
>>> user.save()
>>> newuser= authenticate(username='johnlennon', password='johnpassword')
>>> newuser
>>> print newuser
None
--~--~-~--~~~---~--~~
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: syncdb fails to update Not NULL property in PostgreSQL 8.4

2009-10-21 Thread Karen Tracey
On Wed, Oct 21, 2009 at 1:20 PM, Thomas B. Higgins  wrote:

>
> Using the SVN trunk version of Django, I have observed that if a model
> IntegerField or FloatField is changed by adding "null=True" syncdb
> does not update the Not NULL property of the column using PostgeSQL
> 8.4. Is this correct behavior, or a bug?


It's a documented restriction:

http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb

Integrating some schema evolution into the Django base is a long-term goal,
but it's not close yet.  In the meantime there are multiple external
projects that provide function like this.  Search on Django schema migration
or evolution and you should find pointers to them.

Karen

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



syncdb fails to update Not NULL property in PostgreSQL 8.4

2009-10-21 Thread Thomas B. Higgins

Using the SVN trunk version of Django, I have observed that if a model
IntegerField or FloatField is changed by adding "null=True" syncdb
does not update the Not NULL property of the column using PostgeSQL
8.4. Is this correct behavior, or a bug? The two easy workarounds are
(1) drop the table using pgAdmin III and follow with a syncdb creating
a new table which will have the correct Not NULL status, or (2)
manually change the Not Null property value for the column using
pgAdmin III. Obviously the first method is a bit extreme.

--~--~-~--~~~---~--~~
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: concurrency and threading question

2009-10-21 Thread Mike Thon



On Oct 21, 6:44 pm, Javier Guerra  wrote:
> On Wed, Oct 21, 2009 at 9:49 AM, Michael Thon  wrote:
> > Thanks for pointing me towards celery.  Its probably overkill for what
> > I want to do right now but I'm going to try to set it up anyway.
>
> the roll-your-own alternative is just setting a DB table with the
> queued tasks, and a cron job (or a long-running daemon) that fetches
> the next job from the table to work on it.  it's called 'Ghetto
> queues'.  it works and for small setups can be much ligther, but for
> complex, or high-speed, or critical availability, it can quickly
> become a nightmare to set up right.

That's what I was thinking of doing after reading Jani's reply.  I
could put the data crunching code into a view and then just set a cron
to fetch the view every couple of minutes.  The jobs could overlap so
I'd have to make sure I don't have too many running concurrently
somehow.

I got celery and RabbitMQ installed without any trouble so if I have
time today I'll tinker with getting jobs running on it.  I don't know
if celery will let me call other functions or shell commands outside
of the task function, or if the task function needs to be 'self
contained'.  If not, then ghetto queue it is...
Mike

--~--~-~--~~~---~--~~
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: concurrency and threading question

2009-10-21 Thread Javier Guerra

On Wed, Oct 21, 2009 at 9:49 AM, Michael Thon  wrote:
> Thanks for pointing me towards celery.  Its probably overkill for what
> I want to do right now but I'm going to try to set it up anyway.

the roll-your-own alternative is just setting a DB table with the
queued tasks, and a cron job (or a long-running daemon) that fetches
the next job from the table to work on it.  it's called 'Ghetto
queues'.  it works and for small setups can be much ligther, but for
complex, or high-speed, or critical availability, it can quickly
become a nightmare to set up right.

note that if you write the cron job in Python, you can easily import
Django's ORM to make really easy to share data with the webapp

AFAIK, the 'Queue' module you mention gets it mostly right; but works
only on a single Python interpreter.  If i'm not wrong, it can't
mediate between the webapp and the background job, unless you modify
either mod_wsgi or flup to spawn a thread for background
processing (Graham? what would it take to add that to mod_wsgi?)

-- 
Javier

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



admin actions bar in django 1.1

2009-10-21 Thread kkerbel

i upgraded django 1.0.2 to 1.1 stable and I cannot see the admin
actions bar in one of my apps...or any of them for that matter.  My
fresh install of 1.1 has the bar, however, I can't seem to find the
discrepancy between the two installs.  Have any of you experienced
this?  Thanks!

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



Need Help Migrating to Windows 7 (64-bit), Python 2.6, Django 1.1

2009-10-21 Thread JimR

Hello, All,

I  am trying to migrate my application from Python 2.5, Dango 1.0,
PostgreSQL 8.4, Windows XP (32-bit) to Python 2.6, Django 1.1,
PostgreSQL 8.4, Windows 7 (64-bit).  I have donwloaded and installed
the 64-bit version of Python 2.6.

I am having a problem with a particular model under the new
configuration that doesn't give me any problems in the old
configuration.  I get the same error in my application as I do in the
generic admin view.  All of my other models and views seem to be
working fine, except those that utilize this model.

I've excerpted the relevant code and error messages below, but
hesitate to post the traceback and model definition since both are
rather lengthy, and if this is a relatively straightforward error, I'd
rather not waste your time and the space.

Any suggestions or ideas on where to focus my efforts?  If you'd like
to see the model and traceback, I'd be happy to post it.

Thanks,
Jim

App:
Caught an exception while rendering: maximum recursion depth exceeded
in cmp
...
{% for r in reg_list %}
...
(from views.py: reg_list = Registration.objects.filter
(registered_by=request.user).select_related()

Admin:
TemplateSyntaxError at /admin/registration/registration/
Caught an exception while rendering: maximum recursion depth exceeded
c:\python26\lib\site-packages\django\contrib\admin\templates\admin
\change_list.html, error at line 78:

76 {% block result_list %}
77  {% if action_form and actions_on_top and cl.full_result_count
%}{% admin_actions %}{% endif %}
78  {% result_list cl %}
79  {% if action_form and actions_on_bottom and
cl.full_result_count %}{% admin_actions %}{% endif %}
80  {% endblock %}


The traceback is rather lengthy,



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



import sqlalchemy model

2009-10-21 Thread webdexter

Hi,

I search a way ton simply use my sqlalchemy model in a django project.
The database already exists (created by sqlalchemy) and I would like
to use sqlachemy request on it.
I spent a lot of time to search how to do that, I don't want to use
inspectdb to create a django model but use sqlalchemy only.  Is
someone know how to do that ? I suppose that import my SQLAlchemy
model is the first step but I don't know where enter informations
about my db and how to use sqlalchemy functions.

Thank you for helping me,

Webdexter

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



Problem about write data into the DB

2009-10-21 Thread 邓超
Hi all,
  I deployed a django app on my laptop, the whole environment is like this:
the OS is UBUNTU904, the web server is Apache, and the database is sqlite3.
The deployment is success, but  when I try to write some data into the
database, I get the HTTP 500 error. And I check the error log, it
shows "*OperationalError:
unable to open database file*". What does this error mean? If there are some
operation permission need configure?

-- 
Deng Chao

--~--~-~--~~~---~--~~
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: installing Django on Mac OS 10.6

2009-10-21 Thread robin

Daniel and Hector,

Thank you very very much. I am off install the module.

Robin


On Oct 21, 12:29 pm, Hector Garcia  wrote:
> On the internets?
>
> http://docs.djangoproject.com/en/dev/ref/databases/#mysqldb
>
> Hector Garcia - Web developer, musicianhttp://nomadblue.com/
>
> On Wed, Oct 21, 2009 at 12:56 PM, robin  wrote:
>
> > I have installed Django on my mac with OS 10.6. It installed just fine
> > and I was setting up my first project. I then ran python manage.py
> > syncdb as I am using MySQL, but I got the following errors:
>
> > Traceback (most recent call last):
> >  File "manage.py", line 11, in 
> >    execute_manager(settings)
> >  File "/Library/Python/2.6/site-packages/django/core/management/
> > __init__.py", line 362, in execute_manager
> >    utility.execute()
> >  File "/Library/Python/2.6/site-packages/django/core/management/
> > __init__.py", line 303, in execute
> >    self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File "/Library/Python/2.6/site-packages/django/core/management/
> > base.py", line 195, in run_from_argv
> >    self.execute(*args, **options.__dict__)
> >  File "/Library/Python/2.6/site-packages/django/core/management/
> > base.py", line 221, in execute
> >    self.validate()
> >  File "/Library/Python/2.6/site-packages/django/core/management/
> > base.py", line 249, in validate
> >    num_errors = get_validation_errors(s, app)
> >  File "/Library/Python/2.6/site-packages/django/core/management/
> > validation.py", line 22, in get_validation_errors
> >    from django.db import models, connection
> >  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
> > 41, in 
> >    backend = load_backend(settings.DATABASE_ENGINE)
> >  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
> > 17, in load_backend
> >    return import_module('.base', 'django.db.backends.%s' %
> > backend_name)
> >  File "/Library/Python/2.6/site-packages/django/utils/importlib.py",
> > line 35, in import_module
> >    __import__(name)
> >  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/
> > base.py", line 13, in 
> >    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> > module: No module named MySQLdb
>
> > Obviously the MySQLdb module didn't load or it can't find it. Could
> > someone suggest what I need to do to get it installed?
>
> > Many thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: concurrency and threading question

2009-10-21 Thread Michael Thon


On Oct 21, 2009, at 11:55 AM, Daniel Roseman wrote:

>
> On Oct 21, 9:28 am, Mike Thon  wrote:
>> I'm new to web programming and I have a basic question about the
>> design of my Django application.  my application will do some number
>> crunching on data files uploaded by users.  The data processing will
>> take from minutes to hours for each job.  I don't expect to ever  
>> get a
>> large number of concurrent users but I'd still like to set it up so
>> that I can control the maximum number of data processing jobs that  
>> are
>> run in parallel.  I was planning to write a simple FIFO queue manager
>> (in fact I think there is a python package for this) and then run the
>> data processing in separate threads.  I'm also planning to use the
>> Django data model for storing the data so I would have multiple
>> threads writing to the data store. What is not clear to me is what
>> happens when I have more than one visitor to the site.  Are multiple
>> instances of my Django app launched, one per visitor?   I need to
>> ensure that I only have one queue manager running on the server, not
>> one per visitor.  I would be using Apache and either mySQL or sqlite3
>> as the database, in case that matters.
>>
>> thanks for any help
>> Mike
>
> Take a look at the Celery project[1]. This is a great distributed task
> queue for Django that I think will do exactly what you need - each job
> request is sent to the queue and managed there, so you don't need to
> worry about multiple instances.
>
> [1]:http://ask.github.com/celery/introduction.html
>
Thanks for pointing me towards celery.  Its probably overkill for what  
I want to do right now but I'm going to try to set it up anyway.
Mike


--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson



On 21 Oct, 14:29, bruno desthuilliers 
wrote:
> On 21 oct, 15:05, Peter Bengtsson  wrote:
>
> > Suppose I've got this code:
>
> > # template.html
> > Info: {{ article_instance.count_words }} words
>
> > # models.py
> > class Article(models.Model):
> >    text = models.TextField()
> >    def count_words(self):
> >         raise AttributeError('debugging')
>
>  a NotImplementedError would be more appropriate !-) 
>
I don't know what  means but it's just an example. I could have
written:
class Article(models.Model):
...
def count_words(self):
 return some_complex_calculation(article=self)

> > Then, when I render that page I get:
> > Info:  words
>
> Did you actually tried with this exact code ? If yes, this contradicts
> the FineManual(tm):
> """
> If, during the method lookup, a method raises an exception, the
> exception will be propagated, unless the exception has an attribute
> silent_variable_failure whose value is True. If the exception does
> have a silent_variable_failure attribute, the variable will render as
> an empty string.
> (...)
> Note that django.core.exceptions.ObjectDoesNotExist, which is the base
> class for all Django database API DoesNotExist exceptions, has
> silent_variable_failure = True. So if you're using Django templates
> with Django model objects, any DoesNotExist exception will fail
> silently.
> """http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-c...
>
That's true for other exceptions only. E.g. ValueError or
ZeroDivisionError
I can't set silent_variable_failure=True on TemplateSyntaxError. This
is only applicable when you write your own exception sub classes.

> > When I want is a raised proper error so that I can spot the possible
> > bug in my system. How do I do that?
>
> Not tested, but this might be the answer:
>
> http://docs.djangoproject.com/en/dev/ref/settings/#debug-propagate-ex...
>
I don't know what that does. Perhaps it's related to views only, not
template rendering.
Setting it to True does NOT propagate AttributeErrors in templates
rendering.

> > If what you look up in the template doesn't exist I can accept that
> > Django, currently, prefers to just suppress it
>
> Actually, there's no "suppression", 
> cfhttp://docs.djangoproject.com/en/dev/ref/templates/api/#how-invalid-v...
>
There is.
http://code.djangoproject.com/ticket/11421

I've written a patch that solves it already. Now working on tests for
it.

> HTH
--~--~-~--~~~---~--~~
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: More than one stackedinline in admin

2009-10-21 Thread Daniel Roseman

On Oct 21, 2:42 pm, Caisys  wrote:
> Hi,
> Suppose i have 3 model classes:
> 
> class model1(model.Models):
>     fields .
>
> class child1(models.Model):
>      model1 = models.ForeignKey(model1)
>
> class child2(models.Model):
>      model1 = models.ForeignKey(model1)
>
> --
>
> Is it possible to have child1 and child2 appear on the admin page of
> model1 as StackedInline ??
>
> Thanks

Yes, it is. What happened when you tried?
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



More than one stackedinline in admin

2009-10-21 Thread Caisys

Hi,
Suppose i have 3 model classes:

class model1(model.Models):
fields .

class child1(models.Model):
 model1 = models.ForeignKey(model1)

class child2(models.Model):
 model1 = models.ForeignKey(model1)

--

Is it possible to have child1 and child2 appear on the admin page of
model1 as StackedInline ??

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



Re: "django-pagination" and generic.views.date_based.archive_index()

2009-10-21 Thread tezro

Thanks again. Did it with object_list. Thanks for help :)

On Oct 19, 2:16 pm, Михаил Лукин  wrote:
> Finally, I see only 3 ways:
> 1. copy/paste archive index code and change it's behaviour so it can eat
> num_latest=None
> 2. patch date_based.py in same way as (1)
> 3. use list_detail.object_list
> Since 1-2 are dirty, I would recommend 3rd way. I'll let you know if I could
> suggest something else :)
>
> 2009/10/19 tezro 
>
>
>
>
>
> > Surely I could use the list_detail.object_list, but the use of date
> > based generics though ))
>
> > On Oct 18, 11:45 pm, Михаил Лукин  wrote:
> > > Sorry, didn't look at condition well...:(
>
> > > So, you see the source and you see that there's no way to get all the
> > > records with this view.
> > > Why don't you use list_detail.object_list view? If you need just to order
> > > list by date, you can use ordering on the model level:
> >http://docs.djangoproject.com/en/dev/ref/models/options/#ordering
>
> > > 2009/10/18 tezro 
>
> > > > Would it? If "latest=None" doesn't it mean that there are no entries?
>
> > > > By the way, if I pass None to the condition, it returns False, so
> > > > latest is None.
>
> > > > Or isn't it?
>
> > > > Also the template cannot render it, cause "object of type 'NoneType'
> > > > has no len()".
>
> > > > Anyways, thanks for reply :)
>
> > > > On Oct 18, 11:04 pm, Mihail Lukin  wrote:
> > > > > Look at date_based.py:
>
> > > > >     if date_list and num_latest:
> > > > >         latest = queryset.order_by('-'+date_field)[:num_latest]
> > > > >     else:
> > > > >         latest = None
>
> > > > > So, if you use num_latest=None, you will always get the whole list.
>
> > > > > On Aug 30, 2:47 pm, tezro  wrote:
>
> > > > > > Anyone?
>
> > > > > > On Aug 14, 8:29 am, tezro  wrote:
>
> > > > > > > The question is that
> > > > "django.views.generic.date_based.archive_index()"
> > > > > > > takes an optional argument "num_latest" which is 15 by default.
> > > > > > > Setting it manually to num_latest=10 is way off to
> > correct to
> > > > > > > me. It works. I suppose that it even doesn't retrieve all the
> > tons of
> > > > > > > data from the DB, but what if I have 10 + 1 record :)
>
> > > > > > > What's the right way to use "django-pagination" and the
> > > > "archive_index
> > > > > > > ()" or am I missing something?
>
> > > > > > > Example code.
> > > > > > > ___
>
> > > > > > > def index(request):
> > > > > > >         qs = News.objects.filter(is_published=1)
> > > > > > >         return archive_index(request, qs, 'date',
> > > > num_latest=1)
> > > > > > > ___
>
> > > > > > > Thanks.
>
> > > --
> > > regards,
> > > Mihail
>
> --
> regards,
> Mihail
--~--~-~--~~~---~--~~
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: extends tag in template

2009-10-21 Thread bruno desthuilliers

On 20 oct, 14:55, knight  wrote:
> Thanks for the reply.
> It doesn't matter where I put {{ MEDIA_URL }}.
> I get the error in any case

Please post your actual template code somewhere we can read it.
--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread bruno desthuilliers

On 21 oct, 15:05, Peter Bengtsson  wrote:
> Suppose I've got this code:
>
> # template.html
> Info: {{ article_instance.count_words }} words
>
> # models.py
> class Article(models.Model):
>    text = models.TextField()
>    def count_words(self):
>         raise AttributeError('debugging')

 a NotImplementedError would be more appropriate !-) 

> Then, when I render that page I get:
> Info:  words

Did you actually tried with this exact code ? If yes, this contradicts
the FineManual(tm):
"""
If, during the method lookup, a method raises an exception, the
exception will be propagated, unless the exception has an attribute
silent_variable_failure whose value is True. If the exception does
have a silent_variable_failure attribute, the variable will render as
an empty string.
(...)
Note that django.core.exceptions.ObjectDoesNotExist, which is the base
class for all Django database API DoesNotExist exceptions, has
silent_variable_failure = True. So if you're using Django templates
with Django model objects, any DoesNotExist exception will fail
silently.
"""
http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context


> When I want is a raised proper error so that I can spot the possible
> bug in my system. How do I do that?

Not tested, but this might be the answer:

http://docs.djangoproject.com/en/dev/ref/settings/#debug-propagate-exceptions


> If what you look up in the template doesn't exist I can accept that
> Django, currently, prefers to just suppress it

Actually, there's no "suppression", cf
http://docs.djangoproject.com/en/dev/ref/templates/api/#how-invalid-variables-are-handled

HTH
--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson

Found the ticket for it:
http://code.djangoproject.com/ticket/11421

On 21 Oct, 14:17, Peter Bengtsson  wrote:
> UPDATE!
> If I raise some other error inside the python code (e.g. ValueError)
> it's not suppressed.
> Seems a design error in Django. Will carry on this discussion
> somewhere else.
>
> On 21 Oct, 14:05, Peter Bengtsson  wrote:
>
> > Suppose I've got this code:
>
> > # template.html
> > Info: {{ article_instance.count_words }} words
>
> > # models.py
> > class Article(models.Model):
> >    text = models.TextField()
> >    def count_words(self):
> >         raise AttributeError('debugging')
>
> > Then, when I render that page I get:
> > Info:  words
>
> > When I want is a raised proper error so that I can spot the possible
> > bug in my system. How do I do that?
>
> > If what you look up in the template doesn't exist I can accept that
> > Django, currently, prefers to just suppress it but I'm here talking
> > about things that are found but yields an exception upon executing.
--~--~-~--~~~---~--~~
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: "Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson

UPDATE!
If I raise some other error inside the python code (e.g. ValueError)
it's not suppressed.
Seems a design error in Django. Will carry on this discussion
somewhere else.

On 21 Oct, 14:05, Peter Bengtsson  wrote:
> Suppose I've got this code:
>
> # template.html
> Info: {{ article_instance.count_words }} words
>
> # models.py
> class Article(models.Model):
>    text = models.TextField()
>    def count_words(self):
>         raise AttributeError('debugging')
>
> Then, when I render that page I get:
> Info:  words
>
> When I want is a raised proper error so that I can spot the possible
> bug in my system. How do I do that?
>
> If what you look up in the template doesn't exist I can accept that
> Django, currently, prefers to just suppress it but I'm here talking
> about things that are found but yields an exception upon executing.
--~--~-~--~~~---~--~~
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: efficiently deleting content based on how old it is

2009-10-21 Thread Peter Bengtsson



On 20 Oct, 15:48, Chris Withers  wrote:
> Shawn Milochik wrote:
> > I know this doesn't answer the hard part of your question, but here's  
> > a simple way I delete old stuff from a database via an external script  
> > that's run by cron:
>
> > Item.objects.filter(date_updated__lte = datetime.now() - timedelta
> > (days = 30)).delete()
>
> Yep, that's prettymuch what I ended up writing. Wow, Django's ORM
> expressions are ugly compared to SQLAlchemy ;-)
>
Then just
import sqlalchemy


Don't do URL whacking. Just write a simple management command and wire
that to your crontab.
If the db is a legacy database and things are stored as varchars then
I don't see any point in changing the database so you can use proper
datetimes.
And if it's indexed searching for something like 'April 2009' is going
to be uber fast.

> > old. As for your complicated references, assuming you don't have  
> > cascading deletes happening automatically, you may have to do an  
> > objects.filter(),
>
> Well, cascading deletes do happen automatically with Django, so no
> problem there...
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Batch Processing & Python Consulting
>             -http://www.simplistix.co.uk
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



"Unsupressing" errors when called from templates

2009-10-21 Thread Peter Bengtsson

Suppose I've got this code:

# template.html
Info: {{ article_instance.count_words }} words

# models.py
class Article(models.Model):
   text = models.TextField()
   def count_words(self):
raise AttributeError('debugging')


Then, when I render that page I get:
Info:  words

When I want is a raised proper error so that I can spot the possible
bug in my system. How do I do that?

If what you look up in the template doesn't exist I can accept that
Django, currently, prefers to just suppress it but I'm here talking
about things that are found but yields an exception upon executing.

--~--~-~--~~~---~--~~
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: frameworks based on Django ?

2009-10-21 Thread ssc

that's exactly the one i had come across and couldn't find again,
thank you very much! :-)

On 22 Okt., 00:47, Hector Garcia  wrote:
> http://pinaxproject.com/
>
> Hector Garcia - Web developer, musicianhttp://nomadblue.com/
>
> On Wed, Oct 21, 2009 at 1:35 PM, ssc  wrote:
>
> > The future feature list of the project I am currently working on has a
> > few items that sound to me like they'd been implemented before, but
> > there doesn't seem to be direct support for them in Django itself.
>
> > I seem to remember coming across a few frameworks built on Django and
> > I was hoping to find the required functionality in there, but apart
> > from satchmo (http://www.satchmoproject.com/), I can't remember any
> > names.
>
> > Can someone aid my memory ?
> > Is there a websites like djangosites.com, but not for websites, but
> > for frameworks built on Django ?
--~--~-~--~~~---~--~~
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: Using variables as keywords in QuerySet

2009-10-21 Thread Hector Garcia

Also note the usage of __exact can be discarded in favor of the
'exact' form of keyword, as it is encouraged here:

http://groups.google.com/group/django-users/browse_thread/thread/04b3ca49dc3f9c18/bdfb4849c0e885da?lnk=raot

So,

MyModel.objects.filter(**{a+'__contains': 'foo', b: 'bar';})

Cheers,

Hector Garcia - Web developer, musician
http://nomadblue.com/



On Wed, Oct 21, 2009 at 12:32 PM, Doug Blank  wrote:
>
> On Wed, Oct 21, 2009 at 5:12 AM, Arthur Metasov  wrote:
>>
>> 2009/10/21 valler <180...@gmail.com>:
>>>
>>> Hello. I want to know, if something like that possible:
>>>  MyModel.objects.filter(name__contains='foo',status__exact='bar') =>
>>> It's OK.
>>>
>>> But I want to use dynamic keyword generation, like that:
>>>  a='name'
>>>  b='status'
>>>  MyModel.objects.filter(a__contains='foo',b__exact='bar')
>>>
>>> Is it possible somehow?
>>
>> a='name'
>> b='status'
>> keyword_arguments = {}
>> keyword_arguments[a+'__contains']='foo';
>> keyword_arguments[b+'__exact']='bar';
>> MyModel.objects.filter(**keyword_arguments)
>>
>
> Or, more concisely as:
>
> MyModel.objects.filter(**{a+'__contains':'foo', b+'__exact':'bar';})
>
> -Doug
>
>> >
>>
>
> >
>

--~--~-~--~~~---~--~~
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: Using variables as keywords in QuerySet

2009-10-21 Thread valler

Thank you, it worked perfectly :)
--~--~-~--~~~---~--~~
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: frameworks based on Django ?

2009-10-21 Thread Hector Garcia

http://pinaxproject.com/

Hector Garcia - Web developer, musician
http://nomadblue.com/



On Wed, Oct 21, 2009 at 1:35 PM, ssc  wrote:
>
> The future feature list of the project I am currently working on has a
> few items that sound to me like they'd been implemented before, but
> there doesn't seem to be direct support for them in Django itself.
>
> I seem to remember coming across a few frameworks built on Django and
> I was hoping to find the required functionality in there, but apart
> from satchmo (http://www.satchmoproject.com/), I can't remember any
> names.
>
> Can someone aid my memory ?
> Is there a websites like djangosites.com, but not for websites, but
> for frameworks built on Django ?
>
> >
>

--~--~-~--~~~---~--~~
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: installing Django on Mac OS 10.6

2009-10-21 Thread Hector Garcia

On the internets?

http://docs.djangoproject.com/en/dev/ref/databases/#mysqldb

Hector Garcia - Web developer, musician
http://nomadblue.com/



On Wed, Oct 21, 2009 at 12:56 PM, robin  wrote:
>
> I have installed Django on my mac with OS 10.6. It installed just fine
> and I was setting up my first project. I then ran python manage.py
> syncdb as I am using MySQL, but I got the following errors:
>
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>    execute_manager(settings)
>  File "/Library/Python/2.6/site-packages/django/core/management/
> __init__.py", line 362, in execute_manager
>    utility.execute()
>  File "/Library/Python/2.6/site-packages/django/core/management/
> __init__.py", line 303, in execute
>    self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/Library/Python/2.6/site-packages/django/core/management/
> base.py", line 195, in run_from_argv
>    self.execute(*args, **options.__dict__)
>  File "/Library/Python/2.6/site-packages/django/core/management/
> base.py", line 221, in execute
>    self.validate()
>  File "/Library/Python/2.6/site-packages/django/core/management/
> base.py", line 249, in validate
>    num_errors = get_validation_errors(s, app)
>  File "/Library/Python/2.6/site-packages/django/core/management/
> validation.py", line 22, in get_validation_errors
>    from django.db import models, connection
>  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
> 41, in 
>    backend = load_backend(settings.DATABASE_ENGINE)
>  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
> 17, in load_backend
>    return import_module('.base', 'django.db.backends.%s' %
> backend_name)
>  File "/Library/Python/2.6/site-packages/django/utils/importlib.py",
> line 35, in import_module
>    __import__(name)
>  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/
> base.py", line 13, in 
>    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No module named MySQLdb
>
> Obviously the MySQLdb module didn't load or it can't find it. Could
> someone suggest what I need to do to get it installed?
>
> Many thanks
>
>
> >
>

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



frameworks based on Django ?

2009-10-21 Thread ssc

The future feature list of the project I am currently working on has a
few items that sound to me like they'd been implemented before, but
there doesn't seem to be direct support for them in Django itself.

I seem to remember coming across a few frameworks built on Django and
I was hoping to find the required functionality in there, but apart
from satchmo (http://www.satchmoproject.com/), I can't remember any
names.

Can someone aid my memory ?
Is there a websites like djangosites.com, but not for websites, but
for frameworks built on Django ?

--~--~-~--~~~---~--~~
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: installing Django on Mac OS 10.6

2009-10-21 Thread Daniel Roseman

On Oct 21, 11:56 am, robin  wrote:
> I have installed Django on my mac with OS 10.6. It installed just fine
> and I was setting up my first project. I then ran python manage.py
> syncdb as I am using MySQL, but I got the following errors:
>
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
>     execute_manager(settings)
>   File "/Library/Python/2.6/site-packages/django/core/management/
> __init__.py", line 362, in execute_manager
>     utility.execute()
>   File "/Library/Python/2.6/site-packages/django/core/management/
> __init__.py", line 303, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/Library/Python/2.6/site-packages/django/core/management/
> base.py", line 195, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/Library/Python/2.6/site-packages/django/core/management/
> base.py", line 221, in execute
>     self.validate()
>   File "/Library/Python/2.6/site-packages/django/core/management/
> base.py", line 249, in validate
>     num_errors = get_validation_errors(s, app)
>   File "/Library/Python/2.6/site-packages/django/core/management/
> validation.py", line 22, in get_validation_errors
>     from django.db import models, connection
>   File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
> 41, in 
>     backend = load_backend(settings.DATABASE_ENGINE)
>   File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
> 17, in load_backend
>     return import_module('.base', 'django.db.backends.%s' %
> backend_name)
>   File "/Library/Python/2.6/site-packages/django/utils/importlib.py",
> line 35, in import_module
>     __import__(name)
>   File "/Library/Python/2.6/site-packages/django/db/backends/mysql/
> base.py", line 13, in 
>     raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No module named MySQLdb
>
> Obviously the MySQLdb module didn't load or it can't find it. Could
> someone suggest what I need to do to get it installed?
>
> Many thanks

Did you install MySQLdb? It's not part of Django, and doesn't come
with OSX10.6, but you'll need it if you want to use MySQL. The source
is here:
http://sourceforge.net/projects/mysql-python/
but you may find some gotchas when installing it on OSX, there are
plenty of guides a Google away.
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



installing Django on Mac OS 10.6

2009-10-21 Thread robin

I have installed Django on my mac with OS 10.6. It installed just fine
and I was setting up my first project. I then ran python manage.py
syncdb as I am using MySQL, but I got the following errors:

Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/Library/Python/2.6/site-packages/django/core/management/
__init__.py", line 362, in execute_manager
utility.execute()
  File "/Library/Python/2.6/site-packages/django/core/management/
__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/
base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Library/Python/2.6/site-packages/django/core/management/
base.py", line 221, in execute
self.validate()
  File "/Library/Python/2.6/site-packages/django/core/management/
base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.6/site-packages/django/core/management/
validation.py", line 22, in get_validation_errors
from django.db import models, connection
  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
41, in 
backend = load_backend(settings.DATABASE_ENGINE)
  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line
17, in load_backend
return import_module('.base', 'django.db.backends.%s' %
backend_name)
  File "/Library/Python/2.6/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/
base.py", line 13, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: No module named MySQLdb

Obviously the MySQLdb module didn't load or it can't find it. Could
someone suggest what I need to do to get it installed?

Many thanks


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



Re: Using variables as keywords in QuerySet

2009-10-21 Thread Doug Blank

On Wed, Oct 21, 2009 at 5:12 AM, Arthur Metasov  wrote:
>
> 2009/10/21 valler <180...@gmail.com>:
>>
>> Hello. I want to know, if something like that possible:
>>  MyModel.objects.filter(name__contains='foo',status__exact='bar') =>
>> It's OK.
>>
>> But I want to use dynamic keyword generation, like that:
>>  a='name'
>>  b='status'
>>  MyModel.objects.filter(a__contains='foo',b__exact='bar')
>>
>> Is it possible somehow?
>
> a='name'
> b='status'
> keyword_arguments = {}
> keyword_arguments[a+'__contains']='foo';
> keyword_arguments[b+'__exact']='bar';
> MyModel.objects.filter(**keyword_arguments)
>

Or, more concisely as:

MyModel.objects.filter(**{a+'__contains':'foo', b+'__exact':'bar';})

-Doug

> >
>

--~--~-~--~~~---~--~~
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: efficiently deleting content based on how old it is

2009-10-21 Thread David De La Harpe Golden

Jaime Buelta wrote:
> When I had to do this kind of tasks, I've added a new management command and
> run it from the cron (or manually any time you need it, with params, etc).
> You can run it calling
> 
> python manager.py miCommand parameters
> 

"celery" may seem overkill initially, but works very well for periodic
tasks among other things. Once you have it working, it's straightforward
to use for all manner of time-consuming stuff you might want to push
into the background to keep your http responses timely.

http://ask.github.com/celery/introduction.html#periodic-tasks

(If you want to run a task manually, you can still wrap it in a
management command, or just call it from within ./manage.py shell)

At time of writing AFAIK if you want to use it with python 2.5, you have
to beware of:
http://github.com/ask/celery/issues/closed/#issue/24
- but otherwise it's simple enough to setup (there's a sample
initscript in the source package for linux systems)


--~--~-~--~~~---~--~~
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: concurrency and threading question

2009-10-21 Thread Daniel Roseman

On Oct 21, 9:28 am, Mike Thon  wrote:
> I'm new to web programming and I have a basic question about the
> design of my Django application.  my application will do some number
> crunching on data files uploaded by users.  The data processing will
> take from minutes to hours for each job.  I don't expect to ever get a
> large number of concurrent users but I'd still like to set it up so
> that I can control the maximum number of data processing jobs that are
> run in parallel.  I was planning to write a simple FIFO queue manager
> (in fact I think there is a python package for this) and then run the
> data processing in separate threads.  I'm also planning to use the
> Django data model for storing the data so I would have multiple
> threads writing to the data store. What is not clear to me is what
> happens when I have more than one visitor to the site.  Are multiple
> instances of my Django app launched, one per visitor?   I need to
> ensure that I only have one queue manager running on the server, not
> one per visitor.  I would be using Apache and either mySQL or sqlite3
> as the database, in case that matters.
>
> thanks for any help
> Mike

Take a look at the Celery project[1]. This is a great distributed task
queue for Django that I think will do exactly what you need - each job
request is sent to the queue and managed there, so you don't need to
worry about multiple instances.

[1]:http://ask.github.com/celery/introduction.html

--
DR.
--~--~-~--~~~---~--~~
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: concurrency and threading question

2009-10-21 Thread Jani Tiainen

Use separate background process (daemon) to handle queue + crunching (or 
launching crunching). So your web app just posts jobs to background 
process and then returns control back to user.

Otherwise your idea is quite correct.

Mike Thon kirjoitti:
> I'm new to web programming and I have a basic question about the
> design of my Django application.  my application will do some number
> crunching on data files uploaded by users.  The data processing will
> take from minutes to hours for each job.  I don't expect to ever get a
> large number of concurrent users but I'd still like to set it up so
> that I can control the maximum number of data processing jobs that are
> run in parallel.  I was planning to write a simple FIFO queue manager
> (in fact I think there is a python package for this) and then run the
> data processing in separate threads.  I'm also planning to use the
> Django data model for storing the data so I would have multiple
> threads writing to the data store. What is not clear to me is what
> happens when I have more than one visitor to the site.  Are multiple
> instances of my Django app launched, one per visitor?   I need to
> ensure that I only have one queue manager running on the server, not
> one per visitor.  I would be using Apache and either mySQL or sqlite3
> as the database, in case that matters.


-- 
Jani Tiainen

--~--~-~--~~~---~--~~
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: Using variables as keywords in QuerySet

2009-10-21 Thread Arthur Metasov

2009/10/21 valler <180...@gmail.com>:
>
> Hello. I want to know, if something like that possible:
>  MyModel.objects.filter(name__contains='foo',status__exact='bar') =>
> It's OK.
>
> But I want to use dynamic keyword generation, like that:
>  a='name'
>  b='status'
>  MyModel.objects.filter(a__contains='foo',b__exact='bar')
>
> Is it possible somehow?

a='name'
b='status'
keyword_arguments = {}
keyword_arguments[a+'__contains']='foo';
keyword_arguments[b+'__exact']='bar';
MyModel.objects.filter(**keyword_arguments)

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



Using variables as keywords in QuerySet

2009-10-21 Thread valler

Hello. I want to know, if something like that possible:
  MyModel.objects.filter(name__contains='foo',status__exact='bar') =>
It's OK.

But I want to use dynamic keyword generation, like that:
  a='name'
  b='status'
  MyModel.objects.filter(a__contains='foo',b__exact='bar')

Is it possible somehow?
--~--~-~--~~~---~--~~
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: Adding a custom toolbar button

2009-10-21 Thread Joost Cassee

On 20 okt, 00:54, eka  wrote:

> Is there any way to achieve this with django-tinymce?
>
> http://tinymce.moxiecode.com/examples/example_20.php
>
> I tried configuring it, but seems to not like the way I pass the
> function.

You basically need to generate this piece of configuration:

setup : function(ed) {
  // Add a custom button
  ed.addButton('mybutton', {
title : 'My button',
image : 'img/example.gif',
onclick : function() {
  // Add you own code to execute something on click
  ed.focus();
  ed.selection.setContent('Hello world!');
}
  });
}

What did you try?

Regards,

Joost
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



concurrency and threading question

2009-10-21 Thread Mike Thon

I'm new to web programming and I have a basic question about the
design of my Django application.  my application will do some number
crunching on data files uploaded by users.  The data processing will
take from minutes to hours for each job.  I don't expect to ever get a
large number of concurrent users but I'd still like to set it up so
that I can control the maximum number of data processing jobs that are
run in parallel.  I was planning to write a simple FIFO queue manager
(in fact I think there is a python package for this) and then run the
data processing in separate threads.  I'm also planning to use the
Django data model for storing the data so I would have multiple
threads writing to the data store. What is not clear to me is what
happens when I have more than one visitor to the site.  Are multiple
instances of my Django app launched, one per visitor?   I need to
ensure that I only have one queue manager running on the server, not
one per visitor.  I would be using Apache and either mySQL or sqlite3
as the database, in case that matters.

thanks for any help
Mike

--~--~-~--~~~---~--~~
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: Unittest, fixture and permission

2009-10-21 Thread Hector Garcia

http://www.djangoproject.com/documentation/models/fixtures/

# Load fixture 1. Single JSON file, with two objects.
>>> management.call_command('loaddata', 'fixture1.json', verbosity=0)
>>> Article.objects.all()
[, , ]

# Load fixture 2. JSON file imported by default. Overwrites some
existing objects
>>> management.call_command('loaddata', 'fixture2.json', verbosity=0)
>>> Article.objects.all()
[, , , ]

# Load fixture 3, XML format.
>>> management.call_command('loaddata', 'fixture3.xml', verbosity=0)
>>> Article.objects.all()
[, , ,
, ]

Cheers,

Hector Garcia - Web developer, musician
http://nomadblue.com/



On Wed, Oct 21, 2009 at 2:07 AM, Brice  wrote:
>
> Hello everybody,
>  I'm facing a delicate problem. I want to make ensure the security of
> my app and I created a unitest to do so. To make it easy, I was
> thinking about fixture, but they don't support model permission
> evolution and create conflict over time. So I add a function linked to
> the syncdb signal that take care of the permission assignement to
> different pre-set users for my tests. The only issue is that I need
> first to load my Users from a fixture to get it work. Is there any
> function to load data manually from a fixture directly ?
>
>
> >
>

--~--~-~--~~~---~--~~
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: Apache2+mod_wsgi autoreload?

2009-10-21 Thread Михаил Лукин
Thanks a lot, it works perfect :)

2009/10/21 Graham Dumpleton 

>
>
>
> On Oct 21, 5:07 pm, Graham Dumpleton 
> wrote:
> > On Oct 21, 4:00 pm, Михаил Лукин  wrote:
> >
> > > ./manage runserver is OK for debugging purposes... unless you use
> > > server-specific features, in my case - NTLM authentication. When
> deploying
> > > Django project with Apache2+mod_wsgi, I need to `rcapache2 reload` to
> apply
> > > changes in Python modules (while `manage runserver` does this
> automaticaly).
> > > This is not very comfortable.  Is there a way to tell mod_wsgi to keep
> track
> > > changes in Python modules of my project?
> >
> > Read:
> >
> >  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
>
> And:
>
>
> http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html
>
> http://blog.dscpl.com.au/2009/02/source-code-reloading-with-modwsgi-on.html
>
> Graham
> >
>


-- 
regards,
Mihail

--~--~-~--~~~---~--~~
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: ManyToMany lookups

2009-10-21 Thread koenb

On 20 okt, 21:19, r_f_d  wrote:
> Why not do this:
>
> for p in products.objects.all():
>     for c in p.categories.all():
>          print p,' - ', c
>
> -richard
>
> On Oct 20, 7:57 am, Михаил Лукин  wrote:
>

This will obviously leave you with a lot of queries. Take a look at eg
django-selectreverse [1] for some help reducing your querycount for
this type of nested lists.

Koen

[1]: http://code.google.com/p/django-selectreverse/
--~--~-~--~~~---~--~~
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: Apache2+mod_wsgi autoreload?

2009-10-21 Thread Graham Dumpleton



On Oct 21, 5:07 pm, Graham Dumpleton 
wrote:
> On Oct 21, 4:00 pm, Михаил Лукин  wrote:
>
> > ./manage runserver is OK for debugging purposes... unless you use
> > server-specific features, in my case - NTLM authentication. When deploying
> > Django project with Apache2+mod_wsgi, I need to `rcapache2 reload` to apply
> > changes in Python modules (while `manage runserver` does this automaticaly).
> > This is not very comfortable.  Is there a way to tell mod_wsgi to keep track
> > changes in Python modules of my project?
>
> Read:
>
>  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

And:

  http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html
  http://blog.dscpl.com.au/2009/02/source-code-reloading-with-modwsgi-on.html

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: Apache2+mod_wsgi autoreload?

2009-10-21 Thread Graham Dumpleton



On Oct 21, 4:00 pm, Михаил Лукин  wrote:
> ./manage runserver is OK for debugging purposes... unless you use
> server-specific features, in my case - NTLM authentication. When deploying
> Django project with Apache2+mod_wsgi, I need to `rcapache2 reload` to apply
> changes in Python modules (while `manage runserver` does this automaticaly).
> This is not very comfortable.  Is there a way to tell mod_wsgi to keep track
> changes in Python modules of my project?

Read:

  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

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