Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-16 Thread bobhaugen
Wrapping this up:  the problem was caused by South, happened in migrate 
(found via stack trace).  When I upgraded South, the problem went away.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/9Qi0IFuMMqgJ.
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 apache mod_wsgi permission denied

2012-12-16 Thread Phang Mulianto
THank for the config , i do able to run the apache22 with mod_wsgi + python
2.7 in windows server.



On Sun, Dec 2, 2012 at 3:03 PM, Loai Ghoraba  wrote:

> Thanks a million for the tip :)
>
>
> On Sun, Dec 2, 2012 at 5:08 AM, Chris Cogdon  wrote:
>
>>
>>
>> On Saturday, December 1, 2012 3:47:39 AM UTC-8, Loai Ghoraba wrote:
>>>
>>> no I mean the root of my project guys :) thanks a lot :D which lives in
>>> path/to/my/project :)
>>>
>>
>> Oh thank god for that!
>>
>> I'd actually done something similiar once... I'd removed a bunch of
>> permissions using chmod -R /   rather than chmod -R . ... This was on an
>> oldold NCR Tower 32 running SVR3. I ended up writing a program to go
>> through the archives on tape (yes, tape) and copy only the permission bits
>> from all the tape files.
>>
>> Anyway, a better form of that command is chmod -R a+rX
>>
>> The capital X means "only set the execute bit if any execute bits are
>> set". If you use lower-case x, then you'll send up setting the execute bit
>> for normal files, too, which is another potential security risk. If you
>> want to fix this up, do:
>>
>> find . -type f -print0 | xargs -0 chmod a-x
>> chmod a+x manage.py # Restore x for the Django management command
>>
>> Protip: always use the -print0 | xargs -0  form of the "find/xargs"
>> pattern, as this will prevent spaces in your paths from causing havoc.
>>
>> I wish I knew of a better way to set the x bits all the way up the tree,
>> without giving someone a program to run, the best I can come up with is:
>>
>> cd static
>> chmod a+x . .. ../.. ../../.. ../../../.. ../../../../..
>> ../../../../../.. ../../../../../../..
>>
>> and hope that's enough :)
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/_8jpEFytyesJ.
>>
>> 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.



deploying a dejango app on AWS

2012-12-16 Thread Nicholas Sonnenberg
Hello,

Does anyone know what I need to do to get my django app to run on my 
elastic bean stalk?
I've got the simple voting application from the website running on my local 
machine, but it's crashing when i run it from the aws cloud.

I've done the AWS git.push and that works, but then the website crashes.
Is there a setting that I need to change?  Is there an issue with using 
python 2.7 on my local machine?

-Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dYXTSy7bB3EJ.
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: Authenticate User with Django 1.5

2012-12-16 Thread Tom Christie
> A custom authentication backend isn't required; the ModelBackend should 
adapt to any well-defined User model.

Thanks Russ, I hadn't realized the ModelBackend tied in nicely with those 
changes.

> Have you tried changing USERNAME_FIELD to 'email'? 

+1, looks like that's the OP's issue.

On Sunday, 16 December 2012 01:12:14 UTC, Quartic wrote:
>
> On 15/12/12 11:18, sebastie...@gmail.com  wrote: 
> > Hi, i've an authenticate problem with Django 1.5 
> > All informations are 
> > herehttp://
> stackoverflow.com/questions/13883539/authenticate-with-django-1-5 
> > but i'll resume the situation : 
> > 
> > I've a custum user model which looks like : 
> > 
> > class User(AbstractBaseUser): 
> >  email = models.EmailField(unique=True) 
> >  activation_key = models.CharField(max_length=255) 
> >  is_active = models.BooleanField(default=False) 
> >  is_admin = models.BooleanField(default=False) 
> > 
> >  objects = UserManager() 
> > 
> >  USERNAME_FIELD = 'username' 
> > 
>  
> > 
> > 
> > The probleme is that user = authenticate(username=email, 
> > password=password) gives me None as return. 
> > According to the doc, authenticate takes an usersname, not an email as 
> > arg. But how can i use authenticate because my User model desn't support 
> > Username. 
> > Is there a solution with Django 1.5 ? 
> > 
>
> Have you tried changing USERNAME_FIELD to 'email'? 
>
> Ian 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kz4lo-mJWMUJ.
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 "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-16 Thread Chris Cogdon
Awesome. Thanks for the update.

