Re: Cookie test in login() view

2009-01-31 Thread Karen Tracey
On Sat, Jan 31, 2009 at 9:36 PM, Akbar  wrote:

>
> Hi,
>
> The cookie test in django.contrib.auth.views.login() view doesn't seem
> to work as expected. I disabled cookies in my browser for the
> following test.
>
> 1. The view is called via a GET request and displays the login
> template/form. The test cookie is set.
> 2. The form is posted back to the view. The view is supposed to check
> for the test cookie and throw an error if cookie is not found. This
> check doesn't happen.
>
> The documentation of the init method of AuthenticationForm says it
> will validate that cookies are enabled only if a request is passed in
> when instantiating the form. But on POST the login view doesn't pass
> the request.
>
> I copied the code from the login view and modified it to pass the
> request and the cookie test works.
>
> Is it a defect in the login view or am I doing something wrong?
>
> I am using Django 1.0.2 Final.
>

Looks like a bug, likely an oversight from when the view was change to use
the new forms structure instead of the old manipulators.  Please open a
ticket for it.

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



Wierd FileField behavior

2009-01-31 Thread DrKayBee

Hi,
I have a simple profile model which includes the option to upload a
File (FileField) and a photograph (ImageField). These two fields show
somewhat undesirable behavior:

(1) Let's say I create a profile and upload a photo through the admin.
(2) My member view page shows my photo and other profile details.
(3) Then let's say I go back to change something in my address field.
The filefield correctly shows the "current file" which I uploaded in
(1). I make no other changes and hit Save
(4) I reload my member view page. Now the link to my photograph is
broken.. (photo doesn't exist)
(5) I go back into admin and find there's no photograph associated
with my profile.

Why does it do this? Is there no way to fix this? Am I doing something
wrong? Do I need to upload a file to the database and have it only
store a FilePathField? Is there a workaround?

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



Modifying the Tutorial's Admin Page -- Labels and Items Displayed

2009-01-31 Thread Tom

I'm very new to Django, and I'm working on the official Polls
tutorial.
I've poked around quite a bit, and I am having difficulty figuring out
two things:

1. On the admin index page, how do I get rid of the Auths and the
Sites sections and only leave the Polls section?

2. Just above the Auths section, it says Site Administration. How do I
modify that particular label? I can't seem to find it in any
templates.

To see what I'm talking about, see the third picture down on this
site...
http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02

Thank you in advance for your time and help.

Best,
Tom


--~--~-~--~~~---~--~~
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: remember me on this computer vs SESSION_EXPIRE_AT_BROWSER_CLOSE

2009-01-31 Thread SmileyChris

You're on the right track. As the docs state, you can then override
the site-wide setting:
http://docs.djangoproject.com/en/dev/topics/http/sessions/#browser-length-sessions-vs-persistent-sessions

Steve's comment about requiring a "huge session store" is not really
too much of an issue. It's your responsibility to keep the session
table clean:
http://docs.djangoproject.com/en/dev/topics/http/sessions/#clearing-the-session-table

On Feb 1, 9:29 am, felix  wrote:
> I'm trying to implement the standard option "remember me on this computer"
>
> which in practice means expire the session or not at the end of the session
>
> it looks like django's auth uses a sitewide setting
> SESSION_EXPIRE_AT_BROWSER_CLOSE
>
> does anybody know the best way to approach this ?   is it the
> SessionMiddleware that should be replaced ?
>
>      felix :    crucial-systems.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-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
-~--~~~~--~~--~--~---



Cookie test in login() view

2009-01-31 Thread Akbar

Hi,

The cookie test in django.contrib.auth.views.login() view doesn't seem
to work as expected. I disabled cookies in my browser for the
following test.

1. The view is called via a GET request and displays the login
template/form. The test cookie is set.
2. The form is posted back to the view. The view is supposed to check
for the test cookie and throw an error if cookie is not found. This
check doesn't happen.

The documentation of the init method of AuthenticationForm says it
will validate that cookies are enabled only if a request is passed in
when instantiating the form. But on POST the login view doesn't pass
the request.

I copied the code from the login view and modified it to pass the
request and the cookie test works.

Is it a defect in the login view or am I doing something wrong?

I am using Django 1.0.2 Final.

Thanks,
Akbar

--~--~-~--~~~---~--~~
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: remember me on this computer vs SESSION_EXPIRE_AT_BROWSER_CLOSE

2009-01-31 Thread Steve Holden

felix wrote:
>
> I'm trying to implement the standard option "remember me on this computer"
>
> which in practice means expire the session or not at the end of the
> session
No it doesn't: you want the session to end when the user logs out,
otherwise in a large site you would end up needing a huge session store.
>
> it looks like django's auth uses a sitewide setting
> SESSION_EXPIRE_AT_BROWSER_CLOSE
>
> does anybody know the best way to approach this ?   is it the
> SessionMiddleware that should be replaced ?
>
What you need is to send a cookie that you can use to identify the user
to the site when they come back to the login page. The view that renders
the login page sees the cookie and fills in the correct username, so the
user only has to enter the password to log in.

More and more users are using the browser to store usernames and
passwords anyway, sot he "remember me" option isn't used as much as it
used to be.

regards
 Steve



--~--~-~--~~~---~--~~
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: extending the django admin site

2009-01-31 Thread Santiago

in lines:


2009/2/1 alexander lind :
>
> How do I add a custom field to the a model rendered as a form by
> django admin site?
>

Use custom widgets

> My model has a 'choices' field with 4 possible choices: png, gif, jpg
> and 'none'.  As you can guess this describes the format of an image.
> What I want to do is get the admin site to display a file upload
> widget, and I then want to manually process the uploaded image, save
> it in special way, and set the choices field accordingly.

http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

> Can someone please tell me how I can accomplish this?
>
> I have read the django admin site manual, but it has nothing on this
> kind of customization, which I must assume is not all that uncommon.
>

Check out: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change

> Thanks
> Alec
>
> >
>

--~--~-~--~~~---~--~~
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: FormWizard accessing previous fields data

2009-01-31 Thread mattimust...@gmail.com



On Feb 1, 3:27 am, "lbologn...@gmail.com" 
wrote:
> On Jan 29, 11:31 pm, "lbologn...@gmail.com" 
> wrote:
>
> > Hi all,
>
> > say i have aFormWizardof 5 steps and at the last step i want to
> > display a summary of the submitted data how do i access the value of a
> > field that was in the form at step 1?
>
> Maybe i didn't express myself well enough.
>
> My problem is accessing previous steps fields in the template.
> Something like a classic {{form.foo}} doesn't work because previous
> fields are passed on to the next step as raw html and they're all
> contained in {{form.previous_fields}}
>
> My wizard is like 5 steps and on step 1 the user is asked firstname
> and lastname on a form. At step 5 i want to display a summary of
> submitted info like:
>
> Fistname: John
> Lastname: Doe
>
> but i can't simply do {{form.firstname}}
>
> Thanks,
> Lorenzo

I never understood the logic of it either. I also expected to be able
to do  something like {{ previous_fields.firstname }}.

regards

Matthew

--
http://wadofstuff.blogspot.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-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: Validating and rendering dynamic form

2009-01-31 Thread Louis Sayers

answer from stackoverflow:
http://stackoverflow.com/questions/499964/how-do-you-create-python-methodssignature-and-content-in-code/499982#499982

Python code behaves like this for functions defined in scope of
methods. Use this instead:

for image_name in image_fields:
print "image name is: ", image_name
setattr(new_form, 'clean_' + image_name,
lambda self, iname=image_name: self._clean_photo(iname))

The usage of default keyword argument makes Python remember it at the
time of lambda function creation rather than at the time of its
calling (when it would always take the last image).

yay :)

