Re: {% trans %} and {% blocktrans %} breaking auto escape

2009-02-26 Thread Briel

I have created a new ticket for this issue for those interested.
The ticket number is #10369

On 27 Feb., 03:36, Malcolm Tredinnick 
wrote:
> On Thu, 2009-02-26 at 01:11 -0800, Briel wrote:
> > I stumbled upon this by accident, and after doing some research on the
> > docs, it seems that there is a flaw with the translation template tags
> > and the auto escaping. I might have missed something or maybe it's
> > created to do this, so I'm posting here to figure out what's going on.
>
> > Anyways, the issue is that if I were to put {{ myvar }}, a user
> > submitted variable, it will auto escaped so that harmful text like <>
> > " ect will be escaped. However, if I put my var into a translation tag
> > like
>
> > {% trans myvar %} or
> > {% blocktrans %} this is {{ myvar }}{% endblocktrans %}
>
> > myvar will no longer be escaped, instead if a user would write some
> > harmful js/html code, it would be run. I found that if you put the
> > variables in blocktrans using with, it will be escaped:
>
> > {% blocktrans with myvar as myvar %}this is {{ myvar }}{%
> > endblocktrans %}
>
> > I found this behavior a bit odd, but I might have missed something, so
> > hoping some of you guys can help me clear up the use of the
> > translation tags without making a site unsafe.
>
> Nice catch. These both look like bugs. If you could open a ticket for
> them (put it in the internationalization category), they should be
> fixed.
>
> 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: lighty vs. nginx for deploying Django

2009-02-26 Thread Gour
> "Jacob" == Jacob Kaplan-Moss  writes:
Hi Jacob,

let me express my gratitude for providing Django  1st!

Jacob> The best thing you can do is try both and pick the one that works
Jacob> better for you. Me, I generally try to pick the software that's
Jacob> got better documentation so that I spend less time fussing with
Jacob> it, but other folks might want to choose the faster tool, or the
Jacob> one with more features, or ...

Good advice.

Jacob> Set them both up, run some tests/benchmarks, and pick what you
Jacob> think works best.

I did some benchmarking here...

Jacob> That's really just because when I wrote the docs and that part of
Jacob> the book I didn't know nginx existed -- no other reason.

Considering that nginx is, according to some stats, even more popular
than lighty, it would be nice to update the docs to reflect it.

I'd submit a patch, but still struggling to see admin's media appear in
my login dialog :-/


Sincerely,
Gour

-- 

Gour  | Zagreb, Croatia  | GPG key: C6E7162D



pgpvwRnWjs6fY.pgp
Description: PGP signature


Re: calling a view from within a view

2009-02-26 Thread Malcolm Tredinnick

On Thu, 2009-02-26 at 21:15 -0800, Bobby Roberts wrote:
> Is it possible to execute a view from within a view?
> 
> I've got a situation in my current view where if a condition is met, I
> need to branch control to a new view and send it new parameters.  I
> have the following but it doesn't work:
> 
> Showdetails(request,slug=currentslug,selfbidder=1)

Since a view is just a function, yes it will work. However, a view
function will always return an HttpResponse object, so you probably want
something like

return Showdetails(request,slug=currentslug,selfbidder=1)

so that the returned information is used.

> 
> I have read the docs and can't find any examples of how to call a view
> from a view.  Can someone point me to the right docs or show me what
> i'm doing wrong?

One popular use-case for this style of operation is wrapping generic
views to prepare extra information beforehand. An example is here:
http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-generic-views/

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: calling a view from within a view

2009-02-26 Thread Ranjan Kumar
I guess the error is in the line where u are passing the parameters to
ShowAuctionDetails view. Check if it works without passing request object as
the parameter. It worked in a similar view in my project.

The function signature then would be:

ShowAuctionDetails(slug=currentslug,selfbidder=1)

 Hope it helps.

On Fri, Feb 27, 2009 at 11:05 AM, Bobby Roberts  wrote:

>
> > You just call it, views are normal python functions, that being said it
> is
> > often better to redirect where possible(or sensible).
> >
> > Alex
>
> hey alex -
>
> Thanks for your quick reply.  Is my syntax above correct  to execute
> it?  it doesn't seem to be working  at all.  I know the code is
> executing at the line immediately above this but this line seems to
> just get skipped right on over.  Here's the full code:
>
>
>
>currentauctionid=request.session["newbidauctionid"]
>sb=Bid.objects.order_by('-id').filter(AuctionId=float
> (currentauctionid))
>for id in sb:
>topbidder=id.BidderId #get the top bidder's id  on the auction
>if float(request.user.id)==float(topbidder):  #This will
> determine if the peron is the current high bidder
>currentslug=slug  #this line executes fine
>controltransfer=ShowAuctionDetails
> (request,slug=currentslug,selfbidder=1)  #this will for the "can't
> outbid yourself message... this line is skipped
>else:
>pass
>break   # exit the loop
>
> >
>

--~--~-~--~~~---~--~~
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: calling a view from within a view

2009-02-26 Thread Bobby Roberts

> You just call it, views are normal python functions, that being said it is
> often better to redirect where possible(or sensible).
>
> Alex

hey alex -

Thanks for your quick reply.  Is my syntax above correct  to execute
it?  it doesn't seem to be working  at all.  I know the code is
executing at the line immediately above this but this line seems to
just get skipped right on over.  Here's the full code:



currentauctionid=request.session["newbidauctionid"]
sb=Bid.objects.order_by('-id').filter(AuctionId=float
(currentauctionid))
for id in sb:
topbidder=id.BidderId #get the top bidder's id  on the auction
if float(request.user.id)==float(topbidder):  #This will
determine if the peron is the current high bidder
currentslug=slug  #this line executes fine
controltransfer=ShowAuctionDetails
(request,slug=currentslug,selfbidder=1)  #this will for the "can't
outbid yourself message... this line is skipped
else:
pass
break   # exit the loop

--~--~-~--~~~---~--~~
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: calling a view from within a view

2009-02-26 Thread Alex Gaynor
On Fri, Feb 27, 2009 at 12:15 AM, Bobby Roberts  wrote:

>
> Is it possible to execute a view from within a view?
>
> I've got a situation in my current view where if a condition is met, I
> need to branch control to a new view and send it new parameters.  I
> have the following but it doesn't work:
>
> Showdetails(request,slug=currentslug,selfbidder=1)
>
> I have read the docs and can't find any examples of how to call a view
> from a view.  Can someone point me to the right docs or show me what
> i'm doing wrong?
>
>
> Thanks in advance
>
>
> >
>
You just call it, views are normal python functions, that being said it is
often better to redirect where possible(or sensible).

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



calling a view from within a view

2009-02-26 Thread Bobby Roberts

Is it possible to execute a view from within a view?

I've got a situation in my current view where if a condition is met, I
need to branch control to a new view and send it new parameters.  I
have the following but it doesn't work:

Showdetails(request,slug=currentslug,selfbidder=1)

I have read the docs and can't find any examples of how to call a view
from a view.  Can someone point me to the right docs or show me what
i'm doing wrong?


Thanks in advance


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



Re: reverse question

2009-02-26 Thread Alex Gaynor
On Fri, Feb 27, 2009 at 12:02 AM, adrian  wrote:

>
>
> I have a working app I'm trying to host.   I have this line in urls.py
> in my project directory:
>
>  url(r'^$', direct_to_template, {"template": "homepage.html"},
> name="home")
>
> and my base template uses the tag {% url home %}, and I am getting the
> error message:
>
> NoReverseMatch: Reverse for 'myproject.home' with arguments '()' and
> keyword arguments '{}' not found
>
> I'm guessing the problem is that "myproject" shouldn't be in there
> (it's the name of the folder in which my app and settings.py etc is
> stored).   Can anyone suggest how I should go about debugging this?
> I don't know where to start to fix it, since I don't understand the
> internals of reverse.
>
> I'm using modpython, django 1.0.2 and python 2.5.2.
>
> Thanks
> >
>
Unfortunately reverse raises stupid error message, it tries prepending your
project name to the search if the original lookup fails, so the error
message doesn't usually look correct.  Usual suspects in terms of reverse
not working are *other* views not existing.

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



reverse question

2009-02-26 Thread adrian


I have a working app I'm trying to host.   I have this line in urls.py
in my project directory:

  url(r'^$', direct_to_template, {"template": "homepage.html"},
name="home")

and my base template uses the tag {% url home %}, and I am getting the
error message:

NoReverseMatch: Reverse for 'myproject.home' with arguments '()' and
keyword arguments '{}' not found

I'm guessing the problem is that "myproject" shouldn't be in there
(it's the name of the folder in which my app and settings.py etc is
stored).   Can anyone suggest how I should go about debugging this?
I don't know where to start to fix it, since I don't understand the
internals of reverse.

I'm using modpython, django 1.0.2 and python 2.5.2.

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



Re: How to populate a custom ModelForm?

2009-02-26 Thread rajeesh

Ok, thanks for your time.
--~--~-~--~~~---~--~~
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: Media Root & Templates

2009-02-26 Thread Malcolm Tredinnick

On Thu, 2009-02-26 at 17:04 -0800, AKK wrote:
> Hi,
> 
> I have a template and I want to get some images out of my media root.
> I was wondering is there anyway to automatically return the media root
> from settings.py rather than manually specifying it rather each time.

You are probably wanting the MEDIA_URL setting, not the one called
MEDIA_ROOT. The former setting is the one that allows external users
(e.g. web browsers) to retrieve the media. The latter only describes
where they are stored, locally (not a useful piece of information to
external consumers).

Given that, look at the "media" context processor:
http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media

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: Customizing HTML

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 10:10 PM, Jack Orenstein  wrote:

>
> On Feb 26, 2009, at 10:04 PM, Alex Gaynor wrote:
>
> >
> >
> > On Thu, Feb 26, 2009 at 9:56 PM, Jack Orenstein 
> > wrote:
> >
> > 
> >  > value="m" name="gender" /> male
> >  > value="f" name="gender" /> female
> > 
> >
> > I want to get rid of the ul and li tags, and just put a  between
> > the two inputs.
> >
> > I'm going to try subclassing RadioSelect and overriding render.
> >
>
> > Yep that's the right technique for now, there's  aticket to make
> > those widgets that have multiple tags(checkbox and radio input)
> > iterable so you could iterate over it nicely.
>
> That would be nice. Do you know when this is expected to materialize?
>
> Jack
>
> >
>
I think it's marked as a ticket for 1.1, but as with anything, when there's
a working patch with good tests and docs and then a committer has time to
review it.

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: Customizing HTML

2009-02-26 Thread Jack Orenstein

On Feb 26, 2009, at 10:04 PM, Alex Gaynor wrote:

>
>
> On Thu, Feb 26, 2009 at 9:56 PM, Jack Orenstein   
> wrote:
>
> 
>  value="m" name="gender" /> male
>  value="f" name="gender" /> female
> 
>
> I want to get rid of the ul and li tags, and just put a  between
> the two inputs.
>
> I'm going to try subclassing RadioSelect and overriding render.
>

> Yep that's the right technique for now, there's  aticket to make  
> those widgets that have multiple tags(checkbox and radio input)  
> iterable so you could iterate over it nicely.

That would be nice. Do you know when this is expected to materialize?

Jack

--~--~-~--~~~---~--~~
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: Getting the Current Template Name/Path

2009-02-26 Thread Malcolm Tredinnick

On Thu, 2009-02-26 at 13:00 -0800, Tim White wrote:
> Hi -
> 
>  Is there a way to get the name and path of the current template being
> rendered?

Not really. If settings.DEBUG is True, there is an "origin" attribute on
the template, but it may not contain a useful value (after all,
templates don't need to have a "name" or be stored at a location that
corresponds to a "path").

What is the problem you're trying to solve?

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: Customizing HTML

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 9:56 PM, Jack Orenstein  wrote:

>
> On Feb 26, 2009, at 9:44 PM, Alex Gaynor wrote:
>
> > On Thu, Feb 26, 2009 at 9:42 PM, Jack Orenstein 
> > wrote:
> >
> > Suggestion: Instead of hardwiring formatting into Django, allow
> > attributes to specify formatting. E.g., here is the minimal HTML for
> > radio buttons for selecting gender:
> >
> > Male
> > Female
> >
> > I might want to generate some HTML before the first input, after the
> > last, and between adjacent inputs. RadioFieldRenderer does this in a
> > hardcoded way. How about providing, through the API, widget
> > attributes such as 'before', 'after', and 'in_between'? These could
> > default to what RadioFieldRendered does, but I could also substitute
> > my own.
>
>
> But that includes the default formatting I'm trying to get rid of.
> E.g., for the radio example:
>
> 
>  value="m" name="gender" /> male
>  value="f" name="gender" /> female
> 
>
> I want to get rid of the ul and li tags, and just put a  between
> the two inputs.
>
> I'm going to try subclassing RadioSelect and overriding render.
>
> Jack
>
> >
>
Yep that's the right technique for now, there's  aticket to make those
widgets that have multiple tags(checkbox and radio input) iterable so you
could iterate over it nicely.

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: Customizing HTML

2009-02-26 Thread Jack Orenstein

On Feb 26, 2009, at 9:44 PM, Alex Gaynor wrote:

> On Thu, Feb 26, 2009 at 9:42 PM, Jack Orenstein   
> wrote:
>
> Suggestion: Instead of hardwiring formatting into Django, allow
> attributes to specify formatting. E.g., here is the minimal HTML for
> radio buttons for selecting gender:
>
> Male
> Female
>
> I might want to generate some HTML before the first input, after the
> last, and between adjacent inputs. RadioFieldRenderer does this in a
> hardcoded way. How about providing, through the API, widget
> attributes such as 'before', 'after', and 'in_between'? These could
> default to what RadioFieldRendered does, but I could also substitute
> my own.


But that includes the default formatting I'm trying to get rid of.  
E.g., for the radio example:


 male
 female


I want to get rid of the ul and li tags, and just put a  between  
the two inputs.

I'm going to try subclassing RadioSelect and overriding render.

Jack

