Re: manager.raw returning Capitalized field names

2010-05-20 Thread Russell Keith-Magee
class CheckIn(models.Model):
sample_id = models.AutoField(db_column='SampleID', primary_key=True)
date_arrived = models.DateField(db_column='DateArrived')
company_name = models.CharField(max_length=100, db_column='Company')
< plus any extra fields >

class Meta:
db_table = 'Checkin'

class CheckinTest(CheckIn):
checkin_ptr = models.OneToOneField(CheckIn, db_column='SampleID',
primary_key=True)
< plus any extra fields >

class Meta:
db_table = 'CheckinTests'


Then, your ORM query will be:

CheckinTest.objects.filter(date_arrived=date.today(), company_name='foo')

Then, in templates, you can say {{ obj.date_arrived }} or {{
obj.company_name }}, where obj is an instance of CheckinTest obtained
by iterating over the query results.

Yours,
Russ Magee %-)

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



Re: Module loading error in django trunk.

2010-05-20 Thread ben


On May 18, 9:35 pm, Russell Keith-Magee 
wrote:
> On Tue, May 18, 2010 at 6:12 PM, ben  wrote:
> > Hi All,
>
> > After a recent svn update to my copy of Django/trunk I’ve been getting
> > a persistent error relating to module loading (see below). I am able
> > to create the same error from many but not all views/requests.
>
> > Interesting, when I run my code against a slightly older version of
> > Django trunk (at Rev. 13079) I don’t get these errors.
> > Is this a bug, or have I missed some backwards incompatible change?
>
> It's certainly possible you've found a bug. The module that is raising
> errors was subject to a number of changes in the last days of 1.2
> preparation, and while we've added lots of tests to make sure module
> loading works as expected, it's possible we've missed some edge cases.
>
> There is one thing that is a little suspicious. Your stack track
> contains the following at the end:
>
> File "/django/utils/module_loading.py", line 12, in
> module_has_submodule
>    # zipimport.zipimporter.find_moduleis documented to take
>
> This indicates that there is some confusion over exactly what code is
> running. Line 12 of module_loading.py in 1.2-final is a call tofind_module, 
> not a comment about zipimport. The first step in
> debugging this will be to purge all your .pyc files in case some
> timestamp problems are causing some stale code to execute.
>
> If you still see the problem, the next thing we need to know is
> exactly what is being imported, from where -- and most importantly --
> by what. Assuming the line numbers in the stack trace are correct, the
> block of code that you are tripping over is a walk through
> sys.meta_path, which suggests that you are using a custom module
> loader of some kind. We're going to need lots of details on exactly
> what your stack is doing - how you are storing modules, how they are
> being loaded, any special cases you may have, etc.
>
> The stack trace you've given us looks like it's been cut from a
> standard Django 500 page; if this is the case, it would be helpful to
> have all the local stack information from the last stack frame -- all
> the local variables, as well as anything you can furnish about
> sys.path and sys.meta_path. Ideally, this will lead to a simple test
> case where you can give us the exact conditions under which the
> problem arises.
>
> Yours,
> Russ Magee %-)
>

I have performed a system wide root level expunge of all .pyc's
and a svn up to 1.2.1 pre-alpha SVN-13294, but this sporadic error
still persists.

The same view will not always trigger the error, sometimes the view
function will run successfully, others not.

If i walk though the procedure with pdb (and if i understand what it
is telling me) it seems to indicate an issue with loading taglib and
perhaps one of my apps called 'featured'. but why would this app now
fail to be loaded properly, when previous to django Rev13079 it loaded
fine?

Below is a more full (read lengthy) stack trace. and some pdb output.

If there is more information that i can provide to assist please let
me know, and how to gather it.

Thanks in advance,
Ben


-
Example 500 tracback & request info 

TypeError at /radio/

find_module() takes exactly 3 arguments (2 given)

Request Method: GET
Request URL:http://0.0.0.0:8000/radio/
Django Version: 1.2.1 pre-alpha SVN-13294
Exception Type: TypeError
Exception Value:

find_module() takes exactly 3 arguments (2 given)