--~--~-~--~~~---~--~~
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: Application design question

2009-01-31 Thread alex.gay...@gmail.com



On Jan 31, 8:04 pm, eddie  wrote:
> Hey guys & girls,
>
> I've just started playing with django, and am not sure of the best way
> to do something.
>
> I've got a basic site, where page a displays model a, page b displays
> model b, etc.  Every model has it's own view function and template,
> all extending a base template with a header, footer, etc.  In every
> page's footer, I would like to add a parsed RSS feed (just an ul of
> links).
>
> I don't want to repeat code, so I don't feel like calculating it and
> sending it to every render_to_response that I've got (I'll worry about
> caching later, by the way).  So I wonder if there is a way that I
> could give every template access to this object without adding it to
> my views... though this seems like a kind of "global variable" type
> situation that I'm a little wary of too.
>
> How would you proceed?
>
> Thanks!
> -e

Take a look at implementing a template context processor.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Application design question

2009-01-31 Thread eddie

Hey guys & girls,

I've just started playing with django, and am not sure of the best way
to do something.

I've got a basic site, where page a displays model a, page b displays
model b, etc.  Every model has it's own view function and template,
all extending a base template with a header, footer, etc.  In every
page's footer, I would like to add a parsed RSS feed (just an ul of
links).

I don't want to repeat code, so I don't feel like calculating it and
sending it to every render_to_response that I've got (I'll worry about
caching later, by the way).  So I wonder if there is a way that I
could give every template access to this object without adding it to
my views... though this seems like a kind of "global variable" type
situation that I'm a little wary of too.

How would you proceed?

Thanks!
-e
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



extending the django admin site

2009-01-31 Thread alexander lind

How do I add a custom field to the a model rendered as a form by  
django admin site?

My model has a 'choices' field with 4 possible choices: png, gif, jpg  
and 'none'.  As you can guess this describes the format of an image.  
What I want to do is get the admin site to display a file upload  
widget, and I then want to manually process the uploaded image, save  
it in special way, and set the choices field accordingly.

Can someone please tell me how I can accomplish this?

I have read the django admin site manual, but it has nothing on this  
kind of customization, which I must assume is not all that uncommon.

Thanks
Alec

--~--~-~--~~~---~--~~
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: Validating and rendering dynamic form

2009-01-31 Thread Louis Sayers

For some reason, _clean_photo is being given the last image name for
dataName, and that's why only the last picture is being validated.

The line of code that calls _clean_photo with the image name is:
setattr(new_form, 'clean_' + image_name, lambda self: self._clean_photo
(image_name))

This line is within the make_image_form method:

 for image_name in image_fields:
print "image name is: ", image_name
setattr(new_form, 'clean_' + image_name, lambda self:
self._clean_photo(image_name))


You can see that I'm printing the image name.  The image_name is
changing, but it looks like only the final image_name is used (which
will of course be the last image).  Why would this be happening?  All
of the clean methods are generated correctly (e.g. clean_pic_1,
clean_pic_2)

Is there something to do with lambda expressions that I'm missing?



Thanks,

Louis
--~--~-~--~~~---~--~~
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 newbie question re: porting from Google App Engine to Django standalone

2009-01-31 Thread Mark.Petrovic

Good day.  I'm new here, as well as a new (all of two months of
experience) Python web app developer.

I'm interested in porting a Google App Engine
"google.appengine.ext.webapp"-based app to a standalone Django app on
another platform.  I've ported my data models from GAE to Django, as
well as my data access objects.  And I can see from here what I would
need to do to port my url routes currently expressed through

application = webapp.WSGIApplication([('/admin/account/register',
admincontroller.AdminRegisterController),], debug=True)

to a set of routes in the Django urls.py file.  (Aside:  could I
actually keep the WSGIApplication router, too?!  If yes, how?)

What I am interested in now is preserving as much line by line code in
my various controllers (e.g.,
admincontroller.AdminRegisterController).  I'm less concerned about
building http response objects by hand in Django as I am about the
function vs. class routing disparity between Django and GAE webapp-
based routing.  As I read the Django book by Holovaty, et al., the
urls.py routes take a regex url path and maps it to a function.
Whereas the the GAE routing maps a regex url path to a class that
implements handlers for GET, POST, etc.

Since I'm new at all this, I did not have the foresight to build in
any abstraction as a hedge against a future port.  The app isn't that
large, though, so porting it brute force to use functions instead of
classes in the routing table is not that big a deal.

Can anyone talk about how I get there from here re the routing
semantic disparity?

Thank you.

--~--~-~--~~~---~--~~
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: Validating and rendering dynamic form

2009-01-31 Thread Louis Sayers

Ok... maybe not so solved.
Now ony the last image submitted is validated.  in the _clean_photo
(self, dataName) method, I print the data, and all the images except
for the last one contain None.

