Re: authentication in django

2011-08-28 Thread Kejun He
request.user.is_authenticated()  ???

and the do a HttpResponseRedirect to the url you like.

https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpRequest.user
https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpResponseRedirect


On Mon, Aug 29, 2011 at 11:49 AM, Jian Chang  wrote:

> decorator?
>
>
> 2011/8/27 NISA BALAKRISHNAN 
>
>> Hi,
>>
>> I am new to django.
>> i am making a django app for a logged in user to add movies he
>> watched.
>>
>> how can i block a logged in user from accessing the log in form ?
>> the url .../accounts/login
>>
>> --
>> 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.
>>
>>
>  --
> 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.
>

-- 
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 Development environment

2011-08-28 Thread Sam Walters
Ok :)
Thankyou.

Yes ill try something like that when i have the time later this year!

On Sun, Aug 28, 2011 at 7:31 PM, Simon Connah  wrote:
>
> On 28 Aug 2011, at 04:41, Sam Walters wrote:
>
>> Debug client-side:
>> firebug, yslow, a windows computer with ie7
>
> Rather than using a separate computer with IE 7 I tend to just spin up an 
> Amazon EC2 instance running Windows Server 2003 or Windows Server 2008 for a 
> couple of hours. It makes everything so much easier when it comes to testing.
>
> --
> 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.
>
>

-- 
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 Development environment

2011-08-28 Thread Seth
On Aug 22, 3:07 pm, Stephen Jackson 
wrote:
> I am new to the world of Django. I would like to hear from other django
> developers describe their dev environment (tools, os, editors, etc.).