Exception Location: /workspace/mos-trunk-pre/django/utils/
module_loading.py in module_has_submodule, line 12
Python Executable:  /sw/bin/python2.6
Python Version: 2.6.4
Python Path:['/workspace/mos-trunk-pre', '/workspace/mos-trunk-pre/
contrib', '/workspace/mos-trunk-pre/new_mos', '/sw/lib/python2.6/site-
packages/pip-0.6-py2.6.egg', '/sw/lib/python2.6/site-packages/
Sphinx-0.6.3-py2.6.egg', '/sw/lib/python2.6/site-packages/docutils-0.6-
py2.6.egg', '/sw/lib/python2.6/site-packages/Jinja2-2.2.1-py2.6.egg',
'/sw/lib/python2.6/site-packages/Pygments-1.1.1-py2.6.egg', '/sw/lib/
python2.6/site-packages/Satchmo-1.0_pre-py2.6.egg', '/sw/lib/python2.6/
site-packages/paramiko-1.7.6-py2.6.egg', '/Users/ben/src/pyamf', '/sw/
lib/python26.zip', '/sw/lib/python2.6', '/sw/lib/python2.6/plat-
darwin', '/sw/lib/python2.6/plat-mac', '/sw/lib/python2.6/plat-mac/lib-
scriptpackages', '/sw/lib/python2.6/lib-tk', '/sw/lib/python2.6/lib-
old', '/sw/lib/python2.6/lib-dynload', '/sw/lib/python2.6/site-
packages', '/sw/lib/python2.6/site-packages/PIL', '/workspace/mos-
trunk-pre/contrib/satchmo/apps', '/workspace/mos-trunk-pre/contrib/
satchmo/apps']
Server time:Thu, 20 May 2010 14:33:49 +1000
Environment:

Request Method: GET
Request URL: http://0.0.0.0:8000/radio/
Django Version: 1.2.1 pre-alpha SVN-13294
Python Version: 2.6.4
Installed Applications:
['django.contrib.sites',
 'django.contrib.conte

Django list_filter

2010-05-20 Thread Danfi
Hi,
In my models, I use "parent = models.ForeignKey('self', blank = True,
null = True) " create a Folder tree
like :
A
-a1
-a2
--a21
--a211
--a22
B
-b1

and I use the "parent" as list_filter ,but I get a problem , when I
click 'a1' ,it only show the information in a1,
but I want it also show its childrens' information . For example ,
when I click a21,It can show the informations in
a21 and a211.Do anyone have any idea?
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Module loading error in django trunk.

2010-05-20 Thread Russell Keith-Magee
On Thu, May 20, 2010 at 3:17 PM, ben  wrote:
>
>
> On May 18, 9:35 pm, Russell Keith-Magee 
> wrote:
>> On Tue, May 18, 2010 at 6:12 PM, ben  wrote:
>> > Hi All,
>>
>> > After a recent svn update to my copy of Django/trunk I’ve been getting
>> > a persistent error relating to module loading (see below). I am able
>> > to create the same error from many but not all views/requests.
>>
>> > Interesting, when I run my code against a slightly older version of
>> > Django trunk (at Rev. 13079) I don’t get these errors.
>> > Is this a bug, or have I missed some backwards incompatible change?
>>
>> It's certainly possible you've found a bug. The module that is raising
>> errors was subject to a number of changes in the last days of 1.2
>> preparation, and while we've added lots of tests to make sure module
>> loading works as expected, it's possible we've missed some edge cases.
>>
>> There is one thing that is a little suspicious. Your stack track
>> contains the following at the end:
>>
>> File "/django/utils/module_loading.py", line 12, in
>> module_has_submodule
>>    # zipimport.zipimporter.find_moduleis documented to take
>>
>> This indicates that there is some confusion over exactly what code is
>> running. Line 12 of module_loading.py in 1.2-final is a call tofind_module, 
>> not a comment about zipimport. The first step in
>> debugging this will be to purge all your .pyc files in case some
>> timestamp problems are causing some stale code to execute.
>>
>> If you still see the problem, the next thing we need to know is
>> exactly what is being imported, from where -- and most importantly --
>> by what. Assuming the line numbers in the stack trace are correct, the
>> block of code that you are tripping over is a walk through
>> sys.meta_path, which suggests that you are using a custom module
>> loader of some kind. We're going to need lots of details on exactly
>> what your stack is doing - how you are storing modules, how they are
>> being loaded, any special cases you may have, etc.
>>
>> The stack trace you've given us looks like it's been cut from a
>> standard Django 500 page; if this is the case, it would be helpful to
>> have all the local stack information from the last stack frame -- all
>> the local variables, as well as anything you can furnish about
>> sys.path and sys.meta_path. Ideally, this will lead to a simple test
>> case where you can give us the exact conditions under which the
>> problem arises.
>>
>> Yours,
>> Russ Magee %-)
>>
>
> I have performed a system wide root level expunge of all .pyc's
> and a svn up to 1.2.1 pre-alpha SVN-13294, but this sporadic error
> still persists.
>
> The same view will not always trigger the error, sometimes the view
> function will run successfully, others not.
>
> If i walk though the procedure with pdb (and if i understand what it
> is telling me) it seems to indicate an issue with loading taglib and
> perhaps one of my apps called 'featured'. but why would this app now
> fail to be loaded properly, when previous to django Rev13079 it loaded
> fine?
>
> Below is a more full (read lengthy) stack trace. and some pdb output.
>
> If there is more information that i can provide to assist please let
> me know, and how to gather it.

Ok - that's very helpful for us, but the news isn't so good for you :-)

It looks like the offending party is PyAMF. The issue is the
interpretation and implementation of PEP 302. PEP 302 specifies that a
module loader has a signature of:

finder.find_module(fullname, path=None)

PyAMF 0.5.1, however, implements a module loader as:

pyamf.utils.imports.ModuleLoader.find_module(self, name, path):

The path argument *should* be optional, but PyAMF's implementation
doesn't implement it like that. To make matters worse, the
documentation for PyAMF says that it ignores the path argument anyway
:-)

However, PEP302 also says:

   "If the finder is installed on sys.meta_path, it will
receive a second argument, which is None for a top-level module, or
package.__path__ for submodules or subpackages[7]."

So, under that definition, Django should be specifying a None value for path.

So, this is potentially a bug on both sides. I'll try and chase down
exactly who is in the wrong here from Someone Who Knows (probably
Brett Cannon, who assisted in the implementation of Django's loader).
The fix is trivial on both sides of the fence, but it would be good to
know who is in the wrong here (I suspect the answer may turn out to be
both Django and PyAMF have bugs).

I can't explain why this bug is experienced inconsistently - I can
only guess that as a result of the exact usage in your code, the PyAMF
loader is only getting installed in some specific set of circumstances
(e.g., as a result of hitting a particular view that does an import
that in turn causes the loader to be installed).

This particular bug didn't get triggered previously because Django's
module loading checks were incomplete - we didn't fully cover all the
possibilities

Re: trying not to do any operations in template, but not sure i can avoid it.

2010-05-20 Thread shofty
thanks for the swift response.

On May 19, 10:05 pm, Bill Freeman  wrote:
> You could put a method on your basket object which calculates the shipping.
> Then if the basket object is included in the context, you can trivially call 
> it.
>
That seems simple enough for me to do.


> Or perhaps better, fix up you all_purchases iterable to append it.
> Something like:
>
>    def add_shipping(purchaces_iterable):
>       for i, p in enumerate(purchases_iterable):
>          yield p
>       yield Purchase(name="Shipping",
> amount=Decimal(PER_ITEM_SHIPPING)*(i+1)...)
>
This one seems a bit trickier. where would that code live? is that in
the views module for the basket class?

one thing i thought about last night was that i should probably be
doping this a better way. isnt there a way inside django of creating
an object and including it and everything within it(methods etc) with
a proper simple statement? a so i could do something like

{% basket %}

and the basket html would be written out. i could also define {%
basket_total %} and each page would have a summary of the basket?

is this what decorators are for? if not someone tell me the term for
the funtion i'm describing and i'll go away and do the research. im
not asking anyone to write the code for me.

cheers so far

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



Re: Module loading error in django trunk.

2010-05-20 Thread njoyce
> Now that we have a fully PEP 302 compliant loading structure, it is exposing 
> bugs in the PyAMF loader implementation.

Indeed it is - we have already come across this issue and fixed it -
check http://dev.pyamf.org/ticket/770 for details.

Cheers,

Nick

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



Re: django filters

2010-05-20 Thread Peter Bengtsson
The way you set up the ordering (e.g. 'change_date') just change that
to '-change_date'. A minus in front of the ordering keyword reverses
the sort order.

On 20 May, 06:32, rahul jain  wrote:
> Hi,
>
> In my model, I have set up one filter which helps in filtering out the
> results on admin Panel. The way its works now
> that its displays the old objects first and then the most recent ones. Is it
> possible to make it other way around ?.
>
> Let me know.
>
> --RJ
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Django list_filter

2010-05-20 Thread Peter Bengtsson
There are much more efficient tree implementation made available for
Django.
https://tabo.pe/projects/django-treebeard/
A much better place to start.

On 20 May, 07:06, Danfi  wrote:
> Hi,
> In my models, I use "parent = models.ForeignKey('self', blank = True,
> null = True) " create a Folder tree
> like :
> A
> -a1
> -a2
> --a21
> --a211
> --a22
> B
> -b1
>
> and I use the "parent" as list_filter ,but I get a problem , when I
> click 'a1' ,it only show the information in a1,
> but I want it also show its childrens' information . For example ,
> when I click a21,It can show the informations in
> a21 and a211.Do anyone have any idea?
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Hyperlog