Any Ideas?

On Feb 1, 12:51 pm, DragonSlayre  wrote:
> Solved my problem - data = self.cleaned_data[dataName]  should have
> been:
> data = self.cleaned_data.get(dataName)
>
> Silly me
--~--~-~--~~~---~--~~
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 1.0.2...

2009-01-31 Thread mic

hi Karen,

>> That's odd. Do you have the files:

>> C:\Django-1.0.2-final\django\utils\__init__.py
>> C:\Django-1.0.2-final\django\utils\version.py

I have the following structure...

C:\Django-1.0.2-final\django\__init__.py
C:\Django-1.0.2-final\django\utils\version.py

Can't figure out why this is not working

On Jan 6, 9:11 am, "Karen Tracey"  wrote:
> On Tue, Jan 6, 2009 at 7:16 AM, Jay  wrote:
>
> > Karen, thanks for your comments, you are right.
> > However, it turns out that the file "...\Django-1.0.2-final\django
> > \utils\__init__.py" has size 0, and it seems when using winzip ( I
> > just realized why 7-zip may have been required for unzipping), the 0
> > size file is *not*  written out. In fact "viewing" the file causes an
> > error (at least on my version winzip 7.0 SR-1). The simple work around
> > is to create an empty file named __init__.py in "...\Django-1.0.2-final
> > \django\utils".
>
> > Now the command "setup.py install" works just fine.
>
> Be aware there are many more 0-byte __init__.py files in the django
> tarball.  Any tool that doesn't correctly extract them is probably not
> something you want to be using.  These files are common in any Python-based
> project.
>
> 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
-~--~~~~--~~--~--~---



Re: Validating and rendering dynamic form

2009-01-31 Thread DragonSlayre

Solved my problem - data = self.cleaned_data[dataName]  should have
been:
data = self.cleaned_data.get(dataName)


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



Weird Name error?

2009-01-31 Thread Joshua Bonnett

I am getting a weird error when I call a property from a template. I
also tried calling it from the view and get the same error. However I
have called it from another script it works fine.
Error:
http://dpaste.com/115147/

definition of survivor(which is being included with the same include
that works fine in other places)
http://dpaste.com/115150/

model that contains the property being called
http://dpaste.com/115149/

place where it fails when called:
Survivors:  {{ outpost.pop }}

another place where it failed when I tried it

@ProfileRequired
def outpost_detail(request, outpost_id):
p = request.session['profile']
outpost = Outpost.objects.get(pk=outpost_id)
return render_to_response('outpost/outpost_detail.html',{ 'outpost':
outpost,'pop':outpost.pop}, context_instance=RequestContext(request) )

place where it works.
http://dpaste.com/115152/


So yeah, I am very very confused. It seems to be working in some
places and not others with the same functions being called. There are
no other objects called Survivor anywhere else in my code, though the
one file is included in many, many places.

--~--~-~--~~~---~--~~
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 sqlite autoincrement bug

2009-01-31 Thread alexander lind

>> Anyway, if you you'd like to fix your patch to always do this for the
>> SQLite backend, that would be great (it looks like a one-line patch  
>> to
>> django/db/backends/sqlite/creation.py).
>
> I don't see a simple way to make this happen. Doesn't seem like any
> other backend DB requires similar behavior, so there is no support for
> suffixing the sql table creation line like that.
> Do you have any ideas for what the best solution would be?
>

Found a way, made a patch:

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

Alec

--~--~-~--~~~---~--~~
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: "invalid reference to FROM-clause" for nested annotate query

2009-01-31 Thread Russell Keith-Magee

