Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread huu...@gmail.com

On Mar 17, 10:45 pm, Jacob Kaplan-Moss 
wrote:
> On Tue, Mar 17, 2009 at 8:55 PM, Huuuze  wrote:
> > 7.  Django detects the missing cookie
>
> I think this is where you're getting hung up. Django doesn't "detect"
> a "missing" cookie; Django sees a request from a browser that doesn't
> include a cookie. Nothing's missing; it's just a new browser without a
> cookie.
>
> To Django, there's *no difference* between a user browsing a site
> until his cookie expires then coming back, and the same user browsing
> until the cookie expires and then a *second* user visiting without a
> cookie. There's no "I used to have a cookie but now I don't" header;
> there's either a session cookie, or there isn't.
>
> Huuuze, I can appreciate that this is an infuriating aspect of HTTP --
> statelessness is a real bitch sometimes. But you need to accept that
> you're asking the impossible here and move on.

Jacob, as you can see in my previous post (where I stated "And I agree
with you: I don't think this can be done..."), I have moved on.  There
is no need for the condescending tone in your previous post and lest
we forget this is a *support* group.  I do understand the limitations
and, in the case of my description of Step 7, I simply chose the wrong
words.  Regardless, thank you again for assisting and setting me on
the right path.

>
> Jacob

--~--~-~--~~~---~--~~
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: including text files with django tags?

2009-03-17 Thread Andy Mckay


On 17-Mar-09, at 7:48 PM, codingJoe wrote:
> 
>   
> 
>
> I have a text file that I want the user to see in a scrolling text
> area?

I would recommend reading through the django tutorial on the website,  
since it shows that this is done in python in views and not in a  
template.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


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



including text files with django tags?

2009-03-17 Thread codingJoe

My fist GAE app and I'm having problems importing a text file.   What
is the equivalent of the following include line in django?   If
nothing exists, how do I make that work?


   


I have a text file that I want the user to see in a scrolling text
area?

Thanks!

T
--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Jacob Kaplan-Moss

On Tue, Mar 17, 2009 at 8:55 PM, Huuuze  wrote:
> 7.  Django detects the missing cookie

I think this is where you're getting hung up. Django doesn't "detect"
a "missing" cookie; Django sees a request from a browser that doesn't
include a cookie. Nothing's missing; it's just a new browser without a
cookie.

To Django, there's *no difference* between a user browsing a site
until his cookie expires then coming back, and the same user browsing
until the cookie expires and then a *second* user visiting without a
cookie. There's no "I used to have a cookie but now I don't" header;
there's either a session cookie, or there isn't.

Huuuze, I can appreciate that this is an infuriating aspect of HTTP --
statelessness is a real bitch sometimes. But you need to accept that
you're asking the impossible here and move on.

Jacob

--~--~-~--~~~---~--~~
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: allowing a user to delete their own account and associated data.

2009-03-17 Thread Jacob Kaplan-Moss

On Tue, Mar 17, 2009 at 8:34 PM, tristan  wrote:
> A pointer to where I might find the python that deletes an account in
> the "Auth" admin app would be great, because then I could just copy
> that... I've found that does everything I need, but I need to expose
> it to my users so they can do it themselves...

Remember that the auth app is not anything special -- it's an app just
like any of the apps you'd write. It contains a model called `User`
which is, again, a normal Django model, with all the normal Django
model methods -- specifically, `delete()`.

>From the interactive shell, it's easy to delete a user::

>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username='jacob')
>>> u.delete()

So, you'd need to write a view that essentially does the above.
Remember that in views, the currently-logged-in user is available as
`request.user`, so::

def delete_me(request):
request.user.delete()
return render_to_response('youve_been_deleted.html')

You'll probably want to implement some sort of "are you sure?"
confirmation page, but I'll leave that up to you.

Good luck,

Jacob

--~--~-~--~~~---~--~~
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: My web page can not be Internationalized

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 18:58 -0700, Eric wrote:
> Can anyone help me ?

If somebody could help you, they would have posted a reply.

I know I found your post fairly incomprehensible, since it doesn't give
any real details on how you're implementing any of this. it could be any
one of about two million things.

Constructing a very small example, with, say, a form containing only the
dropdown box, that demonstrates the problem you're seeing would be a
reasonable start. This is very standard stuff.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 18:55 -0700, Huuuze wrote:
> Malcolm, I believe you and appreciate your advice, but you need to
> ease up.  You're getting hung up on semantics.  In this instance, I'm
> simply differentiating between a user clicking a link that says
> "Logout" (a.k.a, a manual logout) versus Django detecting the lack of
> a session cookie and redirecting the user to a login page (a.k.a., an
> automated logout).  From the user's perspective, they have been
> automatically logged out.

The semantics are very important. We've been discussing the problem from
the server side where there is no concept of automatic logout. Using the
wrong words confuses things and there was enough confusion when you
started this thread that being precise is necessary. We aren't
discussing what the user sees here and there's never been any
misunderstanding as to what problem you've been trying to solve.

> 1.  User access Django-based website.
> 2.  Django generates a session cookie with an expiration date based
> upon SESSION_COOKIE_AGE.  (In this example, it's set to 3600)
> 3.  User logs in
> 4.  User traverses website for one hour (3600 seconds)
> 5.  Browser removes expired cookie
> 6.  User attempts to click new link in Django-based website
> 7.  Django detects the missing cookie
> 8.  Django redirects user to login page
> 9.  Django generates session cookie, inserts a new record into
> django.sessions, and leaves old session information in django.sessions
> table

Yes, this is correct and, yes, it's impossible to do anything special at
step 7 because there's absolutely no difference between the expired
session and the new user or somebody who hasn't visited for the past two
years.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: My web page can not be Internationalized

2009-03-17 Thread Eric

 Can anyone help me ?

On Mar 17, 5:22 pm, Eric  wrote:
> Hi, Now , I face a problem about Internationalization, I have used
> django + python + extjs to created a log in html page. And my browser
> is Firefox.
>
> In the page , the user can select the language which will be shown in
> the next page .
>
> For instance, when you open the log in page , it was showed in
> Chinese. Now , I just want to it was showed in English. So , you can
> select the language option to English. After you submit , you will see
> the page as English now. In this time , my Firefox browser use the
> Chinese as default language in language option.
>
> But , there is a problem: when I set the Firefox browser's language
> option as English first , the select option won't work any more.
> Whichever language you select in the page ,it was showed in English
> except the internationalized Javascript. That is , the python code and
> template can't be translated.
>
> When I change the language option of Firefox browser in Chinese ,it
> works again.
>
> This is my problem about Internationalization , please help me !
>
> 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: FIXED: Can't run django on Apache

2009-03-17 Thread Graham Dumpleton

Either way, their dango.root setting is wrong as they are setting it
to physical file system path. Remove that whole django.root setting as
you do not need it when mounting at root of site.

The sooner people stop using mod_python the better. ;-)

Graham

On Mar 18, 12:41 pm, Karen Tracey  wrote:
> On Tue, Mar 17, 2009 at 1:54 PM, Bro  wrote:
>
> > [snip]
> > File "/var/lib/python-support/python2.5/django/core/handlers/
> > base.py", line 44, in load_middleware
> >    raise exceptions.ImproperlyConfigured, 'Middleware module "%s"
> > does not define a "%s" class' % (mw_module, mw_classname)
>
> > ImproperlyConfigured: Middleware module
> > "django.contrib.flatpages.middleware" does not define a
> > "FlatpageFallbackMiddlewar" class
>
> You seem to have dropped the e off the end of FlatpageFallbackMiddelware in
> your MIDDLEWARE_CLASSES setting that includes that middleware.
>
> 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: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Huuuze

Malcolm, I believe you and appreciate your advice, but you need to
ease up.  You're getting hung up on semantics.  In this instance, I'm
simply differentiating between a user clicking a link that says
"Logout" (a.k.a, a manual logout) versus Django detecting the lack of
a session cookie and redirecting the user to a login page (a.k.a., an
automated logout).  From the user's perspective, they have been
automatically logged out.

With that out of the way, let's wrap this up.  Please correct me if
I'm incorrect in this psuedo-code description of the manual login/
automated logout process:

1.  User access Django-based website.
2.  Django generates a session cookie with an expiration date based
upon SESSION_COOKIE_AGE.  (In this example, it's set to 3600)
3.  User logs in
4.  User traverses website for one hour (3600 seconds)
5.  Browser removes expired cookie
6.  User attempts to click new link in Django-based website
7.  Django detects the missing cookie
8.  Django redirects user to login page
9.  Django generates session cookie, inserts a new record into
django.sessions, and leaves old session information in django.sessions
table

The problem I'm trying to solve at this point is to slip in a call to
an audit method between Steps 6 and 8.  As soon as Django realizes the
user's session is gone, I'd like to audit the "idle logout" (again,
this is from the user's perspective).  By "audit", I mean store a
database record in my person.audit table with the user's user ID and a
message noting their session has expired.

And I agree with you: I don't think this can be done and you (and
others) have provided enough explanation to convince me that there is
no simple solution.  I just wanted to make sure we're all on the same
page with respect to the problem I'm trying to resolve.


On Mar 17, 9:35 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2009-03-18 at 01:28 +, Paulo Köch wrote:
> > > Calling logout(), as the original poster requested doesn't achieve
> > > anything (it does nothing). If it did do something, it would still be a
> > > bad idea to call it, because the user could have already logged in again
> > > and logging them out would be unfortunate.
>
> > Doesn't this generate a new session_id?
>
> More importantly it sets the user's status to be logged out. If they had
> logged in again since their previous session expired, you have now just
> logged them out again. In the web business we call that "not friendly".
>
> Malcolm
--~--~-~--~~~---~--~~
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: FIXED: Can't run django on Apache

2009-03-17 Thread Karen Tracey
On Tue, Mar 17, 2009 at 1:54 PM, Bro  wrote:

>
> [snip]



> File "/var/lib/python-support/python2.5/django/core/handlers/
> base.py", line 44, in load_middleware
>raise exceptions.ImproperlyConfigured, 'Middleware module "%s"
> does not define a "%s" class' % (mw_module, mw_classname)
>
> ImproperlyConfigured: Middleware module
> "django.contrib.flatpages.middleware" does not define a
> "FlatpageFallbackMiddlewar" class
>

You seem to have dropped the e off the end of FlatpageFallbackMiddelware in
your MIDDLEWARE_CLASSES setting that includes that middleware.

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: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 18:32 -0700, Huuuze wrote:
[...]

>  As soon as the session expires, Django
> updates the records in the django.sessions table.  As such, the only
> unique identifier for the user, "session_key", is overwritten.

This isn't what happens when a session expires at all. Django doesn't
know that the session has expired because all it sees is a user arriving
without a session cookie (the cookie has expired, so the browser doesn't
send it). Thus, the user looks like a brand new user at that point.

So far this fact (that the cookie is not sent) has been mentioned three
or four times in this thread. You really have to start believing us.

> If there is some straightforward way to intercept the call to update
> that table at the time of the automated logout, I'm all ears.

There is no automated logout, either. There is only explicit logout
prior to a session being expired.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Malcolm Tredinnick

On Wed, 2009-03-18 at 01:28 +, Paulo Köch wrote:
> > Calling logout(), as the original poster requested doesn't achieve
> > anything (it does nothing). If it did do something, it would still be a
> > bad idea to call it, because the user could have already logged in again
> > and logging them out would be unfortunate.
> 
> Doesn't this generate a new session_id?

More importantly it sets the user's status to be logged out. If they had
logged in again since their previous session expired, you have now just
logged them out again. In the web business we call that "not friendly".

Malcolm



--~--~-~--~~~---~--~~
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: Typo for Django or Like?

2009-03-17 Thread Nick Lo

Hi James,

Trying not to be pedantic but are you meaning to ask "if there are any  
applications that the list would recommend" rather than just "if there  
are any". I'm only saying this as it's otherwise it's almost  
impossible not to think http://lmgtfy.com/q=django+blogging 
+application and not be too encouraged to help you.

The short answer is yes there are Django blogging applications and the  
general joke is how many Django developers have built their own  
blogging application. The real answer comes down to what you need from  
your blogging application which is I think what Alex asked originally.

A little more detail will probably get you a few more productive  
responses,

Nick

> Sure,
>
> Typo is a blogging platform/cms (Like wordpress). I know about  
> Django-cms and I am wondering if there are any others?
>
> Thanks
> James
>
> On Wed, Mar 18, 2009 at 12:02 AM, Alex Gaynor  
>  wrote:
>
>
> On Tue, Mar 17, 2009 at 5:59 PM, James Matthews  
>  wrote:
> Hi,
>
> I have been using Django now for a while. I am wondering if there  
> are any applications like Typo for RoR in Django or you have to  
> write it by yourself.
>
> Thanks
> James
>
> -- 
> http://www.astorandblack.com
>
>
>
> Most of us aren't RoR developers so we don't really know what that  
> is, can you provide a description of what it is your looking for?
>
> Alex
>
> -- 
> "I disapprove of what you say, but I will defend to the death your  
> right to say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
>
>
>
>
> -- 
> http://www.goldwatches.com/
>
> http://www.jewelerslounge.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: allowing a user to delete their own account and associated data.

2009-03-17 Thread tristan

I don't suppose anyone has any insight into this do they?
A pointer to where I might find the python that deletes an account in
the "Auth" admin app would be great, because then I could just copy
that... I've found that does everything I need, but I need to expose
it to my users so they can do it themselves...


On Mar 12, 10:12 am, tristan  wrote:
> Hello there,
> I'm currently learning Django by re-implementing a site based on
> Pinax.
> In the Django admin site, I candeleteanaccountand all its
> associated data by going into auth >accountname and deleting it.
> This works just dandy.
> What I would like to do is to expose this same functionality to the
> user on the main site.
> Can anyone point me to what views I might copy, and where from in
> order to achieve this, or give me any other tips?
>
> Thank you in advance.
>
> Tristan
--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Huuuze

Yes, it does generate new session_id.  The user has essentially told
Django to expire the session, which in turn results in a new session
key.

I'm starting to agree with Malcolm.  Outside of an elaborate solution,
this one may not be possible.  As soon as the session expires, Django
updates the records in the django.sessions table.  As such, the only
unique identifier for the user, "session_key", is overwritten.

If there is some straightforward way to intercept the call to update
that table at the time of the automated logout, I'm all ears.

On Mar 17, 9:28 pm, Paulo Köch  wrote:
> > Calling logout(), as the original poster requested doesn't achieve
> > anything (it does nothing). If it did do something, it would still be a
> > bad idea to call it, because the user could have already logged in again
> > and logging them out would be unfortunate.
>
> Doesn't this generate a new session_id?
>
> Cheers,
> Paulo Köch
--~--~-~--~~~---~--~~
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: TemplateDoesNotExist

2009-03-17 Thread Karen Tracey
On Tue, Mar 17, 2009 at 12:00 PM, TP  wrote:

>
> I have an error in my traceback saying the index.html file does not
> exist, but it has been created in the correct DIR.
>

The exception traceback include a list of all the files the template loader
looked for.  Yours says:


> Django tried loading these templates, in this order:
> Using loader django.template.loaders.filesystem.load_template_source:
> /home/csunix/scs5tdp/Desktop/mysite/templates/admin/base_site.html/
> home/csunix/scs5tdp/Desktop/mysite/templates/polls/index.html/home/
> csunix/scs5tdp/Desktop/mysite/mysite/polls/index.html/polls/index.html
> (File does not exist)
> Using loader
> django.template.loaders.app_directories.load_template_source:
> /home/csunix/scs5tdp/python/lib/python2.5/site-packages/django/
> contrib/
> admin/templates/polls/index.html (File does not exist)
>
> [snip]



>
> The File exists in that Dir that is listed in the TEMPLATE_DIR so Im
> confused why I get that error


What exactly do you have TEMPLATE_DIRS set to?  Based on what the template
loader postmortem says it appears to contain a single string:

/home/csunix/scs5tdp/Desktop/mysite/templates/admin/base_site.html/home/csunix/scs5tdp/Desktop/mysite/templates/polls/index.html/home/csunix/scs5tdp/Desktop/mysite/mysite/polls/index.html/polls/

This seems unlikely to be what you intended, so I'd take a closer look at
that TEMPLATE_DIRS setting to see how this has happened.  Are you missing
some commas, maybe?

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: RelatedObject Cache

2009-03-17 Thread Andrew Fong

And there it is! Thanks Alex!

On Mar 17, 2:18 pm, Alex Gaynor  wrote:
> On Tue, Mar 17, 2009 at 5:08 PM, Andrew Fong  wrote:
>
> > Hello all,
>
> > Quick question. Given these models ...
>
> > class A(models.Model): pass
>
> > class B(models.Model):
> >  model_a = models.ForeignKey(A)
>
> > ... getting the model_a attribute on an instance of B will result in
> > that related object being cached. So the question: given an instance
> > of B, how do I know whether the related object has already been
> > cached?
>
> > Been looking through the source code, but I can't find where
> > related_objects are stored. Thanks in advance to anyone who can help!
>
> > -- Andrew
>
> The code to calculate the cache is 
> here:http://code.djangoproject.com/browser/django/trunk/django/db/models/f...
> a lot to follow but it gets used in
> ReverseSingleRelatedObjectDescriptor which calls self.field.get_cache_name()
> which ForeignKey inherits from Field.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Paulo Köch

> Calling logout(), as the original poster requested doesn't achieve
> anything (it does nothing). If it did do something, it would still be a
> bad idea to call it, because the user could have already logged in again
> and logging them out would be unfortunate.

Doesn't this generate a new session_id?

Cheers,
Paulo Köch

--~--~-~--~~~---~--~~
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: memcached: is this thing plugged in?

2009-03-17 Thread hotani

Thanks for the responses - shortly after posting I realized what I
missed for a successful test of the caching software. After adding the
proper lines to 'MIDDLEWARE_CLASSES', memcached came to life.

If anyone is curious, before memcached the test page was getting about
10 trans/sec. After memcached was active, it was more like 250.
--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Malcolm Tredinnick

On Wed, 2009-03-18 at 01:17 +, Paulo Köch wrote:
[...]
> Based on this, I can't see why a simple custom cron job inspecting the
> pickled session data (assuming the user_id is in the session) before
> purging old session would not suffice. Care to elaborate?

I think you've arrived back at the point of what Django already
provides, which is why the original ticket was closed.

You run "django-admin.py cleanup" in a cronjob and all the old sessions
are removed. You don't need to check the user ids or anything like that.
Expired sessions are expired, no matter who they belonged to.

Calling logout(), as the original poster requested doesn't achieve
anything (it does nothing). If it did do something, it would still be a
bad idea to call it, because the user could have already logged in again
and logging them out would be unfortunate.

So, yes, the cronjob is the solution. Which is why it's been in Django
for the last four years. :-)

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: TemplateSyntaxError (newbie)

2009-03-17 Thread PaulE

Indeed I am using 1.0.
Thanks for the info regarding the admin urls.


--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Paulo Köch

On Wed, Mar 18, 2009 at 01:06, Malcolm Tredinnick
 wrote:
> There's no guarantee that the same session
> will go to the same process (not to mention that the processes will stop
> and start over time).
>
> If you're going to do something like this, it has to be external from
> the web-process lifecycle and a centralised point that each process
> talks to. Some kind of server daemon.

Doh, missed that! This would only work in a worker model, restricting
deploy strategies. You're 100% correct. Some elaborate solution would
be required.


> At that point it becomes equivalent to just looking in the sessions
> table for sessions that have already expired (which is a simple
> queryset). (the server daemon in question is the database server, so the
> pattern holds).
>
> I also don't think you're solving the original problem here (detecting
> when a user who is coming back has an expired session, rather than never
> been logged in) and detecting when sessions have expired can already be
> done by looking at the database table.

Based on this, I can't see why a simple custom cron job inspecting the
pickled session data (assuming the user_id is in the session) before
purging old session would not suffice. Care to elaborate?

Cheers.

--~--~-~--~~~---~--~~
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: TemplateSyntaxError (newbie)

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 18:03 -0700, PaulE wrote:
> Malcolm,
> 
> Thanks for the quick reply.
> Problem solved - after reading your reply.
> I changed
> (r'^cms/(.*)', include('cms.urls')),
> to
> (r'^cms/', include('cms.urls')),
> and it works fine.
> 
> I still don't quite understand because this *admin* url works fine
> http://localhost:8000/admin/
> when I have this pattern
> (r'^admin/(.*)', admin.site.root),
> Isn't the regex saying take all characters except a newline?
> I doubt there is anything special about admin urls.

Your assumption is incorrect. The admin.site.root processing does
something quite different to just comparing against a set of
urlpatterns.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: TemplateSyntaxError (newbie)

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 9:03 PM, PaulE  wrote:

>
> Malcolm,
>
> Thanks for the quick reply.
> Problem solved - after reading your reply.
> I changed
>(r'^cms/(.*)', include('cms.urls')),
> to
>(r'^cms/', include('cms.urls')),
> and it works fine.
>
> I still don't quite understand because this *admin* url works fine
>http://localhost:8000/admin/
> when I have this pattern
> (r'^admin/(.*)', admin.site.root),
> Isn't the regex saying take all characters except a newline?
> I doubt there is anything special about admin urls.
>
> Oh wait - I think I see - the whole regex strips away what matches?
> So if my URL is
> http://localhost:8000/cms/first-story/
> This regex r'^cms/(.*)' strips away "cms/first-story/"
> and there is nothing left - thereftroe we see
> arguments '()' and keyword arguments '{}' not found.
>
> Do I have that at least a bit right?
> Many thanks.
> PaulE
>
> >
>
Unfortunately before the 1.1 development version(that is to say in 1.0) the
admin urls were indeed special, in the sense that they didn't include
another URLconf as you're doing with the CMS urls, what they did was they
sent all the URLs to a single view and that view dispatched to other views.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Malcolm Tredinnick