2010-05-20 Thread Marcob
Have you ever wanted to check the contents of a session or to search
the django_admin_log table?

Probably you will find this "free-and-little-more-than-a-snippet-
project" useful:
http://code.google.com/p/hyperlog/

Enjoy :-)

Ciao.
Marco.

--
http://thinkcode.tv/catalog/amazing-python - Capire in 15 minuti cosa
può fare Python
http://stacktrace.it - Aperiodico di resistenza informatica
http://beri.it - Blog di una testina di vitello

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



Reorder fields in tabular admin inline

2010-05-20 Thread Dirk Eschler
Hello,

is there an easy way to reorder field display in a tabular admin inline, like 
fieldsets for common admin forms?

Consider the following models, with Bar being edited inline:

class Foo(models.Model):
field1 = models.CharField(max_length=255)
field2 = models.CharField(max_length=255)
class Meta:
abstract = True

class Bar(Foo):
field3 = models.CharField(max_length=255)

This will result in an display order of [field1, field2, field3], while i want 
it be ordered like [field3, field1, field2] or [field3, field2, field1]. Since 
Foo is abstract, i can't just swap the definition order to achieve this.

Best Regards,
Dirk Eschler

-- 
Dirk Eschler 

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



Re: Uploaded File Security

2010-05-20 Thread Tomasz Zieliński


On 20 Maj, 04:19, Mike Dewhirst  wrote:
>
> If it has to be secure rather than just wishful thinking the webserver
> must demand credentials. If you are using Apache, that means .htaccess
> files which point to a list of credentials for each group.
>

What is the difference between long, random filename and login
+password?


--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to enable Static Generator

2010-05-20 Thread vikk
Hi all,

I got some of the documents to enable static generator but still for
away from the result.
Please show me the way to implement it for my site so that I can
enhance the performance.
I am using apache + mod_wsgi.
I need to get detail about the apache configuration. How can I
configure it for the specific urls ?

Thanks in advance for your valuable reply.

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



Re: Uploaded File Security

2010-05-20 Thread Torsten Bronger
Hallöchen!

Tomasz Zieliński writes:

> On 20 Maj, 04:19, Mike Dewhirst  wrote:
>
>> If it has to be secure rather than just wishful thinking the
>> webserver must demand credentials. If you are using Apache, that
>> means .htaccess files which point to a list of credentials for
>> each group.
>
> What is the difference between long, random filename

Avantages: You can send the deep link to a fellow who can then view
this particular item.  The media server (e.g. Lighty) can serve it.

> and login +password?

Advantages: Nicer URLs, which is not only aesthetical because the
URL is a lot easier to generate.  More flexibility (e.g. generation
on-the-fly if not yet existent).  Less danger that it's stored in a
(shared) browser, e.g. a lab computer.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



Re: New with Django

2010-05-20 Thread Mehul
thank you so much

On Apr 23, 8:19 pm, Nick Serra  wrote:
> Whenever I use django on my windows box, i use XAMPP, which is a all
> in one installer that gets apache and mysql.
>
> So I:
> - install XAMPP
> - install python
> - svn checkout django in the site-packages folder
> - install mysql bindings for python
> - install python image library
>
> and I think you need to add your python path to the windows paths
>
> hope some of that helps.
>
> On Apr 23, 9:09 am, Anand Agarwal  wrote:
>
>
>
>
>
> > You can write a file xyz.wsgi with following content in your application
>
> > import os
> > import sys
>
> > sys.path.append("D:\\workspace\\python\\sspl\\src")
> > sys.path.append("D:\\workspace\\python\\sspl\\src\\ssplsite")
>
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > and in https.conf you need to add following entry
>
> > LoadModule python_module modules/mod_python.so
>
> > and
>
> > WSGIScriptAlias 
> > >
> > Order deny,allow
> > Allow from all
>
> > 
>
> > I think this should work.
>
> > Regards
> > Anandwww.bootstraptoday.com
>
> > On Fri, Apr 23, 2010 at 4:38 PM, Mehul  wrote:
> > > Hi,
> > > Last two days i am trying to set up django on my window machine.
> > > I had installed
> > > 1>python25.msi on d drive(d:/Python25).
> > > 2>django at location :D:\Python25\Lib\site-packages\django.
> > >  It showing a successful message on IP :http://127.0.0.1:8000/
> > > 3>Apache 2.2
> > > 4>mod_python-3.3.1.win32-py2.5-Apache2.2.exe
>
> > > Up to here its working fine.
>
> > > But i am not able to configure Apache for python
>
> > > I added following lines in httpd.conf file
> > > LoadModule python_module modules/mod_python.so
>
> > > 
> > >        SetHandler python-program
> > >        PythonHandler django.core.handlers.modpython
> > >        SetEnv DJANGO_SETTINGS_MODULE testproject.settings
> > >        PythonOption django.root /d:/projects/django/testproject
> > >        PythonDebug On
> > >        PythonPath "['/d:/projects/django/testproject', '/django'] +
> > > sys.path"
> > > 
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com > >  groups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