On Sun, Feb 1, 2009 at 12:44 AM, omat  wrote:
>
> Hi all,
>
> I obtain a list of tag ids by:
> tag_ids = TaggedItem.objects.all().order_by('-added__max').annotate(Max
> ('added'))[:10]
>
> and try to use it in the following query to obtain tag objects:
> Tag.objects.filter(id__in=tag_ids)
>
> But i get "invalid reference to FROM-clause" error:
>
> Caught an exception while rendering: invalid reference to FROM-clause
> entry for table "tagging_taggeditem"
> LINE 1: ...RE "tagging_tag"."id" IN (SELECT U0."tag_id", MAX
> ("tagging_t...
> ^
> HINT:  Perhaps you meant to reference the table alias "u0".
>
>
> If I force the first query to be evaluated, using the step syntax (ie
> [:10:1] instead of [:10]), then everthing works fine.
>
> Seems like a bug?

I'm not seeing this failure on SQLite, Postgres or MySQL. However, I
was testing using my own test models, not your models - it's possible
that the problem could be caused by the interaction of some other
property of your model on the aggregate query.

Can you provide the full definition of the TaggedItem model you are
using? It would also be helpful to know the database version and
operating system you are using.

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-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 sqlite autoincrement bug

2009-01-31 Thread alexander lind

>
>> Reading sqlites manual,
>> this is _supposed_ to work, but doesn't seem to. However and
>> furthermore, you don't really get autoincrement behavior from sqlite
>> unless you add in the SQL keyword "AUTOINCREMENT" when creating the
>> table.
>>
>> Django does not do this currently, so I hacked in an option in
>> db.models, so I can now do:
>
> That's not the right solution. You're making the symptom go away, not
> fixing the problem itself.
>
> Your observation is correct: the SQLite backend doesn't add
> AUTOINCREMENT. The fix is to make it always add AUTOINCREMENT. An
> AutoField is an auto-increment field: it's not optional.
>
> Shows how infrequently AutoField's are really used in practice.  
> They're
> generally just not that useful to specify.
>
> Anyway, if you you'd like to fix your patch to always do this for the
> SQLite backend, that would be great (it looks like a one-line patch to
> django/db/backends/sqlite/creation.py).

Malcolm, in fact the fix is not this easy unfortunately. I assume you  
mean for me to just add "AUTOINCREMENT" in sqlite/creation.py like so:

'AutoField': 'integer',   ->'AutoField':  'integer autoincrement',

That does not do the trick however. The resulting sql becomes:
...
"user_id" integer AUTOINCREMENT NOT NULL PRIMARY KEY,
...

Which is not ok, sqlite requires it to be:
...
"user_id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
...

I don't see a simple way to make this happen. Doesn't seem like any  
other backend DB requires similar behavior, so there is no support for  
suffixing the sql table creation line like that.
Do you have any ideas for what the best solution would be?

Thanks
Alec

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



Apache ImportError: Could not import settings

2009-01-31 Thread DragonSlayre

Hi,

I'm at the final stage in one of my django developments, and am trying
to get my site live.

I've been following instructions on
http://www.jeffbaier.com/2007/07/26/installing-django-on-an-ubuntu-linux-server/
but got the following error:

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 94, in __init__
raise ImportError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE,
e)

ImportError: Could not import settings 'kazbah.settings' (Is it on
sys.path? Does it have syntax errors?): No module named
kazbah.settings


My ubuntu username is git, and the site I've made (kazbah) is at /home/
git/DjangoProjects/kazbah
My httpd.conf settings look like this:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE kazbah.settings
PythonDebug On
PythonPath "['/home/git/DjangoProjects'] + sys.path"



SetHandler None



SetHandler None



SetHandler None



Any ideas about why my settings can't be found?
--~--~-~--~~~---~--~~
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: Building local Django docs as HTML on Win32?

2009-01-31 Thread Technicalbard

OK - figured this out by myself.

- Need the Gnuwin32 version of make
- then need to install sphinx and all it's dependencies.  Simple with
easy_install
- then edit Makefile to adjust it to handle win32 commands, primarily
the use of backslashes:

On Unix/Linux:
 mkdir -p _build/html _build/doctrees

On win32:
 mkdir _build\html _build\doctrees

and change this line:
 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build\html
to use backslash instead of forward slash in the path at the end.

And then it works like it should.

On Jan 31, 1:50 pm, Technicalbard  wrote:
> I've found a number of places on the net that tell me how to build
> myself a copy of Django documentation from the Restructured Text
> format, but they are all for Linux / BSD.
>
> Any advice on how to do this on Windows without Cygwin?
--~--~-~--~~~---~--~~
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 sqlite autoincrement bug

2009-01-31 Thread alexander lind
>>
>> class User(models.Model):
>>  user_id =   
>> models.AutoField(primary_key=True)
>>
>> This produces a table in sqlite that will NOT take NULL for a value
>> when inserting records. You get an error back.
>
> That's correct behaviour. A primary key column must be unique and not
> null. By definition. No bug there.

Right. I stated it because if you do an insert and just leave the  
autoincrementing field out of the field-list, sqlite will return the  
"sorry, null is not an acceptable value for this field". I was a bit  
unclear.

>
> That's not the right solution. You're making the symptom go away, not
> fixing the problem itself.
>
> Your observation is correct: the SQLite backend doesn't add
> AUTOINCREMENT. The fix is to make it always add AUTOINCREMENT. An
> AutoField is an auto-increment field: it's not optional.

You're right.

>
>
> Shows how infrequently AutoField's are really used in practice.  
> They're
> generally just not that useful to specify.

What else do people use for specifying autoinc fields?

>
>
> Anyway, if you you'd like to fix your patch to always do this for the
> SQLite backend, that would be great (it looks like a one-line patch to
> django/db/backends/sqlite/creation.py).

Ok, will do!

Thanks
Alec
--~--~-~--~~~---~--~~
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: Meta-information for model and form fields

2009-01-31 Thread Vinay Sajip



On Jan 30, 1:36 am, Malcolm Tredinnick 
wrote:
> On Wed, 2009-01-28 at 23:21 -0800, Vinay Sajip wrote:
>
> [...]
>
> > I was hoping there was another way. Of course subclassing's not hard
> > to do, but it means doing it for every field class. I was looking at
> > moving an application over from SQLAlchemy, which offers this feature
> > both for models and fields.
>
> That's not very natural Python behaviour, though. You can't expect to
> pass in extra arbitrary arguments to class constructors for normal
> Python classes and have them hold onto it for later collection.
>

I didn't find anything unusual about it. SQLAlchemy does this by
design [1], to allow users to attach additional meta-data, which the
SQLAlchemy team haven't thought of, to their tables and columns. In
the particular application I am looking at, this meta information is
used to control generation of test data and specific client-side UI
behaviour - it's not for the bread-and-butter case.

Their keyword arg is documented as

info – A dictionary which defaults to {}. A space to store application
specific data. This must be a dictionary.

This is available on both table and column abstractions. I certainly
found it a good way of attaching the information I needed, though of
course there are other ways it could have been done.

Regards,

Vinay

[1] 
http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/schema.html#tables-and-columns

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



Building local Django docs as HTML on Win32?

2009-01-31 Thread Technicalbard

I've found a number of places on the net that tell me how to build
myself a copy of Django documentation from the Restructured Text
format, but they are all for Linux / BSD.

Any advice on how to do this on Windows without Cygwin?


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



remember me on this computer vs SESSION_EXPIRE_AT_BROWSER_CLOSE

2009-01-31 Thread felix
I'm trying to implement the standard option "remember me on this computer"

which in practice means expire the session or not at the end of the session

it looks like django's auth uses a sitewide setting
SESSION_EXPIRE_AT_BROWSER_CLOSE

does anybody know the best way to approach this ?   is it the
SessionMiddleware that should be replaced ?


 felix :crucial-systems.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-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: Reverse foreign key lookup with unknown model

2009-01-31 Thread Antoni Aloy

2009/1/31 Julian :
>
> hi there,
>
> I have a problem I really cannot solve on my own. lets say I have
> three models:
>
> class A(models.Model):
> ...
>
> class B(models.Model):
>fk = models.OneToOneField("A")
>
> class C(models.Model):
>fk = models.OneToOneField("A")
>
> If I have then a single A-instance, how can I determine to wich model
> it is connected _without_ knowing wich models do have a OneToOneField
> to A (or a ForeignKey to A)???
>
> my instance
>
> a = A()
>

Just use a property in A

class A(models.Model):

   @property
   def connected(sefl):
   try:
 x = self.b
   except: # put the real exception here
  x = self.c
   return x

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



Re: Template tags question

2009-01-31 Thread Antoni Aloy

2009/1/31 zentur :
>
> Hello,
>
> i´ve got a problem with the template code of django
>
> i would like to realize this simple task
>
> for (i = 0,  i++,  i< list[0].length)
> {
>list[0][i] , list[1][i]
> }
>
> to display some data on a site, but with the django template tags I can
> ´t get somthing similar to work.
>
> Could anyone give me a hint how to realize this with django template
> tags?

templates tags has the for tag that allow you to iterate throught
collections, so you have to rethink your logic to pass the data in a
way that could be iterated and presented in the way you want.

So just pass to the template the list wicth contains the fnal data.


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



Re: Merging results from two tables

2009-01-31 Thread Daniel Roseman

On Jan 31, 12:27 pm, Markus  wrote:
> Hi
>
> just starting to use Django, am stuck with the following problem:
>
> Given
>
> class A(models.Model):
>     ...some fields...
>
> class B(models.Model):
>    A = models.ForeignKey(A)
>    some fields...
>
> I would like to generate a Queryset that returns values from both
> tables, ie in SQL
>
> SELECT A.field1, A.field2, B.field1, B.field2
> FROM A, B
> WHERE A.id = B.A_id AND some filter on A AND .. some further
> conditions to ensure only one row from table B is matched
>
> So far, I found a way to achieve this using the extra operator:
>
> A.objects.filter(..some filter on A..).extra(select={'field1': "select
> B.field1 from B ...", 'field2': 'select B.field2 from B ..."})
>
> This quickly becomes clumsy as the number of fields in table B
> increases. There must be a better way? As I couldnt find anything in
> the documentation, I would appreciate a nudge in the right direction.
>
> Thanks
> Markus

You haven't explained exactly what you want from B - all the values,
or just the ones that have values in A, or just the ones for a single
value of A?

If you just want all the associated B for each value of A, then a
simple queryset will do the trick.
qs = A.objects.all()
for a in qs:
print a.b_set.all()

You can make this a bit more efficient by calling the initial queryset
with select_related.
qs = A.objects.all().select_related()

I would suggest reading the section on related objects again:
http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects
--
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: Using hashing for password checking in auth module

2009-01-31 Thread Kless

Rutenberg, you're correct. bcrypt is only a solution for storing the
hash of passwords of secure way. In fact, it's the way more secure and
easy that I've found; and it has been implemented and is being used by
OpenBSD.

Your method has a point of failure. Whatever can see your code JS
(client-code), so he will know what are you making with the password
that is sent from a form.

The best options are https or using HMAC-SHA1/RIPEMD160

On 31 ene, 12:24, Guy Rutenberg  wrote:
> Hi Kless,
>
> Correct me if I'm wrong but bcrypt can be used as a solution for
> storing the passwords in the database (instead of the default sha1)
> but it doesn't provide the solution I'm looking for: not sending plain-
> text passwords in login forms. Anyway bcrypt sounds interesting,
> especially its ability to adapt to processor improvments.
>
> Thanks,
>
> Guy
>
> On Jan 31, 11:41 am, Kless  wrote:
>
> > I recommend you to use bcrypt, the password-hashing algorithm used in
> > OpenBSD.
>
> > The advantages are that it creates and manages auto. the salt for each
> > password entered; And the most important is that it is adaptable to
> > future processor performance improvements.
>
> >http://pypi.python.org/pypi/bcryptWrap
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Template tags question

2009-01-31 Thread zentur

Hello,

i´ve got a problem with the template code of django

i would like to realize this simple task

for (i = 0,  i++,  i< list[0].length)
{
list[0][i] , list[1][i]
}

to display some data on a site, but with the django template tags I can
´t get somthing similar to work.

Could anyone give me a hint how to realize this with django template
tags?


thx

zentur

--~--~-~--~~~---~--~~
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 ./manage.py test without a database and with a custom test runner fails

2009-01-31 Thread Karen Tracey
On Sat, Jan 31, 2009 at 9:53 AM, Jarkko Laiho wrote:

>
> I'm developing a simple Ajax backend that presently only consists of
> one URLconf and a single view. I'm trying to do test-driven
> development and have a few initial tests present, but 'manage.py test'
> is crapping out on me.
>
> Initially, I got ImproperlyConfiguredError for not having DATABASE_*
> configured in the settings file. Googling this brought me to
>
> http://docs.djangoproject.com/en/dev/topics/testing/#using-different-testing-frameworks
> and Russell Keith-Magee's advice on the issue (e.g.
>
> http://groups.google.com/group/django-users/browse_thread/thread/fe90a261293ea995
> and
> http://groups.google.com/group/django-users/browse_thread/thread/d3cac9794c5e59f1
> ), suggesting creating a custom test runner by copying the code of the
> default runner w/o the test database creation, and then defining
> TEST_RUNNER in the settings file.
>
> That's what I did, but a different set of errors appeared. First,
> here's the code of my custom run_tests, with the database bits
> commented out. (Based off trunk r9800)
>
> [snip good debug info]