On Wed, 2009-03-18 at 00:55 +, Paulo Köch wrote:
> Coder speaks louder. HTH.
> 
> #Pseudo code. Not tested nor proven.
> class TimeoutTimerPool(object):
>   """A pool that tracks a set of users and their active session.
> Tipically used as a singleton."""
>   from threading import Timer
>   def __init__(self):
> self.pool = {}

I'm hesitant to rain on your parade here, as you've put some effort into
writing a bunch of code. But the approach is flawed. As soon as you have
multiple processes involved (which is going to be normal), this
in-memory storage won't work. There's no guarantee that the same session
will go to the same process (not to mention that the processes will stop
and start over time).

If you're going to do something like this, it has to be external from
the web-process lifecycle and a centralised point that each process
talks to. Some kind of server daemon.

At that point it becomes equivalent to just looking in the sessions
table for sessions that have already expired (which is a simple
queryset). (the server daemon in question is the database server, so the
pattern holds).

I also don't think you're solving the original problem here (detecting
when a user who is coming back has an expired session, rather than never
been logged in) and detecting when sessions have expired can already be
done by looking at the database table.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: TemplateSyntaxError (newbie)

2009-03-17 Thread PaulE

Malcolm,

Thanks for the quick reply.
Problem solved - after reading your reply.
I changed
(r'^cms/(.*)', include('cms.urls')),
to
(r'^cms/', include('cms.urls')),
and it works fine.

I still don't quite understand because this *admin* url works fine
http://localhost:8000/admin/
when I have this pattern
(r'^admin/(.*)', admin.site.root),
Isn't the regex saying take all characters except a newline?
I doubt there is anything special about admin urls.

Oh wait - I think I see - the whole regex strips away what matches?
So if my URL is
http://localhost:8000/cms/first-story/
This regex r'^cms/(.*)' strips away "cms/first-story/"
and there is nothing left - thereftroe we see
arguments '()' and keyword arguments '{}' not found.

Do I have that at least a bit right?
Many thanks.
PaulE

--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Paulo Köch

Argh! Code in emails sucks. Besides, there was a typo in the previous
email. See http://dpaste.com/15848/

Cheers,
Paulo Köch

--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Paulo Köch

Coder speaks louder. HTH.

#Pseudo code. Not tested nor proven.
class TimeoutTimerPool(object):
  """A pool that tracks a set of users and their active session.
Tipically used as a singleton."""
  from threading import Timer
  def __init__(self):
self.pool = {}
  def expiration_handler(self, session_id, user_id):
#Take action with session_id and/or user_id here
pass
  def register_user_presence(self, session_id, user_id):
"""Tracks user activity/presence. No magic mojo here, must be
called manually (or integrated in some middleware)."""
# Timers can be reset. So, we just dispose the current and create another.
self.unregister_session(session_id)
self.pool[session_id] = Timer(SESSION_TIMEOUT_OR_SOMETHING,
self.expiration_handler, session_id, user_id)
self.pool[session_id].start()
  def untrack_session(self, session_id):
"""Forfeits user tracking. For logouts and such."""
if self.pool.haskey(session_id):
  current_timer = self.pool[session_id]
  if current_timer.isAlive():
current_time.cancel()
  # Don't kow if this is the right way to dispose a Timer
  del self.pool[session_id]

Cheers,
Paulo Köch

--~--~-~--~~~---~--~~
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: Best practices to define model

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 17:24 -0700, Joshua Partogi wrote:
[...]
>  Any drawback from this approach
> you've found so far?

Everything has drawbacks and advantages. This version involves slightly
more typing in settings, for example. And you have another directory to
remember to rollout.

But there are no major drawbacks. This is a very standard pattern for
providing common dependencies in any inheritance- or dependency-based
system (#includes in C, objects in OO languages, apps in Django,
processing stations in factory production lines, etc). There's nothing
radical here.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: Best practices to define model

2009-03-17 Thread Joshua Partogi



On Mar 18, 10:50 am, Malcolm Tredinnick 
wrote:
> On Wed, 2009-03-18 at 10:48 +1100, Joshua Partogi wrote:
> > Dear all,
>
> > Currently I have a project in which the model will be used by several
> > django application. What is the best practice to define this model?
>
> > Let's say I have a category model that will be used from the blog
> > application and also product application. Do we define that model in
> > either one of the application, and the others will call it? Or should
> > we define the category model in every application?
>
> Why not put it in its own application that the other applications can
> all refer to?
>
> You could put it in one or the other of your existing applications if
> having a dependency of "blog" on "product" at the app-level makes sense.
> But I'd put the common stuff into their own application so you don't
> wonder in three months why "blogs" are dependent on "products", when
> they're not the same thing.

That seems to be a very good idea malcolm. So from your experience I
should define an application something like "common" and just define
the common model like category in there, and let other application
that is dependant on it to call it? Any drawback from this approach
you've found so far?

Thank you very much 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-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: TemplateSyntaxError (newbie)

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 16:47 -0700, PaulE wrote:
> All,
> 
> I am
>  - learning python and django simultaneously.
>  - an experienced developer
>  - a bit frustrated
> 
> While working my way through
> "Python Web Development with Django"
> I stumble on a TemplateSyntaxError  when trying to
> view a non admin page at this url:
> http://localhost:8000/cms/first-story/
> The admin is working fine:
> http://localhost:8000/admin
> I am using the code from here
> http://staticfling.net/withdjango.com/static/code/cms.zip
> 
> Though I suspect the problem is a very simple configuration error,
> I am having trouble figuring it out.
> 
> 
> 
> 
> The stack trace is:
> ==
> TemplateSyntaxError at /cms/first-story/
> 
> Caught an exception while rendering: Reverse for 'cms_site.cms-search'
> with arguments '()' and keyword arguments '{}' not found.
> 
> Original Traceback (most recent call last):
>   File "C:\Python25\lib\site-packages\django\template\debug.py", line
> 71, in render_node
> result = node.render(context)
>   File "C:\Python25\lib\site-packages\django\template\defaulttags.py",
> line 378, in render
> args=args, kwargs=kwargs)
>   File "C:\Python25\lib\site-packages\django\core\urlresolvers.py",
> line 254, in reverse
> *args, **kwargs)))
>   File "C:\Python25\lib\site-packages\django\core\urlresolvers.py",
> line 243, in reverse
> "arguments '%s' not found." % (lookup_view, args, kwargs))
> NoReverseMatch: Reverse for 'cms_site.cms-search' with arguments '()'
> and keyword arguments '{}' not found.

This is the important part to look at here (certainly the place to
start). It's saying it can't look up that URL pattern by name to work
out that URL corresponding to it. Notice that it says no parameters
(arguments or keyword arguments) are being passed in.

Now, I can't see all the URL patterns here, but the problem looks like
this:


[...]
> urlpatterns = patterns('',
> # Example:
> # (r'^foo/', include('foo.foo.urls')),
> 
> # Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
> # to INSTALLED_APPS to enable admin documentation:
> # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> 
> # Uncomment the next line to enable the admin:
> (r'^admin/(.*)', admin.site.root),
> (r'^cms/(.*)', include('cms_site.cms.urls')),

Assuming it's inside that include() that the pattern with the "cms-site"
name lives, it's impossible for any of them to match something with no
parameters. The (.*) bit is capturing information in the reg-exp match,
so at least one parameter will be required.

So either the use the url tag in the template is bad or your URL
configuration is.

Regards,
Malcolm


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

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 8:10 PM, Alex Gaynor  wrote:

>
>
> 2009/3/17 Filip Gruszczyński 
>
>>
>> > Are you talking about autocompletion as in what the browser does, or
>> some
>> > sort of Ajax autocompleter.  If it's the format that's handled through
>> an
>> > html autocomplete="off" attribute on the input so you just need to pass
>> that
>> > in the attrs dictionary to a forms widget.  If it's the later you'll
>> need to
>> > roll your own or use a solution out there like this:
>> >
>> http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/
>>
>> I think it's exactly, what I needed. Thanks a lot :-)
>>
>> Any chance such functionality will put directly into DJango in some
>> future releases?
>>
>> --
>> Filip Gruszczyński
>>
>> >>
>>
> Highly unlike at best, the core developers are of the opinion that
> javascript is a client side matter and shouldn't be dictated by your web
> framework.
>
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>

serverside web frameowkr I should say.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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

2009-03-17 Thread Alex Gaynor
2009/3/17 Filip Gruszczyński 

>
> > Are you talking about autocompletion as in what the browser does, or some
> > sort of Ajax autocompleter.  If it's the format that's handled through an
> > html autocomplete="off" attribute on the input so you just need to pass
> that
> > in the attrs dictionary to a forms widget.  If it's the later you'll need
> to
> > roll your own or use a solution out there like this:
> >
> http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/
>
> I think it's exactly, what I needed. Thanks a lot :-)
>
> Any chance such functionality will put directly into DJango in some
> future releases?
>
> --
> Filip Gruszczyński
>
> >
>
Highly unlike at best, the core developers are of the opinion that
javascript is a client side matter and shouldn't be dictated by your web
framework.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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

2009-03-17 Thread Filip Gruszczyński

> Are you talking about autocompletion as in what the browser does, or some
> sort of Ajax autocompleter.  If it's the format that's handled through an
> html autocomplete="off" attribute on the input so you just need to pass that
> in the attrs dictionary to a forms widget.  If it's the later you'll need to
> roll your own or use a solution out there like this:
> http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/

I think it's exactly, what I needed. Thanks a lot :-)

Any chance such functionality will put directly into DJango in some
future releases?

-- 
Filip Gruszczyński

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



TemplateSyntaxError (newbie)

2009-03-17 Thread PaulE

All,

I am
 - learning python and django simultaneously.
 - an experienced developer
 - a bit frustrated

While working my way through
"Python Web Development with Django"
I stumble on a TemplateSyntaxError  when trying to
view a non admin page at this url:
http://localhost:8000/cms/first-story/
The admin is working fine:
http://localhost:8000/admin
I am using the code from here
http://staticfling.net/withdjango.com/static/code/cms.zip

Though I suspect the problem is a very simple configuration error,
I am having trouble figuring it out.




The stack trace is:
==
TemplateSyntaxError at /cms/first-story/

Caught an exception while rendering: Reverse for 'cms_site.cms-search'
with arguments '()' and keyword arguments '{}' not found.

Original Traceback (most recent call last):
  File "C:\Python25\lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
  File "C:\Python25\lib\site-packages\django\template\defaulttags.py",
line 378, in render
args=args, kwargs=kwargs)
  File "C:\Python25\lib\site-packages\django\core\urlresolvers.py",
line 254, in reverse
*args, **kwargs)))
  File "C:\Python25\lib\site-packages\django\core\urlresolvers.py",
line 243, in reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for 'cms_site.cms-search' with arguments '()'
and keyword arguments '{}' not found.

Request Method: GET
Request URL:http://localhost:8000/cms/first-story/
Exception Type: TemplateSyntaxError
Exception Value:

Caught an exception while rendering: Reverse for 'cms_site.cms-search'
with arguments '()' and keyword arguments '{}' not found.

Original Traceback (most recent call last):
  File "C:\Python25\lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
  File "C:\Python25\lib\site-packages\django\template\defaulttags.py",
line 378, in render
args=args, kwargs=kwargs)
  File "C:\Python25\lib\site-packages\django\core\urlresolvers.py",
line 254, in reverse
*args, **kwargs)))
  File "C:\Python25\lib\site-packages\django\core\urlresolvers.py",
line 243, in reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for 'cms_site.cms-search' with arguments '()'
and keyword arguments '{}' not found.

Exception Location: C:\Python25\lib\site-packages\django\template
\debug.py in render_node, line 81
Python Executable:  c:\Python25\python.exe
Python Version: 2.5.4
Python Path:['C:\\dev\\cms_site', 'C:\\Python25', 'C:\\WINDOWS\
\system32\\python25.zip', 'c:\\Python25\\DLLs', 'c:\\Python25\\lib',
'c:\\Python25\\lib\\plat-win', 'c:\\Python25\\lib\\lib-tk', 'c:\
\Python25\\lib\\site-packages', 'c:\\Python25\\lib\\site-packages\
\PIL']
Server time:Tue, 17 Mar 2009 16:33:16 -0700






My settings are:
==
# Django settings for foo project.

DEBUG = True
TEMPLATE_DEBUG = True