djangojs translations not available

2010-05-20 Thread filias
Hi,

I have a djangojs.po file and am compiling the messages with
compilemessages command.
I don't get any error but I can't see my translations in the js
catalog. I can only see the admin js translations.

How can I debug this problem?

Thanks in advance.

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



Re: Django Sphinx Foreign key search

2010-05-20 Thread David De La Harpe Golden

On 13/04/10 09:04, urukay wrote:

Hi,

I'm trying to create full text search on model, everything goes fine
when
searching TextFields but I have a problem with ForeignKey field.

How can i do that? Can anyone point me to the right direction?



Do you mean you want the results for Model2 searches to include Model2 
instances when when a search string matches text in any of the Model1 
instances related to the Model2 instance?


If you're don't actually need sphinx in particular but rather you are 
looking for the ability to full-text search django models, then 
http://haystacksearch.org/ makes adding search facilities to django 
projects extremely easy. With haystack and the handily-pure-python 
whoosh, you can be up and running basic searches of your django models 
in a matter of minutes.  In the case of the foreign key field, with 
haystack, you could just include texts from related Model1s in the 
search template for Model2.  That's of course a tad wasteful in some 
ways, but OTOH might be exactly what you want.


I don't use django-sphinx so I'm not clear how to do it there, but
a conceptually related approach does work with raw sphinx apparently: 
you can use joins in sql_query in your source declarations. see this:

http://stackoverflow.com/questions/1733816/sphinx-and-one-to-many-associations

[Obviously, you could also search multiple times for a given search 
string submission and then do joins on the various results yourself, 
though that could get painful fast.]


Full text search isn't appropriate for everything, so django-filters is 
also handy to remember for filter query-building type stuff.


http://github.com/alex/django-filter

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



Re: djangojs translations not available

2010-05-20 Thread filias
So, I managed to fix the problem.

If some has the same problem here are some useful infos:
- if you have a normal setting.py file then you should not have this
problem with djangojs domain translations
- if you have your settings.py file split into several sub-settings
the locale directory should be inside an application in order to be
loaded OR you can define the LOCALE_PATHS variable pointing to it in
settings BUT in the second case the djangojs domain translations wont
work, see ticket http://code.djangoproject.com/ticket/5494

So, in this last case, the solution will be to pass the locale with
the djangojs domain files to one of the installed apps and it will
work :)

I hope this helps people with similar problems.

On May 20, 12:17 pm, filias  wrote:
> Hi,
>
> I have a djangojs.po file and am compiling the messages with
> compilemessages command.
> I don't get any error but I can't see my translations in the js
> catalog. I can only see the admin js translations.
>
> How can I debug this problem?
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Uploaded File Security

2010-05-20 Thread SQ9MEV
Lee Hinde pisze:
> What's best practice here?
Yet another way using nginx as a webserver:
http://wiki.nginx.org/NginxHttpAccessKeyModule

-- 
Bart

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



Re: Uploaded File Security

2010-05-20 Thread SQ9MEV
SQ9MEV pisze:
> Lee Hinde pisze:
>> What's best practice here?
> Yet another way using nginx as a webserver:
> http://wiki.nginx.org/NginxHttpAccessKeyModule
And another one:
http://wiki.nginx.org/NginxHttpSecureDownload
-- 
Bart

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



admin fieldsets ?

2010-05-20 Thread paul wisehart
I'm really liking customizing the admin.

I would like to know if I could use the change_view.html template
with my own form data.

My question is how do I setup a fieldset from some arbitrary form such
that I can pass it to a change_view.html page.

I see that there is a admin/includes/fieldset.html.

I'm having trouble following the django code to see how to setup a
fieldset so that that template will display the sets nicely.

any ideas?

do i need to clarify my question?

thanks,
paul w

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



Re: Django list_filter

2010-05-20 Thread Danfi
Thanks Peter ! But I don't want to use these, I want to know how to
realize it, maybe I have to refer to them.

On May 20, 5:59 pm, Peter Bengtsson  wrote:
> There are much more efficient tree implementation made available for
> Django.https://tabo.pe/projects/django-treebeard/
> A much better place to start.
>
> On 20 May, 07:06, Danfi  wrote:
>
>
>
> > Hi,
> > In my models, I use "parent = models.ForeignKey('self', blank = True,
> > null = True) " create a Folder tree
> > like :
> > A
> > -a1
> > -a2
> > --a21
> > --a211
> > --a22
> > B
> > -b1
>
> > and I use the "parent" as list_filter ,but I get a problem , when I
> > click 'a1' ,it only show the information in a1,
> > but I want it also show its childrens' information . For example ,
> > when I click a21,It can show the informations in
> > a21 and a211.Do anyone have any idea?
> > 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Django reversion, AuditTrail, MySQL MyISAM

2010-05-20 Thread Chris Allen
I'm trying to get rid of a weak Updates table that a coworker had been
hacking up for use as a "user was changed on such and such day/
time..." and replace it with AuditTrail but there are a number of
confounding issues.

AuditTrail: I don't have the User model overridden, how would I hook
it into the user model? There doesn't appear to be a way to add
request.user to the extra tracking fields as the callback function
only gets passed the original instance pre-save. Hard to tell if any
real recent changes have been made to it, making Django 1.2 compat a
question mark.

Django-Reversion: Seems to require a transactional database, however
to my eternal chagrin, my coworkers have persistently used MySQL
MyISAM. This appears to be a blocking issue preventing me from using
reversion. By all means, correct me if I'm wrong. There also isn't any
explicit mention of Django 1.2 compatibility.