> I went as far as commenting out all "django-specific" bits of the test
> runner, removing the imports from django.* to make sure that run_tests
> was just using the unittest functionality, and added a single test
> manually to the suite variable, but the same NotImplementedError came
> up. Looks like the empty DATABASE_* settings are causing something
> somewhere in the chain to go to the BaseDatabaseOperations class and
> call its methods, all of which of course return NotImplementedError.
>
> This is now well beyond my skills, so I turn to you, the experts. What
> is the correct method of creating a custom test runner for testing
> Django without a database, and is this different pre- and post-r9756,
> since at least the error message is completely different?
>

What's causing the call to the database is that you are apparently (based on
the tracebacks) using a django.test.TestCase, not a basic
unittest.TestCase.  The django.test.TestCase class assumes the database
exists.  The details of how the database is kept "clean" between different
django.test.TestCase runs differ pre- and post-r9756, so that is why you see
different errors for the different levels.

The doc about defining a different test runner starts with the assumption
you are not using Django's test framework -- I read that to mean you are not
using django.test.TestCase tests, for example.  You can't just rip out the
database-create/destroy parts of the test runner and still expect to run
django.test.TestCase tests to still run, since they do assume a database
exists.

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



Re: FormWizard accessing previous fields data

2009-01-31 Thread lbologn...@gmail.com

On Jan 29, 11:31 pm, "lbologn...@gmail.com" 
wrote:
> Hi all,
>
> say i have aFormWizardof 5 steps and at the last step i want to
> display a summary of the submitted data how do i access the value of a
> field that was in the form at step 1?