--~--~-~--~~~---~--~~
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: Customizing HTML

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 9:42 PM, Jack Orenstein  wrote:

>
> I'm new to Django, and making good progress rewriting a Struts-based
> website. (It started rotting because I found Struts so painful and
> non-intuitive. Django is so much easier.)
>
> The major problems I'm running into have to do with HTML generation,
> first with error messages, and then with RadioSelect. In general, I
> don't like the, default, as_p or as_ul options. I'm also finding that
> the documentation on how to change the HTML is kind of thin, so I'm
> reading code and guessing. For errors, I ended up doing something
> like this:
>
> form.errors # Force creation of _errors
> errors = form._errors.items()
>
> I now have a list of unformatted items which I can format anyway I want.
>
> I'm running into a similar problem with RadioSelect. I found
> widgets.RadioFieldRender, but I can't extend it (it isn't exported).
>
> So I have a question and a suggestion.
>
> Question: How do I control HTML generation, ideally at field- or
> widget-level? I feel I must be overlooking something easy.
>
> Suggestion: Instead of hardwiring formatting into Django, allow
> attributes to specify formatting. E.g., here is the minimal HTML for
> radio buttons for selecting gender:
>
> Male
> Female
>
> I might want to generate some HTML before the first input, after the
> last, and between adjacent inputs. RadioFieldRenderer does this in a
> hardcoded way. How about providing, through the API, widget
> attributes such as 'before', 'after', and 'in_between'? These could
> default to what RadioFieldRendered does, but I could also substitute
> my own.
>
> Jack Orenstein
>
>
> >
>
The best way to do HTML rendering of forms(IMO) is by simply iterating over
the fields:
http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields.

In my experience this is the best balance of power and flexibility.

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



Customizing HTML

2009-02-26 Thread Jack Orenstein

I'm new to Django, and making good progress rewriting a Struts-based  
website. (It started rotting because I found Struts so painful and  
non-intuitive. Django is so much easier.)

The major problems I'm running into have to do with HTML generation,  
first with error messages, and then with RadioSelect. In general, I  
don't like the, default, as_p or as_ul options. I'm also finding that  
the documentation on how to change the HTML is kind of thin, so I'm  
reading code and guessing. For errors, I ended up doing something  
like this:

 form.errors # Force creation of _errors
 errors = form._errors.items()

I now have a list of unformatted items which I can format anyway I want.

I'm running into a similar problem with RadioSelect. I found  
widgets.RadioFieldRender, but I can't extend it (it isn't exported).

So I have a question and a suggestion.

Question: How do I control HTML generation, ideally at field- or  
widget-level? I feel I must be overlooking something easy.

Suggestion: Instead of hardwiring formatting into Django, allow  
attributes to specify formatting. E.g., here is the minimal HTML for  
radio buttons for selecting gender:

 Male
 Female

I might want to generate some HTML before the first input, after the  
last, and between adjacent inputs. RadioFieldRenderer does this in a  
hardcoded way. How about providing, through the API, widget  
attributes such as 'before', 'after', and 'in_between'? These could  
default to what RadioFieldRendered does, but I could also substitute  
my own.

Jack Orenstein


--~--~-~--~~~---~--~~
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: {% trans %} and {% blocktrans %} breaking auto escape

2009-02-26 Thread Malcolm Tredinnick

On Thu, 2009-02-26 at 01:11 -0800, Briel wrote:
> I stumbled upon this by accident, and after doing some research on the
> docs, it seems that there is a flaw with the translation template tags
> and the auto escaping. I might have missed something or maybe it's
> created to do this, so I'm posting here to figure out what's going on.
> 
> Anyways, the issue is that if I were to put {{ myvar }}, a user
> submitted variable, it will auto escaped so that harmful text like <>
> " ect will be escaped. However, if I put my var into a translation tag
> like
> 
> {% trans myvar %} or
> {% blocktrans %} this is {{ myvar }}{% endblocktrans %}
> 
> myvar will no longer be escaped, instead if a user would write some
> harmful js/html code, it would be run. I found that if you put the
> variables in blocktrans using with, it will be escaped:
> 
> {% blocktrans with myvar as myvar %}this is {{ myvar }}{%
> endblocktrans %}
> 
> I found this behavior a bit odd, but I might have missed something, so
> hoping some of you guys can help me clear up the use of the
> translation tags without making a site unsafe.

Nice catch. These both look like bugs. If you could open a ticket for
them (put it in the internationalization category), they should be
fixed.

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: Media Root & Templates

2009-02-26 Thread Chris Czub



if you include the django.core.context_processors.media context processor

http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#django-core-context-processors-media

On Thu, Feb 26, 2009 at 8:04 PM, AKK  wrote:
>
> Hi,
>
> I have a template and I want to get some images out of my media root.
> I was wondering is there anyway to automatically return the media root
> from settings.py rather than manually specifying it rather each time.
>
> 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
-~--~~~~--~~--~--~---



Media Root & Templates

2009-02-26 Thread AKK

Hi,

I have a template and I want to get some images out of my media root.
I was wondering is there anyway to automatically return the media root
from settings.py rather than manually specifying it rather each time.

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: Eager Fetching

2009-02-26 Thread Malcolm Tredinnick

On Wed, 2009-02-25 at 16:42 -0800, saxon75 wrote:
[...]

> The culprits seem to be the for loop in the template that iterates
> over node.article.tags and also the two calls to node.comment_count.
> As you can see from the model, node.comment_count is a member function
> that returns the value of node.comment_set.count, and it looks like
> that isn't being evaluated until the template is rendered.
> 
> What it looks like I need is to get my code to do more eager fetching,
> but I'm not sure exactly how to go about doing that.  Does anyone have
> any thoughts?

Okay, there's loads of code here and I'm not really motivated to wade
through it all. But what you're seeing isn't atypical behaviour. Your
ultimate analysis seems fairly reasonable, though: if you're retrieving
the same data more than once, you need to try and eliminate that, once
you've determined it's the bottleneck.

After all, if retrieving all the data takes 4 - 6 seconds, then
retrieving it all in a slightly different order isn't going to improve
things very much. It's still the same order of magnitude of work. What
you really need to do is change (reduce!) the amount of data you're
retrieving. 

At a minimum, that means trying to retrieve each piece of data only once
(or as few times as possible). That might require changing the types of
data structures you construct in your view, doing less automatic
fetching in the template and more explicit organisation in the view (not
a bad practice in any case).

Further, you might want to look at caching some of the stuff that isn't
going to change particularly often. Start at the top level: can you
cache the whole page result so that the 4-6 second penalty is only paid
every now and again. Lower down, can you cache the individual nodes or
articles, since historical ones are unlikely to change particularly
often? The benefit you get there depends on the frequency of reuse for
each item, so depends on information you'll have to collect from
analysing site usage.

Three areas of API to look at there; the template "cache" tag, Django's
view-level caching decorators, and the low-level caching API (for
caching and retrieving in views).

Coincidentally, I'm in the middle of writing a fairly long blog post on
this type of optimisation. It's both somewhat case-by-case specialised,
but also subject to some general rules (like reducing the amount of
duplicate data retrieval). It's not a quick thing to write about, so I'm
probably a few days away from publishing, but the above paragraphs give
you the meat of the conclusions.

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: Searching a list of Q

2009-02-26 Thread Malcolm Tredinnick

On Wed, 2009-02-25 at 10:41 -0800, Kevin Audleman wrote:
> Ah, gotcha.
> 
> Maybe django should include a iin function =)

We already do. It's spelled reduce(operator.or, [...], Q()). :-)

Databases don't support inexact IN matching, so Django doesn't support
it directly. Wrapping what is already only a one- to three-line function
in user's code would really just be code bloat (in the sense of adding
stuff we have to maintain forever that doesn't really do anything that
isn't already easy).

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: cache backend file: No need for cull

2009-02-26 Thread Malcolm Tredinnick

On Wed, 2009-02-25 at 16:37 +0100, Thomas Guettler wrote:
> Hi,
> 
> I profiled my application and discovered, that it spends
> a lot of time in _cull() and get_num_entries() in the file
> cache backend.
> 
> It is very easy to have a cron job which cleans the directory
> by deleting all files older than N minutes. There is no need to cull during
> request time.
> 
> I suggest that if you set max_entries to zero, _cull() is not called.
> 
> Before I open a ticket, I ask for feedback.

Probably more of a thing for django-dev. However, for what it's worth, I
think this isn't a great change. It requires "extra" setup stuff for
something that, right now, works out of the box.

If you're wanting high performance caching, the answer is going to be
memcache. Using the file system cache is still a big improvement over
nothing, but it's for different situations (limited RAM, for example,
which is certainly an issue in some places). Setting up a cronjob isn't
necessarily trivial for people. Turning on the filecache right now is
trivial.

Since Django already supports pluggable cache backends, if somebody
wants a filesystem cache with external cleansing (using tmpwatch is an
obvious one), then that could be written as a third-party app.