Django-audit-log appears to be abandoned.

Is anyone aware of any functional alternatives or solutions to the
blockers for using the above?

Thank you for reading, :)

--- Chris

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



Re: trying not to do any operations in template, but not sure i can avoid it.

2010-05-20 Thread Bill Freeman
On Thu, May 20, 2010 at 4:24 AM, shofty  wrote:
> thanks for the swift response.
>
> On May 19, 10:05 pm, Bill Freeman  wrote:
>> You could put a method on your basket object which calculates the shipping.
>> Then if the basket object is included in the context, you can trivially call 
>> it.
>>
> That seems simple enough for me to do.
>
>
>> Or perhaps better, fix up you all_purchases iterable to append it.
>> Something like:
>>
>>    def add_shipping(purchaces_iterable):
>>       for i, p in enumerate(purchases_iterable):
>>          yield p
>>       yield Purchase(name="Shipping",
>> amount=Decimal(PER_ITEM_SHIPPING)*(i+1)...)
>>
> This one seems a bit trickier. where would that code live? is that in
> the views module for the basket class?

It's flexible.  My though was to define it in views.py, along with its
free referencee PER_ITEM_SHIPPING, though that could obviously
come from a variable or attribute of an object, or out of the settings
module.  Then the view would call it on the iterable of purchases
that you're using now, and pass the result to the template.

But you could also make (something like it) a method on a basket
object, taking only self as an argument, and querying the original
iterable itseld, then pass the basket to the template and let the
template say something like:

   {% for item in basket.with_added_shipping_item %}

>
> one thing i thought about last night was that i should probably be
> doping this a better way. isnt there a way inside django of creating
> an object and including it and everything within it(methods etc) with
> a proper simple statement? a so i could do something like
>
> {% basket %}
>
> and the basket html would be written out. i could also define {%
> basket_total %} and each page would have a summary of the basket?
>
> is this what decorators are for? if not someone tell me the term for
> the funtion i'm describing and i'll go away and do the research. im
>
Be careful that you don't go too far the other way here.  Just as
logic (and calculation) in the template is to be avoided, not being the
province of the designer, presentation in the code is to be avoided because
it *IS* the province of the designer.  Whatever code implements the
iteration over items, you might consider a separate template to render
the individual row, which the code accesses using render_to_string,
for example.

Personally, I don't find iterating over a set of objects each of which
is rendered the same way, simply by accessing attributes, to be
too much logic in the template.

But, yes, you can do such things.

Look for writing your own template tag in the docs.  Consider an
"inclusion" tag, where you really produce the stuff in a separate
template, because writing more general template tags is tricky.
Yes, it would still be being done in the template language, but your
designer doesn't have to see it, they just see {% basket %}.  This
will require a load tag higher up in the template to load your custom
tag library.  Note that your tag will have to presume what the name
of the variable holding the basket is, unless you pass it as an argument,
e.g.; {% basket basket %} (no problem with the names being the same).

Another approach, also using a custom tag library, but writing a filter,
which is easier to get right than a tag, would result in usage like:
{{ basket|basket }}

Yet another way to do something about as good as this is again using
a method on your basket objects.  This would have usage such as
{{ basket.items_list_html }} and wouldn't require loading a tag library.

Note: in all these cases remember to mark your return string as safe
so that the template engine doesn't escape your less than and ampersand
characters.




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

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



Re: No stylesheet in administration panel

2010-05-20 Thread Carlo Trimarchi
On 18 May 2010 17:30, Mitch Anderson  wrote:
> Depending on your ADMIN_MEDIA_PREFIX in settings.py (default is /media/)
>
> your webserver should be configured to point to the django admin media
> location...
>
> I have this line in my apache config
>
> Alias /media/ /usr/share/pyshared/django/contrib/admin/media/

Thanks, this solved the issue.

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



Looking for a Django Developer

2010-05-20 Thread Aquent Tree
For a one month contract opportunity in Toronto, offsite will be
considered as well.
Individuals only, no third party companies, sorry:)

Please contact me directly at tperro...@aquent.com as soon as possible
if you're interested.
Cheers!
Aquent Tree

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



IronPython AssertionError

2010-05-20 Thread Joe D
Has anyone had any luck running Django on IronPython ?

I get the following error:

File "C:\vcs\django\django\utils\functional.py", line 180, in
__prepare_class__
AssertionError: Cannot call lazy() with both str and unicode return
types.

I tried with the release version of django (1.2) as well as trunk
(r13294) with the same results.

The version of IronPython I'm using is:

IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.4927

This seems to have been reported to the IronPython team here:

http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27007

but the response was that it is a deficiency within Django.

Comments ? Suggestions ?

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



Re: admin media and template override ignored after switch to 1.2rc

2010-05-20 Thread C4m1l0
I've resolved my problem, the django project was in the directory "/
var/aplicações". So I've tried to access the folder "media/css" and I
couldn't because django couldn't resolve name "apilcações". So, I've
just rename the folder.

On May 18, 5:37 pm, C4m1l0  wrote:
> Hi, I've encountered the same problem.  When I look in the page source
> the link point to the correct localization, but the CSS and images
> aren't loaded, the layout is default. Could anyone help us? :)
>
> Thanks!
>
> On May 17, 8:37 am, naos  wrote:
>
>
>
> > Well now I think that it might be related to virtualenv since I
> > created new virtualenv with Django 1.1.1 and have the same result.
>
> > On May 17, 12:44 pm, naos  wrote:
>
> > > Hi All,
>
> > > Today I tried to switch my project  from 1.0.4 to 1.2rc version and I
> > > encountered problem withadminmediadefinitions andtemplate
> > > override. It simply doesn't work :) JS,CSS files are not included in
> > > the html and alltemplatecustomizations are not present, looks like
> > > my custom templates are not loaded anymore.
>
> > > Does anyone have similar problem? Any solutions?
>
> > > Greetings,
> > > Lukasz
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Multi-table inheritance and child model admin add pages

