How can you use the @cache_page decorator with Django class based views?

2015-11-14 Thread daniels


The only method that seems to be working is adding the decorator in urls.py 
which is ugly.

Is there any way to apply this decorator in the view?

class HomeView(View):
@method_decorator(cache_page(60 * 60))
def dispatch(self, *args, **kwargs):
return super(HomeView, self).dispatch(*args, **kwargs)

I've tried the above but it doesn't seem to be working. I've also tried 
adding it to the get method (which is what I want to cache).

I'm using FileBasedCache and only when I use cache_page decorator in 
urls.py I see files being created in my cache folder. With the method above 
nothing happens.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ef695b71-5bcf-4fa7-b3e0-6b622ad8bab5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Existing database - new project

2015-03-13 Thread Robert Daniels

thanks for everyone's input. I'll run parallel implementations and see 
which one works best for the long haul. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d374f960-484a-4317-a68b-0e3727cdf03e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Existing database - new project

2015-03-06 Thread Robert Daniels
I understand it is possible to use an existing database on a new Django 
project. 

As I see it, I have 2 choices.

1 - Use the existing database and deal with it in that fashion.

or

2 - Create a new project to store the same type of data as if there were no 
existing database, Then write a separate export-import script to move the 
data from the existing db to the new structure. 

Wondering if anyone has gone through the "good" and "bad" of each of these. 
I have about 100,000 records in the database, but moving the data across 
should not be that difficult as its a pretty flat model

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/42ee3e9e-3d64-453f-9d6a-53846bec95e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django dev server issue

2011-01-04 Thread daniels
Ok, so i used pdb and did a line by line pass, but i didn't get anything.
All data seems to be normal. I even edited socket.py and did a print on data
to see what's going on and everything seems normal.. :( so i'm left with no 
idea
I guess i'll have to get used with this hangs.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 dev server issue

2011-01-03 Thread daniels
Just tried latest version of Django 1.2.4 and same issue
I'll try that. Never used pdb before so let's see how things will go.
I'll reply with updates.

On Jan 3, 11:35 pm, Shawn Milochik  wrote:
> On Jan 3, 2011, at 4:28 PM, Brian Bouterse wrote:
>
> > Have you tried using pdb to debug the call as it arrives?  You could step 
> > through the code, line by line that way to see what is hanging.
>
> > My 2 cents,
> > Brian
>
> I enthusiastically second this. If you're unfamiliar with pdb, check out this 
> slice of awesome:
>
> http://blog.doughellmann.com/2010/09/pymotw-pdb-interactive-debugger
>
> Incidentally, the Python doc page has just a bit that's not in the tutorial. 
> The only thing that springs to mind is the 'skip' argument, but you might 
> want to skim it. The debugger is a fantastic tool to have in your toolbox.
>
> http://docs.python.org/library/pdb
>
> Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 dev server issue

2011-01-03 Thread daniels
I just tested with sock Python 2.6.6 from the link you gave me and
also tried with Python 2.7
and I'm still having this issue. It is really weird. Like i said 3 out
of 5 page refresh the browser hangs,
and if i press stop button i get the same exception trowed.