On Sunday, December 16, 2012 3:56:22 AM UTC-8, bobhaugen wrote:
>
> Wrapping this up:  the problem was caused by South, happened in migrate 
> (found via stack trace).  When I upgraded South, the problem went away.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/pF5s-oY0lC4J.
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.



Authentication backends

2012-12-16 Thread Michael Anckaert
Hello everyone

On my current project I need a mix of builtin Django authentication and
oAuth2 sources. But when writing a custom authentication backend, when does
it get used? The docs say:

"""Once a user has authenticated, Django stores which backend was used to
authenticate the user in the user's session, and re-uses the same backend
for the duration of that session whenever access to the currently
authenticated user is needed."""

The code of ModelBackend only seems to deal with permissions. Assuming an
oAuth2 source deals with authentication my backend should only handle
permission checks?

Thanks for taking the time to answer this.

Kind regards
Michael

-- 
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: deploying a dejango app on AWS

2012-12-16 Thread Mario Gudelj
You need to enable debug in your settings file and provide the error you
are getting. There is nothing to go by here...
On 17 Dec, 2012 2:30 AM, "Nicholas Sonnenberg" <
nicholas.sonnenb...@gmail.com> wrote:

> Hello,
>
> Does anyone know what I need to do to get my django app to run on my
> elastic bean stalk?
> I've got the simple voting application from the website running on my
> local machine, but it's crashing when i run it from the aws cloud.
>
> I've done the AWS git.push and that works, but then the website crashes.
> Is there a setting that I need to change?  Is there an issue with using
> python 2.7 on my local machine?
>
> -Nick
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/dYXTSy7bB3EJ.
> 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.



django doesn't send me error mails

2012-12-16 Thread Ali Vakilzade
I can send mails using send_mail or mail_admins methods

but django it self doesn't send me any mail on 404 error or 500 error.

I have even added  raise Exception('Test') to my view function
I see the 500 error for that but no mail was sent

This is my settings.py: http://dpaste.com/846959/

I use :
django from git master
python 3.2

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/prMyZWhnEXgJ.
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 doesn't send me error mails

2012-12-16 Thread Chris Cogdon
Oh... there's your problem... you've set the admin email to ... i'm 
sure that doesn't exist! :)

Seriously, though... all that looks correct. Can you check your server's 
/var/log/maillog to see if the mail is being accepted?

On Sunday, December 16, 2012 1:33:01 PM UTC-8, Ali Vakilzade wrote:
>
> I can send mails using send_mail or mail_admins methods
>
> but django it self doesn't send me any mail on 404 error or 500 error.
>
> I have even added  raise Exception('Test') to my view function
> I see the 500 error for that but no mail was sent
>
> This is my settings.py: http://dpaste.com/846959/
>
> I use :
> django from git master
> python 3.2
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/xvjr1lPm7rAJ.
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 doesn't send me error mails

2012-12-16 Thread Ali Vakilzade
I don't have access to that file on server.
and log from uwsgi doesn't have any error massage about mail sending

can it be a python3 branch related bug?


در دوشنبه 17 دسامبر 2012، ساعت 1:36:05 (UTC+3:30)، Chris Cogdon نوشته:
>
> Oh... there's your problem... you've set the admin email to ... i'm 
> sure that doesn't exist! :)
>
> Seriously, though... all that looks correct. Can you check your server's 
> /var/log/maillog to see if the mail is being accepted?
>
> On Sunday, December 16, 2012 1:33:01 PM UTC-8, Ali Vakilzade wrote:
>>
>> I can send mails using send_mail or mail_admins methods
>>
>> but django it self doesn't send me any mail on 404 error or 500 error.
>>
>> I have even added  raise Exception('Test') to my view function
>> I see the 500 error for that but no mail was sent
>>
>> This is my settings.py: http://dpaste.com/846959/
>>
>> I use :
>> django from git master
>> python 3.2
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7vvyV4a3btMJ.
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: Authenticate User with Django 1.5

2012-12-16 Thread Russell Keith-Magee
On Sun, Dec 16, 2012 at 9:12 AM, Ian Foote  wrote:

> On 15/12/12 11:18, sebastien.mor...@gmail.com wrote:
>
>> I've a custum user model which looks like :
>>
>> class User(AbstractBaseUser):
>>  email = models.EmailField(unique=True)
>>  activation_key = models.CharField(max_length=**255)
>>  is_active = models.BooleanField(default=**False)
>>  is_admin = models.BooleanField(default=**False)
>>
>>  objects = UserManager()
>>
>>  USERNAME_FIELD = 'username'
>>
>>  
>
>
>>
>> The probleme is that user = authenticate(username=email,
>> password=password) gives me None as return.
>> According to the doc, authenticate takes an usersname, not an email as
>> arg. But how can i use authenticate because my User model desn't support
>> Username.
>> Is there a solution with Django 1.5 ?
>>
>>
> Have you tried changing USERNAME_FIELD to 'email'?
>
>
Well spotted Ian -- that's clearly the problem. Sebastian; ignore my
previous advice :-)

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.



Re: Authentication backends

2012-12-16 Thread Russell Keith-Magee
On Mon, Dec 17, 2012 at 4:53 AM, Michael Anckaert  wrote:

> Hello everyone
>
> On my current project I need a mix of builtin Django authentication and
> oAuth2 sources. But when writing a custom authentication backend, when does
> it get used? The docs say:
>
> """Once a user has authenticated, Django stores which backend was used to
> authenticate the user in the user's session, and re-uses the same backend
> for the duration of that session whenever access to the currently
> authenticated user is needed."""
>
> The code of ModelBackend only seems to deal with permissions. Assuming an
> oAuth2 source deals with authentication my backend should only handle
> permission checks?
>
Well, that depends entirely on what you're trying to achieve.

Logging in a Django user requires two calls on Django's auth interface:

 * authenticate(), which validates that the user is allowed to access the
site
 * login() which actually does the login.

The call to authenticate() is then passed off to the various authentication
backends. The ModelBackend has an easy task here, because all the necessary
data is local to the database, so the call to authenticate is not much more
than a check that the password in the database matches the one provided by
the user.

On subsequent requests, the get_user() method on the backend is used to
retrieve the user instance.

Once that authentication is performed, the authentication backend is used
for permissions checks. However, there's no requirement that you use this
permissions interface -- you can use your own if you want.

You can have multiple authentication backends if you want, so users can log
in using multiple sources of credentials.

So - what does your authentication backend need to implement? If you want
the auth backend to handle authentication, you need to implement
authenticate() and get_user(). If you want your backend to handle
authorisation and permissions, you need to implement the permissions
methods (strictly, you should always implement the permissions methods,but
they don't have to actually grant any permissions; they can be no-op
methods)

Also - before you start implementing your own OAuth implementation, might I
suggest you have a look around at existing implementations.
django-social-auth, for example, has support for a lot of OAuth and OAuth2
providers, and the documentation is fairly extensive.

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.



Re: Python Multiprocessing With Django

2012-12-16 Thread Peter Schmidt
Just in case someone else stumbles across this old thread.

TLDR: The recipe may be able to be improved - I only needed to close the 
connection in the parent Python process, not in the child process.

--
Best guess hypothesis as to what's going on is when you fork a process, the 
OS (e.g. OSX Mountain Lion for me) will simply copy the memory, including 
any current DB connection details.

Then the child process in Django sometimes tries to reuse it.
I say sometimes because Django's backend.mysql.base.py tries:

self.connection.ping()


If that fails, it closes the connection, then the Django magic of creating 
a new connection to the default DB will happen later when it is needed.

Reusing a connection then sometimes leads to one or more whacky things in 
the child processes:
- DatabaseError: (2013, 'Lost connection to MySQL server during query')
- DatabaseError: (2006, 'MySQL server has gone away')
- MultipleObjectsReturned: get() returned more than one  matching query does not exist.

Perhaps someone will be motivated one day to patch something like this into 
Django itself, but it feels like something that comes with the territory of 
handling multiprocessing without using a meaningful subset of concurrency 
such as RabbitMQ/Celery for a task queue. In other words, there's a reason 
Python's multiprocessing documentation is filled with many notes and 
warnings - concurrency is one of the more difficult to use constructs in 
the developer toolbox and as developers we should use it only when it is 
justified by specific requirements for extreme performance (or perhaps for 
the personal challenge).