Note also that "files older than N minutes" isn't a reliable culling
strategy. You need to manage space constraints. A spike in traffic load
could end up chewing up a lot of disk space. You also want to probably
only delete files last accessed more than N minutes ago, not older than
N minutes by creation time. Or maybe not -- there are at least half a
dozen valid caching strategies and FIFO is one of them that works for
highly random access requirements with minimal overhead. However, for
websites requiring caching, an LRU-style strategy tends to be more
productive if you're going to cache at all, since there is locality of
use (the most active pages are accessed far more often; distribution
isn't uniform across all cached pages).

So it's not an entirely trivial cronjob to set up, although it's also
not rocket science.

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



Populating list_display with data from two models?

2009-02-26 Thread Jamie Richard Wilson

I've extended the User model with a UserPofile model and have inline
editing working. Setup is something like this:

class UserProfile(models.Model):
user = models.ForeignKey(
   User,
   unique=True,
   )
   position = models.ForeignKey(Position)
   ...etc...

I need a list_display in admin.py to display 'username', 'first_name',
'last_name', and 'position'. I also need to be able to use list_filter
for 'position'. The problem I have is that the data is split between the
built-in User model and UserProfile model. Is there anyway for me to
combine data from two models into a single list view or will I need to
duplicate info such as first_name and last_name into the UserProfile
model and use that list_view?

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



password_reset and the "next" parameter

2009-02-26 Thread zellyn

I'm curious if anyone knows why you can't thread a "next" parameter
through the contrib.auth password reset machinery the way you can with
login/logout/etc.

Is it an oversight, or have folks thought it through carefully and
pronounced it a bad idea?

(Just thought I'd check before I cut-n-paste rebuild password_reset
and wrap password_reset_confirm. I'd like users to eventually be taken
back to where they were, after they successfully reset their
passwords.)

Thanks,

Zellyn Hunter

--~--~-~--~~~---~--~~
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: DEFAULT_FILE_STORAGE settings conflict

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 6:13 PM, jacks...@gmail.com <
jackson.torr...@gmail.com> wrote:

>
> I try to make my own custom storage like:
>
> from django.core.files.storage import Storage
>
> CUSTOM_MEDIA_ROOT = 'blah'
> CUSTOM_MEDIA_URL = 'bleh'
>
>
> class MediaStorage(Storage):
>def __init__(self, location=CUSTOM_MEDIA_ROOT,
> base_url=CUSTOM_MEDIA_URL, *args, **kwargs):
>super(MediaStorage, self).__init__(*args, **kwargs)
>self.location = os.path.abspath(location)
>self.base_url = base_url
>
>
> , but when i put that custom storage in the settings:
>
> DEFAULT_FILE_STORAGE = 'path_to_my_custom_storage'.MediaStorage
>
> and i try to restore the database django raise this error:
>
>  ...
>  from django.core.files.storage import Storage
>  File "/usr/lib/python2.5/django/core/files/storage.py", line 118, in
> 
>class FileSystemStorage(Storage):
>  File "/usr/lib/python2.5/django/core/files/storage.py", line 124, in
> FileSystemStorage
>def __init__(self, location=settings.MEDIA_ROOT,
> base_url=settings.MEDIA_URL):
>  File "/usr/lib/python2.5/django/conf/__init__.py", line 28, in
> __getattr__
>self._import_settings()
>  File "/usr/lib/python2.5/django/conf/__init__.py", line 57, in
> _import_settings
>raise ImportError("Settings cannot be imported, because
> environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined.
>
> Somebody help?
>
> >
> That's probably because DEFAULT_FILE_STORAGE =
'path_to_my_custom_storage'.MediaStorage would be a typo, it should be
'path.to.storage.MediaStorage'.

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: Queryset Caching

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 6:26 PM, Jason Broyles  wrote:

>
> Thanks for the reply. I was talking about using memcache to cache the
> view. If a search changes, will it get the cache or hit the database?
>
> On Feb 26, 6:11 pm, Alex Gaynor  wrote:
> > On Thu, Feb 26, 2009 at 6:08 PM, Jason Broyles 
> wrote:
> >
> > > I have a question about per view caching. Say I have a search form and
> > > someone performs a query that returns all of the results, then those
> > > results are cached. If they then did a new search with criteria in the
> > > search, will it use the cache or hit the database again? Or if they
> > > just sorted those results by an order_by, would it hit the database
> > > again?
> >
> > It only doesn't hit the DB if you load something in from the cache.  The
> > buitin queryset caching just caches for the length of that object, it's
> not
> > any sort of global, cross request cache.
> >
> > 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
> >
>
Cache lookups occur by key, so if the key is found it will return the old
queryset, it won't be invalidated because the result set *would* change
unless you explicitly unset it.

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



DEFAULT_FILE_STORAGE settings conflict

2009-02-26 Thread jacks...@gmail.com

I try to make my own custom storage like:

from django.core.files.storage import Storage

CUSTOM_MEDIA_ROOT = 'blah'
CUSTOM_MEDIA_URL = 'bleh'


class MediaStorage(Storage):
def __init__(self, location=CUSTOM_MEDIA_ROOT,
 base_url=CUSTOM_MEDIA_URL, *args, **kwargs):
super(MediaStorage, self).__init__(*args, **kwargs)
self.location = os.path.abspath(location)
self.base_url = base_url


, but when i put that custom storage in the settings:

DEFAULT_FILE_STORAGE = 'path_to_my_custom_storage'.MediaStorage

and i try to restore the database django raise this error:

  ...
  from django.core.files.storage import Storage
  File "/usr/lib/python2.5/django/core/files/storage.py", line 118, in

class FileSystemStorage(Storage):
  File "/usr/lib/python2.5/django/core/files/storage.py", line 124, in
FileSystemStorage
def __init__(self, location=settings.MEDIA_ROOT,
base_url=settings.MEDIA_URL):
  File "/usr/lib/python2.5/django/conf/__init__.py", line 28, in
__getattr__
self._import_settings()
  File "/usr/lib/python2.5/django/conf/__init__.py", line 57, in
_import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

Somebody help?

--~--~-~--~~~---~--~~
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: A solution for django/postgresql transaction problem

2009-02-26 Thread Karen Tracey
On Thu, Feb 26, 2009 at 9:22 AM, Sushant Sinha  wrote:

> I agree with you that a user code can best determine whether to roll
> back or commit. However, I think this is not reflected in the
> documentation for the models at all.
>
> http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs
> http://docs.djangoproject.com/en/dev/topics/db/models/#topics-db-models
>
> My understanding is that updates/insert/delete to database models are
> handled as auto-commit transactions (each model query is itself a
> transaction). However, in case of a failure, django gives me a bad state
> of the database. And my rest of the code fails if I do not explicitly
> handle the transaction commit/rollover. This seems really problematic
> for the programmer.
>
> If a single query fails, then what does commit mean. Shouldn't we do
> just rollover as commit has no meaning?
>

See this thread:

http://groups.google.com/group/django-developers/browse_thread/thread/620ccff354c859c2/5bec41ee3271f30a
?

for a long discussion of why Django's "autocommit-like" mode is the way it
is.  It's a subject I haven't followed in any great detail but I think the
upshot is that when the ticket mentioned in that thread gets committed, you
will be able to configure things to use "native" autocommit, in which case I
expect you will not need to worry about commit or rollback after an error.
At the moment, though, whenever your code catches a database-related
exception, it does need to worry about cleaning up the transaction before
attempting more database operations.

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: Queryset Caching

2009-02-26 Thread Jason Broyles

Thanks for the reply. I was talking about using memcache to cache the
view. If a search changes, will it get the cache or hit the database?

On Feb 26, 6:11 pm, Alex Gaynor  wrote:
> On Thu, Feb 26, 2009 at 6:08 PM, Jason Broyles  wrote:
>
> > I have a question about per view caching. Say I have a search form and
> > someone performs a query that returns all of the results, then those
> > results are cached. If they then did a new search with criteria in the
> > search, will it use the cache or hit the database again? Or if they
> > just sorted those results by an order_by, would it hit the database
> > again?
>
> It only doesn't hit the DB if you load something in from the cache.  The
> buitin queryset caching just caches for the length of that object, it's not
> any sort of global, cross request cache.
>
> 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: Queryset Caching

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 6:08 PM, Jason Broyles  wrote:

>
> I have a question about per view caching. Say I have a search form and
> someone performs a query that returns all of the results, then those
> results are cached. If they then did a new search with criteria in the
> search, will it use the cache or hit the database again? Or if they
> just sorted those results by an order_by, would it hit the database
> again?
> >
>
It only doesn't hit the DB if you load something in from the cache.  The
buitin queryset caching just caches for the length of that object, it's not
any sort of global, cross request cache.

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



Queryset Caching

2009-02-26 Thread Jason Broyles

I have a question about per view caching. Say I have a search form and
someone performs a query that returns all of the results, then those
results are cached. If they then did a new search with criteria in the
search, will it use the cache or hit the database again? Or if they
just sorted those results by an order_by, would it hit the database
again?
--~--~-~--~~~---~--~~
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: Postgis on Mac OS Leopard

2009-02-26 Thread Graham Dumpleton



On Feb 27, 12:29 am, "omat * gezgin.com"  wrote:
> Thanks for the pointer.
>
> But I checked the architecture of the liblwgeom.so with 'file' and the
> result is:
> /usr/local/pgsql_saved_0804141532/lib/liblwgeom.so: Mach-O bundle i386
>
> which is the correct architecture for my Intel based macbook pro.

But how is your application being run in the first place? A MacBook
Pro has 64 bit Intel CPU. If you are running with mod_wsgi or
mod_python under operating system supplied Apache, then because Apache
will run as 64 bit, all the libraries etc have to be available as 64
bit as well.

So, explain how Python gets run. Are you running command line Python
to see this error, running Django under Apache.

Graham

> I am lost.
>
> On Feb 26, 1:25 pm, Graham Dumpleton 
> wrote:
>
> > On Feb 26, 10:07 pm, omat  wrote:
>
> > > Hi all,
>
> > > Following the instructions on inhttp://geodjango.org/docs/install.html,
> > > i managed to get to "Creating a Spatial Database Template" section.
>
> > > But when trying to execute the line below (as postgres user of
> > > course):
> > > $ psql -d template_postgis -f `pg_config --sharedir`/lwpostgis.sql
>
> > > it complained that it cannot find "liblwgeom".
>
> > > I found the lwpostgis.sql under directory:
> > > /usr/local/pgsql_saved_0804141532/share/
> > > which does not look very right. I examined the file and it has:
> > > ...
> > > CREATE OR REPLACE FUNCTION histogram2d_in(cstring)
> > >         RETURNS histogram2d
> > >         AS '$libdir/liblwgeom', 'lwhistogram2d_in'
> > >         LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
> > > ...
>
> > > $libdir shell variable is ''. I located the liblwgeom.so which is
> > > refered in the sql file here:
> > > /usr/local/pgsql_saved_0804141532/lib/liblwgeom.so
>
> > > When I tried to run the sql command above on the template_postgis db,
> > > fixing the paths manually, I get:
>
> > > ERROR:  could not load library "/usr/local/pgsql_saved_0804141532/lib/
> > > liblwgeom.so": dlopen(/usr/local/pgsql_saved_0804141532/lib/
> > > liblwgeom.so, 10): no suitable image found.  Did find:
> > >         /usr/local/pgsql_saved_0804141532/lib/liblwgeom.so: mach-o, but 
> > > wrong
> > > architecture
>
> > > Can it be that a conflicting version already existed and caused
> > > problems? Or what?
>
> > > I took the "build from source" path as instructed in the install
> > > documentation. I am using PostgreSQL 8.2 / PostGIS 1.3.5 on Mac OS X
> > > Leopard (10.5.6)
>
> > Read:
>
> >  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
>
> > Various sections in this cover aspects of this problem which would be
> > relevant, even if you aren't usingmod_wsgi.
>
> > It is all because MacOS X can run on different architectures. That is,
> > PPC and Intel, plus 32 bit and 64 bit variants of same. Your library
> > doesn't have required architecture for what application that is using
> > it is running as.
>
> > Use 'file' command on the library to work out what architectures it
> > does provide. You then need to recompile stuff so it also includes
> > other architectures that may be required.
>
> > There are some pointers in that document about how to compile for all
> > architectures.
>
> > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Configuring django cms with mod_python

2009-02-26 Thread Karen Tracey
On Thu, Feb 26, 2009 at 7:22 AM, stuart  wrote:

>
> Hi,
>
> I'm new to django and am having problems configuring the django-cms
> application with apache (using mod_python). I have followed the
> install steps (http://django-cms.org/installation/) but Apache throws
> the following error:
>
> ImportError: No module named cms
>
> My foo.com website code has 1 inventory application with the following
> file system paths:
>
> /home/mycode/foo
> /home/mycode/foo/inventory
> /home/mycode/foo/cms
>
> ... my apache virtual hosts file contains:
>
> 
>ServerName foo.co.uk
>ServerAlias *foo.*
>DocumentRoot /home/mycode/foo
>
>
>allow from all
>Options None
>
>
>
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>PythonPath "['/home/mycode'] + sys.path"
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>
>
>
>SetHandler None
>
> 
>
> ... and my /home/mycode/foo/settings.py file contains:
>
> INSTALLED_APPS = (
>'django.contrib.auth',
>'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'django.contrib.admin',
>'foo.inventory',
>'cms',
> )
>
> (I restarted apache after the configuration changes too)
>
> Is there a problem with my virtual host or mod_python configuration?


You only added /home/mycode to your PythonPath under Apache, not
/home/mycode/foo, but you put cms under /home/mycode/foo.  Either put cms
under /home/mycode, or add /home/mycode/foo to your PythonPath.

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



Getting the Current Template Name/Path

2009-02-26 Thread Tim White

Hi -

 Is there a way to get the name and path of the current template being
rendered?

Thanks!

Tim

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

2009-02-26 Thread Peter Herndon

>   Django Reference suggests that we use Transaction Middleware in the
> web applications.

Mm, the documentation doesn't suggest you use it, it merely details
how to use it if you in fact need it.  Whether you need it or not is a
design decision you must make.

>   What is the usual practice followed here? Do we use Transaction
> Middleware most of the time?

You need to think about transactions and your application.  That is,
does your application actually require transactions?  Do you have
multiple database operations that really MUST be performed as a unit,
or rolled back as a unit?  In most web applications, that's not likely
to be the case.  Commercial websites, money exchanges, these sorts of
operations normally require transactions, but does a To-Do list
application, a blog, or a photo gallery?  So you need to think about
whether your application truly requires transactions.  Most of my apps
do not, though I do have one use case in one app where I am using
transactions to ensure logical consistency.

>
>   The reason why I am asking is due to the following reason:
>   In my code, I at many places do the following
>   Obj = Model(parm1, parm2)
>   Obj.save()
>   # Now store the id for future use
>   l.append(Obj.id)

No, don't do the above.  Instead, do:

l.append(Obj)

>   Now, I think this sort of code should be very usual in Web
> Applications. But I cannot understand how this will work, since as per
> my understanding, the _id_ will not be obtained until the DB actually
> assigns one. Since transaction middleware allows the transaction to be
> commited only at the end, this should fail right?

As per above, don't store the id for future use.  You've already got a
reference to the model object, Obj.  Append that to your list instead,
if you need to refer to it.  You don't have to worry about the id, and
you don't have to worry about transactions (whether or not you decide
to use them).  If you keep the reference to the Obj throughout your
transaction, you need never refer to the id explicitly, just use the
object reference.  Then later, when you commit your transaction, your
object *in its final form* is saved to the database, and an ID is
assigned.

Hope that helps,

---Peter

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



Re: get translated text from ugettext_lazy() result

2009-02-26 Thread Arien

[fixed top-posting]

On Thu, Feb 26, 2009 at 09:31, Matej  wrote:
> On Feb 26, 3:38 pm, Alex Gaynor  wrote:
>> On Thu, Feb 26, 2009 at 4:36 AM, Matej  wrote:
>>
>> > Hello.
>> > I would like to get my translated text from ugettext_lazy() result.
>> > How can I do that?
>>
>> > Example:
>> >http://dpaste.com/1744/
>>
>> > #models.py
>> > RATING_CHOICES = (
>> >    ('0', _('I don\'t know')),
>> >    ('1', _('Very bad')),
>> >    ('2', _('Bad')),
>> >    ('3', _('OK')),
>> >    ('4', _('Good')),
>> >    ('5', _('Excelent')),
>> > )

[...]

>> Perhaps you're looking for this 
>> method:http://docs.djangoproject.com/en/dev/ref/models/instances/#get-foo-display

> This looks like it should work but it does not.
> WebStoreRating fields delivery and ui have defined
> choices=RATING_CHOICES
>
 r = WebStoreRating.objects.filter(pk=1)
 r = r[0]
 r.get_delivery_display()
> 3
 r.get_ui_display()
> 3

Just a guess: you're using some kind of *integer* model field but
since your choices are tuples with *strings* as the first element.
Use integers for the first element of each tuple instead:

  RATING_CHOICES = (
  (0, _('I don\'t know')),
  (1, _('Very bad')),
  (2, _('Bad')),
  (3, _('OK')),
  (4, _('Good')),
  (5, _('Excelent')),
  )


Arien

--~--~-~--~~~---~--~~
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: error while trying save a model form

2009-02-26 Thread uno...@gmail.com

Daniel,

thanks much. That was the problem.

Damn -- its so freakishly easy to miss such nasty little things when
you're over worked :-)

thanks again.

-pranav.

On Feb 26, 4:03 pm, Daniel Roseman 
wrote:
> On Feb 26, 8:12 pm, "uno...@gmail.com"  wrote:
>
>
>
> > I have the following model form:
>
> > class EditProfileForm(ModelForm):
>
> >     class Meta:
> >         model = UserProfile
> >         exclude = ('user',)
>
> > The corresponding model is:
>
> > class UserProfile(models.Model):
>
> >     user = models.ForeignKey(User)
> >     firstname = models.CharField(max_length=50,blank=True)
> >     lastname = models.CharField(max_length=50,blank=True)
> >     blog = models.URLField(blank=True)
> >     location = models.CharField(max_length=50,blank=True)
> >     karma = models.IntegerField(editable=False,default="0")
>
> > and the view is:
>
> > def editprofile(request):
>
> >     user = request.user
> >     profile = UserProfile.objects.get_or_create(user=user)
>
> >     if request.method == "POST":
>
> >         form = EditProfileForm(request.POST,instance=profile)
> >         if form.is_valid():
> >             profile = form.save()
> >             return HttpResponseRedirect("/myprofile/")
> >     else:
> >         form = EditProfileForm(instance=profile)
>
> >     return render_to_response("editprofile.html",{"form":form},
> >                               context_instance=RequestContext
> > (request))
>
> > I keep getting the following error:
>
> > AttributeError: 'tuple' object has no attribute '_meta'
>
> > on the line:  form = EditProfileForm(instance=profile)
>
> > any ideas what's wrong here ?
>
> Your problem is in this line:
> profile = UserProfile.objects.get_or_create(user=user)
>
> Look closely at the documentation for the get_or_create method 
> -http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-cre...
> You'll see it returns *two* arguments: the object, and a boolean to
> show whether or not the object was newly created. Because you have
> only given one name on the left-hand side of the assignment, Python
> packs the two values into a tuple, which explains your error message.
>
> Instead, use two variables:
> profile, created = UserProfile.objects.get_or_create(user=user)
> and all should be fine.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use django-profiles / Editing user properties (without admin interface)

2009-02-26 Thread Baxter

My suggestion would be don't. I think allowing users to edit their own
emails will create more problems than it will solve, as I don't think
you can trust users to put in valid info their email unless they have
a motivating reason (like registering). Better to put a contact link
to an admin to change it, in my opinion.

If you really want to do it, I think in your public form you can
create the field from MySiteProfile.user.email and make it work that
way.
--~--~-~--~~~---~--~~
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: is_authenticated

2009-02-26 Thread Tim

I started exploring this, but quickly hit the roadblock of how to get
the session associated with a particular user. This is not easily done
- the only way I can see doing it is to iterate over all session
objects, decode them and check for the user id. That seems like a lot
of overhead with the relatively small payoff of showing whether a user
is online or not.

All in all, I think you're right though, that this would be the way to
go if I wanted to stick with existing tools. There may be a way to get
something wrapped around the session framework to populate another
table with the user id and delete it on logout or expiration. I'll
have to mess around a bit more.

- Tim

On Feb 21, 12:53 pm, Chris Czub  wrote:
> If you are using default Django sessions, they will be stored in the database.
>
> From the docs:
> By default, Django stores sessions in your database (using the model
> django.contrib.sessions.models.Session). Though this is convenient, in
> some setups it's faster to store session data elsewhere, so Django can
> be configured to store session data on your filesystem or in your
> cache.
>
> >>> from django.contrib.sessions.models import Session
> >>> Session.objects.all()
>
> [, ,  Session object>, , ,
> , ,  Session object>, , ,
> , ,  Session object>, , ,
> , ,  Session object>, , ,
> '...(remaining elements truncated)...']>>> 
> Session.objects.all()[0].get_decoded()
>
> {'_auth_user_id': 1L, '_auth_user_backend':
> 'django.contrib.auth.backends.ModelBackend'}
>
> On Sat, Feb 21, 2009 at 12:27 PM, Tim  wrote:
>
> > Hi -
>
> > I am using the Django auth backend and I'd like to test which users
> > are currently logged in. I can't do this just by grabbing
> > User.objects.all() and testing each with is_authenticated, because the
> > User objects being User objects as opposed to AnonymousUser objects
> > will always return True for is_authenticated. Can anyone point me to
> > the right way to do this?
>
> > - Tim
--~--~-~--~~~---~--~~
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: error while trying save a model form

2009-02-26 Thread Daniel Roseman

On Feb 26, 8:12 pm, "uno...@gmail.com"  wrote:
> I have the following model form:
>
> class EditProfileForm(ModelForm):
>
>     class Meta:
>         model = UserProfile
>         exclude = ('user',)
>
> The corresponding model is:
>
> class UserProfile(models.Model):
>
>     user = models.ForeignKey(User)
>     firstname = models.CharField(max_length=50,blank=True)
>     lastname = models.CharField(max_length=50,blank=True)
>     blog = models.URLField(blank=True)
>     location = models.CharField(max_length=50,blank=True)
>     karma = models.IntegerField(editable=False,default="0")
>
> and the view is:
>
> def editprofile(request):
>
>     user = request.user
>     profile = UserProfile.objects.get_or_create(user=user)
>
>     if request.method == "POST":
>
>         form = EditProfileForm(request.POST,instance=profile)
>         if form.is_valid():
>             profile = form.save()
>             return HttpResponseRedirect("/myprofile/")
>     else:
>         form = EditProfileForm(instance=profile)
>
>     return render_to_response("editprofile.html",{"form":form},
>                               context_instance=RequestContext
> (request))
>
> I keep getting the following error:
>
> AttributeError: 'tuple' object has no attribute '_meta'
>
> on the line:  form = EditProfileForm(instance=profile)
>
> any ideas what's wrong here ?

Your problem is in this line:
profile = UserProfile.objects.get_or_create(user=user)

Look closely at the documentation for the get_or_create method -
http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-create-kwargs
You'll see it returns *two* arguments: the object, and a boolean to
show whether or not the object was newly created. Because you have
only given one name on the left-hand side of the assignment, Python
packs the two values into a tuple, which explains your error message.

Instead, use two variables:
profile, created = UserProfile.objects.get_or_create(user=user)
and all should be fine.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: updated poll example to take points for each item, gives more than 1 to upack err

2009-02-26 Thread Daniel Roseman

On Feb 26, 7:10 pm, seamusjr  wrote:
> > But what is points? Where is it coming from? As the traceback shows
> > you, you haven't set the points variable anywhere. Where are you
> > expecting it to come from?
> > --
> > DR.
>
> I want to iterate thru the points property of the Song object, from
> models.py, how can I output that from the views to the db?  Below is
> from models.py
>
> class Song(models.Model):
>         poll = models.ForeignKey(Poll)
>         name = models.CharField(max_length=200)
>         points = models.IntegerField()
>
>         def __unicode__(self):
>                 return self.song

I'm sorry, I really don't understand what you're trying to do. How do
you mean, iterate through? Points is an integer field, there is only
one value.

If you want me to help you, please post your entire views.py,
models.py and template on dpaste.com. Post the link here, along with a
full explanation of what you're trying to do, and what you expect the
output to be.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: error while trying save a model form

2009-02-26 Thread Atishay



On Feb 26, 3:12 pm, "uno...@gmail.com"  wrote:
> I have the following model form:
>
> class EditProfileForm(ModelForm):
>
>     class Meta:
>         model = UserProfile
>         exclude = ('user',)
>
> The corresponding model is:
>
> class UserProfile(models.Model):
>
>     user = models.ForeignKey(User)
>     firstname = models.CharField(max_length=50,blank=True)
>     lastname = models.CharField(max_length=50,blank=True)
>     blog = models.URLField(blank=True)
>     location = models.CharField(max_length=50,blank=True)
>     karma = models.IntegerField(editable=False,default="0")
>
> and the view is:
>
> def editprofile(request):
>
>     user = request.user
>     profile = UserProfile.objects.get_or_create(user=user)
>
>     if request.method == "POST":
>
>         form = EditProfileForm(request.POST,instance=profile)
>         if form.is_valid():
>             profile = form.save()
>             return HttpResponseRedirect("/myprofile/")
>     else:
>         form = EditProfileForm(instance=profile)
>
>     return render_to_response("editprofile.html",{"form":form},
>                               context_instance=RequestContext
> (request))
>
> I keep getting the following error:
>
> AttributeError: 'tuple' object has no attribute '_meta'
>
> on the line:  form = EditProfileForm(instance=profile)
>
> any ideas what's wrong here ?

Could you please post more details.
a) Error is in forms.py or views.py or models.py ?