:(

On Jan 3, 9:36 pm, "W. Craig Trader" <craig.tra...@gmail.com> wrote:
> I'm currently developing on Windows 7 (64-bit) with stock Python 2.6.6
> (32-bit) and Django 1.2.3, and having no problems when running the Django
> development server from the command line.
>
> I'd recommend using the normal Python 
> (http://www.python.org/download/releases/2.6.6/) instead of ActivePython and
> see if that improves things.
>
> - Craig -
>
>
>
>
>
>
>
> On Mon, Jan 3, 2011 at 14:09, daniels <daniels0...@gmail.com> wrote:
> > Hi,
> > Unfortunately i did not found the case, and i'm getting it pretty
> > often, about 3 out of 5 times i refresh the page.
> > If i leave it loading and i don't stop it it stays like that for about
> > 30-40 seconds and then the page loads.
> > I just don't understand what is causing this.
> > I've restarted the server like 10 time or more from the first time i
> > got this and i'm still getting it every time i run it.
>
> > My Python version is : ActivePython 2.6.6.17 (ActiveState Software
> > Inc.) based on
> > Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit
> > (Intel)] on
> > win32
>
> > and Django: (1, 2, 3, 'final', 0)
>
> > I did a lot of dev on Windows 7 before but i never had this issue. So
> > my thoughts are that this is either
> > related to this Django version or Python version.
>
> > On Jan 3, 5:43 pm, Tiago Almeida <tiago.b.alme...@gmail.com> wrote:
> > > Hi,
>
> > > Your files seem fine, I believe.
> > > Have you found the cause? What version of python and django are you
> > > using? I also have this issue but it is not often enough for me to
> > > worry too much. Killing the server and restarting it solves it for
> > > me..
>
> > > BR,
> > > 
>
> > > On 3 Jan, 08:00, daniels <daniels0...@gmail.com> wrote:
>
> > > > Here are the relevant files:
>
> > > > myproject/urls.py
> > > > --
> > > > from django.conf.urls.defaults import *
> > > > from django.conf import settings
>
> > > > # Uncomment the next two lines to enable the admin:
> > > > # from django.contrib import admin
> > > > # admin.autodiscover()
>
> > > > urlpatterns = patterns('',
> > > >     (r'^$', include('myproject.apps.acasa.urls')),
>
> > > >     # Dev only
> > > >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > > > {'document_root': settings.MEDIA_ROOT}),
>
> > > >     # Uncomment the admin/doc line below to enable admin
> > > > documentation:
> > > >     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> > > >     # Uncomment the next line to enable the admin:
> > > >     # (r'^admin/', include(admin.site.urls)),
> > > > )
>
> > > > myproject/apps/acasa/urls.py
> > > > ---
> > > > from django.conf.urls.defaults import *
>
> > > > urlpatterns = patterns('myproject.apps.acasa.views',
> > > >     (r'^$', 'index'),
> > > > )
>
> > > > myproject/apps/acasa/views.py
> > > > -
> > > > from django.template  import RequestContext
> > > > from django.shortcuts import render_to_response
>
> > > > def index(request):
> > > >     return render_to_response('acasa/default.html',
> > > >         context_instance=RequestContext(request))
>
> > > > myproject/templates/base.html
> > > > 
> > > > 
> > > > 
> > > > 
> > > >     Myproject - {% block title %}{% endblock %}
> > > >     
> > > >     
> > > >     
> > > >     
> > > >      > > > media="all" />
> > > >     

Re: Django dev server issue

2011-01-03 Thread daniels
Hi,
Unfortunately i did not found the case, and i'm getting it pretty
often, about 3 out of 5 times i refresh the page.
If i leave it loading and i don't stop it it stays like that for about
30-40 seconds and then the page loads.
I just don't understand what is causing this.
I've restarted the server like 10 time or more from the first time i
got this and i'm still getting it every time i run it.

My Python version is : ActivePython 2.6.6.17 (ActiveState Software
Inc.) based on
Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit
(Intel)] on
win32

and Django: (1, 2, 3, 'final', 0)

I did a lot of dev on Windows 7 before but i never had this issue. So
my thoughts are that this is either
related to this Django version or Python version.


On Jan 3, 5:43 pm, Tiago Almeida <tiago.b.alme...@gmail.com> wrote:
> Hi,
>
> Your files seem fine, I believe.
> Have you found the cause? What version of python and django are you
> using? I also have this issue but it is not often enough for me to
> worry too much. Killing the server and restarting it solves it for
> me..
>
> BR,
> ----
>
> On 3 Jan, 08:00, daniels <daniels0...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Here are the relevant files:
>
> > myproject/urls.py
> > --
> > from django.conf.urls.defaults import *
> > from django.conf import settings
>
> > # Uncomment the next two lines to enable the admin:
> > # from django.contrib import admin
> > # admin.autodiscover()
>
> > urlpatterns = patterns('',
> >     (r'^$', include('myproject.apps.acasa.urls')),
>
> >     # Dev only
> >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.MEDIA_ROOT}),
>
> >     # Uncomment the admin/doc line below to enable admin
> > documentation:
> >     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> >     # Uncomment the next line to enable the admin:
> >     # (r'^admin/', include(admin.site.urls)),
> > )
>
> > myproject/apps/acasa/urls.py
> > ---
> > from django.conf.urls.defaults import *
>
> > urlpatterns = patterns('myproject.apps.acasa.views',
> >     (r'^$', 'index'),
> > )
>
> > myproject/apps/acasa/views.py
> > -
> > from django.template  import RequestContext
> > from django.shortcuts import render_to_response
>
> > def index(request):
> >     return render_to_response('acasa/default.html',
> >         context_instance=RequestContext(request))
>
> > myproject/templates/base.html
> > 
> > 
> > 
> > 
> >     Myproject - {% block title %}{% endblock %}
> >     
> >     
> >     
> >     
> >      > media="all" />
> >     

Re: Django dev server issue

2011-01-03 Thread daniels
Here are the relevant files:

myproject/urls.py
--
from django.conf.urls.defaults import *
from django.conf import settings

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^$', include('myproject.apps.acasa.urls')),

# Dev only
(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),

# Uncomment the admin/doc line below to enable admin
documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
)



myproject/apps/acasa/urls.py
---
from django.conf.urls.defaults import *

urlpatterns = patterns('myproject.apps.acasa.views',
(r'^$', 'index'),
)



myproject/apps/acasa/views.py
-
from django.template  import RequestContext
from django.shortcuts import render_to_response


def index(request):
return render_to_response('acasa/default.html',
context_instance=RequestContext(request))



myproject/templates/base.html




Myproject - {% block title %}{% endblock %}









{% block content %}
{% endblock %}





myproject/templates/acasa/default.html
-
{% extends "base.html" %}
{% block title %}Acasă{% endblock %}
{% block content %}
Hello World!
{% endblock %}

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



Re: New to Django, sheet music organization site

2011-01-02 Thread daniels
SlugField ?

On Jan 3, 12:56 am, Kyle  wrote:
> Ok I have a good start. I have run into a problem though. In my
> database, I have an artist field. Most artists have a space in there
> name. When creating my URLs, how can I ignore white space?
>
> For example, take the artist Chris Tomlin. In my database, it will
> show as "Chris Tomlin", but I don't want to type "music/Chris Tomlin"
> to access it, I want to type "music/christomlin" or "music/
> chris_tomlin". How can I do this?
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, 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 dev server issue

2011-01-02 Thread daniels
Hi,
I'm having a issue with Django's dev server. I did a "django-admin.py
startproject" then "manage.py startapp home", then added the app in
settings.py and in urls.py. The app only has  a index function in
views.py which is mapped to / and just renders a simple html template.
What happens is that sometimes(and this is often) when i load the page
in a broswer (tryed Chrome and Firefox) or refresh it, the page starts
loading but it never finishes. And if i hit the browser's stop button
i get this in the console



Exception happened during processing of request from ('127.0.0.1',
52495)
Traceback (most recent call last):
  File "C:\Python26\lib\SocketServer.py", line 283, in
_handle_request_noblock
self.process_request(request, client_address)
  File "C:\Python26\lib\SocketServer.py", line 309, in process_request
self.finish_request(request, client_address)
  File "C:\Python26\lib\SocketServer.py", line 322, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "C:\Python26\lib\site-packages\django\core\servers
\basehttp.py", line 562, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
  File "C:\Python26\lib\SocketServer.py", line 618, in __init__
self.finish()
  File "C:\Python26\lib\SocketServer.py", line 661, in finish
self.wfile.flush()
  File "C:\Python26\lib\socket.py", line 297, in flush
self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 10053] An established connection was aborted by the
software in your host machine



Any idea what's causing this? As it really cripples my dev time.
I'm on a Windows 7 32bit machine

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



Re: Best OS - VPS environment

2010-08-16 Thread daniels
+1 for Debian or FreeBSD and Nginx
Really fast/easy to setup and works withouth any problems.

On Aug 16, 12:48 pm, Alex  wrote:
> FreeBSD
>
> On Mon, Aug 16, 2010 at 12:39 PM, Kenneth Gonsalves wrote:
>
> > On Mon, 2010-08-16 at 01:54 -0700, Dan wrote:
> > > What do people recommend?
>
> > debian lenny
> > --
> > regards
> > Kenneth Gonsalves
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Session not working as i had hoped

2010-05-26 Thread daniels
Also move :
  request.session['has_visited'] = True
above the return statement.

On May 26, 4:02 pm, Nuno Maltez  wrote:
> http://docs.djangoproject.com/en/dev/topics/http/sessions/#using-sess...
>
> >    if request.session.get('has_visited',True):
>
> You're passing True as the default value to the get method  - get(key,
> default=None); this means that when 'has_visited' isn't set in your
> session (1st visit) it still returns True.
>
> Just replace :
>
>    if request.session.get('has_visited',True):
>        visited = True
>    else:
>        visited = False
>
> with
>
> visited = request.session.get('has_visited', False)
>
> hth,
> Nuno

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: temp url with time limit

2010-04-23 Thread daniels
Take a look at this Lighttpd module:
http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModSecDownload
You could implement something based on what the module above is doing.


On Apr 23, 12:26 pm, Faizan  wrote:
> Wondering if there is a good way to generate temporary URLs that
> expire in X days. Would like to email out a URL that the recipient can
> click to access a part of the site that then is inaccessible via that
> URL after some time period.
>
> Thanks,
> Faizian
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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