On Saturday, March 7, 2009 2:30:47 AM UTC+11, Jirka Vejrazka wrote:
>
> > I have a management command that that starts up a few process to process 
> a
> > request: http://dpaste.com/7925/.
>
> Hi, I was recently debugging similar issue and came to a conclusion
> (which may be wrong of course :)  that multiprocessing and Django DB
> connections don't play well together. I ended up closing Django DB
> connection first thing in the new process. It'll recreate a new
> connection when it needs one, but that one will have no references to
> the connection used by the parent.
>
> So, my Process.start() calls a function which starts with:
> >>> from django.db import connection
> >>> connection.close()
>
>   This solved my problem.
>
>Cheers
>
>  Jirka
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-u-g-YzdJTQJ.
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-registration fork for 1.5?

2012-12-16 Thread Detectedstealth
You really don't need a fork I am using the latest dev build of django and 
the only thing you need to change is the direct_to_template in the urls.py 
to use the new class based views and everything else works as is, I even 
have a custom user.

On Wednesday, December 12, 2012 2:44:53 PM UTC-8, mikegolf wrote:
>
> Hi,
> is there any django-registration fork that works on Django 1.5?
>
> thanks,
> mg
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/bN0cgBMx-FUJ.
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: ImageField in admin always required

2012-12-16 Thread Detectedstealth
Thanks required=False is what I needed :). 

"ImageField is not required as expected" Isn't that what you want? :) Yes 
that is exactly what I wanted but also wanted to display the actual  
setting the required=False allows me to have my cake and eat it too :). Not 
sure why required vs blank, null slipped my mind.

PS: It gives great JOY :D

On Wednesday, December 12, 2012 1:39:36 PM UTC-8, Chris Cogdon wrote:
>
>
>
> NOTE: I tried adding null=True, blank=True to forms.ImageField however I 
>> get errors __init__() got an unexpected keyword argument so I guess I can't 
>> use them options. If I comment out the def formfield_for_dbfield(self, 
>> db_field, **kwargs): then the ImageField is not required as expected.
>>
>
> "ImageField is not required as expected" Isn't that what you want? :)
>
> Anyway, the attribute for allowing a FormField to be "left blank" is 
> required=False... blank=True and null=True are for ModelFields
>
> If that knowledge doesn't give you any joy, try constructing a simple 
> model that is not inherited from AbstractBaseUser... does that still end up 
> having the picture be required?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/csQYMquCKr0J.
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 doesn't send me error mails

2012-12-16 Thread Chris Cogdon
My best guess is that the mail transport agent on the server is rejecting 
the mail because something is different from mail that is send through 
other places in your django code. Perhaps the mail "sender" is not correct, 
for example?

Unfortunately, looking at the mail log is the best way to see what's 
happening. If that's not available, you might want to see what is being 
sent.

Set this:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

and then run your project with "runserver". The mail that it tries to send 
will be sent to the console instead. Check out the "from" headers and make 
sure they make sense. Compare that to the other kinds of email that are 
sent.

(Make sure you're still running with DEBUG=False)



On Sunday, December 16, 2012 2:18:26 PM UTC-8, Ali Vakilzade wrote:
>
> I don't have access to that file on server.
> and log from uwsgi doesn't have any error massage about mail sending
>
> can it be a python3 branch related bug?
>
>
> در دوشنبه 17 دسامبر 2012، ساعت 1:36:05 (UTC+3:30)، Chris Cogdon نوشته:
>>
>> Oh... there's your problem... you've set the admin email to ... i'm 
>> sure that doesn't exist! :)
>>
>> Seriously, though... all that looks correct. Can you check your server's 
>> /var/log/maillog to see if the mail is being accepted?
>>
>> On Sunday, December 16, 2012 1:33:01 PM UTC-8, Ali Vakilzade wrote:
>>>
>>> I can send mails using send_mail or mail_admins methods
>>>
>>> but django it self doesn't send me any mail on 404 error or 500 error.
>>>
>>> I have even added  raise Exception('Test') to my view function
>>> I see the 500 error for that but no mail was sent
>>>
>>> This is my settings.py: http://dpaste.com/846959/
>>>
>>> I use :
>>> django from git master
>>> python 3.2
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VGNyODw_eXQJ.
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: Implementing a monitoring system with django.

2012-12-16 Thread Ryan Nowakowski
Checkout Graphite[1].  It seems like it would handle your graphing
requirement.

1. http://graphite.wikidot.com/start

On Mon, Dec 10, 2012 at 08:41:14PM +0100, Marc Aymerich wrote:
> Hi,
> I'm considering to implement a simple monitorization system that
> basically gathers some data from a set of nodes (<1000 nodes). The
> gathered data should be stored in order to let users perform some
> queries and maybe also generate some graphs.
> 
> I'm looking for advice in what components are best suited for each of
> the following parts:
> 
> 1) Storage: maybe something nonsql like MongoDB? or perhaps RRD?
> 2) Data gathering: celery periodic tasks?
> 3) Graphs: rrd? or some java script framework for graphing?
> 
> thanks for your comments!!
> -- 
> Marc
> 
> -- 
> 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.