b) Can you figure out which lines are giving the error ?

You could use http://dpaste.com/ to paste the error details and send
us the link. that would save long email with error messages.

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



reverse errors while hosting app at WebFaction

2009-02-26 Thread adrian


I'm putting a Pinax-based app on WebFaction using mod_python.  It's
generating
these errors in the apache error log:

http://dpaste.com/1966/

This is probably an apache configuration or settings.py or path issue
because I don't get the error
with the dev server.   The directory structure is as follows:

~/webapps/django/myproject/  contains settings.py and my app
~/webapps/django/pinax-0.5.1/ contains /apps  and /libs  - all the
pinax apps and python libs needed

Here's the httpd.conf:

ServerRoot "/home/adriannye/webapps/django/apache2"

LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule python_module modules/mod_python.so
LoadModule rewrite_module modules/mod_rewrite.so

KeepAlive Off
Listen 8133
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\"" combined
CustomLog logs/access_log combined
ServerLimit 2


PythonHandler myproject.deploy.modpython
PythonDebug On
PythonPath "['/home/adriannye/webapps/django', '/home/adriannye/
webapps/django/pinax-0.5.1', '/home/adriannye/webapps/django/lib/
python2.5'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
SetHandler python-program


SetHandler None



The myproject.deploy.modpython handler is the one that comes with
PINAX - it sets the PYTHONPATH to include all the apps and libraries
it needs, then calls the django handler.   Here it is:

import os
import sys
import logging

from os.path import abspath, dirname, join
from site import addsitedir

from django.core.handlers.modpython import ModPythonHandler

PINAX_ROOT = abspath(join(dirname(__file__), "../../pinax-0.5.1/"))
PROJECT_ROOT = abspath(join(dirname(__file__), "../"))

class PinaxModPythonHandler(ModPythonHandler):
def __call__(self, req):
path = addsitedir(join(PINAX_ROOT, "libs/external_libs"), set
())
if path:
sys.path = list(path) + sys.path

sys.path.insert(0, join(PINAX_ROOT, "apps/external_apps"))
sys.path.insert(0, join(PINAX_ROOT, "apps/local_apps"))
sys.path.insert(0, join(PROJECT_ROOT, "apps"))

sys.path.insert(0, abspath(join(dirname(__file__), "../../")))

return super(PinaxModPythonHandler, self).__call__(req)

def handler(req):
# mod_python hooks into this function.
return PinaxModPythonHandler()(req)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



error while trying save a model form

2009-02-26 Thread uno...@gmail.com

I have the following model form:

class EditProfileForm(ModelForm):

class Meta:
model = UserProfile
exclude = ('user',)

The corresponding model is:

class UserProfile(models.Model):

user = models.ForeignKey(User)
firstname = models.CharField(max_length=50,blank=True)
lastname = models.CharField(max_length=50,blank=True)
blog = models.URLField(blank=True)
location = models.CharField(max_length=50,blank=True)
karma = models.IntegerField(editable=False,default="0")


and the view is:


def editprofile(request):

user = request.user
profile = UserProfile.objects.get_or_create(user=user)

if request.method == "POST":

form = EditProfileForm(request.POST,instance=profile)
if form.is_valid():
profile = form.save()
return HttpResponseRedirect("/myprofile/")
else:
form = EditProfileForm(instance=profile)

return render_to_response("editprofile.html",{"form":form},
  context_instance=RequestContext
(request))


I keep getting the following error:

AttributeError: 'tuple' object has no attribute '_meta'

on the line:  form = EditProfileForm(instance=profile)

any ideas what's wrong here ?

--~--~-~--~~~---~--~~
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 Question TextArea Html field and one about Admin Interface

2009-02-26 Thread Atishay

Hi

I am wondering if I can use django and create forms which have
textarea and people are allowed to format its content (like bold,
italics)..Something like WYSIWYG


Second Question, in admin interface I am able to group fields together
and assign them a class.
Ex: ('Date information', {'fields': ['pub_date'], 'classes':
['collapse']}),

How can I figure out all possible values for classes and what
facilities are there.
--~--~-~--~~~---~--~~
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 MPTT Admin

2009-02-26 Thread Antoni Aloy