2010-05-20 Thread peppo
Hi,
I have the following problem with admin and multi table inheritance I
don't understand (django 1.1.1).

Model definition

class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)

class Restaurant(Place):
serves_hot_dogs = models.BooleanField()
serves_pizza = models.BooleanField()

In the admin pages for adding restaurant instances I see the field of
the parent class (name and address) and the parent instance get
created as expected.

How can I link directly to an _exixting_ Place instance?
If I fill in name and address in the child admin add page, then I get
duplicates in the parent table.

Is there a solution or I am missing something trivial?

Thanks in advance,

__peppo

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



Re: Multi-table inheritance and child model admin add pages

2010-05-20 Thread Karen Tracey
On Thu, May 20, 2010 at 4:26 PM, peppo  wrote:

> I have the following problem with admin and multi table inheritance I
> don't understand (django 1.1.1).
>
> Model definition
>
> class Place(models.Model):
>name = models.CharField(max_length=50)
>address = models.CharField(max_length=80)
>
> class Restaurant(Place):
>serves_hot_dogs = models.BooleanField()
>serves_pizza = models.BooleanField()
>
> In the admin pages for adding restaurant instances I see the field of
> the parent class (name and address) and the parent instance get
> created as expected.
>
> How can I link directly to an _exixting_ Place instance?
> If I fill in name and address in the child admin add page, then I get
> duplicates in the parent table.
>
> Is there a solution or I am missing something trivial?
>

No, this is not currently supported by the ORM. There is a ticket requesting
it:

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

Karen
-- 
http://tracey.org/kmt/

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



Re: Multi-table inheritance and child model admin add pages

2010-05-20 Thread peppo
Thanks Karen for the reply.
I overlooked the ticket you mention.

Just for reference for others reading in the future this thread, here
is a simpler (and more portable) solution other than applying the
patch attached to http://code.djangoproject.com/ticket/7623.

If you modify the child model as follow (therefore bypassyng table
inheritance by setting an explicit OneToOne relation):
class Restaurant(models.Model):
place_ptr=models.OneToOneField(Place, primary_key=True)
serves_hot_dogs = models.BooleanField()
serves_pizza = models.BooleanField()

everything works as expected also in the admin interface and the final
result is the same (although less elegant than multi table
inheritance).

Note that using place_ptr as the field name (the default name used by
the implicit OneToOne relation created by the multi inheritance
machinery), it is not necessary to change anything at the database
level: just change the model definition (and probably some definitions
in admin. py) and all is OK.

regards,

__peppo

On 20 Mag, 22:34, Karen Tracey  wrote:
> On Thu, May 20, 2010 at 4:26 PM, peppo  wrote:
> > I have the following problem with admin and multi table inheritance I
> > don't understand (django 1.1.1).
>
> > Model definition
>
> > class Place(models.Model):
> >    name = models.CharField(max_length=50)
> >    address = models.CharField(max_length=80)
>
> > class Restaurant(Place):
> >    serves_hot_dogs = models.BooleanField()
> >    serves_pizza = models.BooleanField()
>
> > In the admin pages for adding restaurant instances I see the field of
> > the parent class (name and address) and the parent instance get
> > created as expected.
>
> > How can I link directly to an _exixting_ Place instance?
> > If I fill in name and address in the child admin add page, then I get
> > duplicates in the parent table.
>
> > Is there a solution or I am missing something trivial?
>
> No, this is not currently supported by the ORM. There is a ticket requesting
> it:
>
> http://code.djangoproject.com/ticket/7623
>
> Karen
> --http://tracey.org/kmt/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Reload WSGI per request?

2010-05-20 Thread VWAllen
I have my project set up to use Apache/mod_wsgi with different configs
for dev, staging and production. I'd like to set up my dev server to
automatically reload the WSGI app per request (without touching my
django.wsgi file each time). I looked at two wsgi middleware projects,
memento and amnesia, but I was not able to get them to work (and the
docs are not particularly thorough for either).

Is anyone using a setup like this? Any tips for using these projects
or something similar?

Much appreciated,

V

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



more complex queries

2010-05-20 Thread Chris Withers

Hi All,

I have a Transaction model with a DecimalField called "amount" and a 
CharField called "action".


How do I sum all the transactions, multipling the amount by -1 when the 
action is REFUND?


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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: more complex queries

2010-05-20 Thread John M
Sounds like two queries to me, sum all the refunds and then subtract
them from all the non-refund amounts.  does that work for ya?

On May 20, 5:17 pm, Chris Withers  wrote:
> Hi All,
>
> I have a Transaction model with a DecimalField called "amount" and a
> CharField called "action".
>
> How do I sum all the transactions, multipling the amount by -1 when the
> action is REFUND?
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: more complex queries

2010-05-20 Thread Chris Withers

John M wrote:

Sounds like two queries to me, sum all the refunds and then subtract
them from all the non-refund amounts.  does that work for ya?


Not really, that requires two queries. I know this can be done in one 
query in SQL, just wondering how to express that in Django ORM speak...


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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: group password

2010-05-20 Thread Eric Chamberlain
I would use auth.User as is.

When a new user (no existing django session) enters the code, django creates a 
user account (random username and password) behind the scenes and logs in the 
user.  Then the user is identifiable as long as they stay on that machine.  Set 
the logout interval to whatever you need for the experiment duration.

On May 19, 2010, at 2:50 PM, Junkie Dolphin wrote:

> Hello everybody,
> I am coding a django app for performing an online, anonymous
> experiment system. The idea is that we give a login code to a group of
> participants (e.g. students at our university) and tell them a
> specific time window (usually a couple of hours) during which they can
> login to the website using that code we gave them (hence no
> registration required). Once they login the website randomly matches
> pairs of participants for a game (the actual experiment).
> 
> The key factor here is anonymity. We don't want participants to give
> us any personal information, but still we need to identify each
> anonymous user in order to do the random matching.
> 
> What would be the best solution? I was thinking to use the builtin
> authentication system but I don't know if it would be better to extend
> django.contrib.auth.User or just use a plain form.
> 
> -Giovanni
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: If is first time logging in