"Compatibility with old signed data" issue

2012-12-16 Thread Jury Gerasimov
Hi all,

we're migrating from Django 1.2 to 1.5, and we've fixed all the 
compatibility issues except one. It's "Compatibility with old signed data" 
https://docs.djangoproject.com/en/dev/releases/1.4/#compatibility-with-old-signed-data.
 
In short, it drops users sessions and forces them to re-login. We cannot 
drop all the sessions on the website up and running.

So is there any idea how to convert sessions from 1.2 format to 1.5 without 
losing them?

Thank you,
Jury.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/m5_1fjcgSQoJ.
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: "Compatibility with old signed data" issue

2012-12-16 Thread Russell Keith-Magee
Hi Jury,

As the release notes indicate, there was some conversion code in place to
help make this transition; however, that code was removed in the 1.4
release. This means you have two options:

 1) Run your site for a while on Django 1.3 before upgrading to 1.5, where
"a while" is the length of SESSION_COOKIE_AGE. This will give enough time
to ensure that old cookies are updated to the new signed format.

 2) Write a custom session backend that re-introduces the old fallback. If
you get the 1.3 codebase, the conversion code is all contained in the
decode() method of django.contrib.sessions.backends.base.py; it's a
relatively simple fallback mechanism which shouldn't be too hard to add
back to a custom session backend. Once SESSION_COOKIE_AGE has expired,
you'll be able to remove this custom backend, and go back to the normal
session backends.

Yours,
Russ Magee %-)

On Mon, Dec 17, 2012 at 12:28 PM, Jury Gerasimov  wrote:

> Hi all,
>
> we're migrating from Django 1.2 to 1.5, and we've fixed all the
> compatibility issues except one. It's "Compatibility with old signed data"
> https://docs.djangoproject.com/en/dev/releases/1.4/#compatibility-with-old-signed-data.
> In short, it drops users sessions and forces them to re-login. We cannot
> drop all the sessions on the website up and running.
>
> So is there any idea how to convert sessions from 1.2 format to 1.5
> without losing them?
>
> Thank you,
> Jury.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/m5_1fjcgSQoJ.
> 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.



trouble with pre_delete signal method

2012-12-16 Thread Mike Dewhirst

I'm getting a baffling ValidationError.

Request URL:http://127.0.0.1:8000/admin/assembly/item/4/
Django Version: 1.4.3
Exception Type: ValidationError
Exception Value: 	[u'Select a valid choice. That choice is not one of 
the available choices.']


Exception Location: 	C:\usr\bin\lib\site-packages\django\forms\models.py 
in to_python, line 988

Python Version: 2.7.3

Background ...

I have an Item model which has two one-to-many relationships with other 
types of child records (call them A and B models).


In the Admin, when the user adds an A record, some B records get added 
automatically.


The next A record to get added does much the same but if there are any B 
duplicates it doesn't try to add those but instead just adds its mark to 
a special field in the B record which is already there.


My code - which from embedded print statements appears to be doing 
exactly what I want - will either delete the B record or just remove the 
mark previously added. Eventually when the last A record is deleted the 
idea is that the last B records will go at the same time.


Unfortunately, at the final hurdle we get the ValidationError at line 
988 in to_python.


The local vars nominate ...

self
value   u'251'
key 'pk'

... and that is the pk of the A record which triggers the Item code via 
a pre_delete signal.


Summarising:

- the deletion/mark removal method lives in the Item model
- the pre-delete signal is detected in the A record
- the signal connects a stub method in the A record
- the stub method in the A record calls the Item method
- the Item method iterates over a filtered queryset of B records and 
uses the passed value (the aforesaid mark from the A record) to decide 
whether to delete the B record or just remove the mark and save it


None of my code appears in the TraceBack so I assume the Admin is trying 
to delete the A record. I've tried both pre_delete and post_delete 
signals in the A record.


Why is it so?

Thanks for any hints

Mike


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