Maybe i didn't express myself well enough.

My problem is accessing previous steps fields in the template.
Something like a classic {{form.foo}} doesn't work because previous
fields are passed on to the next step as raw html and they're all
contained in {{form.previous_fields}}

My wizard is like 5 steps and on step 1 the user is asked firstname
and lastname on a form. At step 5 i want to display a summary of
submitted info like:

Fistname: John
Lastname: Doe

but i can't simply do {{form.firstname}}

Thanks,
Lorenzo
--~--~-~--~~~---~--~~
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: "invalid reference to FROM-clause" for nested annotate query

2009-01-31 Thread Alex Koshelev
What database backend do you use?


On Sat, Jan 31, 2009 at 6:44 PM, omat  wrote:

>
> Hi all,
>
> I obtain a list of tag ids by:
> tag_ids = TaggedItem.objects.all().order_by('-added__max').annotate(Max
> ('added'))[:10]
>
> and try to use it in the following query to obtain tag objects:
> Tag.objects.filter(id__in=tag_ids)
>
> But i get "invalid reference to FROM-clause" error:
>
> Caught an exception while rendering: invalid reference to FROM-clause
> entry for table "tagging_taggeditem"
> LINE 1: ...RE "tagging_tag"."id" IN (SELECT U0."tag_id", MAX
> ("tagging_t...
> ^
> HINT:  Perhaps you meant to reference the table alias "u0".
>
>
> If I force the first query to be evaluated, using the step syntax (ie
> [:10:1] instead of [:10]), then everthing works fine.
>
> Seems like a bug?
>
> ps: I am using a recent svn version.
>
>
> 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: new record - onetoonefield - create related record

2009-01-31 Thread John M

Hi Karen, and thanks for the reply.

I've always wanted to use the 1-1 field, but whenever a new parent
record is added, I want it to automatically add (via the save() )
ovoerride above to the child 1-1 table.

Yes, the debug does print, and the above code seems to work from the
shell too, it's just when I try to create a new record from the shell,
using the above model code, it doesn't work.  I'm thinking I'm missing
something simple?

I wonder if I should create the child record with :

hs = hostsetting(host=h)
hs.save()

?

I hope this helps you find my bug.

Thanks

John

On Jan 30, 8:15 pm, Karen Tracey  wrote:
> On Fri, Jan 30, 2009 at 4:29 PM, John M  wrote:
>
> > Given the model's below, I'm trying to make it add the related 1-1
> > record automatically, but it's not working, what am i missing?
>
> Perhaps if you described what "not working" looks like in more detail it
> would be easier for people to help.  I can see you've got at least one
> debugging print -- do you ever see that issued?  Also, how are you creating
> the objects -- custom view, admin site...?
>
> 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
-~--~~~~--~~--~--~---



Re: "setup_environ" can't help to run a standalone script

2009-01-31 Thread 文武
I approve it
You should just check your project's settings.py can be import

2009/1/31 Orcun Avsar 

>
>
> On 31 Ocak, 03:09, Malcolm Tredinnick 
> wrote:
>
> > I suspect you just haven't set
> > up your Python path correctly (which is the cause of about 98% of all
> > import-related problems on this list).
> >
> > Regards,
> > Malcolm
>
> i checked my python path and added two path.
>
> 1)DIR=os.path.abspath(__file__)
>   sys.path.append(os.path.split(os.path.split(DIR)[0])[0])
>
>   thats the folder that contains my project folder. (Desktop)
>
> 2)sys.path.append(imp.find_module("django")[1])
>
>   django lib  (site_packages/django)
>
>
> here is my python path now...
> ['C:\\Documents and Settings\\orcun\\Desktop\\indir', 'C:\\WINDOWS\
> \system32\\py
> thon25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\
> \lib\\plat
> -win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\
> \site-pac
> kages', 'C:\\Python25\\lib\\site-packages\\PIL', 'C:\\Python25\\lib\
> \site-packag
> es\\django', 'C:\\Documents and Settings\\orcun\\Desktop']
>
> python path isn't seemed to be the problem.
>
> what can be made different when i run manage.py/shell ? it works
> correct on shell.
> >
>

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



Merging results from two tables

2009-01-31 Thread Markus

Hi

just starting to use Django, am stuck with the following problem:

Given

class A(models.Model):
...some fields...

class B(models.Model):
   A = models.ForeignKey(A)
   some fields...

I would like to generate a Queryset that returns values from both
tables, ie in SQL

SELECT A.field1, A.field2, B.field1, B.field2
FROM A, B
WHERE A.id = B.A_id AND some filter on A AND .. some further
conditions to ensure only one row from table B is matched

So far, I found a way to achieve this using the extra operator:

A.objects.filter(..some filter on A..).extra(select={'field1': "select
B.field1 from B ...", 'field2': 'select B.field2 from B ..."})

This quickly becomes clumsy as the number of fields in table B
increases. There must be a better way? As I couldnt find anything in
the documentation, I would appreciate a nudge in the right direction.

Thanks
Markus


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



"invalid reference to FROM-clause" for nested annotate query

2009-01-31 Thread omat

Hi all,

I obtain a list of tag ids by:
tag_ids = TaggedItem.objects.all().order_by('-added__max').annotate(Max
('added'))[:10]

and try to use it in the following query to obtain tag objects:
Tag.objects.filter(id__in=tag_ids)

But i get "invalid reference to FROM-clause" error:

Caught an exception while rendering: invalid reference to FROM-clause
entry for table "tagging_taggeditem"
LINE 1: ...RE "tagging_tag"."id" IN (SELECT U0."tag_id", MAX
("tagging_t...
 ^
HINT:  Perhaps you meant to reference the table alias "u0".


If I force the first query to be evaluated, using the step syntax (ie
[:10:1] instead of [:10]), then everthing works fine.

Seems like a bug?

ps: I am using a recent svn version.


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: How do I correctly format a Querydict derived list in a url?

2009-01-31 Thread NoviceSortOf

> > > myurl.com/activities/[u'ireland',
> > > u'nireland']/: what I really want
> > > is:
>
> > > /activities/ireland-nireland/
>


I'm not sure if any of this is the 'correct' way but it likely
will work.

Try a combination of python's eval() and str()
function to convert/maninuplate the location_filter
object into a string and format into the string you want.

As well it seems you should be able to pull the elements out
of the location_filter using something like location_filter[1]
and location_filter[2] and then format the string to your
requirements.

Also note there is a django function smart_str() that might
help with working with the unicode formating.

I've not tested this exactly but something like this, in
theory

from django.utils.encoding import smart_str
location_filterAscii = smart_str(location_filter,encoding='utf-8')

Or you can simply do something like mystring.replace("u,","") and
other
python string manipulators to get the string like you want it.

Otherwise it seems this is python string manipulation stuff
you can workout on the command line, using str() and/or eval(),
and .replace.


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



Reverse foreign key lookup with unknown model

2009-01-31 Thread Julian

hi there,

I have a problem I really cannot solve on my own. lets say I have
three models:

class A(models.Model):
 ...

class B(models.Model):
fk = models.OneToOneField("A")

class C(models.Model):
fk = models.OneToOneField("A")

If I have then a single A-instance, how can I determine to wich model
it is connected _without_ knowing wich models do have a OneToOneField
to A (or a ForeignKey to A)???

my instance

a = A()

has to methods in this case: a.b and a.c wich either return an
instance of B respectivly of C or throw an exception...but I have to
know their names to call them ;-)


--~--~-~--~~~---~--~~
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 ./manage.py test without a database and with a custom test runner fails

2009-01-31 Thread Jarkko Laiho

I'm developing a simple Ajax backend that presently only consists of
one URLconf and a single view. I'm trying to do test-driven
development and have a few initial tests present, but 'manage.py test'
is crapping out on me.

Initially, I got ImproperlyConfiguredError for not having DATABASE_*
configured in the settings file. Googling this brought me to
http://docs.djangoproject.com/en/dev/topics/testing/#using-different-testing-frameworks
and Russell Keith-Magee's advice on the issue (e.g.
http://groups.google.com/group/django-users/browse_thread/thread/fe90a261293ea995
and 
http://groups.google.com/group/django-users/browse_thread/thread/d3cac9794c5e59f1
), suggesting creating a custom test runner by copying the code of the
default runner w/o the test database creation, and then defining
TEST_RUNNER in the settings file.

That's what I did, but a different set of errors appeared. First,
here's the code of my custom run_tests, with the database bits
commented out. (Based off trunk r9800)

- - - - -
import unittest
from django.conf import settings
from django.db.models import get_app, get_apps
from django.test.utils import setup_test_environment,
teardown_test_environment
from django.test.simple import build_suite, reorder_suite

def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=
[]):
"""A copy of django.test.simple.run_tests with the test DB
creation commented out."""
setup_test_environment()