OS: Mac OS X (Snow Leopard)
Editor: TextMate with ProjectPlus plugin, Eclipse+PyDev for debugging
ONLY (and rarely). All of the cross platform editors Eclipse/PyCharm/
NetBeans/Wing/Komodo/Eric4/SPE are too buggy and/or mac-unfriendly to
be useful day-to-day ... I really wish TextMate had better completion
like PyDev, and debugging :(
DB: sqlite, PostgreSQL (if I need GIS support), mysql (if I don't need
GIS support)
Source control: mercurial, using hooks for production deployment on
push
Apps: South (must have), rpc4django (must have), profiler middleware
(http://djangosnippets.org/snippets/1579/), djcelery + celery +
rabbitmq.
Other Tools: memcached (must have), logging module, closure compiler,
WebKit's WebInspector, virtualenv, Pixelmator, Photoshop, Sphinx (for
docs)
Deployment: turnkeylinux django image (Ubuntu 10 + apache2.2 +
mod_wsgi), Windows 7 + apache2.2 + mod_wsgi
Hosting: webfaction

I've been doing 100% django development for about two years now, and
am much relieved be free of C# and Java in my daily workflow.

- S -

-- 
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: authentication in django

2011-08-28 Thread Jian Chang
decorator?

2011/8/27 NISA BALAKRISHNAN 

> Hi,
>
> I am new to django.
> i am making a django app for a logged in user to add movies he
> watched.
>
> how can i block a logged in user from accessing the log in form ?
> the url .../accounts/login
>
> --
> 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.
>
>

-- 
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 Development environment

2011-08-28 Thread kenneth gonsalves
On Fri, 2011-08-26 at 23:44 -0400, Steven Elliott Jr wrote:
> > On Fri, 2011-08-26 at 15:07 +0100, Simon Connah wrote:
> >> Mercurial or Git (depends on whether the project is open source or
> not)
> 
> Kenneth,
> 
> I think he means whether or not the repository will be public or
> private. Github (git) does not offer private repos unless you pay
> whereas bitbucket (mercurial) gives you 5 private ones for free as
> well as the option for creating public ones. I personally am a big
> BitBucket fan as I find it much much easier to manage and also a bit
> faster. 

me too - my one experience with github has not been good.
-- 
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-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 email as user login name

2011-08-28 Thread Shawn Milochik

On 08/28/2011 03:26 PM, quasar wrote:

Question is how to use email as user login name, and make user name
not unique? What's the best way to do that?



To use e-mail as login, write your own backend (about four lines of 
code). You'll be using the 'email' field, not username, because username 
isn't long enough.


You can not make username not unique if you're using 
contrib.auth.models.User, but you can populate it with whatever junk you 
want because you won't be using it for anything else.


https://docs.djangoproject.com/en/1.3/topics/auth/#authentication-backends



--
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: why is settings.py executed twice?

2011-08-28 Thread Mike Dewhirst

Best answer is here ...

http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

M


On 28/08/2011 11:02am, Gelonida N wrote:

Hi,

This is also one of the things (I just started using django, so I have
still quite many questions) , that I don't really understand.

It doesn't break anything and I am not stuck.
I'd just like to understand.



$ django-admin startproject settings_twice
$ echo 'print "SOMETEXT"'>>  settings.py
$ ./manage.py shell

The output, that I get is
SOMETEXT
SOMETEXT

In [1]:


So it seems settings.py is executed twice.

I would have expected, that settings.py is imported multiple times.
What I thought though is, that a module is normally only executed once
during the first import
and that subsequent imports do not execute settings.py anymore.

It seems even, that all modules imported by settings.py are executed twice.

Is ./manage.py shell starting two processes??

If yes, why wasn't settings.py imported before 'forking' ?

Thanks a lot 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: template list empty in with django test client

2011-08-28 Thread Juan Pablo Romero Méndez
My fault. I was testing from the console. Within an actual test the
request does have the templates.

   Juan Pablo

El día 28 de agosto de 2011 17:50, Juan Pablo Romero Méndez
 escribió:
> Hello,
>
> I'm using the django test client, like this:
>
 c = Client()
 r = c.get("/content/new/")
 r.status_code
> 200
 r.templates
> []
>
> Is this normal?
>
> Regards,
>
>  Juan Pablo
>

-- 
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: why is settings.py executed twice?

2011-08-28 Thread Russell Keith-Magee
On Sun, Aug 28, 2011 at 9:02 AM, Gelonida N  wrote:
> Hi,
>
> This is also one of the things (I just started using django, so I have
> still quite many questions) , that I don't really understand.
...
> So it seems settings.py is executed twice.

Yes, it is; an exceptionally comprehensive analysis and explanation of
this is given by Graham Dumpleton (of mod_wsgi fame):

http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

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.



template list empty in with django test client

2011-08-28 Thread Juan Pablo Romero Méndez
Hello,

I'm using the django test client, like this:

>>> c = Client()
>>> r = c.get("/content/new/")
>>> r.status_code
200
>>> r.templates
[]

Is this normal?

Regards,

  Juan Pablo

-- 
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 email as user login name

2011-08-28 Thread quasar
Question is how to use email as user login name, and make user name
not unique? What's the best way to do that?

-- 
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 was: No module named io

2011-08-28 Thread Goran
maybe it is path problem,
try to use:
from projectname.base.view import io
not base.view import io

in INSTALLED_APPS use:
'projectname.base',
not just 'base',

hope it helps,
Goran

On Aug 28, 2:59 am, CrabbyPete  wrote:
> I developed my code with python 2.6 and django 1.3. Now that I am
> deploying it on a dreamhost server the python is version 2.5 and I get
> the error above. Is there a work around. Do I need to upgrade python?

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



Delete after specific date

2011-08-28 Thread Goran
I have model with DateTimeField where I store date when object will be
deleted.

class Something(models.Model):
...
end_date = models.DateTimeField(editable=False, blank=True,
null=True)

after some request my app store future date in that field using:

something.end_date = datetime.datetime.now() + timedelta(days=60)
something.save()

Now I need the easy way to delete it from db when this date come and
need advice from you. To use cron job to check all once a day or to
check on every queryset like

today = datetime.datetime.now()
for_delete =  Something.objects.all().filter(end_date >= today)
for x in for_delete:
x.delete()

I expect a lot of page requests so I don't like example below. Does
anyone have some better way to suggest?

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: Where's the code picking apart the info about selected filters in the admin change_list stored in the current session?

2011-08-28 Thread Thomas Weholt
Is this just spam/phising or what?

Thomas

On Sun, Aug 28, 2011 at 6:44 PM,  wrote:

> I am out of office right now and will get back to you when I return. If you
> don't hear from me, my assistant should contact you shortly. Check out this
> massage chair that I just bought to help relax me after work!.Click 
> Here
>
> Enable images or click 
> here
>
> 
> Let me know what you think after you have a chance to review.
> Cheers!
>
> If you no lon ger wish to receive emails, please 
> unsubscribe
>
> 866-288-1880
> 5150 yarmouth ave, Encino, CA 91316
> On Sun, 28 Aug 2011 18:43:54 +0200, Thomas Weholt ** wrote:
>



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.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.



Where's the code picking apart the info about selected filters in the admin change_list stored in the current session?

2011-08-28 Thread Thomas Weholt
Where's the code picking apart the info about selected filters stored
in the current session? I see from the source that setting filters in
the admin change_list are stored in the session, but I cannot find the
code picking the session data apart and building a queryset. Do you
have any tips? I want to create a similar piece of code as an
alternative change_list in the admin.

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.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.



Re: Python Shell

2011-08-28 Thread j0ker
The second problem seems to be caused by a not set environment
variable that Django needs. You could do that manually, but the
recommended way is to use the shell provided by Django.
Just use 'python manage.py shell' instead of IDLE. The missing
Variables will be set. That should do the trick.

On 28 Aug., 15:17, Kheyreddine Hadri  wrote:
> when I use Python shell to work with Django I allways get an error
> when I use "def" or "for" or "while" :
>   File "", line 2
>     pass
>        ^
> IndentationError: expected an indented block
> and when I create a template on the IDLE I get this message:
>
> Traceback (most recent call last):
>   File "C:\Python27\Scripts\project\template.py", line 16, in 
>     t = Template(values)
>   File "C:\Python27\lib\site-packages\django\template\base.py", line
> 106, in __init__
>     if settings.TEMPLATE_DEBUG and origin is None:
>   File "C:\Python27\lib\site-packages\django\utils\functional.py",
> line 276, in __getattr__
>     self._setup()
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line
> 40, in _setup
>     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.
> 
> any 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.



Python Shell

2011-08-28 Thread Kheyreddine Hadri
when I use Python shell to work with Django I allways get an error
when I use "def" or "for" or "while" :
  File "", line 2
pass
   ^
IndentationError: expected an indented block
and when I create a template on the IDLE I get this message:

Traceback (most recent call last):
  File "C:\Python27\Scripts\project\template.py", line 16, in 
t = Template(values)
  File "C:\Python27\lib\site-packages\django\template\base.py", line
106, in __init__
if settings.TEMPLATE_DEBUG and origin is None:
  File "C:\Python27\lib\site-packages\django\utils\functional.py",
line 276, in __getattr__
self._setup()
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line
40, in _setup
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.

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



Model.save() does nothing

2011-08-28 Thread j0ker
I'm playing around with Django at the moment and have a strange
problem.

There is a view function which basicly does nothing else than toggle a
boolean value in a model field - or at least should do so.

The field definition:

class Character(models.Model):
...
ready = models.BooleanField(default=False)
...

The view function:

@decorators.login_required
def character_toggle_ready(request, id):
character = get_object_or_404(Character, pk=id)
character.ready = not character.ready
character.save()
return redirect(request.META.get('HTTP_REFERER', '/accounts/
overview'))

The url conf:
urlpatterns = patterns('',
...
url(r'^character/toggle_ready/(\d+)/$',
views.character_toggle_ready),
...)

In practice I want to have the ready-value toggled when clicking on a
hyperlink on my site. E.g. when clicking on '/character/toggle_ready/
1', the value should be toggled and then the view function should
redirect to the page before.

That works as intended, when I access the view from a template which
belongs to the app in which this view is definded. But strangely it
does not work if the link is in a different app. So, when the toggle-
view lies in the app 'accounts', it's no problem when accessing it
from a template that's rendered by another view of this app. But when
the template comes from the app 'core', it wouldn't save. The
redirection still works as a charm and also the object is retrieved
and the value is toggled, I've checked that with print-functions. But
after the save seems to be before the save.

Has anybody an idea what the reason for that behavior could be? Is the
save-function dependend on the passed request? Or am I overlooking
something?

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



Re: Error was: No module named io

2011-08-28 Thread CrabbyPete
Thanks, but that's not the problem.  Here is the traceback

Traceback:
File "/home/brightmap/lib/python2.5/site-packages/Django-1.3-py2.5.egg/
django/core/handlers/base.py" in get_response
  101. request.path_info)
File "/home/brightmap/lib/python2.5/site-packages/Django-1.3-py2.5.egg/
django/core/urlresolvers.py" in resolve
  252. sub_match = pattern.resolve(new_path)
File "/home//brightmap/lib/python2.5/site-packages/Django-1.3-
py2.5.egg/django/core/urlresolvers.py" in resolve
  158. return ResolverMatch(self.callback, args, kwargs,
self.name)
File "/home/brightmap/lib/python2.5/site-packages/Django-1.3-py2.5.egg/
django/core/urlresolvers.py" in _get_callback
  167. raise ViewDoesNotExist("Could not import %s. Error
was: %s" % (mod_name, str(e)))

Exception Type: ViewDoesNotExist at /
Exception Value: Could not import base.views. Error was: No module
named io

On Aug 27, 10:06 pm, sreekanth  wrote:
> Hi,
>
> Please check the path , as you changed to a new server and also check the
> permissions.
>
>
>
>
>
>
>
> On Sun, Aug 28, 2011 at 6:29 AM, CrabbyPete  wrote:
> > I developed my code with python 2.6 and django 1.3. Now that I am
> > deploying it on a dreamhost server the python is version 2.5 and I get
> > the error above. Is there a work around. Do I need to upgrade python?
>
> > --
> > 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.

-- 
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: Your Webinar Invitation: Join us for "Django site with 40mil+ rows of data"

2011-08-28 Thread Cal Leeming [Simplicity Media Ltd]
Thanks for 'Derek / gamesbook' for indicating that this webcast software
isn't compatible with Linux.

I've therefore created a relay of the meeting using WebEx (seems to be same
quality/delay)

For those with a Linux system, you can use the following details to join the
webcast:

Host Key: 426916
Meeting Number: 702 136 716
Meeting URL:
https://ukfreetrial.webex.com/ukfreetrial/j.php?ED=185534402=503673467=MiMyMQ%3D%3D

The above URL can be used for both time slots.

Thanks

Cal


On Sat, Aug 27, 2011 at 9:53 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Sorry, the damn thing refused to send invitations to all email addresses.
> How annoying - so I've had to send to the list directly. Apologies.
>Django site with 40mil+ rows of data1 hour webcast showing
> some of the techniques we used to handle large data sets in Django, with
> minimal hardware requirements. *Register for a session now by clicking
> a date below:*   Mon, Aug 29, 2011 3:00 PM - 5:00 PM 
> BST   Mon,
> Aug 29, 2011 9:00 PM - 11:00 PM 
> BST  Once
> registered you will receive an email confirming your registration
> with information you need to join the Webinar.*System Requirements*
> PC-based attendees
> Required: Windows® 7, Vista, XP or 2003 Server   Macintosh®-based
> attendees
> Required: Mac OS® X 10.5 or newer
>
>
>

-- 
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 Development environment

2011-08-28 Thread Simon Connah

On 28 Aug 2011, at 04:41, Sam Walters wrote:

> Debug client-side:
> firebug, yslow, a windows computer with ie7

Rather than using a separate computer with IE 7 I tend to just spin up an 
Amazon EC2 instance running Windows Server 2003 or Windows Server 2008 for a 
couple of hours. It makes everything so much easier when it comes to testing.

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