2009/2/26 Matthias Kestenholz :
>
> Hey,
>
> A topic which comes up on this list from time to time is an automatic
> admin interface for django-mptt. I'd like to advertise a piece of code
> we have written at our company a little bit, and I'd also like to invite
> everyone to give comments and feedbacks. I do have many more ideas
> floating around, and there are a couple of issues still open, but I think
> the code is ready for wider review and maybe usage, who knows?
>
>
> The current version of the code generates an interface with drag/drop
> capabilities for managing mptt-based trees. It's still very clear that the
> code was extracted from a `classical' page cms. All you need to do
> is the following:
>
>
> -- 8< --
>
> from django.db import models
>
> class Category(models.Model):
>    title = models.CharField(max_length=200)
>    parent = models.ForeignKey('self', related_name='children',
> blank=True, null=True)
>
> -- 8< --
>
> from django.contrib import admin
> from feincms.admin import editor
>
> class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
>    pass
>
> admin.site.register(Category, CategoryAdmin)
>
> -- 8< --
>
> The generated admin interface looks like that:
>
> http://spinlock.ch/pub/feincms/category_tree_admin.png
>
> The page cms feeling is still very much there, but we'll see.
>
> In any case, you'll find the code on github:
> http://github.com/matthiask/feincms/tree/master
>
>
> Thanks,
> Matthias
>
>

It seems very nice. I'm going to give it a try. :)

Thank you!



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

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



how to use django-profiles / Editing user properties (without admin interface)

2009-02-26 Thread mahesh

Editing user properties (without admin interface)

I would like User to be able to user properties like email, and user
profile stuff like secret question, location etc.

I have created AUTH_PROFILE_MODULE; which has User as foreign key
models.ForeignKey(User,unique=True)

class MySiteProfile(models.Model):
location = models.CharField(max_length=3, choices=location)
user = models.ForeignKey(User,unique=True)
challenge= models.CharField(max_length=12)
response= models.CharField(max_length=12)

Question ->
I am using django-profiles; edit profile shows only 4 fields above; I
would like to see email (from class User) in profile modification
form, how do I accomplish this ?


--~--~-~--~~~---~--~~
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: updated poll example to take points for each item, gives more than 1 to upack err

2009-02-26 Thread seamusjr


> But what is points? Where is it coming from? As the traceback shows
> you, you haven't set the points variable anywhere. Where are you
> expecting it to come from?
> --
> DR.

I want to iterate thru the points property of the Song object, from
models.py, how can I output that from the views to the db?  Below is
from models.py

class Song(models.Model):
poll = models.ForeignKey(Poll)
name = models.CharField(max_length=200)
points = models.IntegerField()

def __unicode__(self):
return self.song
--~--~-~--~~~---~--~~
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: updated poll example to take points for each item, gives more than 1 to upack err

2009-02-26 Thread seamusjr


> But what is points? Where is it coming from? As the traceback shows
> you, you haven't set the points variable anywhere. Where are you
> expecting it to come from?
> --
> DR.

I want to iterate thru the points property of the Song object, from
models.py, how can I output that from the views to the db?  Below is
from models.py

class Song(models.Model):
poll = models.ForeignKey(Poll)
name = models.CharField(max_length=200)
points = models.IntegerField()

def __unicode__(self):
return self.song
--~--~-~--~~~---~--~~
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: updated poll example to take points for each item, gives more than 1 to upack err

2009-02-26 Thread seamusjr


> But what is points? Where is it coming from? As the traceback shows
> you, you haven't set the points variable anywhere. Where are you
> expecting it to come from?
> --
> DR.

I want to iterate thru the points property of the Song object, from
models.py, how can I output that from the views to the db?  Below is
from models.py

class Song(models.Model):
poll = models.ForeignKey(Poll)
name = models.CharField(max_length=200)
points = models.IntegerField()

def __unicode__(self):
return self.song
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Anyone using FCKEditor?

2009-02-26 Thread Brandon Taylor

Hi everyone,

I've had pretty good success with TinyMCE/django-admin-uploads so far,
but FCKEditor is boasting Python integration. Sure would be nice to
get built-in file handling support for Images, Flash, etc without
having to integrate any other 3rd party apps.

Has anyone been able to integrate FCKEditor with admin and use their
File Browser?

Cheers,
Brandon
--~--~-~--~~~---~--~~
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: Passing HTML Table to a Template

2009-02-26 Thread AmanKow



On Feb 26, 11:20 am, tyler kunter  wrote:
> thanks eric...I was able to fgure that out after a lil frustration thank you
> for your response.
>
> On Thu, Feb 26, 2009 at 1:32 AM, Eric Abrahamsen  wrote:
>
> > On Feb 26, 2009, at 4:30 PM, tykun...@gmail.com wrote:
>
> > > Hi I am trying to pass an HTML table to a template and have it display
>
> > > Currently I have{{table1}} inside my template to mark the position
> > > I wish to display the table
>
> > > In my views.py I havereturn render_to_response('results_s.html',
> > > {'table1': table1})
>
> > > From this all I get back is the code for the HTML table inside my
> > > template rather than having the template recognize it as HTML
>
> > You're almost certainly getting autoescaped (
> >http://docs.djangoproject.com/en/dev/topics/templates/#id2
> > ). Try using {{ table1|safe }} in your template.
>
> > Yours,
> > Erc
>
> > > Any suggestions on how I can pass the table and display it inside a
> > > template.
>
> > > thanks
Seems to me that the view is certainly aware that the html in table1
is safe.  Rather than filtering table1, putting the onus on the
template writer to know this, the view could simply:

from django.utils.safestring import mark_safe
...
return render_to_response('results_s.html', {'table1': mark_safe
(table1)})

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



Form & Paging

2009-02-26 Thread tsmets


I have a simple question over the best way I can paginate the result
coming from parameters passed by a POST.

In my current impelementation, I do the following :
The Form "posts" the information to filter the data and the result
is : "page one" of the query result.
The resulting page generates a link to access the page 2 / 3 / ... via
GET.
If the browser resubmits a POST.. it goes back to the page one of the
new result.

I have 2 problem with my solution :
[*] Paging is currently not generic
[*] URL are not clean anymore (as all the informations are passed by
the GET parameters).

Any hint into a clean solution would be appreciated.
I have looked at various extensions to do it automatically but ...

Tx,

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



Django Transaction Management

2009-02-26 Thread koranthala

Hi,
   Django Reference suggests that we use Transaction Middleware in the
web applications.
   What is the usual practice followed here? Do we use Transaction
Middleware most of the time?

   The reason why I am asking is due to the following reason:
   In my code, I at many places do the following
   Obj = Model(parm1, parm2)
   Obj.save()
   # Now store the id for future use
   l.append(Obj.id)
   etc.

   Now, I think this sort of code should be very usual in Web
Applications. But I cannot understand how this will work, since as per
my understanding, the _id_ will not be obtained until the DB actually
assigns one. Since transaction middleware allows the transaction to be
commited only at the end, this should fail right?

So, I wonder whether there is something missing in my code (say -
do transaction.commit() myself etc), if everybody does use transaction
middleware.
--~--~-~--~~~---~--~~
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 tapping into Amazon web service

2009-02-26 Thread Baxter

Disregard. Change was due to some changes in Amazon and/or XMLtramp,
coupled with inadequate error handling in my code.
--~--~-~--~~~---~--~~
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: updated poll example to take points for each item, gives more than 1 to upack err

2009-02-26 Thread Daniel Roseman

On Feb 26, 5:10 pm, seamusjr  wrote:
> Ok, I got rid of the pointx variables, replaced them with the
> following and restarted the server.
>
> selected_song_set.points = points
> selected_song_set.save()
>
> Here is the traceback:
>
> Environment:
>
> Request Method: POST
> Request URL:http://127.0.0.1:8000/polls/1/vote/
> Django Version: 1.1 pre-alpha SVN-9814
> Python Version: 2.5.1
> Installed Applications:
> ['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.comments',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'mysite.polls']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> Traceback:
> File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
> in get_response
>   86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/Users/seamus/Sources/django/mysite/../mysite/polls/views.py" in
> vote
>   18.           selected_song_set.points = points
>
> Exception Type: NameError at /polls/1/vote/
> Exception Value: global name 'points' is not defined

But what is points? Where is it coming from? As the traceback shows
you, you haven't set the points variable anywhere. Where are you
expecting it to come from?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: template ifequal substitution of value

2009-02-26 Thread Jesse

I figured out what to do.

I created a new instance in the view.py:

def search(request):
newdate='1999'

In the template I used the "Y" for both instances and was able to get
the comparison to work:

{% ifequal  items.startdt|date:"Y"  newdate|date:"Y"  %}

this does the correct comparison

   {% endifequal %}
--~--~-~--~~~---~--~~
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 nube

2009-02-26 Thread Serdar T.



> j...@john-laptop:~/Django/mysite$ ls -l

Try using the full path to the file rather than the ~ shortcut:

/home/username/Django/mysite/mysite_data.db
--~--~-~--~~~---~--~~
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: Beginners question

2009-02-26 Thread wegi

Thanks, everyone exactly what I was missing.
wegi

On 25 Feb., 15:28, Daniel Roseman 
wrote:
> On Feb 25, 12:33 pm,wegi wrote:
>
>
>
> > Hi all,
> > I'm new to django, made my way through the tutorial and parts of the
> > remaining documentation. But one thing remains unclear to me. Let's
> > assume I have two apps news and links which just manage these type of
> > objects. I have a view and a template for displaying a list of the 5
> > newest entries in each app.
> > As long as I just display static content and the latest 5 news (or
> > links) entries everything is fine (something like base.html with news/
> > 5_newest_entries.html).
> > But now I want to embed these apps in a site and want to display both,
> > the newest 5 news AND newest 5 links on the startpage. I can have a
> > template with blocks defined, ...
> > Can I reuse the views of the apps or do I have to write a special view
> > doing all the logic of the apps views again? Of course the given
> > example is trivial, but the question is a general one.
> > What is the preferred way of embedding multiple app views in one page?
> > I guess I missed something in the docs, any hints will be appreciated.
>
> > thanks,
> >wegi
>
> This is what templatetags are for. In particular, inclusion tags are
> well-suited to this: they're basically a way of encapsulating code to
> render a template fragment, including any database logic, which you
> can then embed in any other template. 
> See:http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#incl...
>
> And James Bennett did a great post on these a few years 
> ago:http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-tem...
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to populate a custom ModelForm?

2009-02-26 Thread rajeesh

Sorry for repeating this, but I'm still clue-less on it and the
deadline approaches fast: The current work_around(http://dpaste.com/
hold/427) seems too ugly. But that's not why I'm back. I've stumbled
upon one more similar problem. Both can be grouped together into this
statement: What's the right approach in saving a ModelForm when it
contains a subset of fields of a related_field or an inline_formset
formed by such a subset? All those excluded arguments are required and
need to be attached to the related_instance at some_point. A Note at
the documentation, 
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form
seems to identify the problem but offers a trivial solution at api
level.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem tapping into Amazon web service

2009-02-26 Thread bax...@gretschpages.com

This code used to work, but appears to have stopped working at some
point. I suspect it's either a unicode or escaping thing. I'm trying
to use Amazon web services and return books:

amazonfile = urllib.urlopen("http://webservices.amazon.com/onca/xml?
Service=AWSECommerceService=mykey=myID=ItemSearch=myAuthor=Books=Medium").read
()

xml = xmltramp.parse(amazonfile)

for item in xml.Items:
   ""do stuff. For purposes of debugging..."
  print item.ItemAttributes.Title

It fails with "no child element named ItemAttributes"

Looking at the XML, I clearly see ItemAttributes as a child of Items.

When I have it print xml, I'm not seeing an xml format, so that's why
I'm suspecting some kind of unicode or escaping problem.

Thoughts?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: updated poll example to take points for each item, gives more than 1 to upack err

2009-02-26 Thread seamusjr

Ok, I got rid of the pointx variables, replaced them with the
following and restarted the server.

selected_song_set.points = points
selected_song_set.save()

Here is the traceback:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/polls/1/vote/
Django Version: 1.1 pre-alpha SVN-9814
Python Version: 2.5.1
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.comments',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'mysite.polls']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/seamus/Sources/django/mysite/../mysite/polls/views.py" in
vote
  18.   selected_song_set.points = points

Exception Type: NameError at /polls/1/vote/
Exception Value: global name 'points' is not defined

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



clear() seems not to work

2009-02-26 Thread super

using django 1.0.x from svn

I'm doing the following to disassociates a relation.

instance = Some.objects.get(pk=1)
insance.bar_set.clear()

bar_set has a method clear yet and the foreignkey in bar is
"null=True"

Yet if I call "clear()" then nothing happens. the foreignkeys are not
set to NULL ...

What am I not understanding about this. I'm reading this part of the
docs
http://docs.djangoproject.com/en/dev/ref/models/relations/#ref-models-relations
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Can't get the CsrfMiddleware to work with Ajax requests

2009-02-26 Thread Sylvain

Hello everybody,

I've been hitting my head against the walls for the last two days
because I can't figure out what I'm doing wrong with this middleware.
I added the middleware in my MIDDLEWARE_CLASSES that way :

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.csrf.middleware.CsrfMiddleware',
'myproject.apps.punbb.middleware.CookieRenewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'myproject.apps.punbb.middleware.CookieLoginMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

In my CookieRenewMiddleware I have a process_response which deals with
the request.user so I placed it before the Authentication and Session
middlewares so the response is treated only after the request.user
object is available.

In my CookieLoginMiddeware I have a process_request which also deals
with the request.user, so I placed it after the Authentication and
Session middlewares so the request is treated only after the
request.user object is available.

There wasn't any problem so far, so I decided to add the
CsrfMiddleware. I tried it on various forms and it seemed to work
pretty well. Then I tried to use an Ajax form but I got an internal
server error :

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 277, in run
self.result = application(self.environ, self.start_response)

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 634, in __call__
return self.application(environ, start_response)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 243, in __call__
response = middleware_method(request, response)

  File "/myproject/apps/punbb/middleware/__init__.py", line 64, in
 process_response
if COOKIE_NAME in request.COOKIES and request.user.is_authenticated
():

  File "/usr/lib/python2.5/site-packages/django/contrib/auth/
middleware.py", line 5, in __get__
request._cached_user = get_user(request)

  File "/usr/lib/python2.5/site-packages/django/contrib/auth/
__init__.py", line 83, in get_user
user_id = request.session[SESSION_KEY]

AttributeError: 'WSGIRequest' object has no attribute 'session'

I tried changing the order of the middlewares but it doesn't seem to
do anything. If I remove the "CookieRenewMiddleware" it works but I
get a 403 response from the CsrfMiddleware, saying that a CSRF has
been detected, although it's an Ajax POST request WITH a X-Requested-
With header (using jQuery) ! Also if I remove the CsrfMiddleware,
everything works fine...

I'm using Django 1.0.

I really don't know what to do, so any help would be highly
appreciated,
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: Connecting to Oracle

2009-02-26 Thread Brandon Taylor

Hi Karen,

5.0.1 just came out a few days ago. Upgrading solved the issue and now
I can get connected to Oracle. Woohoo.

b

On Feb 20, 11:44 am, Karen Tracey  wrote:
> On Fri, Feb 20, 2009 at 10:52 AM, Brandon Taylor 
> wrote:
>
>
>
>
>
> > Hi everyone,
>
> > I'm having a hell of a time getting connected to Oracle...
>
> > We're running Intel MacBooks, OS X 10.5.6, Python 2.6.1, Django Trunk,
> > Oracle InstantClient 10_2.
>
> > We have tried using cx_Oracle-5.0 and 4.4.1. cx_Oracle seems to
> > compile and install successfully, but, when we attempt to run a
> > project using the built-in server, we're getting an error with both
> > versions:
>
> > Unhandled exception in thread started by  > 0x782030>
> > [snip]
> >  Referenced from: /Users/bft228/.python-eggs/cx_Oracle-4.4.1-py2.6-
> > macosx-10.3-i386.egg-tmp/cx_Oracle.so
> >  Reason: image not found
>
> > Can anyone out there help me get this working? I have very limited
> > experience with Oracle, so please bear with me.
>
> Have you read this page or the ones it references:
>
> http://codingnaked.wordpress.com/2008/05/07/build-and-install-cx_orac...
>
> ?
>
> Someone in the comments there had the same error message and seemed to
> figure out how to fix it.
>
> Also, do not use cx_oracle 5.0.  It has a bug that will cause problems, see:
>
> http://code.djangoproject.com/ticket/9935#comment:4
>
> 5.0.1 will apparently be OK, but 5.0 is definitely not good.
>
> 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: Fwd: python sql query in django

2009-02-26 Thread Jesse

Thank you for all the suggestions!

Solution 1 - Did not work:  pub4=Publication.objects.filter
(techpubcombo__technology=t).filter(pathpubcombo__pathology=p).filter
(commpubcombo__commodity=c)
Solution 1 didn't pull any records

Solution 2 - Did not work:
pub5=Publication.objects.filter(commpubcombo__commodity=c)
pub5=Publication.objects.filter(pathpubcombo__pathology=p)
pub5=Publication.objects.filter(techpubcombo__technology=t)
Solution 2:  Grabbed the last selection, overwriting the two previous
selections

Solution 3 - Did work!
for publication in pub1:
if publication not in list:
list.append(publication)
for publication in pub2:
if publication not in list:
list.append(publication)
for publication in pub3:
if publication not in list:
list.append(publication)

My last question!  How do I sort the list.append(publication) by
pubtitle?

Thank you!




On Feb 25, 9:24 pm, Parthan SR  wrote:
> On Thu, Feb 26, 2009 at 2:24 AM, Jesse  wrote:
>
> > I have three statements:
> > publications = Publication.objects.filter(techpubcombo__technology=t)
> > publications2 = Publication.objects.filter(pathpubcombo__pathology=p)
> > publications3 = Publication.objects.filter(commpubcombo__commodity=c)
>
> > I need to combine the three sets into one set to eliminate duplication
> > in the publications and then output the final set to the template.
>
> If am not wrong, the result of first filter is a query object until
> you do .all() on it (for ex.) and hence the query object can be
> subjected to other filters as well if required. So you should be able
> to do one of the following..
>
> [1] publications =
> Publication.objects.filter(techpubcombo__technology=t).filter(pathpubcombo__pathology=p).filter(commpubcombo__commodity=c)
> [2]  publications = Publication.objects.filter(techpubcombo__technology=t)
>  publications = Publication.objects.filter(pathpubcombo__pathology=p)
>  publications = Publication.objects.filter(commpubcombo__commodity=c)
>
> both [1] and [2] applies all the three filter conditions on the
> Publication.objects and return you the final query object on which you
> might be able to do publications.all() and get all the results.
>
> --
> With Regards,
>
> Parthan "Technofreak" (2FF01026)http://blog.technofreak.in
--~--~-~--~~~---~--~~
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: lighty vs. nginx for deploying Django

2009-02-26 Thread Jacob Kaplan-Moss

On Thu, Feb 26, 2009 at 2:46 AM, Gour  wrote:
> Although I'm still fiddling on my 'localhost', I'd like to know which
> web server you recommend to settle on between lighty and nginx (Apache
> excluded) so I can be clear in the future when choosing hosting/VPS for
> Django sites and can learn about it on my localhost?

The best thing you can do is try both and pick the one that works
better for you. Me, I generally try to pick the software that's got
better documentation so that I spend less time fussing with it, but
other folks might want to choose the faster tool, or the one with more
features, or ...

Set them both up, run some tests/benchmarks, and pick what you think works best.

> The 'django' book and official docs gives example of lighty, but I'm not
> sure it is due whether it is due to it advantage over nginx or something
> else...

That's really just because when I wrote the docs and that part of the
book I didn't know nginx existed -- no other reason.

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: Passing HTML Table to a Template

2009-02-26 Thread tyler kunter
thanks eric...I was able to fgure that out after a lil frustration thank you
for your response.

On Thu, Feb 26, 2009 at 1:32 AM, Eric Abrahamsen  wrote:

>
>
> On Feb 26, 2009, at 4:30 PM, tykun...@gmail.com wrote:
>
> >
> > Hi I am trying to pass an HTML table to a template and have it display
> >
> > Currently I have{{table1}} inside my template to mark the position
> > I wish to display the table
> >
> > In my views.py I havereturn render_to_response('results_s.html',
> > {'table1': table1})
> >
> > From this all I get back is the code for the HTML table inside my
> > template rather than having the template recognize it as HTML
>
> You're almost certainly getting autoescaped (
> http://docs.djangoproject.com/en/dev/topics/templates/#id2
> ). Try using {{ table1|safe }} in your template.
>
> Yours,
> Erc
>
>
> >
> > Any suggestions on how I can pass the table and display it inside a
> > template.
> >
> > 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: Sessions with different expiry dates

2009-02-26 Thread ggates03

Thank you, that set me on the right track.

On Feb 24, 9:35 pm, Malcolm Tredinnick 
wrote:
> On Tue, 2009-02-24 at 11:36 -0800, ggates03 wrote:
> > Is there any way to have multiple sessions for one browser?
> >  Basically
> > I have a need for different cookie values to expire at different
> > times.  There are some values I want to expire with the browser
> >session, however there are other values I would like to last longer,
> > for example a last visited date.
>
> Multiple sessions? No, since the Django sessions framework is
> implemented via a single cookie on the client side.
>
> Multiple cookies, however, is easy. Just set the cookie details in the
> HttpReponse yourself, giving them whatever names and expiry times you
> like. See the django.contrib.sessions.* code for an example of how to do
> this if you like.
>
> Hmm ... just occurred to me: you could combine both solutions. Implement
> the whole multiple cookies stuff and make it into asessionbackend.
> Django supports custom / third-partysessionbackends (it's pluggable),
> so once you get this working by hand, you could make it work
> transparently via thesessionmechanism with a bit of extra work.
>
> 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: get translated text from ugettext_lazy() result

2009-02-26 Thread Matej

This looks like it should work but it does not.
WebStoreRating fields delivery and ui have defined
choices=RATING_CHOICES

>>> r = WebStoreRating.objects.filter(pk=1)
>>> r = r[0]
>>> r.get_delivery_display()
3
>>> r.get_ui_display()
3
>>>

I get the first field insted of the second.
Here I get 3 but I want 'OK' or it's translation.

On Feb 26, 3:38 pm, Alex Gaynor  wrote:
> On Thu, Feb 26, 2009 at 4:36 AM, Matej  wrote:
>
> > Hello.
> > I would like to get my translated text from ugettext_lazy() result.
> > How can I do that?
>
> > Example:
> >http://dpaste.com/1744/
>
> > #models.py
> > RATING_CHOICES = (
> >    ('0', _('I don\'t know')),
> >    ('1', _('Very bad')),
> >    ('2', _('Bad')),
> >    ('3', _('OK')),
> >    ('4', _('Good')),
> >    ('5', _('Excelent')),
> > )
>
> > #extra_tags.py
> > @register.simple_tag
> > def show_webstore_user_ratings(user_ratings):
> >    A = RATING_CHOICES[user_ratings]
> >    return A[1]
>
> Perhaps you're looking for this 
> method:http://docs.djangoproject.com/en/dev/ref/models/instances/#get-foo-di...
>
> 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
-~--~~~~--~~--~--~---



broken pipe urlpattern

2009-02-26 Thread Adonis

hello dear djangonauts,

Could anyone explain what is wrong here and i am getting an error 32:
broken pipe?
I am using this url: ...appname/mama/10/10/

*
url.py

(r'^appname/mama/(?P\d+)/(?P\d+)/$',
'appname.views.mama')
(r'^appname/mama/(?P\d+)/(?P\d+)/(?P.*)$',
'django.views.static.serve', {'document_root': '/blah'})

views.py

def mama(request, arg_one=0, arg_two=0):
print arg_one
print arg_two
return render_to_response('blah/mainIntro.html')
*

Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Docstring documentation

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 7:23 AM, Stefan Tunsch  wrote:

>
> Hi!
>
> I have a site that is starting to be used by a growing number of users,
> and I find myself in the need of creating some kind of user manual.
> My first thought has been to use the docstrings with which I'm
> documenting my code.
> I've seen that django comes with a Documentation option in the admin
> that pulls the docstrings present in your code.
>
> My question is:
>
> How can I use this in my own views?
> Anyone has some experience with this issue?
> What approach would be best.
>
>
> Right now I'm not even capable of  placing the docstring of a view
> inside of a variable of this same view in order to use it in my context...
>
>
> Regards, Stefan
>
> >
> This occurs through introspection of view and template tags by using the
docutils module and the __doc__ attribute on functions, you can see how it
occurs here:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admindocs/views.py

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: get translated text from ugettext_lazy() result

2009-02-26 Thread Alex Gaynor
On Thu, Feb 26, 2009 at 4:36 AM, Matej  wrote:

>
> Hello.
> I would like to get my translated text from ugettext_lazy() result.
> How can I do that?
>
> Example:
> http://dpaste.com/1744/
>
> #models.py
> RATING_CHOICES = (
>('0', _('I don\'t know')),
>('1', _('Very bad')),
>('2', _('Bad')),
>('3', _('OK')),
>('4', _('Good')),
>('5', _('Excelent')),
> )
>
> #extra_tags.py
> @register.simple_tag
> def show_webstore_user_ratings(user_ratings):
>A = RATING_CHOICES[user_ratings]
>return A[1]
>
> >
>
Perhaps you're looking for this method:
http://docs.djangoproject.com/en/dev/ref/models/instances/#get-foo-display

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: A solution for django/postgresql transaction problem

2009-02-26 Thread Sushant Sinha

On Wed, 2009-02-25 at 23:09 -0500, Karen Tracey wrote:
> You want to use the transaction commit/rollback routines, not cursor
> ones:
> 
> http://docs.djangoproject.com/en/dev/topics/db/transactions/

I did not know about this. 

>   
> 
> I think that the cursor should rollback if there is an error
> and then
> throw the exception. Thats a more reasonable behavior than
> what we
> have right now.
> 
> Except rollback isn't the only option, from what I read.  Though I
> have never experimented with it, apparently your code could also
> choose to commit the transaction at this point.  Your code is the only
> code with enough context to know whether what's been done so far
> should be committed anyway despite the error or if the error should
> cause the whole thing to be rolled back.  

I agree with you that a user code can best determine whether to roll
back or commit. However, I think this is not reflected in the
documentation for the models at all.

http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs
http://docs.djangoproject.com/en/dev/topics/db/models/#topics-db-models

My understanding is that updates/insert/delete to database models are
handled as auto-commit transactions (each model query is itself a
transaction). However, in case of a failure, django gives me a bad state
of the database. And my rest of the code fails if I do not explicitly
handle the transaction commit/rollover. This seems really problematic
for the programmer.

If a single query fails, then what does commit mean. Shouldn't we do
just rollover as commit has no meaning?

-Sushant.

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



django.test HTTP/XMLRPC Testing with use of settings.TEST_DATABASE_NAME

2009-02-26 Thread x_O

Hi

Recently I'm trying to write tests for almost every thing in my code.
Including HTTP and XMLRPC requests.

from django.test import TestCase

class XmlRpcCase(TestCase):
def setUp(self):
self.xmlrpc = xmlrpclib.ServerProxy("http://127.0.0.1:8000/
store/xmlrpc")

def testCreate(self):
case = dict(name='case_name')
self.xmlrpc.Case.create(case)
self.assertEquals(Case.objects.count(), 1)

Right now test will use a DATABASE_NAME to create a case object by
XMLRPC request, and after that will use in assertion
TEST_DATABASE_NAME. So the result will be always failed.

Any ideas for some smart solution for this kind of cases.

x_O

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



Configuring django cms with mod_python

2009-02-26 Thread stuart

Hi,

I'm new to django and am having problems configuring the django-cms
application with apache (using mod_python). I have followed the
install steps (http://django-cms.org/installation/) but Apache throws
the following error:

ImportError: No module named cms

My foo.com website code has 1 inventory application with the following
file system paths:

/home/mycode/foo
/home/mycode/foo/inventory
/home/mycode/foo/cms

... my apache virtual hosts file contains:


ServerName foo.co.uk
ServerAlias *foo.*
DocumentRoot /home/mycode/foo


allow from all
Options None



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



SetHandler None



... and my /home/mycode/foo/settings.py file contains:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'foo.inventory',
'cms',
)

(I restarted apache after the configuration changes too)

Is there a problem with my virtual host or mod_python configuration?

--~--~-~--~~~---~--~~
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: Postgis on Mac OS Leopard

2009-02-26 Thread omat * gezgin.com

Thanks for the pointer.

But I checked the architecture of the liblwgeom.so with 'file' and the
result is:
/usr/local/pgsql_saved_0804141532/lib/liblwgeom.so: Mach-O bundle i386

which is the correct architecture for my Intel based macbook pro.

I am lost.





On Feb 26, 1:25 pm, Graham Dumpleton 
wrote:
> On Feb 26, 10:07 pm, omat  wrote:
>
>
>
> > Hi all,
>
> > Following the instructions on inhttp://geodjango.org/docs/install.html,
> > i managed to get to "Creating a Spatial Database Template" section.
>
> > But when trying to execute the line below (as postgres user of
> > course):
> > $ psql -d template_postgis -f `pg_config --sharedir`/lwpostgis.sql
>
> > it complained that it cannot find "liblwgeom".
>
> > I found the lwpostgis.sql under directory:
> > /usr/local/pgsql_saved_0804141532/share/
> > which does not look very right. I examined the file and it has:
> > ...
> > CREATE OR REPLACE FUNCTION histogram2d_in(cstring)
> >         RETURNS histogram2d
> >         AS '$libdir/liblwgeom', 'lwhistogram2d_in'
> >         LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
> > ...
>
> > $libdir shell variable is ''. I located the liblwgeom.so which is
> > refered in the sql file here:
> > /usr/local/pgsql_saved_0804141532/lib/liblwgeom.so
>
> > When I tried to run the sql command above on the template_postgis db,
> > fixing the paths manually, I get:
>
> > ERROR:  could not load library "/usr/local/pgsql_saved_0804141532/lib/
> > liblwgeom.so": dlopen(/usr/local/pgsql_saved_0804141532/lib/
> > liblwgeom.so, 10): no suitable image found.  Did find:
> >         /usr/local/pgsql_saved_0804141532/lib/liblwgeom.so: mach-o, but 
> > wrong
> > architecture
>
> > Can it be that a conflicting version already existed and caused
> > problems? Or what?
>
> > I took the "build from source" path as instructed in the install
> > documentation. I am using PostgreSQL 8.2 / PostGIS 1.3.5 on Mac OS X
> > Leopard (10.5.6)
>
> Read:
>
>  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
>
> Various sections in this cover aspects of this problem which would be
> relevant, even if you aren't using mod_wsgi.
>
> It is all because MacOS X can run on different architectures. That is,
> PPC and Intel, plus 32 bit and 64 bit variants of same. Your library
> doesn't have required architecture for what application that is using
> it is running as.
>
> Use 'file' command on the library to work out what architectures it
> does provide. You then need to recompile stuff so it also includes
> other architectures that may be required.
>
> There are some pointers in that document about how to compile for all
> architectures.
>
> Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: updated poll example to take points for each item, gives more than 1 to upack err

2009-02-26 Thread Daniel Roseman

On Feb 26, 3:41 am, seamusjr  wrote:
> I am trying to modify the polls example from djangoproject.com to take
> a integer point value for each of the 1 thru 5 poll items instead of
> having a radio button where u select one.  However, I am having
> problems with the views.py syntax.  I changed the Choice obejct to be
> a Song object and changed the name of the choice and votes properties
> to be name and points respectively.  I keep getting this annoying
> "need more than 1 value to unpack" error.  Below are some snippets of
> code.  Please can someone help me out with the views syntax, or do I
> need to create a ModelForm/form to deal with getting the input to the
> views.
>
> Thanks in advance,
> Seamus
>



Is there any reason you couldn't actually post the traceback - which
shows exactly where the error happens - instead of this load of random
code snippets? I don't know if anyone will be bothered to read through
it all to find out what's wrong, especially when there's no way your
code could run as posted (where do all those pointx variables come
from?)

Please, post the traceback, and the minimal amount of actual code that
produces the error.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Docstring documentation

2009-02-26 Thread Stefan Tunsch

Hi!

I have a site that is starting to be used by a growing number of users, 
and I find myself in the need of creating some kind of user manual.
My first thought has been to use the docstrings with which I'm 
documenting my code.
I've seen that django comes with a Documentation option in the admin 
that pulls the docstrings present in your code.

My question is:

How can I use this in my own views?
Anyone has some experience with this issue?
What approach would be best.


Right now I'm not even capable of  placing the docstring of a view 
inside of a variable of this same view in order to use it in my context...


Regards, Stefan

--~--~-~--~~~---~--~~
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 about "You appear not to have the 'sqlite3' program installed or on your path."

2009-02-26 Thread Ramiro Morales

On Thu, Feb 26, 2009 at 9:51 AM, jason zones  wrote:
> hello, all.
> i have a problem when i type "python manage.py dbshell" in the commandline
> within the mysite folder. i used sqlite3 as the db.
> when i typed the command, it showed the error "You appear not to have the
> 'sqlite3' program installed or on your path."
> my installed python version is 2.6 and it is said the sqlite3 being a
> module in the python, so i tried "import sqlite3", and it worked. so it
> seemed sqlite3 module was there in the python, but it just cannot go into
> the dbshell with "python manage.py dbshell" as the djangobook told. i also
> tried to append the dir"c:\python26\Lib\sqlite3" to the sys path, but it
> seemed not work.  my operating system is windows xp, anyone knows what's
> wrong?

There are two thing named sqlite3 at play here:

First, the sqlite3 module that is part of the standard library  for Python 2.5
and newer. The fact that's it's included means, in your platform, some files
and directories named sqlite3.* and _sqlite3 under your C:\python2x
installation directory, but you aren't supposed to mess with them because they
are an implementation detail and you'd be breaking your Python installation if
you did (just for completeness: they are the SQLite library in a dynamic
library form and the Python DB-API 2module that allows Python programs like
Django to access SQLite databases).

Second there is the sqlite3.exe utility that can be download from SQLIte web
site. It's a program that also knows how to access SQLite databases because it
includes the SQLite library compiled statically for its own use (so the program
can be used in an standalone fashion).

The dbshell Django management command uses this utility. So you need
to download sqlite3.exe if you want to use it.

Regards,

--
 Ramiro Morales

--~--~-~--~~~---~--~~
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: optional parameter url

2009-02-26 Thread Adonis

Thank you for your replies,

Kevin,
Adding a slash does no good when it comes to calling static files
using serve(). It works different than the regexp for calling a def
from views.py because it searches for directories, file extensions
etc.

Raffaele,
swaping the lines produces an "error 32, broken pipe".
I have been trying to figure out why but i did not find anything yet.
The parameters though are read and printed. I can not manage to do sth
with Error handling.

Any further suggestions?

On Feb 25, 7:23 pm, Raffaele Salmaso 
wrote:
> Adonis wrote:
> > (r'^appname/mainpage/(?P.*)$', 'django.views.static.serve',
> > {'document_root': '/mesa'}),
>
> this takes *everything* as 'path'> 
> (r'^appname/mainpage/(?P\d+)/(?P.*)$',
> > 'django.views.static.serve', {'document_root': '/mesa'}),
>
> this takes only digits as 'xexe', but it never get called because it
> cames after .*
>
> swap them as
> (r'^appname/mainpage/(?P\d+)/(?P.*)$',
>  'django.views.static.serve', {'document_root': '/mesa'}),
> (r'^appname/mainpage/(?P.*)$', 'django.views.static.serve',
>  {'document_root': '/mesa'}),
>
> --
> ()_() | That said, I didn't actually _test_ my patch.      | +
> (o.o) | That's what users are for!                         | +---+
> 'm m' |                                   (Linus Torvalds) |  O  |
> (___) |                      raffaele at salmaso punto org |
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem about "You appear not to have the 'sqlite3' program installed or on your path."

2009-02-26 Thread jason zones
hello, all.
i have a problem when i type "python manage.py dbshell" in the commandline
within the mysite folder. i used sqlite3 as the db.
when i typed the command, it showed the error "You appear not to have the
'sqlite3' program installed or on your path."
my installed python version is 2.6 and it is said the sqlite3 being a
module in the python, so i tried "import sqlite3", and it worked. so it
seemed sqlite3 module was there in the python, but it just cannot go into
the dbshell with "python manage.py dbshell" as the djangobook told. i also
tried to append the dir"c:\python26\Lib\sqlite3" to the sys path, but it
seemed not work.  my operating system is windows xp, anyone knows what's
wrong?
many thanks.

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



Re: Django nube

2009-02-26 Thread john

Or perhaps they will remain trivial for a while.

I added the name as such:
DATABASE_NAME = '/Django/mysite/mysite_data.db'
{I have tried w/ ~, w/o leading /, with /john/Djan..., and w/ john/
Dja...}

My project looks like this:
j...@john-laptop:~/Django/mysite$ ls -l
total 24
-rw-r--r-- 1 john john0 2009-02-25 22:48 __init__.py
-rw-r--r-- 1 john john  133 2009-02-25 23:09 __init__.pyc
-rw-r--r-- 1 john john  546 2009-02-25 22:48 manage.py
-rw-r--r-- 1 john john 2805 2009-02-26 05:03 settings.py
-rw-r--r-- 1 john john 1699 2009-02-26 05:03 settings.pyc
-rw-r--r-- 1 john john  537 2009-02-25 22:48 urls.py
-rw-r--r-- 1 john john  233 2009-02-25 23:11 urls.pyc
j...@john-laptop:~/Django/mysite$

Now I am getting:
  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", line 145, in _cursor
self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file



On Feb 26, 4:19 am, john  wrote:
> WOW!!! That was painfully obvious.  As I said newbe...to python,
> django, and programming.  Hopefully my questions will get more
> interesting soon!
>
> Thanks
>
> On Feb 26, 3:29 am, Karen Tracey  wrote:
>
> > On Thu, Feb 26, 2009 at 2:41 AM, john  wrote:
>
> > > I am trying to follow the Django | Writing your first Django ap part 1
> > > tutorial.  When I get to the python manage.py syncdb command I get the
> > > following:
>
> > > Traceback (most recent call last):
> > > [snip]
> > >    raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> > > settings module before using the database."
> > > django.core.exceptions.ImproperlyConfigured: Please fill out
> > > DATABASE_NAME in the settings module before using the database.
>
> > > Here is how my settings. py file is settup.
>
> > > ADMINS = (
> > >    # ('Your Name', 'your_em...@domain.com'),
> > > )
>
> > > MANAGERS = ADMINS
>
> > > DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2',
> > > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> > > DATABASE_NAME = ''             # Or path to database file if using
> > > sqlite3.
>
> > You need to decide on a name and fill on in here.  (Note the comments don't
> > say "Not used with sqlite3" for this one, as they do for the following
> > ones.  The DATABASE_NAME is required for sqlite3.
>
> > > DATABASE_USER = ''             # Not used with sqlite3.
> > > DATABASE_PASSWORD = ''         # Not used with sqlite3.
> > > DATABASE_HOST = ''             # Set to empty string for localhost.
> > > Not used with sqlite3.
> > > DATABASE_PORT = ''             # Set to empty string for default. Not
> > > used with sqlite3.
>
> > > [snip]
> > > My understanding is, that because I am using sqlite it will
> > > automatically create a database file when I run the syncdb command.  I
> > > had a slightly different experience with Turbogears.
>
> > Yes, it will be created automatically.  So if the file you specify in
> > DATABASE_NAME does not exist, it will be created.  You still have to specify
> > a name for it, though, as described here:
>
> >http://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup
>
> > 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
-~--~~~~--~~--~--~---



Postgis on Mac OS Leopard

2009-02-26 Thread omat

Hi all,

Following the instructions on in http://geodjango.org/docs/install.html,
i managed to get to "Creating a Spatial Database Template" section.

But when trying to execute the line below (as postgres user of
course):
$ psql -d template_postgis -f `pg_config --sharedir`/lwpostgis.sql

it complained that it cannot find "liblwgeom".

I found the lwpostgis.sql under directory:
/usr/local/pgsql_saved_0804141532/share/
which does not look very right. I examined the file and it has:
...
CREATE OR REPLACE FUNCTION histogram2d_in(cstring)
RETURNS histogram2d
AS '$libdir/liblwgeom', 'lwhistogram2d_in'
LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
...

$libdir shell variable is ''. I located the liblwgeom.so which is
refered in the sql file here:
/usr/local/pgsql_saved_0804141532/lib/liblwgeom.so

When I tried to run the sql command above on the template_postgis db,
fixing the paths manually, I get:

ERROR:  could not load library "/usr/local/pgsql_saved_0804141532/lib/
liblwgeom.so": dlopen(/usr/local/pgsql_saved_0804141532/lib/
liblwgeom.so, 10): no suitable image found.  Did find:
/usr/local/pgsql_saved_0804141532/lib/liblwgeom.so: mach-o, but wrong
architecture


Can it be that a conflicting version already existed and caused
problems? Or what?

I took the "build from source" path as instructed in the install
documentation. I am using PostgreSQL 8.2 / PostGIS 1.3.5 on Mac OS X
Leopard (10.5.6)


Thanks for any help.


--
omat

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



Re: How to select a single field from database with django QuerySet API?

2009-02-26 Thread marco sedda

Thanks!!!

On Feb 26, 10:28 am, Eric Abrahamsen  wrote:
> On Feb 26, 2009, at 6:23 PM, marco sedda wrote:
>
>
>
> > Hi,
> >   I want to select a "single" field from a table, i've read the
> > QuerySet API reference but i can't find anything to solve my query.
>
> > Just to explain:
>
> > If i've a table like:
>
> > User
> >   first_name = models.CharField(max_length=30)
> >   last_name = models.CharField(max_length=30)
>
> > how i can execute a sql query "SELECT first_name FROM User" with
> > QuerySet API?
>
> You want the values() queryset call 
> (http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
> ). Your query would probably look like  
> User.objects.values('first_name'), or if you wanted a plain list  
> (values usually returns a dictionary), you can use values_list() with  
> the 'flat' parameter.
>
> Hope that helps,
> 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: How to select a single field from database with django QuerySet API?

2009-02-26 Thread Eric Abrahamsen


On Feb 26, 2009, at 6:23 PM, marco sedda wrote:

>
> Hi,
>   I want to select a "single" field from a table, i've read the
> QuerySet API reference but i can't find anything to solve my query.
>
> Just to explain:
>
> If i've a table like:
>
> User
>   first_name = models.CharField(max_length=30)
>   last_name = models.CharField(max_length=30)
>
> how i can execute a sql query "SELECT first_name FROM User" with
> QuerySet API?

You want the values() queryset call 
(http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields 
). Your query would probably look like  
User.objects.values('first_name'), or if you wanted a plain list  
(values usually returns a dictionary), you can use values_list() with  
the 'flat' parameter.

Hope that helps,
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: How to select a single field from database with django QuerySet API?

2009-02-26 Thread Russell Keith-Magee

On Thu, Feb 26, 2009 at 7:23 PM, marco sedda  wrote:
>
> Hi,
>   I want to select a "single" field from a table, i've read the
> QuerySet API reference but i can't find anything to solve my query.
>
> Just to explain:
>
> If i've a table like:
>
> User
>   first_name = models.CharField(max_length=30)
>   last_name = models.CharField(max_length=30)
>
> how i can execute a sql query "SELECT first_name FROM User" with
> QuerySet API?

Depending on the exact format of the output that you want, either use values():

http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields

or values_list():

http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list-fields

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



How to select a single field from database with django QuerySet API?

2009-02-26 Thread marco sedda

Hi,
   I want to select a "single" field from a table, i've read the
QuerySet API reference but i can't find anything to solve my query.

Just to explain:

If i've a table like:

User
   first_name = models.CharField(max_length=30)
   last_name = models.CharField(max_length=30)

how i can execute a sql query "SELECT first_name FROM User" with
QuerySet API?

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

2009-02-26 Thread john

WOW!!! That was painfully obvious.  As I said newbe...to python,
django, and programming.  Hopefully my questions will get more
interesting soon!

Thanks

On Feb 26, 3:29 am, Karen Tracey  wrote:
> On Thu, Feb 26, 2009 at 2:41 AM, john  wrote:
>
> > I am trying to follow the Django | Writing your first Django ap part 1
> > tutorial.  When I get to the python manage.py syncdb command I get the
> > following:
>
> > Traceback (most recent call last):
> > [snip]
> >    raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> > settings module before using the database."
> > django.core.exceptions.ImproperlyConfigured: Please fill out
> > DATABASE_NAME in the settings module before using the database.
>
> > Here is how my settings. py file is settup.
>
> > ADMINS = (
> >    # ('Your Name', 'your_em...@domain.com'),
> > )
>
> > MANAGERS = ADMINS
>
> > DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2',
> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> > DATABASE_NAME = ''             # Or path to database file if using
> > sqlite3.
>
> You need to decide on a name and fill on in here.  (Note the comments don't
> say "Not used with sqlite3" for this one, as they do for the following
> ones.  The DATABASE_NAME is required for sqlite3.
>
>
>
> > DATABASE_USER = ''             # Not used with sqlite3.
> > DATABASE_PASSWORD = ''         # Not used with sqlite3.
> > DATABASE_HOST = ''             # Set to empty string for localhost.
> > Not used with sqlite3.
> > DATABASE_PORT = ''             # Set to empty string for default. Not
> > used with sqlite3.
>
> > [snip]
> > My understanding is, that because I am using sqlite it will
> > automatically create a database file when I run the syncdb command.  I
> > had a slightly different experience with Turbogears.
>
> Yes, it will be created automatically.  So if the file you specify in
> DATABASE_NAME does not exist, it will be created.  You still have to specify
> a name for it, though, as described here:
>
> http://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup
>
> 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
-~--~~~~--~~--~--~---



Django MPTT Admin

2009-02-26 Thread Matthias Kestenholz

Hey,

A topic which comes up on this list from time to time is an automatic
admin interface for django-mptt. I'd like to advertise a piece of code
we have written at our company a little bit, and I'd also like to invite
everyone to give comments and feedbacks. I do have many more ideas
floating around, and there are a couple of issues still open, but I think
the code is ready for wider review and maybe usage, who knows?


The current version of the code generates an interface with drag/drop
capabilities for managing mptt-based trees. It's still very clear that the
code was extracted from a `classical' page cms. All you need to do
is the following:


-- 8< --

from django.db import models

class Category(models.Model):
title = models.CharField(max_length=200)
parent = models.ForeignKey('self', related_name='children',
blank=True, null=True)

-- 8< --

from django.contrib import admin
from feincms.admin import editor

class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
pass

admin.site.register(Category, CategoryAdmin)

-- 8< --

The generated admin interface looks like that:

http://spinlock.ch/pub/feincms/category_tree_admin.png

The page cms feeling is still very much there, but we'll see.

In any case, you'll find the code on github:
http://github.com/matthiask/feincms/tree/master


Thanks,
Matthias




-- 
"Programming is an art form, like the creation
of poetry or music." (Donald E. Knuth, 1974)

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



get translated text from ugettext_lazy() result

2009-02-26 Thread Matej

Hello.
I would like to get my translated text from ugettext_lazy() result.
How can I do that?

Example:
http://dpaste.com/1744/

#models.py
RATING_CHOICES = (
('0', _('I don\'t know')),
('1', _('Very bad')),
('2', _('Bad')),
('3', _('OK')),
('4', _('Good')),
('5', _('Excelent')),
)

#extra_tags.py
@register.simple_tag
def show_webstore_user_ratings(user_ratings):
A = RATING_CHOICES[user_ratings]
return A[1]

--~--~-~--~~~---~--~~
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: Passing HTML Table to a Template