settings.DEBUG = False
suite = unittest.TestSuite()

if test_labels:
for label in test_labels:
if '.' in label:
suite.addTest(build_test(label))
else:
app = get_app(label)
suite.addTest(build_suite(app))
else:
for app in get_apps():
suite.addTest(build_suite(app))

for test in extra_tests:
suite.addTest(test)

suite = reorder_suite(suite, (TestCase,))

# old_name = settings.DATABASE_NAME
# from django.db import connection
# connection.creation.create_test_db(verbosity, autoclobber=not
interactive)
result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
# connection.creation.destroy_test_db(old_name, verbosity)

teardown_test_environment()

return len(result.failures) + len(result.errors)

- - - - -

Given that, the correct TEST_RUNNER setting and nine tests to be run,
this is the output of ./manage.py test:

- - - - -
E
==
ERROR: Views should return HTTP 400 when receiving syntactically
invalid JSON as POST.
--
Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/django/test/testcases.py",
line 238, in __call__
self._pre_setup()
  File "/Library/Python/2.5/site-packages/django/test/testcases.py",
line 213, in _pre_setup
self._fixture_setup()
  File "/Library/Python/2.5/site-packages/django/test/testcases.py",
line 410, in _fixture_setup
if not settings.DATABASE_SUPPORTS_TRANSACTIONS:
  File "/Library/Python/2.5/site-packages/django/conf/__init__.py",
line 32, in __getattr__
return getattr(self._target, name)
AttributeError: 'Settings' object has no attribute
'DATABASE_SUPPORTS_TRANSACTIONS'

[...same traceback reported eight more times, once per test...]
--
Ran 0 tests in 0.002s

FAILED (errors=9)

- - - - -

