urlpattern help

2005-11-18 Thread Bryan Murdock

How do you write a urlpattern to match something like this:

/accounts/login/?next=/add_object/

?

I have this:

r'^accounts/login/\?next=(?P.*)$'

and it seems to match because my view function is called, but no next
parameter is passed in.  Oh wait, it's actually matching the previous
urlpattern:

r'^accounts/login/$'

Shouldn't the $ at the end prevent a string with stuff after the
'login/' from matching that one?  When I do this in a python shell:

 match = re.compile( r'^accounts/login/$' ).search(
'accounts/login/?next=/add_object/' )

match is None.  When I do this:

match = re.compile( r'^accounts/login/\?next=(?P.*)$' ).search(
'accounts/login/?next=/add_object/' )

match is not None and match.group('next') == '/add_object/'

What gives?

Bryan


Re: Why it doesn't work in Django

2005-11-18 Thread David Ascher
On 11/18/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
The Web page isn't recognizing your CSS file. Django isn't intendedserve static media files -- such as CSS -- so you'll need to useanother server, such as Apache, to serve the CSS file. Alternatively,check out the 
django.views.static.serve, which is for developmentpurposes only and isn't yet documented (but will be soon).There is draft docs in this ticket:
http://code.djangoproject.com/ticket/810(helped me).--david


Re: Why it doesn't work in Django

2005-11-18 Thread Bryan L. Fordham

On Fri, Nov 18, 2005 at 01:32:34PM -0800, PythonistL wrote:

> But why? Where did I make a mistake?

because it's trying to serve the page like it's a view.  For instance, if
your view is /foo/bar, go to /foo/style.css and you'll get a 404. But that's
where it's trying to load it.

You'll want to serve the style sheet from another place.

--B


Why it doesn't work in Django

2005-11-18 Thread PythonistL

I have a following problem with CSS file.

My template Test.html looks like this
##







TEST ONLY


###

where Test.css looks like this
###

body
{
background: #00;
color: #FF;
font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica,
sans-serif;
margin: 5px 5px 10px 5px;
}
#

And now when I open the Test.html file in my web browser I will receive
 black background with the white TEST ONLY text, which is correct

But when I try it in Django like

...
...
return render_to_response('board/Test')
###
it does NOT work( the text is not white and background is not black.

But why? Where did I make a mistake?
Thanks for help.
L.



Re: Anonymous Sessions

2005-11-18 Thread Brant Harris

Unfortunately the whole thing seemed to cause the "User tampered with
cookie" error.  I'm not sure why, or how, but storing the results
seemed to create the erorr.

O well.

On 11/18/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 11/16/05, Brant Harris <[EMAIL PROTECTED]> wrote:
> > Is it wise to store a large amount of data in an anonymous session?
> > For instance, and most applicable to my design, if I store results of
> > a search in a session like so:
> > request.session['search_results'] = objects.get_list(name__icontains=query)
> >
> > And then I can more easily give paged results back to the user.  So
> > that if they request again with a "page" specified in the request.GET
> > dict, then I can simply return the results from the cached list.
> >
> > My concern is that this will eat up memory like a zombie.
>
> Because sessions are stored in the database, this won't eat up much
> memory. It's an interesting idea, and I'd encourage you to explore it
> more and report back to the list with how it's working.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


How to add user registration/login to an existing app?

2005-11-18 Thread David Ascher
I've read the docs on the Django authentication model, and it seems pretty good.  What I'm looking for now is some pointers re: how to leverage the code that's used for the admin view in adding login/logout/registration/email password pages to my existing app (or similar contrib code).
How are people dealing with non-admin user registration/login?Thanks,--da


Re: 20 minute wiki, sortof.

2005-11-18 Thread David Ascher
On 11/18/05, Simon Willison <[EMAIL PROTECTED]> wrote:
Alternatively, we could just have CommonMiddleware throw a deliberateserver error if a POST is made to a IRL that doesn't have a trailingslash. That should make things abundantly clear :) POSTing to a URLthat CommonMiddleware wants to redirect is most definitely a bug in
an application, and should be treated as such. The redirect plainshouldn't happen.Makes sense to me.  Shouldn't even break old code, assuming they care what's in the POST data ="">kb: there is no base template -- was that a hint that I should use template inheritance instead of an if/else/endif?
Thanks for the pointers to django.views.static and {% load markup %}.  I'd clearly missed those.re: load markup, I suggest a comment at the top of the markup.py file telling people to read up on the load markup docs.  Also, what's the rationale for failing silently if the required modules aren't installed?
re: django.views.static: I suspect that given the number of times I saw my question asked and answered with "django doesnt' do that" in the IRC logs, that it may qualify as a FAQ.Cheers,
--david


Re: Using umlauts

2005-11-18 Thread Steffen Glückselig

Right, I changed the slugfield into a charfield.

I cannot add a user with an username that contains an umlaut with the
default admin-interface, though. How could I change that?

best regards



Re: 20 minute wiki, sortof.

2005-11-18 Thread Simon Willison



On 18 Nov 2005, at 15:26, Robert Wittams wrote:


Hm, maybe when DEBUG is on, CommonMiddleware should put up an
interstitial page to tell the developer what is happening? It does  
seem

to bite a lot of people.


Alternatively, we could just have CommonMiddleware throw a deliberate  
server error if a POST is made to a IRL that doesn't have a trailing  
slash. That should make things abundantly clear :) POSTing to a URL  
that CommonMiddleware wants to redirect is most definitely a bug in  
an application, and should be treated as such. The redirect plain  
shouldn't happen.


Cheers,

Simon


Re: 20 minute wiki, sortof.

2005-11-18 Thread hugo

> * I was stumped by the fact that I had to setup another web server to serve
>static files. It'd be nice if it was possible to serve static files with the
>development server. I'd consider sending in a patch if someone could throw
>suggestions my way on what approach would work best (or maybe it actually
>_is_ supported, I just didn't find out how!).

There is a django.views.static module that has a "serve" view function
that can be used for serving static files from a directory. So no need
to send in a patch ;-)

(I think this static view should be listed more prominently in the
documentation and tutorial, even though it's not meant to be used for
production use - the how-to-serve-static-files question is quite common
with newbies, and all of them want to write their own ;-) )

bye, Georg



Re: 20 minute wiki, sortof.

2005-11-18 Thread Simon Willison



On 18 Nov 2005, at 09:12, David Ascher wrote:

Specifically, I'd love feedback on the views ( http:// 
da.textdriven.com:8027/sydney/file/trunk/wiki/apps/pages/views.py)  
and the template ( http://da.textdriven.com:8027/sydney/file/trunk/ 
wiki/templates/pages/page.html


You should do this in the template: Replace

{{page.data}}textarea>


With

{{page.data| 
escape}}


Great feedback on the problems you can in to - we should fix those!



Re: Django/lighttpd weirdness (solved)

2005-11-18 Thread James Bennett

On 11/17/05, James Bennett <[EMAIL PROTECTED]> wrote:
> I'm working on writing instructions for deploying Django at TextDrive,
> and so I'm using the Django/lighttpd_FCGI instructions here:
> https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/DjangoFcgiLighttpd

Never mind, I was misinterpreting this and thinking lighttpd was
supposed to spawn the FCGI stuff, when in fact with these instructions
it's not. Everything is hunky-dory now; thanks to Georg for explaining
this to me on IRC!


--
"May the forces of evil become confused on the way to your house."
  -- George Carlin