2009-02-26 Thread Eric Abrahamsen


On Feb 26, 2009, at 4:30 PM, tykun...@gmail.com wrote:

>
> Hi I am trying to pass an HTML table to a template and have it display
>
> Currently I have{{table1}} inside my template to mark the position
> I wish to display the table
>
> In my views.py I havereturn render_to_response('results_s.html',
> {'table1': table1})
>
> From this all I get back is the code for the HTML table inside my
> template rather than having the template recognize it as HTML

You're almost certainly getting autoescaped 
(http://docs.djangoproject.com/en/dev/topics/templates/#id2 
). Try using {{ table1|safe }} in your template.

Yours,
Erc


>
> Any suggestions on how I can pass the table and display it inside a
> template.
>
> 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 nube

2009-02-26 Thread Karen Tracey
On Thu, Feb 26, 2009 at 2:41 AM, john  wrote:

>
> I am trying to follow the Django | Writing your first Django ap part 1
> tutorial.  When I get to the python manage.py syncdb command I get the
> following:
>
> Traceback (most recent call last):
> [snip]
>raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> settings module before using the database."
> django.core.exceptions.ImproperlyConfigured: Please fill out
> DATABASE_NAME in the settings module before using the database.
>
>
> Here is how my settings. py file is settup.
>
> ADMINS = (
># ('Your Name', 'your_em...@domain.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> DATABASE_NAME = '' # Or path to database file if using
> sqlite3.


You need to decide on a name and fill on in here.  (Note the comments don't
say "Not used with sqlite3" for this one, as they do for the following
ones.  The DATABASE_NAME is required for sqlite3.


>
> DATABASE_USER = '' # Not used with sqlite3.
> DATABASE_PASSWORD = '' # Not used with sqlite3.
> DATABASE_HOST = '' # Set to empty string for localhost.
> Not used with sqlite3.
> DATABASE_PORT = '' # Set to empty string for default. Not
> used with sqlite3.
>
> [snip]


> My understanding is, that because I am using sqlite it will
> automatically create a database file when I run the syncdb command.  I
> had a slightly different experience with Turbogears.
>

Yes, it will be created automatically.  So if the file you specify in
DATABASE_NAME does not exist, it will be created.  You still have to specify
a name for it, though, as described here:

http://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup

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 nube

2009-02-26 Thread Paul Nema
The error message provides the answer: "Please fill out DATABASE_NAME in the
settings module before using the database."
When using sqlite3 you are required to provide a path the target DB as per
comment: # Or path to database file if using sqlite3.
so

Add the full path to DATABASE_NAME.  I.E.
DATABASE_NAME = '/path/to/app/db_name.db'
On Thu, Feb 26, 2009 at 10:41 AM, john  wrote:

>
> I am trying to follow the Django | Writing your first Django ap part 1
> tutorial.  When I get to the python manage.py syncdb command I get the
> following:
>
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 340, in execute_manager
>utility.execute()
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 295, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 192, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 219, in execute
>output = self.handle(*args, **options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 348, in handle
>return self.handle_noargs(**options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> commands/syncdb.py", line 51, in handle_noargs
>cursor = connection.cursor()
>  File "/usr/lib/python2.5/site-packages/django/db/backends/
> __init__.py", line 56, in cursor
>cursor = self._cursor(settings)
>  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 139, in _cursor
>raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> settings module before using the database."
> django.core.exceptions.ImproperlyConfigured: Please fill out
> DATABASE_NAME in the settings module before using the database.
> j...@john-laptop:~/Django/mysite$ python manage.py syncdb
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 340, in execute_manager
>utility.execute()
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 295, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 192, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 219, in execute
>output = self.handle(*args, **options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 348, in handle
>return self.handle_noargs(**options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> commands/syncdb.py", line 51, in handle_noargs
>cursor = connection.cursor()
>  File "/usr/lib/python2.5/site-packages/django/db/backends/
> __init__.py", line 56, in cursor
>cursor = self._cursor(settings)
>  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 139, in _cursor
>raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> settings module before using the database."
> django.core.exceptions.ImproperlyConfigured: Please fill out
> DATABASE_NAME in the settings module before using the database.
>
>
> Here is how my settings. py file is settup.
>
> ADMINS = (
># ('Your Name', 'your_em...@domain.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> DATABASE_NAME = '' # Or path to database file if using
> sqlite3.
> DATABASE_USER = '' # Not used with sqlite3.
> DATABASE_PASSWORD = '' # Not used with sqlite3.
> DATABASE_HOST = '' # Set to empty string for localhost.
> Not used with sqlite3.
> DATABASE_PORT = '' # 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 = 'Am
>
> My understanding is, that because I am using sqlite it will
> automatically create a database file when I run the syncdb command.  I
> had a slightly different experience with Turbogears.
>
> My thought is that my sqlite is not set up correctly, but I don't even
> know where to start looking.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, 

Passing HTML Table to a Template

2009-02-26 Thread tykun...@gmail.com

Hi I am trying to pass an HTML table to a template and have it display

Currently I have{{table1}} inside my template to mark the position
I wish to display the table

In my views.py I havereturn render_to_response('results_s.html',
{'table1': table1})

>From this all I get back is the code for the HTML table inside my
template rather than having the template recognize it as HTML

Any suggestions on how I can pass the table and display it inside a
template.

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: Re: NetBeans IDE for Python

2009-02-26 Thread bruce.hpshare
It's a good news for the django develpement ...


2009-02-26 



bruce.hpshare 



发件人: पुनित मदान 
发送时间: 2009-02-26  15:31:41 
收件人: django-users 
抄送: 
主题: Re: NetBeans IDE for Python 
 
u dont need to move django ... but need to configure python path in project 
properties 


2009/2/26 Amirouche aka Mouche 


It looks like they plan to give some love to django in the next
release

http://wiki.netbeans.org/Python70Roadmap

here is the pre-beta nb 7
http://bits.netbeans.org/download/6.7/m2/

their is a ruby column but no python ! Hell ! I wonder why ! Is ruby
that mainstream ?

can't try it myself now, hope it helps !


On Feb 26, 5:38 am, Amirouche aka Mouche

 wrote:
> On Feb 4, 10:54 pm, phillc  wrote:
>
> > mine wasnt working exactly as you all described it...
>
> > until i moved my django symlink to someplace else on my python path...
> > and it suddenly worked its really odd.
>
> uhh what do you mean ?
>
> > On Feb 3, 12:49 am, mrsixcount  wrote:
>
> > > Can't seem to get the auto complete to work when I import
> > > django.db.models as models.  Shows models when I start typing but
> > > after the . nothing in the django model section comes up.  Shows the
> > > master list of python options.  IntegerField isn't in there nor could
> > > I find any of the other ones.  Oh well hopefully it will be out soon
> > > with more support for Django
>
> > > On Jan 17, 3:29 am, Gautam  wrote:
>
> > > > There is some problem with the parser recognizing package imports in
> > > > the from ... import ... syntax. What seems to work is if you import
> > > > packages directly as import ... as 
>
> > > > So for the django models import as:
>
> > > > import django.db.models as models
>
> > > > And voila, completion in Netbeans works!
>
> > > > On Nov 20 2008, 5:01 pm, lig  wrote:
>
> > > > > On 19 нояб, 21:22, Delta20  wrote:
>
> > > > > > NetBeans for Python has been released and based on the NB Python
> > > > > > roadmap, it looks interesting for those of us working with Django. I
> > > > > > haven't had much of a chance to play with it yet since it just came
> > > > > > out today, but here's the info for anyone interested:
>
> > > > > > NetBeans IDE for 
> > > > > > Python:http://download.netbeans.org/netbeans/6.5/python/ea/
> > > > > > NB Python Roadmap:http://wiki.netbeans.org/Python
>
> > > > > from django.db import models
>
> > > > > class Page(models.Model):
> > > > > name= models. # hitting Ctrl+Space here don't show field type
> > > > > suggestions or anything from imported models package
>
>





-- 
If you spin an oriental man, does he become disoriented?
(-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu

is der net süß » ε(●̮̮̃•̃)з 
-PM


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

2009-02-26 Thread john

I am trying to follow the Django | Writing your first Django ap part 1
tutorial.  When I get to the python manage.py syncdb command I get the
following:

Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 340, in execute_manager
utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 219, in execute
output = self.handle(*args, **options)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 348, in handle
return self.handle_noargs(**options)
  File "/usr/lib/python2.5/site-packages/django/core/management/
commands/syncdb.py", line 51, in handle_noargs
cursor = connection.cursor()
  File "/usr/lib/python2.5/site-packages/django/db/backends/
__init__.py", line 56, in cursor
cursor = self._cursor(settings)
  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", line 139, in _cursor
raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
settings module before using the database."
django.core.exceptions.ImproperlyConfigured: Please fill out
DATABASE_NAME in the settings module before using the database.
j...@john-laptop:~/Django/mysite$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 340, in execute_manager
utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 219, in execute
output = self.handle(*args, **options)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 348, in handle
return self.handle_noargs(**options)
  File "/usr/lib/python2.5/site-packages/django/core/management/
commands/syncdb.py", line 51, in handle_noargs
cursor = connection.cursor()
  File "/usr/lib/python2.5/site-packages/django/db/backends/
__init__.py", line 56, in cursor
cursor = self._cursor(settings)
  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", line 139, in _cursor
raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
settings module before using the database."
django.core.exceptions.ImproperlyConfigured: Please fill out
DATABASE_NAME in the settings module before using the database.


Here is how my settings. py file is settup.

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

MANAGERS = ADMINS

DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '' # Or path to database file if using
sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # 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 = 'Am

My understanding is, that because I am using sqlite it will
automatically create a database file when I run the syncdb command.  I
had a slightly different experience with Turbogears.

My thought is that my sqlite is not set up correctly, but I don't even
know where to start looking.

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



{% trans %} and {% blocktrans %} breaking auto escape

2009-02-26 Thread Briel

I stumbled upon this by accident, and after doing some research on the
docs, it seems that there is a flaw with the translation template tags
and the auto escaping. I might have missed something or maybe it's
created to do this, so I'm posting here to figure out what's going on.

Anyways, the issue is that if I were to put {{ myvar }}, a user
submitted variable, it will auto escaped so that harmful text like <>
" ect will be escaped. However, if I put my var into a translation tag
like

{% trans myvar %} or
{% blocktrans %} this is {{ myvar }}{% endblocktrans %}

myvar will no longer be escaped, instead if a user would write some
harmful js/html code, it would be run. I found that if you put the
variables in blocktrans using with, it will be escaped:

{% blocktrans with myvar as myvar %}this is {{ myvar }}{%
endblocktrans %}

I found this behavior a bit odd, but I might have missed something, so
hoping some of you guys can help me clear up the use of the
translation tags without making a site unsafe.
--~--~-~--~~~---~--~~
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   >