2010-05-20 Thread Eric Chamberlain
Anything wrong with adding a flag to the profile model?  If the flag is not 
set, show the profile stuff?

It keeps all the profile management in one model.

The "flag" could even be a timestamp, so you could show the prompt again, if 
after X time the user has not added anything to their profile.

On May 19, 2010, at 2:05 PM, Nick wrote:

> I'm trying to figure out a way to see if it is a users first time
> logging in after registering on the site. If it is then I will pass
> them through some formsets, otherwise I let them go to their profile
> page.
> 
> I tried using date_joined == last_login but that doesn't work, as the
> last login date changes the second you log in.
> 
> Anyone ever done anything like this?
> 
> Any thoughts?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: more complex queries

2010-05-20 Thread Shawn Milochik
You could create your own manager and have it do whatever you want -- even run 
the SQL query you already want to write and still return a queryset.

http://docs.djangoproject.com/en/1.1/topics/db/managers/#id2

Shawn

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



URL Fetching Method Timing Out? Strange problem

2010-05-20 Thread Eric
Hi, I'm writing a facebook app with django and it is running on google
app engine. Part of the application is calculating the strength of a
relationship between friends, and classifying it as 1 (weak), 2
(acquaintance), or 3 (close bond).
A copy of the relevant code is http://pastebin.com/AtQZDu65
Lines 11 and 12 are the relevant method calls. Looking at
calc_strength (which runs perfectly locally, but does take about 5
seconds on my home connection), the only possible values that could be
returned are 1, 2, or 3. This should pass as the strength to
connectNodes, or if it is not called then connectNodes should have a
default strength of 1.
However, on execution on my app engine server, the values in the
matrix (which connectNodes is supposed to modify) remain 0, which is
their initial value. This means that either a) calc_strength is
returning 0, or b) that connectNodes is never being called.
calc_strength does handle a significant amount of data, but I don't
believe that it takes more than about 3 seconds to complete on the app
engine server.
The view that these methods are called in returns a redirect, could
the view possibly move on to the next line of code before
calc_strength completes?
Any other ideas why this isn't working?

Relevantly, this works as expected (matrix has values of 1) when
calc_strength is set to immediately return 1.
Help would be much appreciated, 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How can you include annotated results in a serialized QuerySet

2010-05-20 Thread Werner
Hello,

How can you include annotated results in a serialized QuerySet?

I have this serialized query:
serializers.serialize('json', 
Song.objects.filter(is_playing=False).annotate(nr_votes=Count('votes')).order_by('-nr_votes'))

However the key/value pare {'nr_votes': number} is not include into the json 
result.

abe

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



Re: Reload WSGI per request?

2010-05-20 Thread Matt Cooney
On Fri, May 21, 2010 at 11:45 AM, VWAllen  wrote:

> I have my project set up to use Apache/mod_wsgi with different configs
> for dev, staging and production. I'd like to set up my dev server to
> automatically reload the WSGI app per request (without touching my
> django.wsgi file each time).


I've used Graham Dumpleton's suggestion with some success:

  http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html

It only reloads the app if something has changed on disk.

Cheers
Matt

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



is it possible ?

2010-05-20 Thread rahul jain
Hi Everyone,

I would like to implement different views in admin panel based on the user.

if the user is any other user apart from admin

then for all those models, the user should just be able to see those
objects,( no change, delete and add).
Those users should also not see the select boxes or basically select all.

So by default django provides three permissions, add, delete,change. I
would like to add one more permission on admin panel.

I know this could be done on our own views through this

class USCitizen(models.Model):
# ...
class Meta:
permissions = (
("can_drive", "Can drive"),
("can_vote", "Can vote in elections"),
("can_drink", "Can drink alcohol"),
)


{% if perms.foo %}
You have permission to do something in the foo app.
{% if perms.foo.can_vote %}
You can vote!
{% endif %}
{% if perms.foo.can_drive %}
You can drive!
{% endif %}
{% else %}
You don't have permission to do anything in the foo app.
{% endif %}


But how to do the same thing on the django admin. Also, how to remove
the select all functionality for selected users.

--RJ

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



Re: Reload WSGI per request?

2010-05-20 Thread Graham Dumpleton


On May 21, 9:45 am, VWAllen  wrote:
> I have my project set up to use Apache/mod_wsgi with different configs
> for dev, staging and production. I'd like to set up my dev server to
> automatically reload the WSGI app per request (without touching my
> django.wsgi file each time).

If you want to do that you may as well use a CGI script with a CGI/
WSGI adapter.

Be warned that performance will be abysmal if you reload the
application on every request with todays modern fat Python web
frameworks.

As suggested by someone else, see my blog posts and the mod_wsgi
documentation which describe the automatic reload mechanism you can
implement.

Graham

> I looked at two wsgi middleware projects,
> memento and amnesia, but I was not able to get them to work (and the
> docs are not particularly thorough for either).
>
> Is anyone using a setup like this? Any tips for using these projects
> or something similar?
>
> Much appreciated,
>
> V
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: is it possible ?

2010-05-20 Thread Danfi
In Auth group you can create a group and set the limits.

see different panel maybe use changelist_view

I saw this just be similar to yours'

class Part(models.Model):
is_deleted = models.BooleanField()
//
class PartAdmin(admin.ModelAdmin):
actions =None
def change_view(self, request, object_id, extra_context=None):
if Part.objects.get(id=object_id).is_deleted==True and
request.user.is_superuser == False:
return HttpResponseRedirect('/admin/')
else:
return super(PartAdmin, self).change_view(request,
object_id,extra_context=None)

/
edit admin/views/main.py
IS_DELETED_VAR = 'is_deleted'

class ChangeList(object):
def __init__(self, request, model, list_display, list_display_links,
list_filter, date_hierarchy, search_fields, list_select_related,
list_per_page, list_editable, model_admin):
self.model = model
self.opts = model._meta
self.lookup_opts = self.opts
self.root_query_set = model_admin.queryset(request)
  try:
f =self.lookup_opts.get_field(IS_DELETED_VAR)
except models.FieldDoesNotExist:
self.root_query_set = self.root_query_set
else:
if isinstance(f,models.BooleanField) and (request.user.is_superuser ==
False):
self.root_query_set = self.root_query_set.exclude(is_deleted = 'True')
else:
self.root_query_set = self.root_query_set

On 5月21日, 下午12时01分, rahul jain  wrote:
> Hi Everyone,
>
> I would like to implement different views in admin panel based on the user.
>
> if the user is any other user apart from admin
>
> then for all those models, the user should just be able to see those
> objects,( no change, delete and add).
> Those users should also not see the select boxes or basically select all.
>
> So by default django provides three permissions, add, delete,change. I
> would like to add one more permission on admin panel.
>
> I know this could be done on our own views through this
>
> class USCitizen(models.Model):
> # ...
> class Meta:
> permissions = (
> ("can_drive", "Can drive"),
> ("can_vote", "Can vote in elections"),
> ("can_drink", "Can drink alcohol"),
> )
>
> {% if perms.foo %}
> You have permission to do something in the foo app.
> {% if perms.foo.can_vote %}
> You can vote!
> {% endif %}
> {% if perms.foo.can_drive %}
> You can drive!
> {% endif %}
> {% else %}
> You don't have permission to do anything in the foo app.
> {% endif %}
>
> But how to do the same thing on the django admin. Also, how to remove
> the select all functionality for selected users.
>
> --RJ
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: IronPython AssertionError

2010-05-20 Thread Russell Keith-Magee
On Fri, May 21, 2010 at 1:47 AM, Joe D  wrote:
> Has anyone had any luck running Django on IronPython ?

Testing under IronPython hasn't been part of our regular testing
regimen, so I can't comment on the level of compatibility.

> This seems to have been reported to the IronPython team here:
>
> http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27007
>
> but the response was that it is a deficiency within Django.

My immediate reaction is that if IronPython doesn't behave like
CPython on a basic datatyping issue, it's a deficiency in IronPython,
not a problem with Django.

That said, we've made minor changes to Django in order to support
Jython and PyPy in (mostly changes avoiding certain CPython-specific
assumptions about PYTHONPATH and garbage collection strategies), so
I'm not opposed to making similar minor changes in order to
accommodate IronPython.

However, I'm not an IronPython expert myself, and IronPython
compatibility is a pretty low personal priority. What is needed is
someone who understands IronPython who is sufficiently enthused to do
the work. Volunteers welcome.

Yours,
Russ Magee %-)

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



Re: How can you include annotated results in a serialized QuerySet

2010-05-20 Thread Russell Keith-Magee
On Fri, May 21, 2010 at 9:41 AM, Werner  wrote:
> Hello,
>
> How can you include annotated results in a serialized QuerySet?
>
> I have this serialized query:
> serializers.serialize('json', 
> Song.objects.filter(is_playing=False).annotate(nr_votes=Count('votes')).order_by('-nr_votes'))
>
> However the key/value pare {'nr_votes': number} is not include into the json 
> result.

This is a known limitation of the serialization framework, logged as
#5711 [1]. More broadly, there is a known need to rework the
serialization framework to make it more flexible. This is one of the
many use cases that needs to be addressed.

[1] http://code.djangoproject.com/ticket/5711

Yours,
Russ Magee %-)

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



Re: is it possible ?

2010-05-20 Thread rahul jain
Hi Danfi,

Thanks for your quick response. But can you explain a little more how
can we connect ChangeList class with that function change_view.
Confuse about it.

--RJ



2010/5/20 Danfi :
> In Auth group you can create a group and set the limits.
>
> see different panel maybe use changelist_view
>
> I saw this just be similar to yours'
>
> class Part(models.Model):
> is_deleted = models.BooleanField()
> //
> class PartAdmin(admin.ModelAdmin):
> actions =None
> def change_view(self, request, object_id, extra_context=None):
> if Part.objects.get(id=object_id).is_deleted==True and
> request.user.is_superuser == False:
> return HttpResponseRedirect('/admin/')
> else:
> return super(PartAdmin, self).change_view(request,
> object_id,extra_context=None)
>
> /
> edit admin/views/main.py
> IS_DELETED_VAR = 'is_deleted'
>
> class ChangeList(object):
> def __init__(self, request, model, list_display, list_display_links,
> list_filter, date_hierarchy, search_fields, list_select_related,
> list_per_page, list_editable, model_admin):
> self.model = model
> self.opts = model._meta
> self.lookup_opts = self.opts
> self.root_query_set = model_admin.queryset(request)
>  try:
> f =self.lookup_opts.get_field(IS_DELETED_VAR)
> except models.FieldDoesNotExist:
> self.root_query_set = self.root_query_set
> else:
> if isinstance(f,models.BooleanField) and (request.user.is_superuser ==
> False):
> self.root_query_set = self.root_query_set.exclude(is_deleted = 'True')
> else:
> self.root_query_set = self.root_query_set
>
> On 5月21日, 下午12时01分, rahul jain  wrote:
>> Hi Everyone,
>>
>> I would like to implement different views in admin panel based on the user.
>>
>> if the user is any other user apart from admin
>>
>> then for all those models, the user should just be able to see those
>> objects,( no change, delete and add).
>> Those users should also not see the select boxes or basically select all.
>>
>> So by default django provides three permissions, add, delete,change. I
>> would like to add one more permission on admin panel.
>>
>> I know this could be done on our own views through this
>>
>> class USCitizen(models.Model):
>> # ...
>> class Meta:
>> permissions = (
>> ("can_drive", "Can drive"),
>> ("can_vote", "Can vote in elections"),
>> ("can_drink", "Can drink alcohol"),
>> )
>>
>> {% if perms.foo %}
>> You have permission to do something in the foo app.
>> {% if perms.foo.can_vote %}
>> You can vote!
>> {% endif %}
>> {% if perms.foo.can_drive %}
>> You can drive!
>> {% endif %}
>> {% else %}
>> You don't have permission to do anything in the foo app.
>> {% endif %}
>>
>> But how to do the same thing on the django admin. Also, how to remove
>> the select all functionality for selected users.
>>
>> --RJ
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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