ADMINS = (
# ('Your Name', 'your_em...@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2'   #
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'cms' # Or path to database file if using
sqlite3.
DATABASE_USER = 'cms' # Not used with sqlite3.
DATABASE_PASSWORD = 'cms' # Not used with sqlite3.
DATABASE_HOST = 'localhost' # Set to empty string for
localhost. Not used with sqlite3.
DATABASE_PORT = '5432' # Set to empty string for default.
Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'bl$w+bpck...@y$)wk7k#)z%2ohi9fw-*+gojgf9f_k%$$&=c2'

# List of callables that know how to import templates from vario

Re: Best practices to define model

2009-03-17 Thread Malcolm Tredinnick

On Wed, 2009-03-18 at 10:48 +1100, Joshua Partogi wrote:
> Dear all,
> 
> Currently I have a project in which the model will be used by several
> django application. What is the best practice to define this model?
> 
> Let's say I have a category model that will be used from the blog
> application and also product application. Do we define that model in
> either one of the application, and the others will call it? Or should
> we define the category model in every application?

Why not put it in its own application that the other applications can
all refer to?

You could put it in one or the other of your existing applications if
having a dependency of "blog" on "product" at the app-level makes sense.
But I'd put the common stuff into their own application so you don't
wonder in three months why "blogs" are dependent on "products", when
they're not the same thing.

Regards,
Malcolm



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



Best practices to define model

2009-03-17 Thread Joshua Partogi

Dear all,

Currently I have a project in which the model will be used by several
django application. What is the best practice to define this model?

Let's say I have a category model that will be used from the blog
application and also product application. Do we define that model in
either one of the application, and the others will call it? Or should
we define the category model in every application?

Any inputs?

Thank you very much in advance.

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi

--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 23:26 +, Paulo Köch wrote:
> My previous idea was to maintain a Timer pool based on session ids.
> Every time a request with a session hits your server, you reset the
> Timer object associated with it. If a user logs out, you cancel the
> respective timer. If a timer triggers, it's a timeout.
> 
> But, we can try a simpler approach. Assuming you don't need realtime
> audit logs, can you exploit the expired sessions not being
> automatically cleaned up?

Both of these solutions have the same showstopping flaw: There's no way,
on the server side, to associate a timed-out user with their previous
session. Because the web browser doesn't send the session cookie. This
whole "request for an enhancement" is based on wanting Django to act on
information it cannot possibly know about in the first place and your
solution suffers from the same problem.

The only way to work around something like this is to have "never
expire" sessions and manually manage the timing out on the server side.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: Model inheritance vs. User.get_profile()

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 09:49 -0700, ntoll wrote:
> Guys,
> 
> Asking for advice here.
> 
> What is the best way to extend the User class in
> django.contrib.auth.models...?
> 
> I could either inherit the class for my own model and add fields /
> methods or use get_profile(). Now, whilst I realise that get_profile()
> is the official advice it seems a tad out-of-date now that there is
> model inheritance (for which get_profile() provided a means of
> overcoming).

That's not correct. They are two different approaches, with different
functionality.

Once you've created a User instance, you cannot create a subclass
instanced based on the original instance (you can't do it even in
Python, but Django also doesn't provide any way to wrap the database
equivalent, since Django's model inheritance is modeled on Python's).
Whereas you *can* create a user profile object after the fact and it
will be retreived with get_profile().

Since User objects are often created quite separately from profiles
(e.g. through the admin), this means the get_profile() approach is
probably going to be more generally useful.

This has come up a number of times in the past. I wrote a more expansive
reply here, for example:
http://groups.google.com/group/django-users/msg/baa3afd55b14ad68

Regards,
Malcolm




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

2009-03-17 Thread Alex Gaynor
2009/3/17 Filip Gruszczyński 

>
> Does DJango forms provide option of completions? I mean the ones we
> can see in Google recently or in youtube. If not, could you point me
> to the part of the code,where this could be added?
>
> --
> Filip Gruszczyński
>
> >
>
Are you talking about autocompletion as in what the browser does, or some
sort of Ajax autocompleter.  If it's the format that's handled through an
html autocomplete="off" attribute on the input so you just need to pass that
in the attrs dictionary to a forms widget.  If it's the later you'll need to
roll your own or use a solution out there like this:
http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Paulo Köch

My previous idea was to maintain a Timer pool based on session ids.
Every time a request with a session hits your server, you reset the
Timer object associated with it. If a user logs out, you cancel the
respective timer. If a timer triggers, it's a timeout.

But, we can try a simpler approach. Assuming you don't need realtime
audit logs, can you exploit the expired sessions not being
automatically cleaned up?

Cheers,
Paulo Köch



On Tue, Mar 17, 2009 at 20:28, Huuuze  wrote:
>
> Paulo, thank you for the link, but I don't see how that will help.  To
> help articulate the problem, here is a post I included on
> StackOverflow.com:
>
>>> I would like to audit when a user has experienced an idle timeout in my 
>>> Django application. In other words, if the user's session cookie's 
>>> expiration date exceeds the SESSION_COOKIE_AGE found in settings.py, the 
>>> user is redirected to the login page. When that occurs, an audit should 
>>> also occur.
>
>>> Currently, I have configured some middleware to capture these events. 
>>> Unfortunately, Django generates a new cookie when the user is redirected to 
>>> the login page, so I cannot determine if the user was taken to the login 
>>> page via an idle timeout or some other event.
>
>>> From what I can tell, I would need to work with the "django_session" table. 
>>> However, the records in this table cannot be associated with that user 
>>> because the sessionid value in the cookie is reset when the redirect occurs.
>
>>> I'm guessing I'm not the first to encounter this dilemma. Does anyone have 
>>> insight into how to resolve the problem?
>
>
> On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
> wrote:
>> On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
>> > Does anyone else agree with my viewpoints on this matter?  If so,
>> > please post your comments in the ticket.
>>
>> Actually, the right way to get your viewpoint heard is to take the
>> matter to the django-developers mailing list, where topics related to
>> Django's development are discussed. You'll have more luck posting
>> suggestions and criticism there than here or on the ticket tracker.
>>
>> However, please keep in mind that we're currently running up to Django
>> 1.1, so it's likely that anything that's not an outright bug might be
>> left by the wayside while we close bugs for the final release. If you
>> don't get an immediate response, be patient and wait until a bit after
>> the release when we all have a bit more time.
>>
>> Jacob
> >
>

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



Completions

2009-03-17 Thread Filip Gruszczyński

Does DJango forms provide option of completions? I mean the ones we
can see in Google recently or in youtube. If not, could you point me
to the part of the code,where this could be added?

-- 
Filip Gruszczyński

--~--~-~--~~~---~--~~
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: memcached: is this thing plugged in?

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 14:19 -0700, hotani wrote:
[...]
> Is there a way to check memcached to see if it is functioning
> correctly? 

Memcached supports a "stats" command. One way to view it is simply
telnet to the memcache port. For example:

`--> telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
stat
ERROR
stats
STAT pid 6795
STAT uptime 7
STAT time 1237331791
STAT version 1.2.5
STAT pointer_size 32
STAT rusage_user 0.000999
STAT rusage_system 0.003999
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 5
STAT total_connections 6
STAT connection_structures 6
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 13
STAT bytes_written 7
STAT limit_maxbytes 67108864
STAT threads 4
END

I only just started memcached for the purposes of that test, so it's
empty. But you watch the get_hits and get_misses stats, for example, to
see if it's being used.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: Switching database backends at runtime?

2009-03-17 Thread Oliver Beattie

Nope, seems this is actually impossible (at least using manage.py
shell), since it will load all of the models and hold references to
them on initialization until termination, so the settings-definte
backend is tied to BaseQuery forever :(

On Mar 17, 12:01 pm, Oliver Beattie  wrote:
> Thanks for your quick reply :)
>
> Basically, what I want to do has to apply to every query made to the
> database, not just one query. Basically, I want to do a dry-run of
> some things before doing them. Since MySQL doesn't support schema
> alterations inside a transaction, I can't do it that way.
>
> I'm sadly bound to using the release version of Django… so will this
> apply?
>
> On Mar 16, 10:25 pm, Alex Gaynor  wrote:
>
>
>
> > On Mon, Mar 16, 2009 at 6:20 PM, Oliver Beattie  wrote:
>
> > > Does anyone know if it's possible to switch the database backend in
> > > Django at runtime (let's say I want to use dummy for something, but
> > > then switch it back to the original after I'm done).
>
> > > Is this possible using django.db.load_backend or something (I'm
> > > doubting it as I see there is some module-level code in there that
> > > takes info directly from settings).
>
> > > I know it's a bit of a cardinal sin, but would altering settings at
> > > runtime have any effect? Again probably no since there will still be
> > > things pointing to the old backend instance, but worth a shot.
>
> > It sort of depends on what you're trying to do, if you want to work with a
> > queryset using a different database you can do something like 
> > this:http://www.eflorenzano.com/blog/post/easy-multi-database-support-djan...
> > for if you're using django trunk you can use django.db.load_backend
> > and the new DatabaseWrapper constructor(which takes a dict of settings) to
> > do it, instead of futzing with the global settings.
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your right to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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: nested dereferencing of values within value calls in templates

2009-03-17 Thread Malcolm Tredinnick

On Tue, 2009-03-17 at 16:03 -0500, Jay Deiman wrote:
[..].
> Template code:
> ==
> 
> Output "eggs": {{ foo.{{ spam }} }}
> 
> ==
> 
> Is there any way at all to do something like that?

Write a custom filter that takes "spam" as an argument and does the
lookup for you.

[...]
> In the template, while looping through "list1", I want to be able to 
> directly access by index the corresponding value in "list2".  I know the 
> following doesn't work, but again, it seems like there should be a way 
> to do this.  Note that this is a greatly simplified version of what I'm 
> actually trying to accomplish!!

The general plan is to either (a) write a custom template filter to do
this (similar to the last case and use forloop.counter as the argument)
or (b) stop trying to programming in templates and do programming in
your views instead. Arrange the datastructures that are passed to the
templates so that you can retrieve all the data value in a single loop.
Zip the lists together, or write a function that returns the
corresponding elements via an iterator and loop over that.

Django doesn't provide indirect variable references out of the box
intentionally.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: memcached: is this thing plugged in?

2009-03-17 Thread Russell Keith-Magee

On Wed, Mar 18, 2009 at 6:19 AM, hotani  wrote:
>
> The result? No difference. Memcached does not provide any benefit
> according to my testing. I have siege set to log in as a user, then
> hit a single page which makes several db calls. The memcached server
> shows no movement in CPU, memory, or network usage which makes me
> wonder if I even have things set up correctly at all.

Have you actually done anything in your application to utilize
caching? Memcached isn't some sort of fairy dust that you turn on and
your application magically becomes faster - you need to utilize the
cache throughout your application. You mention that you have changed
the cache backend, but you haven't mentioned what you have done in
your application to make it use the cache.

There are lots more details on what you can do here:

http://docs.djangoproject.com/en/dev/topics/cache/

> Is there a way to check memcached to see if it is functioning
> correctly? I tried entering a bogus ip in the CACHE_BACKEND setting in
> settings.py and nothing changed. Django restarted normally with no
> errors.

To check if the cache is working at all, use the low-level cache API.
Launch a Python shell, and try to put a key-value pair into the cache,
then check that you can retrieve the value. The docs for the low-level
cache API should give you an idea of what to run.

http://docs.djangoproject.com/en/dev/topics/cache/#the-low-level-cache-api

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: Model inheritance vs. User.get_profile()

2009-03-17 Thread Dougal Matthews
get_profile is newer than model inheritance I believe.
Working with profile is how everybody seems to be doing it, so follow the
trend and it'll make every bodies lives easier ;)

If you really want to read more about it, there is loads of chatter on the
subject so to avoid reppetition;
http://www.google.co.uk/search?q=django+extending+user (granted, lots of it
is old)

Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/17 ntoll 

>
> Guys,
>
> Asking for advice here.
>
> What is the best way to extend the User class in
> django.contrib.auth.models...?
>
> I could either inherit the class for my own model and add fields /
> methods or use get_profile(). Now, whilst I realise that get_profile()
> is the official advice it seems a tad out-of-date now that there is
> model inheritance (for which get_profile() provided a means of
> overcoming).
>
> Pros/cons of each method? To my mind inheriting from User class is
> more elegant... but would love to know your thoughts on this.
>
> All the best,
>
> ntoll
>
> >
>

--~--~-~--~~~---~--~~
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 first app doubt

2009-03-17 Thread Jacob Kaplan-Moss

> I suspect it might be a bug with a change in Django I made today --
> are you running Django out of SVN?

Er, no, the bug I thought was there isn't. Still, it'll always help to
tell us what version of Django you're running.

Jacob

--~--~-~--~~~---~--~~
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 first app doubt

2009-03-17 Thread Jacob Kaplan-Moss

On Tue, Mar 17, 2009 at 12:53 PM, Gustavo Senise
 wrote:
> I am trying to access http://localhost:8000/polls/admin/ and getting a error
> 'MediaDefiningClass' object is not iterable.
>
> Can anyone help!?

Can you post the full traceback?

I suspect it might be a bug with a change in Django I made today --
are you running Django out of SVN?

Jacob

--~--~-~--~~~---~--~~
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 first app doubt

2009-03-17 Thread Gustavo Senise
Hello fellows,

I am starting the django first app and I am having a little trouble trying
to understand why the admin area is not working after I changed the views to
the Generic Views. Well, I can't access the admin area anymore.

It seems that the tutorial doesn't cover the url for admin after splitting
the url file.

I am trying to access http://localhost:8000/polls/admin/ and getting a error
'MediaDefiningClass' object is not iterable.

Can anyone help!?

Thanks,
-- 
Gustavo

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



Model inheritance vs. User.get_profile()

2009-03-17 Thread ntoll

Guys,

Asking for advice here.

What is the best way to extend the User class in
django.contrib.auth.models...?

I could either inherit the class for my own model and add fields /
methods or use get_profile(). Now, whilst I realise that get_profile()
is the official advice it seems a tad out-of-date now that there is
model inheritance (for which get_profile() provided a means of
overcoming).

Pros/cons of each method? To my mind inheriting from User class is
more elegant... but would love to know your thoughts on this.

All the best,

ntoll

--~--~-~--~~~---~--~~
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 can i access UserProfile from User in the views?

2009-03-17 Thread ntoll

{{ user.get_profile.home_address }} should do the trick.

On Mar 17, 4:46 pm, Paolo Corti  wrote:
> Hi
> I know is easy to access to the UserProfile, like here:
>
> from django.contrib.auth.models import User
> u = User.objects.get(pk=1) # Get the first user in the system
> user_address = u.get_profile().home_address
>
> but is there a way to access to UserProfile in the view?
> supposing the UserProfile model is called myprofile, this will not do
> the trick:
>
> {{ user.myprofile.home_address }}
>
> any advice? Thanks

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



Re: Django Admin Titles

2009-03-17 Thread AKK

Thanks, thats worked fine. I don't know why my original message has
reproduced itself.

Regards,

Andrew
--~--~-~--~~~---~--~~
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 Admin Titles

2009-03-17 Thread AKK

Hi,

I've got the django adming setup but if i look at posts for example i
just get a with post object loads of times. How can i it so it
displays the post title?

In my admin.py i have:

admin.site.register(Post)

and the model is:

 post_title = models.CharField(max_length=750)
.
 post_tags = models.ManyToManyField(Tag)

   def _str_(self):
return self.post_title

if i had to guess i imangine this would be sommet to do with def_str_

thanks,

Andrew
--~--~-~--~~~---~--~~
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: Typo for Django or Like?

2009-03-17 Thread James Matthews
Sure,

Typo is a blogging platform/cms (Like wordpress). I know about Django-cms
and I am wondering if there are any others?

Thanks
James

On Wed, Mar 18, 2009 at 12:02 AM, Alex Gaynor  wrote:

>
>
> On Tue, Mar 17, 2009 at 5:59 PM, James Matthews wrote:
>
>> Hi,
>>
>> I have been using Django now for a while. I am wondering if there are any
>> applications like Typo for RoR in Django or you have to write it by
>> yourself.
>>
>> Thanks
>> James
>>
>> --
>> http://www.astorandblack.com
>>
>>
>>
> Most of us aren't RoR developers so we don't really know what that is, can
> you provide a description of what it is your looking for?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>


-- 
http://www.goldwatches.com/

http://www.jewelerslounge.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: Typo for Django or Like?

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 5:59 PM, James Matthews  wrote:

> Hi,
>
> I have been using Django now for a while. I am wondering if there are any
> applications like Typo for RoR in Django or you have to write it by
> yourself.
>
> Thanks
> James
>
> --
> http://www.astorandblack.com
>
> >
>
Most of us aren't RoR developers so we don't really know what that is, can
you provide a description of what it is your looking for?

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Typo for Django or Like?

2009-03-17 Thread James Matthews
Hi,

I have been using Django now for a while. I am wondering if there are any
applications like Typo for RoR in Django or you have to write it by
yourself.

Thanks
James

-- 
http://www.astorandblack.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: Setting up Facebook Connect for your test environment

2009-03-17 Thread Roboto

thanks I'll try.

Looks like they don't allow sandbox type environments yet.

On Mar 17, 9:56 am, Chris Scott  wrote:
> On Mar 17, 2009, at 8:43 AM, Roboto wrote:
>
>
>
> > Hey guys,
>
> > I'm trying to get facebook connect to work on my django site.  I've
> > hit a little snag where I imagine many of you just walked passed, but
> > I'm clueless right now.
>
> > My runserver runs on localhost:8000  --- but when I setup facebook
> > connect the app is looking for http:///xd_receiver
>
> > Any ideas how I jump this hurdle?
>
> You can edit this in the FB app settings (on the FB developer's  
> site).  When you edit the app settings, choose the Connect tab on the  
> left and then update the Connect URL in the first section.
>
> I'm not familiar w/the django app for this, but some FB Connect  
> integration apps use the API to set the Connect URL for you based on  
> either a settings file or automagic so if that setting keeps getting  
> overwritten after you save it manually that may be the reason.
>
>
>
> > Thanks
>
> > Actual error message below
> > Invalid Argument
>
> > The Facebook Connect cross-domain receiver URL (http://localhost:8000/
> > xd_receiver.htm#fname=_opener&%7B%22t%22%3A3%2C%22h%22%3A
> > %22fbCancelLogin%22%2C%22sid%22%3A%220.982%22%7D) must have the
> > application's Connect URL (http://www.) as a prefix. You can
> > configure the Connect URL in the Application Settings Editor.
>
> --
> Chris Scotthttp://iamzed.com/http://hailtheale.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: Django Admin Titles

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 5:27 PM, AKK  wrote:

>
> Hi,
>
> I've got the django adming setup but if i look at posts for example i
> just get a with post object loads of times. How can i it so it
> displays the post title?
>
> In my admin.py i have:
>
> admin.site.register(Post)
>
> and the model is:
>
>  post_title = models.CharField(max_length=750)
> .
>  post_tags = models.ManyToManyField(Tag)
>
>   def _str_(self):
>return self.post_title
>
> if i had to guess i imangine this would be sommet to do with def_str_
>
> thanks,
>
> Andrew
> >
>
You have def _str_ it should be __str__(2 underscores before and after),
also if you're on 1.0 you should probably be using __unicode__ instead).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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

2009-03-17 Thread AKK

Hi,

I've got the django adming setup but if i look at posts for example i
just get a with post object loads of times. How can i it so it
displays the post title?

In my admin.py i have:

admin.site.register(Post)

and the model is:

 post_title = models.CharField(max_length=750)
.
 post_tags = models.ManyToManyField(Tag)

   def _str_(self):
return self.post_title

if i had to guess i imangine this would be sommet to do with def_str_

thanks,

Andrew
--~--~-~--~~~---~--~~
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 critter helps us code at the speed of light.

2009-03-17 Thread Eric Walstad

On Mar 16, 10:00 am, Klowner  wrote:
> That's just awesome.
>
> Quick and dirty 3D version done in blender 
> :)http://img.skitch.com/20090316-82bsdnfjm15xarx3t9c1e4a7q9.png
>
> - Mark
Lucinda says: "I really like the 3D version; it's brilliant."
-ew
--~--~-~--~~~---~--~~
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: Models and select

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 5:13 PM, Juan Hernandez wrote:

> Hi there:
>
> I have this model for example
>
> class Categories(models.Model):
> name = models.CharField(max_length=30)
>
> which holds this data on the DB
>
> ++--+
> | id | name |
> ++--+
> |  1 | Musica   |
> |  2 | Programacion |
> |  3 | Libros   |
> |  4 | Politica |
> |  5 | Humor|
> |  6 | Basura   |
> |  7 | Varios   |
>
> How come now, everytime I create a form with either this
>
> class PostForm(ModelForm):
> post = forms.CharField(widget=forms.Textarea({'rows': '20', 'cols':
> '75'}))
> class Meta:
> model = Post
> exclude = 'id'
>
> or this
>
>
> class CategoriesForm(forms.Form):
> categories = forms.ModelChoiceField(queryset=Categories.objects.all())
>
>
> It shows this HTML output on the select field?
>
> Categories:
>
> 
>
> -
>
> Categories object
> Categories object
>
> Categories object
> Categories object
>
> Categories object
>
> Categories object
> Categories object
>
> 
>
> What is going on here? Am I missing something now? I've been doing this for
> a long time and I guess I forgot something
>
> >
>
By default it uses the __unicode__ method to show the output.  So either
define __unicode__ on the Post class, or do what's described here:
http://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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: objects.filter (calling a method) ?

2009-03-17 Thread arbi

Ok thanks,
But it would be great to have such things implemented in Django!

On 17 mar, 22:13, Alex Gaynor  wrote:
> On Tue, Mar 17, 2009 at 5:06 PM, arbi  wrote:
>
> > Hi,
>
> > I would like to do something like that, but I don't know if I can (I
> > didn't find it on djangoproject.com) :
>
> > Here is myClass :
>
> > myClass:
> >  def __init__(self) :
> >       ...
> >      
> >  def similiarity_to(other_object) :
> >      return an integer
>
> > And somewhere in my view I want to do :
> > MyClass.objects.filter(similarity_to(some_object) >0 )
>
> > Is it possible to do so, meaning calling a method in filter?
> > Thx
>
> > Arbi
>
> No, there's no way to do pure python filtering using the filter() method.
> If you want you can do it using the Python filter function: qs =
> filter(lambda obj: obj.method() > 0, qs).  But remember that will need to
> pull in all possible records from the DB to do that filtering.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



memcached: is this thing plugged in?

2009-03-17 Thread hotani

I have a test server which is running the db and django app (apache/
mod_python). Before moving to production, I'm running stress tests and
optimizing performance. My plan is to optimize on the test box, see
what works, then implement these on production which is separate db
and app servers.

Here's what I did today to test memcached:
- ran stress test using siege before installing memcached
- installed memcached on separate machine, opened port 11211, started
daemon
- pointed test server to memcached box using method in django docs
- restarted apache/django on test box
- ran siege again (a few times just to be sure)

The result? No difference. Memcached does not provide any benefit
according to my testing. I have siege set to log in as a user, then
hit a single page which makes several db calls. The memcached server
shows no movement in CPU, memory, or network usage which makes me
wonder if I even have things set up correctly at all.

Is there a way to check memcached to see if it is functioning
correctly? I tried entering a bogus ip in the CACHE_BACKEND setting in
settings.py and nothing changed. Django restarted normally with no
errors.
--~--~-~--~~~---~--~~
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: RelatedObject Cache

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 5:08 PM, Andrew Fong  wrote:

>
> Hello all,
>
> Quick question. Given these models ...
>
> class A(models.Model): pass
>
> class B(models.Model):
>  model_a = models.ForeignKey(A)
>
> ... getting the model_a attribute on an instance of B will result in
> that related object being cached. So the question: given an instance
> of B, how do I know whether the related object has already been
> cached?
>
> Been looking through the source code, but I can't find where
> related_objects are stored. Thanks in advance to anyone who can help!
>
> -- Andrew
> >
>
The code to calculate the cache is here:
http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/__init__.py#L171it's
a lot to follow but it gets used in
ReverseSingleRelatedObjectDescriptor which calls self.field.get_cache_name()
which ForeignKey inherits from Field.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



filter calling a method?

2009-03-17 Thread arbi

Hi,

My message seems to have been deleted (I have just wrote it, I don't
understand!)
So, I want to do this, but I can't find it in Django :

Here is MyClass

MyClass :
   def __init__(self) :
  ...
  ...

   def similarity_to(self, other_object) :
  return integer

I want to tell in my view something like :

MyClass.objects.filter ( similarity_to(some_object) > 0 )
Is it possible in Django to call methods in "filter"?
Thx!

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



Models and select

2009-03-17 Thread Juan Hernandez
Hi there:

I have this model for example

class Categories(models.Model):
name = models.CharField(max_length=30)

which holds this data on the DB

++--+
| id | name |
++--+
|  1 | Musica   |
|  2 | Programacion |
|  3 | Libros   |
|  4 | Politica |
|  5 | Humor|
|  6 | Basura   |
|  7 | Varios   |

How come now, everytime I create a form with either this

class PostForm(ModelForm):
post = forms.CharField(widget=forms.Textarea({'rows': '20', 'cols':
'75'}))
class Meta:
model = Post
exclude = 'id'

or this


class CategoriesForm(forms.Form):
categories = forms.ModelChoiceField(queryset=Categories.objects.all())


It shows this HTML output on the select field?

Categories:

-
Categories object
Categories object
Categories object
Categories object

Categories object
Categories object
Categories object


What is going on here? Am I missing something now? I've been doing this for
a long time and I guess I forgot something

--~--~-~--~~~---~--~~
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: objects.filter (calling a method) ?

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 5:06 PM, arbi  wrote:

>
> Hi,
>
> I would like to do something like that, but I don't know if I can (I
> didn't find it on djangoproject.com) :
>
> Here is myClass :
>
> myClass:
>  def __init__(self) :
>   ...
>  
>  def similiarity_to(other_object) :
>  return an integer
>
> And somewhere in my view I want to do :
> MyClass.objects.filter(similarity_to(some_object) >0 )
>
> Is it possible to do so, meaning calling a method in filter?
> Thx
>
> Arbi
> >
>
No, there's no way to do pure python filtering using the filter() method.
If you want you can do it using the Python filter function: qs =
filter(lambda obj: obj.method() > 0, qs).  But remember that will need to
pull in all possible records from the DB to do that filtering.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



RelatedObject Cache

2009-03-17 Thread Andrew Fong

Hello all,

Quick question. Given these models ...

class A(models.Model): pass

class B(models.Model):
  model_a = models.ForeignKey(A)

... getting the model_a attribute on an instance of B will result in
that related object being cached. So the question: given an instance
of B, how do I know whether the related object has already been
cached?

Been looking through the source code, but I can't find where
related_objects are stored. Thanks in advance to anyone who can help!

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



objects.filter (calling a method) ?

2009-03-17 Thread arbi

Hi,

I would like to do something like that, but I don't know if I can (I
didn't find it on djangoproject.com) :

Here is myClass :

myClass:
  def __init__(self) :
   ...
  
  def similiarity_to(other_object) :
  return an integer

And somewhere in my view I want to do :
MyClass.objects.filter(similarity_to(some_object) >0 )

Is it possible to do so, meaning calling a method in filter?
Thx

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



nested dereferencing of values within value calls in templates

2009-03-17 Thread Jay Deiman

Ok, I'm wondering if there is any way to do this.  Let me give a couple 
of ***simplified*** examples to clarify what I'm talking about here.  I 
make "simplified" previously apparent because what I'm actually trying 
to do is much more complicated than these examples.

View code:
==

return render_to_response('/path/to/html' , {
 'foo': {'bar': 'eggs'} ,
 'spam': 'bar' ,
})

==

Now, in my template I want to access {{ foo.bar }} via the dereferenced 
*value* of "spam".  Essentially, though I know this doesn't work, it 
would look like this:

Template code:
==

Output "eggs": {{ foo.{{ spam }} }}

==

Is there any way at all to do something like that?

Here is another example, though I already know a workaround for it (at 
the bottom), it seems like there should be a better way.

View code:
==

list1 = ['one' , 'two' , 'three']
list2 = [1 , 2 , 3]
return render_to_response('/path/to/html' , {
 'list1': list1 ,
 'list2': list2 ,
})

==

In the template, while looping through "list1", I want to be able to 
directly access by index the corresponding value in "list2".  I know the 
following doesn't work, but again, it seems like there should be a way 
to do this.  Note that this is a greatly simplified version of what I'm 
actually trying to accomplish!!

Template code:
==

{% for item in list1 %}
   {{ item }}: {{ list2.{{ forloop.counter0 }} }}
{% endfor %}

==

Now, I know I can accomplish the above with a highly inefficient nested 
loop:

Template code:
==

{% for item in list1 %}
   {{ item }}:
 {% for item2 in list2 %}
   {% ifequal forloop.counter0 forloop.parentloop.counter0 %}
 {{ item2 }}
   {% endifequal %}
 {% endfor %}
{% endfor %}

==

Essentially, is there any way of performing a nested dereference 
operation like these?

Jay

-- 
Jay Deiman

\033:wq!

--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Huuuze

Paulo, thank you for the link, but I don't see how that will help.  To
help articulate the problem, here is a post I included on
StackOverflow.com:

>> I would like to audit when a user has experienced an idle timeout in my 
>> Django application. In other words, if the user's session cookie's 
>> expiration date exceeds the SESSION_COOKIE_AGE found in settings.py, the 
>> user is redirected to the login page. When that occurs, an audit should also 
>> occur.

>> Currently, I have configured some middleware to capture these events. 
>> Unfortunately, Django generates a new cookie when the user is redirected to 
>> the login page, so I cannot determine if the user was taken to the login 
>> page via an idle timeout or some other event.

>> From what I can tell, I would need to work with the "django_session" table. 
>> However, the records in this table cannot be associated with that user 
>> because the sessionid value in the cookie is reset when the redirect occurs.

>> I'm guessing I'm not the first to encounter this dilemma. Does anyone have 
>> insight into how to resolve the problem?


On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
wrote:
> On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> > Does anyone else agree with my viewpoints on this matter?  If so,
> > please post your comments in the ticket.
>
> Actually, the right way to get your viewpoint heard is to take the
> matter to the django-developers mailing list, where topics related to
> Django's development are discussed. You'll have more luck posting
> suggestions and criticism there than here or on the ticket tracker.
>
> However, please keep in mind that we're currently running up to Django
> 1.1, so it's likely that anything that's not an outright bug might be
> left by the wayside while we close bugs for the final release. If you
> don't get an immediate response, be patient and wait until a bit after
> the release when we all have a bit more time.
>
> Jacob
--~--~-~--~~~---~--~~
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: Lookup across relations

2009-03-17 Thread 3xM

On Mar 16, 5:29 pm, Matías Costa  wrote:

> BTW,  this is Django 1.0, I had to rename your maxlength field parameter to
> max_length. Are you using 0.96?

Yes I am... 0.96 is what comes with Ubuntu 8.04 LTS.

I'll upgrade to Ubuntu 8.10 (with django 1.0) as soon as possible and
get back to tell if solved the problem.

Sorry for wasting your time if this is what is wrong.

--

Mikkel
--~--~-~--~~~---~--~~
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 bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Paulo Köch

Taking the lead from
http://www.artfulcode.net/articles/threading-django/ I would sugest
you use a Timer object
(http://www.python.org/doc/2.5.2/lib/timer-objects.html).

DISCLAIMER: Careful! I haven't tested this! A Timer object uses a
thread internally. Be careful with synchronization and related stuff.

HTH.
Cheers,
Paulo Köch

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



Select multiple db items and print

2009-03-17 Thread bsisco

i know that this is probably a RTFM situation but i've been through it
and can't seem to find what i'm looking for.  i would like to be able
to have a table very similar to the change_list in the admin.  within
that table i would like to be able to select multiple records via
checkboxes then print the selected records.  if someone could point me
in the right direction on this i would greatly appreciate it.

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: Conditional row coloring in django-admin changelist --SOLVED

2009-03-17 Thread bsisco

ok...i figured it out.  i added the following to the
change_llist_results.html template and it worked like a charm:

{% for result in results %}

  $(document).ready(function(){
  var column = 12
  $('img[alt="1"]').parent().filter('td:nth-child('+ (column)
+')').parent().css("background","#9FFF9F");
  });

{% for item in result %}{{ item|
truncatewords_html:3 }}{% endfor %}
{% endfor %}

On Mar 16, 8:58 am, "Blake M. Sisco"  wrote:
> one thing that i should point out is that the column is "prettified" so it
> uses the "on" image instead of the value of the db field.  don't know if
> this makes a difference or not cuz the value is the img alt.
> Blake M. Sisco
> LOR Manufacturing Co., Inc
> Web Presence • Graphic Designwww.lormfg.com
> (866) 644-8622
> (888) 524-6292 FAX
>
> The information transmitted by Blake Sisco herewith is intended only for the
> person or entity to which it is addressed and may contain confidential
> and/or privileged material.  Any review, retransmission, dissemination or
> other use of, or taking of any action in reliance upon, this information by
> persons or entities other than the intended recipient is prohibited.  If you
> received this in error, please contact the sender and delete the material
> from any computer
>
> On Mon, Mar 16, 2009 at 8:55 AM, Blake M. Sisco wrote:
>
> > okmy jquery knowledge is severely lacking and I can't figure out how
> > the heck to get this to work...i've spent the last 2+ hours on it :-/  Could
> > you give me an example of how i would set this up?
> > Blake M. Sisco
> > LOR Manufacturing Co., Inc
> > Web Presence • Graphic Design
> >www.lormfg.com
> > (866) 644-8622
> > (888) 524-6292 FAX
>
> > The information transmitted by Blake Sisco herewith is intended only for
> > the person or entity to which it is addressed and may contain confidential
> > and/or privileged material.  Any review, retransmission, dissemination or
> > other use of, or taking of any action in reliance upon, this information by
> > persons or entities other than the intended recipient is prohibited.  If you
> > received this in error, please contact the sender and delete the material
> > from any computer
>
> > On Mon, Mar 16, 2009 at 6:43 AM, Blake M. Sisco 
> > wrote:
>
> >> Malcom,
> >> awesome i'll give it a try this morning and let you know how it
> >> workedthanks a ton
>
> >> Blake M. Sisco
> >> LOR Manufacturing Co., Inc
> >> Web Presence • Graphic Design
> >>www.lormfg.com
> >> (866) 644-8622
> >> (888) 524-6292 FAX
>
> >> The information transmitted by Blake Sisco herewith is intended only for
> >> the person or entity to which it is addressed and may contain confidential
> >> and/or privileged material.  Any review, retransmission, dissemination or
> >> other use of, or taking of any action in reliance upon, this information by
> >> persons or entities other than the intended recipient is prohibited.  If 
> >> you
> >> received this in error, please contact the sender and delete the material
> >> from any computer
>
> >> On Fri, Mar 13, 2009 at 8:05 PM, Malcolm Tredinnick <
> >> malc...@pointy-stick.com> wrote:
>
> >>> On Fri, 2009-03-13 at 15:39 -0400, Blake M. Sisco wrote:
> >>> > Here's my problem.  I have set up a django app for my company to make
> >>> > it easier for our warranty manager to track warranties.  It's working
> >>> > great (it's the first thing I've done w/ django and I love it) with
> >>> > one exception.  I have a boolean field (recieved_vendor) in my
> >>> > warranty model that, when checked, needs to modify the row color in
> >>> > the change_list view so he knows that we have received the product
> >>> > back from our vendor.  I've been through everything (docs, groups,
> >>> > irc) that I can think of, all to no avail. I apologize if this is a
> >>> > very noobish question, but hey, I'm a relative django virgin here.
> >>> > Any help or insight you guys/gals could give would be greatly
> >>> > appreciated...
>
> >>> Out-of-the-box, this isn't an option that exists.
>
> >>> However, it wouldn't be particularly tricky to implement with something
> >>> like jQuery or other preferred Javascript library of choice: when the
> >>> document DOM is ready, iterate through the rows in the table and change
> >>> the CSS property on the tr element if the boolean widget is checked. In
> >>> jQuery it's just about a one-line, in fact.
>
> >>> Regards,
> >>> Malcolm
--~--~-~--~~~---~--~~
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 critter helps us code at the speed of light.

2009-03-17 Thread Eric Walstad

On Mar 15, 8:56 am, mrts  wrote:
> I takes a brave man to identify himself with the grrly Pony, so thumbs
> up to everybody who have that much bravado in themselves :)
>
> I don't, therefore I'm all for the critter and my (styled) take is
> here:http://mrts-foo.appspot.com/
>
> (Created with Inkscape, but Illustrator is also able to open SVGs).
Nice work.  It is really cool to see interest in Lucinda's work and to
build and improve upon it.
Thanks!
Eric.


--~--~-~--~~~---~--~~
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 critter helps us code at the speed of light.

2009-03-17 Thread Eric Walstad

On Mar 16, 5:29 pm, Scott Lyons  wrote:
> Based on mrts' drawings, I made two backgrounds. I'm open to
> suggestions or requests.
>
> http://www.flickr.com/photos/damagedgenius/3361587194/
>
> and
>
> http://www.flickr.com/photos/damagedgenius/3361587300/in/photostream/
Excellent!
A version without the halo would be really nice, too.

Thanks,

Eric.
--~--~-~--~~~---~--~~
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 critter helps us code at the speed of light.

2009-03-17 Thread Eric Walstad

On Mar 16, 11:00 am, Klowner  wrote:
> Quick and dirty 3D version done in blender 
> :)http://img.skitch.com/20090316-82bsdnfjm15xarx3t9c1e4a7q9.png
Oooh, very cool!
--~--~-~--~~~---~--~~
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 can i access UserProfile from User in the views?

2009-03-17 Thread Andy Mckay


On 17-Mar-09, at 10:36 AM, Paolo Corti wrote:

> if i use this in the template i get this error: Caught an exception
> while rendering: Cannot resolve keyword 'user' into field

So it has no variable user, that has nothing to do with the rest of  
your problem.

If you use request context then you will get the user available:

http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#django-core-context-processors-auth
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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: FIXED: Can't run django on Apache

2009-03-17 Thread Bro

Hi

I've installed Django 1.02 on my dedibox. I'm trying to make .py file
readable and executable.
Apache, Python, Django are installed.
We have many website :
/var/www/mysite1
/var/www/mysite2
/var/www/mysite3

we have :
/var/django/mysite1
/var/django/mysite2

We configure in /etc/apache2/site-available/mysite1 :

--

ServerAdmin webmas...@localhost
ServerName mysite1.com
ServerAlias mysite1.com www.mysite1.fr mysite1.fr

DocumentRoot /var/www/mysite1/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all




SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite1.settings
PythonOption django.root /var/django/mysite1
PythonPath "['/var/django/', '/var/www'] + sys.path"
PythonDebug On


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error,
crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128



--

But when we go in this url : mysite1.com
We get this error


MOD_PYTHON ERROR

ProcessId:  14693
Interpreter:mysite.com'

ServerName: 'mysite.com'
DocumentRoot:   '/var/www/mysite/'

URI:'/'
Location:   '/'
Directory:  None
Filename:   '/var/www/mysite/'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)

  File "/var/lib/python-support/python2.5/django/core/handlers/
modpython.py", line 228, in handler
return ModPythonHandler()(req)

  File "/var/lib/python-support/python2.5/django/core/handlers/
modpython.py", line 191, in __call__
self.load_middleware()

  File "/var/lib/python-support/python2.5/django/core/handlers/
base.py", line 44, in load_middleware
raise exceptions.ImproperlyConfigured, 'Middleware module "%s"
does not define a "%s" class' % (mw_module, mw_classname)

ImproperlyConfigured: Middleware module
"django.contrib.flatpages.middleware" does not define a
"FlatpageFallbackMiddlewar" class

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



Re: Django book mostly done?

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 1:47 PM, waltbrad  wrote:

>
> I happened to visit the Django Book site 2.0   It still says that it's
> not complete, but it seems to cover everything the 1.0 did except for
> deployment and the Appendices.  Could a person get a pretty good
> grounding in django now by reading 2.0?  I guess what I mean is that
> for the past few months it's been suggested to go through the tutorial
> and the documentation rather than the django book.  But, is the 2.0
> book a good starting place now?
>
> Can't really say I'm a noob at this point, I've been through about 4
> different books on django. But, I still feel as though I don't have as
> thorough an overview as I'd like to have.
> >
>
Adrian just put the last batch of chapters online, so I believe all the
content is now up.  Having skimmed most of it I can say it looks really good
and I'm sure it basically all works, that said it isn't a final addition so
there may be tiny errors, typos, or other mistakes.  I wouldn't have a
problem reading through that(I originally learned from the original book
before it was published).  If you haven't already I would take a look at the
official django docs/tutorial, they really are quite good :).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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: Numbering of items in template

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 1:48 PM, Jacob Kaplan-Moss <
jacob.kaplanm...@gmail.com> wrote:

>
> On Tue, Mar 17, 2009 at 12:46 PM, Jesse  wrote:
> > I'm please to know of such a tag.  Do you know of a good example of
> > how it is used with the sum filter?  Otherwise, I will try.
>
> I don't know why you'd need the sum filter; the for tag does
> everything you'd want. See
> http://docs.djangoproject.com/en/1.0/ref/templates/builtins/#for for
> details of the {% for %} tag. You want something like::
>
> {% for record in record_list %}
>{{ forloop.counter }}: {{ record }}
> {% endfor %}
>
> Jacob
>
> >
>
Jacob, if I understand the issue is that on the 2nd page he wants to start
the count at 101, not 1.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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: Numbering of items in template

2009-03-17 Thread Jacob Kaplan-Moss

On Tue, Mar 17, 2009 at 12:46 PM, Jesse  wrote:
> I'm please to know of such a tag.  Do you know of a good example of
> how it is used with the sum filter?  Otherwise, I will try.

I don't know why you'd need the sum filter; the for tag does
everything you'd want. See
http://docs.djangoproject.com/en/1.0/ref/templates/builtins/#for for
details of the {% for %} tag. You want something like::

{% for record in record_list %}
{{ forloop.counter }}: {{ record }}
{% endfor %}

Jacob

--~--~-~--~~~---~--~~
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: Numbering of items in template

2009-03-17 Thread Jesse

I'm please to know of such a tag.  Do you know of a good example of
how it is used with the sum filter?  Otherwise, I will try.

Thanks!

On Mar 17, 9:51 am, Alex Koshelev  wrote:
> You can use `forloop.counter` with `sum` filter. Or use `ol` html tag
> with proper `start` attribute.
>
> On Tue, Mar 17, 2009 at 7:47 PM, Jesse  wrote:
>
> > Hello,
>
> > I've finally gotten pagination to work.  Now I would like to add a
> > sequential number to the beginning of each record in the output.  In
> > previous languages I used something like count=count+1 and then placed
> > count at the beginning of each record output in the template.  How is
> > a record count created in django that can be displayed at the
> > beginning of each record in the template?
>
> > If I use  the count starts over again for each page under
> > pagination.  I need to be able to label records 1 - 100 across several
> > pages.
> > 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
-~--~~~~--~~--~--~---



Django book mostly done?

2009-03-17 Thread waltbrad

I happened to visit the Django Book site 2.0   It still says that it's
not complete, but it seems to cover everything the 1.0 did except for
deployment and the Appendices.  Could a person get a pretty good
grounding in django now by reading 2.0?  I guess what I mean is that
for the past few months it's been suggested to go through the tutorial
and the documentation rather than the django book.  But, is the 2.0
book a good starting place now?

Can't really say I'm a noob at this point, I've been through about 4
different books on django. But, I still feel as though I don't have as
thorough an overview as I'd like to have.
--~--~-~--~~~---~--~~
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 can i access UserProfile from User in the views?

2009-03-17 Thread Paolo Corti

Hello Andy

>
> Do you mean in the template?

yes, sorry...

>
> I don't use Django templating but have you tried:
>
> user.get_profile.home_address
>

if i use this in the template i get this error: Caught an exception
while rendering: Cannot resolve keyword 'user' into field

thanks anyway

--~--~-~--~~~---~--~~
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 can i access UserProfile from User in the views?

2009-03-17 Thread Andy Mckay


On 17-Mar-09, at 9:46 AM, Paolo Corti wrote:
> from django.contrib.auth.models import User
> u = User.objects.get(pk=1) # Get the first user in the system
> user_address = u.get_profile().home_address
>
> but is there a way to access to UserProfile in the view?

Do you mean in the template?

The view is python and you can access the profile just as you do so

> supposing the UserProfile model is called myprofile, this will not do
> the trick:
>
> {{ user.myprofile.home_address }}

I don't use Django templating but have you tried:

user.get_profile.home_address

Not sure why you'd be using myprofile there where in python you used  
get_profile.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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: FIXED: Can't run django on Apache

2009-03-17 Thread Bro

The result is :


 SetHandler python-program
 PythonHandler django.core.handlers.modpython
 SetEnv DJANGO_SETTINGS_MODULE mysite.settings
 PythonOption django.root /home/rex/django/mturk
 PythonDebug On
 PythonPath "['/home/rex/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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with formsets and uploading of files

2009-03-17 Thread motard

I found the error in this post:
http://groups.google.com/group/django-users/browse_thread/thread/adf591a15786ca98

Feel a bit embarrassed...

Wasn't setting the enctype attribute in my form html tag...

Regards, Stefan

On 17 mar, 17:06, Alex Gaynor  wrote:
> On Tue, Mar 17, 2009 at 11:09 AM, Stefan Tunsch  wrote:
>
> > Hi!
>
> > I am having trouble getting a formset to work and handling the uploaded
> > files.
>
> > First of all, let me say that it's the first time I'm working with
> > formsets.
> > I've also never before tried to upload files.
> > It is possible that I might be misunderstanding some basic stuff...
>
> > My scenario is the following:
>
> > I have a form with one FileField:
>
> > class AttachmentForm(forms.Form):
> >    myfile = forms.FileField(required=False)
>
> > In my views.py file i do the following:
>
> > from django.forms.formsets import formset_factory
> > AttachmentFormSet = formset_factory(AttachmentForm, extra=3)
>
> > if request.method == 'POST':
> >    attachmentset = HoraAdjuntoFormSet(request.POST, request.FILES)
> >    if attachmentset.is_valid:
> >        #This is when things start to be awkward
> >        print len(request.FILES) #returns zero
> >        print len(attachmentset.cleaned_data) #returns 3, which is correct
> >        for cd in attachmentset.cleaned_data:
> >            print cd #Returns 3 empty dictionary {}
>
> > Any help will be appreciated.
>
> > Regards, Stefan
>
> You should be calling `is_valid` as it's a function, not a property:
> attachmentset.is_valid()
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
--~--~-~--~~~---~--~~
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: TemplateDoesNotExist

2009-03-17 Thread TP

Still stuck on this.

The tutorial says:

Put the following code in that template:

{% if latest_poll_list %}

{% for poll in latest_poll_list %}
{{ poll.question }}
{% endfor %}

{% else %}
No polls are available.
{% endif %}


by the template does it meant the index.html file?
--~--~-~--~~~---~--~~
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: Numbering of items in template

2009-03-17 Thread Alex Koshelev

You can use `forloop.counter` with `sum` filter. Or use `ol` html tag
with proper `start` attribute.


On Tue, Mar 17, 2009 at 7:47 PM, Jesse  wrote:
>
> Hello,
>
> I've finally gotten pagination to work.  Now I would like to add a
> sequential number to the beginning of each record in the output.  In
> previous languages I used something like count=count+1 and then placed
> count at the beginning of each record output in the template.  How is
> a record count created in django that can be displayed at the
> beginning of each record in the template?
>
> If I use  the count starts over again for each page under
> pagination.  I need to be able to label records 1 - 100 across several
> pages.
> 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: static files protect access

2009-03-17 Thread alain31

Got it, thanks. For  Apache, I found a clear tutorial :
http://codeutopia.net/blog/2009/03/06/sending-files-better-apache-mod_xsendfile-and-php/

Alain.

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



Numbering of items in template

2009-03-17 Thread Jesse

Hello,

I've finally gotten pagination to work.  Now I would like to add a
sequential number to the beginning of each record in the output.  In
previous languages I used something like count=count+1 and then placed
count at the beginning of each record output in the template.  How is
a record count created in django that can be displayed at the
beginning of each record in the template?

If I use  the count starts over again for each page under
pagination.  I need to be able to label records 1 - 100 across several
pages.
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
-~--~~~~--~~--~--~---



How can i access UserProfile from User in the views?

2009-03-17 Thread Paolo Corti

Hi
I know is easy to access to the UserProfile, like here:

from django.contrib.auth.models import User
u = User.objects.get(pk=1) # Get the first user in the system
user_address = u.get_profile().home_address

but is there a way to access to UserProfile in the view?
supposing the UserProfile model is called myprofile, this will not do
the trick:

{{ user.myprofile.home_address }}

any advice? 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: Problem with formsets and uploading of files

2009-03-17 Thread motard

This is an error of mine that happened when transcribing my code to
the mail.

I DO call is_validate()

The issue here seems to be something I miss regarding the use of file
uploads together with formsets...

Regards, Stefan

On Mar 17, 5:06 pm, Alex Gaynor  wrote:
> On Tue, Mar 17, 2009 at 11:09 AM, Stefan Tunsch  wrote:
>
> > Hi!
>
> > I am having trouble getting a formset to work and handling the uploaded
> > files.
>
> > First of all, let me say that it's the first time I'm working with
> > formsets.
> > I've also never before tried to upload files.
> > It is possible that I might be misunderstanding some basic stuff...
>
> > My scenario is the following:
>
> > I have a form with one FileField:
>
> > class AttachmentForm(forms.Form):
> >    myfile = forms.FileField(required=False)
>
> > In my views.py file i do the following:
>
> > from django.forms.formsets import formset_factory
> > AttachmentFormSet = formset_factory(AttachmentForm, extra=3)
>
> > if request.method == 'POST':
> >    attachmentset = HoraAdjuntoFormSet(request.POST, request.FILES)
> >    if attachmentset.is_valid:
> >        #This is when things start to be awkward
> >        print len(request.FILES) #returns zero
> >        print len(attachmentset.cleaned_data) #returns 3, which is correct
> >        for cd in attachmentset.cleaned_data:
> >            print cd #Returns 3 empty dictionary {}
>
> > Any help will be appreciated.
>
> > Regards, Stefan
>
> You should be calling `is_valid` as it's a function, not a property:
> attachmentset.is_valid()
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: multiple python versions

2009-03-17 Thread TheIvIaxx

I tried do the whole 64 bit thing but ran into several headaches with
compiling the modules for AMD64 on vista.  I've never done it before
and i kept having to download this and that sdk just to find it not
working.  So i just left everything 32 bit and got to work on the
django app.

I'll try launching from the 32bit python executable
--~--~-~--~~~---~--~~
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: Many to Many is empty when saving parent object

2009-03-17 Thread Brandon Taylor

Ah, gotcha, so my signal is attached to the wrong sender. I was
thinking I would have access to the categories during the Entry's save
operation due to the m2m relationship on the field, but obviously not.

I'll move the signal and see what happens.

Thank you,
Brandon

On Mar 16, 6:53 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2009-03-16 at 08:48 -0700, Brandon Taylor wrote:
> > Hi everyone,
>
> > I'm running Python 2.6.1, Django Trunk.
>
> > I have a model (Entry) with a ManyToMany (Categories). I need to be
> > able to iterate over these categories whenever my parent model is
> > saved.
>
> > I've tried overriding save_model in the admin, and adding a post_save
> > signal to Entry in order to be able to iterate over the categories.
> > The problem only occurs on an insert. If I do:
>
> > class Entry(models.Model):
> >     name = models.CharField(max_length=100)
> >     categories = models.ManyToManyField(Category)
>
> >     class Meta:
> >         verbose_name_plural = 'Entries'
>
> >     def __unicode__(self):
> >         return self.name
>
> > class EntryAdmin(admin.ModelAdmin):
> >     def save_model(self, request, obj, form, change):
> >         obj.save()
> >         print obj.categories.all()
>
> > obj.categories.all() = []
>
> > However, when performing an update, I have a list of Category objects.
> > Is this a model lifecycle issue as far as when the ManyToMany gets
> > saved? What can I do to be able to access the list of categories when
> > the object is created?
>
> Many-to-many relations cannot be saved until the object itself is saved,
> since they need ot know the object's pk value to use in the relation
> table. Consequently, many-to-many handling in forms is done after saving
> the model itself. You're trying to look up the categories before they've
> been saved.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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: Port in use Error

2009-03-17 Thread TP

gordyt

Thanks this does help, I managed to overcome this problem yesterday,
but was still slightly confused as to
why I had the error in the first place, this helps me understand!

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



  1   2   >