Googling the issue, I stumbled across changeset 9756 (
http://code.djangoproject.com/changeset/9756 ) which appears to
introduce the DATABASE_SUPPORTS_TRANSACTIONS setting. Thinking it
might have introduced a bug, I tried running the tests against trunk
r9755. This is what happened then with ./manage.py test:

[...]
ImportError: cannot import name reorder_suite

reorder_suite was apparently introduced between r9755 and r9800, so I
took out the import and replaced my custom run_tests to be based off
r9755 (copy verbatim, comment out the DB bits just like before) and
ran ./manage.py test once more. This is the result:

- - - - - - -

E
==
ERROR: Views should return HTTP 400 when receiving syntactically
invalid JSON as POST.
--
Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/django/test/testcases.py",
line 207, in __call__
self._pre_setup()
  File "/Library/Python/2.5/site-packages/django/test/testcases.py",
line 188, in _pre_setup
call_command('flush', verbosity=0, interactive=False)
  File "/Library/Python/2.5/site-packages/django/core/management/
__init__.py", line 158, in call_command
return klass.execute(*args, **options)
  File "/Library/Python/2.5/site-packages/django/core/management/
base.py", line 222, in execute
output = self.handle(*args, **options)
  File 

i need help about comments.

2009-01-31 Thread Muslu Yüksektepe

hi guys;

i am preparing to blog and i need help about comments. i am using
v1.0.2.

who can tell me how can i add comments on 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: Snippets app ?

2009-01-31 Thread Steve Holden

Nicolas Steinmetz wrote:
> Hi djangonauts,
>
> For my site, I planned to include a snippets app and was thinking about 
> cab [1] which powers djangosnippets or some other snippets app.
>
> For Cab, it looks it's not updated since April 2007 so I think it's not 
> compatible with Django 1.0.x or do not take benefit from 1.0.x features 
> and improvements.
>
> The code of snipt.net is no longer available on Google Code too. I found 
> some pastebin app (like Spaste) but I wish more a snippets repository 
> than a pastebin.
>
> Do someone know some snippets app available somewhere ?
>
>   
Hmm, I see cab *is* what drives Django snippets. Sorry 'bout that. If it
needs any updates I am sure James would be happy to consider
contributions. Seems to work fine, though. Why not just give it a try?

regards
 Steve


--~--~-~--~~~---~--~~
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: Snippets app ?

2009-01-31 Thread Steve Holden

Nicolas Steinmetz wrote:
> Hi djangonauts,
>
> For my site, I planned to include a snippets app and was thinking about 
> cab [1] which powers djangosnippets or some other snippets app.
>
> For Cab, it looks it's not updated since April 2007 so I think it's not 
> compatible with Django 1.0.x or do not take benefit from 1.0.x features 
> and improvements.
>
> The code of snipt.net is no longer available on Google Code too. I found 
> some pastebin app (like Spaste) but I wish more a snippets repository 
> than a pastebin.
>
> Do someone know some snippets app available somewhere ?
>
>   
Maybe there's a snippets app on Django snippets?

  http://djangosnippets.org

alas the site has no index, so you may need to call up your Google fu ...

regards
 Steve


--~--~-~--~~~---~--~~
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: Someone using django trunk for production?

2009-01-31 Thread Andrew Ingram

Alessandro Ronchi wrote:
> I need to use aggregation features of django 1.1 (i need AVG, SUM).
>
> My production site uses 1.0.2.
>
> Can I upgrade to trunk without worrying?
>
>   
Are you using the width_field and height_field properties of ImageField 
at all? They're broken if used in the admin module after revision 9765. 
That's the only issue I'm aware of with trunk.

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



Re: Using hashing for password checking in auth module

2009-01-31 Thread Guy Rutenberg

Hi Kless,

Correct me if I'm wrong but bcrypt can be used as a solution for
storing the passwords in the database (instead of the default sha1)
but it doesn't provide the solution I'm looking for: not sending plain-
text passwords in login forms. Anyway bcrypt sounds interesting,
especially its ability to adapt to processor improvments.

Thanks,

Guy

On Jan 31, 11:41 am, Kless  wrote:
> I recommend you to use bcrypt, the password-hashing algorithm used in
> OpenBSD.
>
> The advantages are that it creates and manages auto. the salt for each
> password entered; And the most important is that it is adaptable to
> future processor performance improvements.
>
> http://pypi.python.org/pypi/bcryptWrap

--~--~-~--~~~---~--~~
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: "setup_environ" can't help to run a standalone script

2009-01-31 Thread Orcun Avsar


On 31 Ocak, 03:09, Malcolm Tredinnick 
wrote:

> I suspect you just haven't set
> up your Python path correctly (which is the cause of about 98% of all
> import-related problems on this list).
>
> Regards,
> Malcolm

i checked my python path and added two path.

1)DIR=os.path.abspath(__file__)
   sys.path.append(os.path.split(os.path.split(DIR)[0])[0])

   thats the folder that contains my project folder. (Desktop)

2)sys.path.append(imp.find_module("django")[1])

   django lib  (site_packages/django)


here is my python path now...
['C:\\Documents and Settings\\orcun\\Desktop\\indir', 'C:\\WINDOWS\
\system32\\py
thon25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\
\lib\\plat
-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\
\site-pac
kages', 'C:\\Python25\\lib\\site-packages\\PIL', 'C:\\Python25\\lib\
\site-packag
es\\django', 'C:\\Documents and Settings\\orcun\\Desktop']

python path isn't seemed to be the problem.

what can be made different when i run manage.py/shell ? it works
correct on shell.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Someone using django trunk for production?

2009-01-31 Thread Alessandro Ronchi

I need to use aggregation features of django 1.1 (i need AVG, SUM).

My production site uses 1.0.2.

Can I upgrade to trunk without worrying?

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

--~--~-~--~~~---~--~~
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 hashing for password checking in auth module

2009-01-31 Thread Kless

I recommend you to use bcrypt, the password-hashing algorithm used in
OpenBSD.

The advantages are that it creates and manages auto. the salt for each
password entered; And the most important is that it is adaptable to
future processor performance improvements.

http://pypi.python.org/pypi/bcryptWrap


On 30 ene, 19:36, Guy Rutenberg  wrote:
> Hi,
>
> I've started using Django recently and when I've used the auth module
> I noticed that it only verifies a plain text password. I'm not
> comfortable with this behaviour as it means that passwords have to be
> sent by login forms in plain text.
>
> In previous projects of mine I've used a solution that sent involved
> comparing a hash value of a given salt with the hash of the password
> (which is stored in the database). A salt is sent with the login form
> and upon submission, using javascript the salt is concated with a
> hahed password and then both of them are hashed again. The same thing
> happens in the server-side and only the result hashes are compared.
> This eliminates the need to send the password in plain-text in the
> login forms and adds extra security.
>
> Is it possible to such thing with the current auth module? if not how
> hard it will be to add such functionality to the current module/write
> a new authentication backend for it?
>
> Thanks,
>
> Guy Rutenberg
--~--~-~--~~~---~--~~
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: Inherit/Override custom Form class methods in a custom ModelForm class

2009-01-31 Thread Daniel Roseman

On Jan 31, 1:26 am, Malcolm Tredinnick 
wrote:
> On Fri, 2009-01-30 at 12:19 -0800, Daniel Roseman wrote:
>
> [...]
>
> > This is an ideal case for mixins. A mixin is a basic class which is
> > 'mixed in' to other classes, which inherit both the attributes of
> > their base class and the mixin class. So, for example, you could do:
>
> > class MyMixin(object):
> >     def as_span(self):
> >         
>
> > class MyForm(forms.Form, MyMixin):
> >     ...
>
> > class MyModelForm(forms.ModelForm, MyMixin):
> >     ...
>
> You have to put the mixin class before the class you're trying to
> overrides. Python's method resolution order is essentially "first to
> last" for immediate parent classes. The way you've written the above,
> any name "foo" will first be looked up in forms.ModelForm and, only if
> it does exist there, will it be lookup up in MyMixin -- which is
> backwards from what is intended.
>
> Regards,
> Malcolm

Thanks Malcolm - I seem to be getting a lot of Python tips from you
recently...
--
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
-~--~~~~--~~--~--~---