Re: low-level cache & pagination

2007-11-30 Thread Chris G

Alright, I think I answered my own question. It seems the current
RequestContext is a little messed up and not only requests cache to be
remade, but also crashes runserver upon more than 1 request.

On Nov 30, 7:26 pm, Chris G <[EMAIL PROTECTED]> wrote:
> I have a large query that is ran and takes about 50 seconds to
> completely and is pretty resource intensive. So what I have done is
> cached it into a key via cache.set('my_query_results', results, 300)
>
> The problem is that I also use pagination which results from this
> query. So when navigating to ?page=2~ it should in theory just re-use
> the cache and output page 2's data. But it doesn't. What it does is re-
> run and re-cache the entire query again. I'm guessing that this is due
> to the 'request' (MyView(request) is changing (?page=2).
>
> Is it possible to override this? Or am I just doing something this
> whole thing wrong?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



low-level cache & pagination

2007-11-30 Thread Chris G

I have a large query that is ran and takes about 50 seconds to
completely and is pretty resource intensive. So what I have done is
cached it into a key via cache.set('my_query_results', results, 300)

The problem is that I also use pagination which results from this
query. So when navigating to ?page=2~ it should in theory just re-use
the cache and output page 2's data. But it doesn't. What it does is re-
run and re-cache the entire query again. I'm guessing that this is due
to the 'request' (MyView(request) is changing (?page=2).

Is it possible to override this? Or am I just doing something this
whole thing wrong?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Simple input forms which show more than one row - easy/possible in django?

2011-10-05 Thread Chris G
I want to create a simple data entry form on a web page that shows all
the columns of a database across the page (there aren't many columns,
they will fit!) and a number of rows down the page.

I.e. I want a data entry form that looks like MS Access 'tabular'
format, as follows:-

Col1Row1Col2Row1Col3Row1Col4Row1Col5Row1
Col1Row2Col2Row2Col3Row2Col4Row2Col5Row2
Col1Row3Col2Row3Col3Row3Col4Row3Col5Row3
Col1Row4Col2Row4Col3Row4Col4Row4Col5Row4
Col1Row5Col2Row5Col3Row5Col4Row5Col5Row5
Col1Row6Col2Row6Col3Row6Col4Row6Col5Row6
New DataNew DataNew DataNew DataNew Data


Can django do this easily in a 'ready made' sort of way or do I have to
actually create the form and all its fields?

-- 
Chris Green

-- 
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: Simple input forms which show more than one row - easy/possible in django?

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 03:13:08PM +, Brett Epps wrote:
> Hi Chris,
> 
> Once you've defined a model for your data, you can use a ModelForm [1] to
> automatically generate a form for that model.
> 
> You might also want to check out the admin site [2], which displays data
> in a tabular format similar to what you describe.
> 
Yes, I'd seen that, can I get the admin forms to work 'outside' as it
were? 

> 1. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
> 2. https://docs.djangoproject.com/en/dev/ref/contrib/admin/
> 
Thanks, it looks as if ModelForm will do most of what I want.

-- 
Chris Green

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



Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
I'm an experienced programmer (started around 1971 or so!) and I've done
lots of things over the years, much of my background is in Unix (Solaris).
In the last few years I have done quite a lot of web related stuff.

I'm trying to get my mind round django.  I have it installed on my
unbuntu server, it works, I've worked through tutorials 1 and 2 and a
bit of 3.  I can get the admin screens up and the basics of the polls
example work.

However two rather basic things still elude me:-

Where/how do I actually start creating the top level/page of a web
site?   Do I just open vi and create some HTML and embed django
code?  That seems unlikely but I can't see anywhere that tells me
what the code that creates a django site looks like and/or where it
resides.   An actual example of a two or three page working django
based web site would be a huge help.

I can't see anywhere that seems to tell me the issues involved with
moving from using the built in web server to using apache2 (or
whatever, I have apache2 on my system).

I know that in a few days time when I have got over the initial hump all
the above will seem trivial so sorry to ask, but at the moment I'm
feeling a bit lost!  :-)

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 08:58:10PM +0100, Cal Leeming [Simplicity Media Ltd] 
wrote:
>Hi Chris,
>I'm assuming that you don't have any experience with Python??

No/yes, I *do* have Python experience, it's my language of choice for
scripts which require a bit more than basic shell scripting.


>Also - have you read the intro overview, as that pretty much answers your
>questions, unless I'm missing something
>[1]https://docs.djangoproject.com/en/1.3/intro/overview/
>Cal
> 
I've looked at that, but maybe not hard enough.  A quick glance seems to
raise some of the same questions, there are lots of code snippets in
there but it's not *very* clear where they all live or even whether one
has to write them or they're generated by django.  It does seem a bit
clearer at a second reading though so I suspect it will all become clear
eventually. 

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 11:02:03PM +0300, Yaşar Arabacı wrote:
>This documentation goes over deployment of
>django: [1]https://docs.djangoproject.com/en/1.3/howto/deployment/
> 
Ah, brilliant, thanks, that certainly answers my question about how to
use it with apache.

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 03:02:13PM -0500, Javier Guerra Giraldez wrote:
> On Wed, Oct 5, 2011 at 2:55 PM, Chris G  wrote:
> > I'm trying to get my mind round django.  I have it installed on my
> > unbuntu server, it works, I've worked through tutorials 1 and 2 and a
> > bit of 3.  I can get the admin screens up and the basics of the polls
> > example work.
> 
> just finish the tutorial.  seriously, even if you're so experienced,
> it's a much needed introduction.
> 
> about how to write, check the paragraph about the MTV architecture:
> model, view template.  in short, that means: write your models with
> most of the conceptual functionality; then write a view that gathers
> all needed info from the models and calls a template to show it as a
> web page.  templates should have very minimal 'code' embedded, just to
> display the data gathered by the view.
> 
> but please, do the tutorial.
> 
OK, I'll work through the rest of it, thanks.

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-05 Thread Chris G
On Wed, Oct 05, 2011 at 04:35:49PM -0400, Peter Herndon wrote:
> 
> On Oct 5, 2011, at 3:55 PM, Chris G wrote:
> > 
> > However two rather basic things still elude me:-
> > 
> >Where/how do I actually start creating the top level/page of a web
> >site?   Do I just open vi and create some HTML and embed django
> >code?  That seems unlikely but I can't see anywhere that tells me
> >what the code that creates a django site looks like and/or where it
> >resides.   An actual example of a two or three page working django
> >based web site would be a huge help.
> 
> I've seen a few different patterns in regards to this question. One scenario 
> is where you have a multi-purpose Django site comprised of multiple reusable 
> apps with no obvious top-level entry point, you can create a view "def 
> index(request)", and have it render a template with whatever data you want to 
> send it -- including perhaps no data at all. Then map your index view to '/' 
> in urls.py at the project level, put together a template and you're all set.
> 
> Another option I've seen is if you have a single-purpose site where one app 
> is primary, you map your primary app's start page as your index. An example 
> would be a blog, and you would set up your chronological entries list page as 
> the index.
> 
OK, so there isn't a single simple answer.  However it would still be
really nice to see a complete two or three page django site with a
database behind it fully implemented as an example.

> 
> > 
> >I can't see anywhere that seems to tell me the issues involved with
> >moving from using the built in web server to using apache2 (or
> >whatever, I have apache2 on my system).
> 
> The short version is that the built-in server was built as a 
> just-good-enough-to-use-while-developing solution, and is not sufficient to 
> handle more than a minimal load. The trade-off is that configuring apache2 + 
> mod_wsgi, or nginx + gunicorn, is more complex than just running the 
> devserver.
> 
Sorry, I maybe didn't explain well what I wanted.  I realise that
configuring apache2 to do all this involves more work, what I wanted was
the steps required to go from a working django project under the
built-in server to one that works under apache2.

Someone else has pointed me at 
https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
though which seems to be what I need.

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 11:01:13AM +0530, kenneth gonsalves wrote:
> On Wed, 2011-10-05 at 23:02 +0100, Chris G wrote:
> > OK, so there isn't a single simple answer.  However it would still be
> > really nice to see a complete two or three page django site with a
> > database behind it fully implemented as an example.
> > 
> > 
> 
> this is as simple as it gets
> https://bitbucket.org/lawgon/django-addition/overview

Too simple for me, it doesn't run.

chris$ python manage.py runserver
Error: No module named addition.addnums
chris$ 

My own working through the tutorial does though:-

chris$ python manage.py runserver
Validating models...
0 errors found

Django version 1.2.3, using settings 'djdb1.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.


-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 01:14:37AM -0700, Daniel Roseman wrote:
>  On Wednesday, 5 October 2011 20:55:33 UTC+1, Chris Green wrote:
> 
>  I'm an experienced programmer (started around 1971 or so!) and I've done
>  lots of things over the years, much of my background is in Unix
>  (Solaris).
>  In the last few years I have done quite a lot of web related stuff.
> 
>  I'm trying to get my mind round django.  I have it installed on my
>  unbuntu server, it works, I've worked through tutorials 1 and 2 and a
>  bit of 3.  I can get the admin screens up and the basics of the polls
>  example work.
> 
>  However two rather basic things still elude me:-
> 
>  Where/how do I actually start creating the top level/page of a web
>  site?   Do I just open vi and create some HTML and embed django
>  code?  That seems unlikely but I can't see anywhere that tells me
>  what the code that creates a django site looks like and/or where it
>  resides.   An actual example of a two or three page working django
>  based web site would be a huge help.
> 
>You *really* need to do the tutorial. If you think that "creating HTML and
>embedding Django code" is how it works, then you haven't read it. That's
>not how it works at all.

I was semi joking, I realise that this *isn't* how it works but so far
I'm not at all clear how it does work.

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-06 Thread Chris G
On Thu, Oct 06, 2011 at 10:09:05AM +0100, Cal Leeming [Simplicity Media Ltd] 
wrote:
>Chris -
>The only thing I can say, is that you've been given some really good
>advice on this thread so far.

Yes, I'm not complaining at all, the feedback has all been very helpful.
I'm just rather impatient when I start trying to use something new.  :-)

So, thank you everyone who has replied, I do appreciate all the help.

 and I will continue through the tutorials.  :-)

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-07 Thread Chris G
On Fri, Oct 07, 2011 at 11:47:49AM +0530, kenneth gonsalves wrote:
> On Thu, 2011-10-06 at 10:00 +0100, Chris G wrote:
> > > this is as simple as it gets
> > > https://bitbucket.org/lawgon/django-addition/overview
> > 
> > Too simple for me, it doesn't run.
> > 
> > chris$ python manage.py runserver
> > Error: No module named addition.addnums 
> 
> you did not follow the instructions here:
> 
> https://bitbucket.org/lawgon/django-addition/wiki/Home

Ah, OK, I did look around for some instructions but didn't find them. 
Thank you, I'll go and play some further!  :-)

-- 
Chris Green

-- 
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: Beginner a bit lost - need some pointers please

2011-10-07 Thread Chris G
On Fri, Oct 07, 2011 at 11:40:03AM +0100, Chris G wrote:
> On Fri, Oct 07, 2011 at 11:47:49AM +0530, kenneth gonsalves wrote:
> > On Thu, 2011-10-06 at 10:00 +0100, Chris G wrote:
> > > > this is as simple as it gets
> > > > https://bitbucket.org/lawgon/django-addition/overview
> > > 
> > > Too simple for me, it doesn't run.
> > > 
> > > chris$ python manage.py runserver
> > > Error: No module named addition.addnums 
> > 
> > you did not follow the instructions here:
> > 
> > https://bitbucket.org/lawgon/django-addition/wiki/Home
> 
> Ah, OK, I did look around for some instructions but didn't find them. 
> Thank you, I'll go and play some further!  :-)
> 
Actually my only real problem was that I hadn't renamed django-addition
to addition.  :-)

-- 
Chris Green

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