Re: request.method not working as expected

2011-09-21 Thread Babatunde Akinyanmi
Your post showed the trailing url...anyway I agree with your
diagnosis. With my noob knowledge of django, django tries to add a
trailing slash to your url when you don't. I believe she does that by
adding the trailing slash to the url and then asking the server to
redirect to the url which is the reason why the development server
logs show 301 status. However, when a 301 is gotten in response to a
request and the request method wasn't GET or HEAD, the client is
expected to ask the user before redirecting. If there is no automatic
addition of the trailing slash, the server will return a 500 instead
because django would be able to find the url in your given pattern and
raise an error.
My guess is that maybe django explicitly does the redirection by
sending a GET. I guess this is one of the times we need to check the
guts of django to understand her more.
However, if you believe you simply won't be able to cope with the
trailing slash, you could change your url pattern to exclude the
trailing slash though I don't know if that has side effects.that's
if you must absolutely hard code the url

On 9/21/11, Fabio Natali  wrote:
> On 09/20/2011 07:15 PM, dm03514 wrote:
>> Fabio in your dev server output is it saying the type of request is
>> get?
>> ARe you accessing "/method/" through your form or are you just
>> directing your webserver to http://192.168.0.2:8000/method/???
>
> Hi dm03514 and thanks for your help!
>
> Thanks to your suggestion I managed to resolve my issue. I looked at my
> development server logs and noticed 2 lines:
>
> [20/Sep/2011 12:17:27] "POST /method HTTP/1.1" 301 0
> [20/Sep/2011 12:17:27] "GET /method/ HTTP/1.1" 200 3
>
> I guess the lack of a trailing slash in my url was causing some sort of
> internal redirection. That redirection eventually caused the loss of
> POST stuff.
>
> I was using this:
> http://192.168.0.2:8000/method";>
> I changed that to:
> http://192.168.0.2:8000/method/";>
> and everything was fixed.
>
> Don't you think this is too fragile and error prone? I guess I may
> forget the trailing slash again in the future and that will mean the
> break of everything... Is there any best practice for this?
>
> Thanks! Greetings, Fabio.
>
> --
> Fabio Natali FNstudio
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: request.method not working as expected

2011-09-21 Thread Babatunde Akinyanmi
What's in your add_to_cart view function?

On 9/21/11, Fabio Natali  wrote:
> On 09/21/2011 07:57 AM, Andres Reyes wrote:
>> I believe that the best practice is to always use the {% url %} template
>> tag and not hardcoding your URL's
>
> That makes perfect sense. Thanks for your precious tip!
>
> So I added {% url add_to_cart %} to my template. However, it silenty
> fails and I am redirected to my main page with no error whatsoever.
>
> ### urls.py
> (r'^add_to_cart/$', add_to_cart)
>
> Any tips?
>
> Thanks and greetings, Fabio.
>
> --
> Fabio Natali FNstudio
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: Create socket server in django

2011-09-21 Thread Micke
Wow. I will try, and if it works as you say, its wonderful! :)


On Sep 20, 12:26 pm, Thorsten Sanders 
wrote:
> import sys,os
>
> sys.path.append('/path/to/your/django_project')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'your_settings_file'
>
> This works fine for a cronjob I created
>
> On 20.09.2011 10:48, Thomas Orozco wrote:
>
>
>
>
>
>
>
>
>
> > You just have to run your server as a daemon and use Django's
> > setup_environment so you can use the ORM to interact with your Django DB.
>
> > I can try and find the lines you need to do that if you can't find them.
>
> > Le 20 sept. 2011 09:08, "Micke"  > > a �crit :
> > --
> > 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.



How to solve MultiValueDictKeyError

2011-09-21 Thread Kayode Odeyemi
Hello friends,

I don't know why Django is so unstable.

Before restarting my computer everything works fine. Django could parse a
simple
POST request without complaining KeyError.

I'm simply making a POST request like this:

curl -v -H "Content-Type: application/json" -A 'Mozilla' -X POST --data
'fees={"fees":{"status":"pending","timeout":5},
"hostel":{"status":"pending","timeout": 3}}'
http://127.0.0.1:8000/api/transaction/add/ > post_data.txt

I also have it in valid dict format like this:

curl -v -H "Content-Type: application/json" -X POST --data
'fees={"fees":[("status","pending"),("timeout",5)],
"hostel":[("status","pending"),("timeout", 3)]'
http://127.0.0.1:8000/api/transaction/add/ > post_data.txt

This worked throughout yesterday. Just hoping to continue from where I left
off, and I can't progress as I would love to.

Trace:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/api/transaction/add/

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'django.contrib.humanize',
 'axes',
 'webapp',
 'djangorestframework',
 'django_tables',
 'django_tables.app',
 'pagination',
 'south',
 'djcelery']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'djangoflash.middleware.FlashMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'axes.middleware.FailedLoginMiddleware',
 'audit_log.middleware.UserLoggingMiddleware')


Traceback:
File
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\core\handlers\base.py"
in get_response
  111. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\wamp\www\edupay\api\views.py" in add_transaction
  44. req_fees = json.loads(QueryDict(request.POST.__getitem__('fees')))
File
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\utils\datastructures.py"
in __getitem__
  256. raise MultiValueDictKeyError("Key %r not found in %r" %
(key, self))

Exception Type: MultiValueDictKeyError at /api/transaction/add/
Exception Value: 'Key \'fees\' not found in '

The problem is simply understandable, but why didn't Django say this when I
worked on it yesterday. This is not fair Djanjo. It is not!

Somebody please help me.

Thanks

-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
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 solve MultiValueDictKeyError

2011-09-21 Thread Tom Evans
On Wed, Sep 21, 2011 at 11:33 AM, Kayode Odeyemi  wrote:
> Hello friends,
>
> I don't know why Django is so unstable.

I don't know why you cross posted this to django-developers.

>
> Before restarting my computer everything works fine. Django could parse a
> simple
> POST request without complaining KeyError.
>
> I'm simply making a POST request like this:
>
> curl -v -H "Content-Type: application/json" -A 'Mozilla' -X POST --data
> 'fees={"fees":{"status":"pending","timeout":5},
> "hostel":{"status":"pending","timeout": 3}}'
> http://127.0.0.1:8000/api/transaction/add/ > post_data.txt

Thats not x-www-form-urlencoded data, so expecting django to parse it
is not going to happen. Django parses x-www-form-urlencoded data.

>
> I also have it in valid dict format like this:
>
> curl -v -H "Content-Type: application/json" -X POST --data
> 'fees={"fees":[("status","pending"),("timeout",5)],
> "hostel":[("status","pending"),("timeout", 3)]'
> http://127.0.0.1:8000/api/transaction/add/ > post_data.txt
>
> This worked throughout yesterday. Just hoping to continue from where I left
> off, and I can't progress as I would love to.
>

It didn't work yesterday, you are mistaken. Django has never
automatically parsed json encoded post data, so if you think it did
yesterday, you are wrong.

Tom

-- 
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 solve MultiValueDictKeyError

2011-09-21 Thread Kayode Odeyemi
On Wed, Sep 21, 2011 at 11:43 AM, Tom Evans wrote:

> On Wed, Sep 21, 2011 at 11:33 AM, Kayode Odeyemi 
> wrote:
> > Hello friends,
> >
> > I don't know why Django is so unstable.
>
> I don't know why you cross posted this to django-developers.
>

My apologies for cross-posting. (My hands to my chest and head bowed)

>
> >
> > Before restarting my computer everything works fine. Django could parse a
> > simple
> > POST request without complaining KeyError.
> >
> > I'm simply making a POST request like this:
> >
> > curl -v -H "Content-Type: application/json" -A 'Mozilla' -X POST --data
> > 'fees={"fees":{"status":"pending","timeout":5},
> > "hostel":{"status":"pending","timeout": 3}}'
> > http://127.0.0.1:8000/api/transaction/add/ > post_data.txt
>
> Thats not x-www-form-urlencoded data, so expecting django to parse it
> is not going to happen. Django parses x-www-form-urlencoded data.
>
> OK! Thanks

> This worked throughout yesterday. Just hoping to continue from where I
left
> off, and I can't progress as I would love to.
>

It didn't work yesterday, you are mistaken. Django has never
> automatically parsed json encoded post data, so if you think it did
> yesterday, you are wrong.
>

I can swear it worked. I had the data in a queue and then processed.
Seriously.
I'm not kidding.



-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
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 solve MultiValueDictKeyError

2011-09-21 Thread Kayode Odeyemi
On Wed, Sep 21, 2011 at 11:43 AM, Tom Evans wrote:

>
> On Wed, Sep 21, 2011 at 11:33 AM, Kayode Odeyemi 
> wrote:
> > curl -v -H "Content-Type: application/json" -A 'Mozilla' -X POST --data
> > 'fees={"fees":{"status":"pending","timeout":5},
> > "hostel":{"status":"pending","timeout": 3}}'
> > http://127.0.0.1:8000/api/transaction/add/ > post_data.txt
>
> Thats not x-www-form-urlencoded data, so expecting django to parse it
> is not going to happen. Django parses x-www-form-urlencoded data.
>
> The problem is not the content-type. It's because of the space in between
--data and 'fees=

I've fixed that and it worked :)

Thanks anyway

It didn't work yesterday, you are mistaken. Django has never
> automatically parsed json encoded post data, so if you think it did
> yesterday, you are wrong.
>
> It worked yesterday and worked today. I hope it works tomorrow :)


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
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 solve MultiValueDictKeyError

2011-09-21 Thread Florian Apolloner
Hi,

please post in django-users, this mailinglist is about the development of 
django itself, not about enduser problems.

-- 
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/-/x4TGJNjIK8YJ.
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: mysql installation error

2011-09-21 Thread Thorsten Sanders
When I first installed django, that made me going crazy to try to 
install that library, in the end I just went with a pre-compiled from


http://www.lfd.uci.edu/~gohlke/pythonlibs/

On 21.09.2011 04:59, PremAnand Lakshmanan wrote:

Hi,
When I try to install mysql I get the following error,
Pls provide your inputs.

C:\MYSQL\MySQL-python-1.2.3\MySQL-python-1.2.3>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 15, in 
metadata, options = get_config()
  File 
"C:\MYSQL\MySQL-python-1.2.3\MySQL-python-1.2.3\setup_windows.py", line 7

, in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 
options['registry_ke

y'])
WindowsError: [Error 2] The system cannot find the file specified
--
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: Custom model field/form: __init__() got multiple values for keyword argument 'baz'

2011-09-21 Thread Michal Petrucha
On Tue, Sep 20, 2011 at 04:18:28PM -0700, Micky Hulse wrote:
> Optimally, I think I would prefer to keep the verbose name in the
> first position (as an arg, not kwarg) in order to keep things
> consistent.
> 
> If you look at fields.py:
> 
> 
> 
> Line #s 13 and 16, I do this:
> 
> def __init__(self, *args, **kwargs):
> self._baz = kwargs.get('baz', None)
> 
> But when I do that, I get this error:
> 
> File "/.../test/fields.py", line 19, in __init__
> TypeError: __init__() got an unexpected keyword argument 'baz'

In this case, the problem is a little bit different.
models.CharField.__init__ knows nothing about any 'baz' keyword
argument. With your current code, however, you keep the 'baz' item in
the kwargs dictionary and also pass this argument to
CharField.__init__. That's the cause of this error.

The remedy is simple, instead of kwargs.get use kwargs.pop.

Michal


signature.asc
Description: Digital signature


Re: DjangoCon US 2011 Videos

2011-09-21 Thread Slafs
I would be interested also in watching those videos

Regards

-- 
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/-/C0sVOMIzq3UJ.
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: DjangoCon US 2011 Videos

2011-09-21 Thread Brian Bouterse
Me 2.  I was at the conference but missed one or two key sessions that I
wanted to see.

Brian

On Wed, Sep 21, 2011 at 9:09 AM, Slafs  wrote:

> I would be interested also in watching those videos
>
> Regards
>
>
>  --
> 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/-/C0sVOMIzq3UJ.
>
> 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.
>



-- 
Brian Bouterse
ITng Services

-- 
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: DjangoCon US 2011 Videos

2011-09-21 Thread Cal Leeming [Simplicity Media Ltd]
+1

On Wed, Sep 21, 2011 at 2:09 PM, Slafs  wrote:

> I would be interested also in watching those videos
>
> Regards
>
>
>  --
> 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/-/C0sVOMIzq3UJ.
>
> 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: DjangoCon US 2011 Videos

2011-09-21 Thread Derek
+2

On Sep 21, 3:10 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> +1
>
> On Wed, Sep 21, 2011 at 2:09 PM, Slafs  wrote:
> > I would be interested also in watching those videos
>
> > Regards
>
> >  --
> > 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/-/C0sVOMIzq3UJ.
>
> > 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: DjangoCon US 2011 Videos

2011-09-21 Thread Jason Keene
I agree, was hoping these would already be up.  We should all tweet
@nextdayvideo  see if we can elicit a
response.


On Wed, Sep 21, 2011 at 9:12 AM, Derek  wrote:

> +2
>
> On Sep 21, 3:10 pm, "Cal Leeming [Simplicity Media Ltd]"
>  wrote:
> > +1
> >
> > On Wed, Sep 21, 2011 at 2:09 PM, Slafs  wrote:
> > > I would be interested also in watching those videos
> >
> > > Regards
> >
> > >  --
> > > 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/-/C0sVOMIzq3UJ.
> >
> > > 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: request.method not working as expected

2011-09-21 Thread Fabio Natali

On 09/21/2011 09:39 AM, Babatunde Akinyanmi wrote:

What's in your add_to_cart view function?


Hi Babatunde,

at the moment, the add_to_cart view is just printing the POST data on 
the screen.


Cheers, Fabio.

--
Fabio Natali FNstudio
http://fnstudio.it
fabio_natali@skype

--
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: request.method not working as expected

2011-09-21 Thread Fabio Natali

On 09/21/2011 09:37 AM, Babatunde Akinyanmi wrote:

Your post showed the trailing url...


Yes! You are perfectly right, it was my fault! (But you have to admit it 
was hard to find, that little trailing slash! :-))



anyway I agree with your diagnosis.

[...]

Yes, I'll follow Andres Reyes advice and use {% url %} tag. I'm still 
having a few problems with it, but it sounds like the way to go.


Thanks! Fabio.

--
Fabio Natali FNstudio

--
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: Is it possible to run from Django script?

2011-09-21 Thread Malcolm Box
On 20 September 2011 21:36, Stone  wrote:

> Dear users,
>
> I have simple question which regards with running script from view.py.
> 
> Is it possible to do that over subprocess command?
>
>
Yes, you can run a script from within your view. Whether you *should* or not
depends largely on how long the script might take to run. While it's running
the Django instance serving the user's request and the user's browser will
hang waiting for it to complete, so if it's going to take a while then you'd
be better off running the script using something like Celery.

Cheers,

Malcolm

-- 
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 does form.is_valid() clean the form?

2011-09-21 Thread Jacob G
Thanks all.

I figured out my mess-up: In the view, I instantiated the form incorrectly 
as follows:

form = AuthenticationForm(request.POST)

Instead of the correct way:

form = AuthenticationForm(request, data=request.POST)


The debugger weirdness distracted me from the real problem. I still don't 
know what happened with the debugger, but I've got other things to do, so 
I'm moving on...

-- 
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/-/xXaFMc2KYboJ.
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: Using success_url with reverse() in class-based generic view

2011-09-21 Thread Daniel P
Same problem. You'r not alone!

this is also a solution: http://djangosnippets.org/snippets/2445/

-- 
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: request.method not working as expected

2011-09-21 Thread Fabio Natali

On 09/21/2011 03:32 PM, Fabio Natali wrote:
[...]

Yes, I'll follow Andres Reyes advice and use {% url %} tag. I'm still
having a few problems with it, but it sounds like the way to go.


Ok, it works now. I just had to use the proper syntax! :-)

### urls.py
...
url(r'^add_to_cart/$', add_to_cart, name='add_to_cart'),

Cheers, Fabio.

--
Fabio Natali FNstudio

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



Getting a count of a RawQuerySet object

2011-09-21 Thread Jack
Hello everyone, I'm quite new to django and python in general so I'm
sure there's just something I missed in my searching to answer this.
But...

Is there a way to count the number of results returned in the
RawQuerySet option?

I've tried the len() function and I've search the django documentation
with no results. So, any help would be very welcomed.

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.



changes to .py file is not reflected until server is restarted.

2011-09-21 Thread vijaymohan
I am new to django and did't find solution googling. i changed a .py
file in my app and hit refresh button on web browser but the changes
are not reflected until i restart the httpd. is there any flag i need
to set this to happen.

I set PythonAutoReload On in python.conf.
Changes to template file are reflecting but not the .py files.

Can someone help me ?

Thanks,
Vijay

-- 
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: Getting a count of a RawQuerySet object

2011-09-21 Thread delegbede
Let's say you have a model Utility, you can do Utility.objects.all().count()
Hope that helps. 
Regards. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: Jack 
Sender: django-users@googlegroups.com
Date: Wed, 21 Sep 2011 09:10:49 
To: Django users
Reply-To: django-users@googlegroups.com
Subject: Getting a count of a RawQuerySet object

Hello everyone, I'm quite new to django and python in general so I'm
sure there's just something I missed in my searching to answer this.
But...

Is there a way to count the number of results returned in the
RawQuerySet option?

I've tried the len() function and I've search the django documentation
with no results. So, any help would be very welcomed.

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.

-- 
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread Cal Leeming [Simplicity Media Ltd]
Hi Vijay,

Some web app servers will allow you to 'touch' the wrapper file (wsgi.py for
example) which will in turn trigger a restart. Running manage.py in
'runserver' mode will also do this (this is for dev, NOT for production).

But for the most part, production will require you to restart the webapp
service in order to recognise changes (an exception being Apache, which
allows the 'touch' approach).

Hope this helps

Cal

On Wed, Sep 21, 2011 at 5:13 PM, vijaymohan  wrote:

> I am new to django and did't find solution googling. i changed a .py
> file in my app and hit refresh button on web browser but the changes
> are not reflected until i restart the httpd. is there any flag i need
> to set this to happen.
>
> I set PythonAutoReload On in python.conf.
> Changes to template file are reflecting but not the .py files.
>
> Can someone help me ?
>
> Thanks,
> Vijay
>
> --
> 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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread vijaymohan
i am using Apache, touch approach is not working for me.Is there any change 
i need to make in httpd.conf ? 

-- 
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/-/2woUQpBtcVIJ.
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread Cal Leeming [Simplicity Media Ltd]
May I ask which file you are attempting to 'touch'? You can only do it on
the bootstrapper.

Cal

On Wed, Sep 21, 2011 at 5:58 PM, vijaymohan  wrote:

> i am using Apache, touch approach is not working for me.Is there any change
> i need to make in httpd.conf ?
>
> --
> 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/-/2woUQpBtcVIJ.
>
> 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: Custom model field/form: __init__() got multiple values for keyword argument 'baz'

2011-09-21 Thread Micky Hulse
On Wed, Sep 21, 2011 at 6:08 AM, Michal Petrucha  wrote:
> The remedy is simple, instead of kwargs.get use kwargs.pop.

Ahhh, I see! Thanks so much for the explanation and clarification.

Much appreciated.

Have an excellent day!

Cheers,
Micky

-- 
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: Getting a count of a RawQuerySet object

2011-09-21 Thread Jack Morgan
Hi, thanks!
The issue I'm getting here is that the RawQuerySet object does not have the
.count() method so it just gives an error.
I also just checked that it does not have the 'all()' method either.


On Wed, Sep 21, 2011 at 9:23 AM,  wrote:

> Let's say you have a model Utility, you can do
> Utility.objects.all().count()
> Hope that helps.
> Regards.
> Sent from my BlackBerry wireless device from MTN
>
> -Original Message-
> From: Jack 
> Sender: django-users@googlegroups.com
> Date: Wed, 21 Sep 2011 09:10:49
> To: Django users
> Reply-To: django-users@googlegroups.com
> Subject: Getting a count of a RawQuerySet object
>
> Hello everyone, I'm quite new to django and python in general so I'm
> sure there's just something I missed in my searching to answer this.
> But...
>
> Is there a way to count the number of results returned in the
> RawQuerySet option?
>
> I've tried the len() function and I've search the django documentation
> with no results. So, any help would be very welcomed.
>
> 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.
>
> --
> 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: Getting a count of a RawQuerySet object

2011-09-21 Thread dm03514
If you're writing your own queries, can't you just write a count
query??
or when you're iterating over your results just keep the count???

-- 
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread vijaymohan
[vijay]$ cd /var/www/html/mysite/
[vijay mysite]$ ls
__init__.py  manage.py  settings.py  templates  urls.py  views.py

modified views.py file.

-- 
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/-/ZHZIP-0A3sEJ.
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread Cal Leeming [Simplicity Media Ltd]
Yeah that won't work.

You need to 'touch' your bootstrapper.

Cal

On Wed, Sep 21, 2011 at 6:24 PM, vijaymohan  wrote:

> [vijay]$ cd /var/www/html/mysite/
> [vijay mysite]$ ls
> __init__.py  manage.py  settings.py  templates  urls.py  views.py
>
> modified views.py file.
>
> --
> 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/-/ZHZIP-0A3sEJ.
>
> 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: How to solve MultiValueDictKeyError

2011-09-21 Thread Jacob Kaplan-Moss
On Wed, Sep 21, 2011 at 5:43 AM, Tom Evans  wrote:
> On Wed, Sep 21, 2011 at 11:33 AM, Kayode Odeyemi  wrote:
>> Hello friends,
>>
>> I don't know why Django is so unstable.
>
> I don't know why you cross posted this to django-developers.

Tom, the snarky tone is un-called-for and not OK. Cross-posting is
against our normal standards, but there's not reason for Kayode to
have known that. Please try to be nice when telling people about our
community standards.

And Kayode: I think you'll find you have a lot more luck getting your
questions answered if you're polite and don't insult the work of a
bunch of volunteers. Calling Django "unstable" is a really bad way to
motivate the people who wrote it to try to help you out.

Remember folks: at the other end of that email is "a real person, a
lot like you" (http://sivers.org/real).

Jacob

-- 
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread vijaymohan
i am in very early stage of learning django. if you don't mind could you 
tell me what the bootstrapper is ?

-- 
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/-/98ZrsVwVYGUJ.
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread Cal Leeming [Simplicity Media Ltd]
Sorry, I should have been more clear on this.

In your apache config, you should have specified a WSGI file to attach to
(assuming you are using WSGI) - this is the file you need to touch.

If not, please specify how you are telling Apache to connect to your python
app.

Cal



On Wed, Sep 21, 2011 at 6:44 PM, vijaymohan  wrote:

> i am in very early stage of learning django. if you don't mind could you
> tell me what the bootstrapper is ?
>
> --
> 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/-/98ZrsVwVYGUJ.
>
> 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.



Customizing forms html

2011-09-21 Thread Jacob G
I'm trying to customize Django forms html based on three requirements:
1) Html output to match html given to me by a web site designer.
2) Automatically generate forms, so I don't have to duplicate html in 
templates.
3) Re-use as match of Django forms code as possible.

For my first attempt, I'm working on an authentication form. So here's what 
I did:
1) Derive AuthenticationForm class so that I can create use derived classes 
for the CharFields
2) Derive CharField to set css class in widget_attrs
3) Derived ErrorList to use own custom html for errors

Another problem came up: Django assumes that field errors should be 
displayed before the field label. However, I want to display the field error 
after the field's input (after a line break). It would seem that I would 
have to override BaseForm method _html_output, which I would like to avoid.

*Summary Question*: Is there a simpler way to output field error html after 
field, rather than before field, without having to override _html_output?

Thanks.

-- 
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/-/TEvOanYctRYJ.
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: Customizing forms html

2011-09-21 Thread Jacob G
And I also want to display non-field errors after the form, not before.

-- 
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/-/66g7i8P5DqEJ.
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.



Comment Framework and Session Variables

2011-09-21 Thread SixDegrees

I'm using the Django-supplied comment framework, and I would like to
initialize the email field of the comment form with a value stored in a
session variable. The forms, however, are created using template tags; they
aren't instantiated in the view, for example, where I could easily provide
the session value as part of the 'initial' dictionary. I don't see any way
in the template to pass this value along so the form can make use of it. How
can I do this?
-- 
View this message in context: 
http://old.nabble.com/Comment-Framework-and-Session-Variables-tp32503766p32503766.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread vijaymohan
i did't modify httpd.conf
i just included the below line in /etc/httpd/conf.d/python.conf

LoadModule python_module modules/mod_python.so


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonAutoReload On
PythonPath "['/var/www/html'] + sys.path"



and  mysite directory i have the below files
__init__.py  manage.py  settings.py  templates  urls.py  views.py


so, which file should i touch ?

-- 
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/-/ifGSAsCZWlUJ.
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread Cal Leeming [Simplicity Media Ltd]
Oh jeez - modpython, I've nfi how to make that work with the same approach.
Maybe check mod_python docs??

Cal

On Wed, Sep 21, 2011 at 7:25 PM, vijaymohan  wrote:

> i did't modify httpd.conf
> i just included the below line in /etc/httpd/conf.d/python.conf
>
> LoadModule python_module modules/mod_python.so
>
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> PythonOption django.root /mysite
> PythonDebug On
> PythonAutoReload On
> PythonPath "['/var/www/html'] + sys.path"
> 
>
>
> and  mysite directory i have the below files
> __init__.py  manage.py  settings.py  templates  urls.py  views.py
>
>
> so, which file should i touch ?
>
> --
> 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/-/ifGSAsCZWlUJ.
>
> 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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread Daniel Roseman
On Wednesday, 21 September 2011 19:25:08 UTC+1, vijaymohan wrote:
>
> i did't modify httpd.conf
> i just included the below line in /etc/httpd/conf.d/python.conf
>
> LoadModule python_module modules/mod_python.so
>
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> PythonOption django.root /mysite
> PythonDebug On
> PythonAutoReload On
> PythonPath "['/var/www/html'] + sys.path"
> 
>
>
> and  mysite directory i have the below files
> __init__.py  manage.py  settings.py  templates  urls.py  views.py
>
>
> so, which file should i touch ?
>

Firstly, mod_python is deprecated. Don't use it. Use mod_wsgi instead for 
production.

Secondly, for development, don't use Apache. Use the built-in runserver. 
That's what it's for.
--
DR.

-- 
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/-/EGeD6Z5etUQJ.
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: Using success_url with reverse() in class-based generic view

2011-09-21 Thread Xavier Ordoquy
Hi,

You can also use get_success_url for that:

class ContactView(generic.FormView):
form_class = ContactForm

def get_success_url(self):
return reverse('contact-sent')

Regards,
Xavier

Linovia.

Le 21 sept. 2011 à 00:08, Daniel P a écrit :

> Same problem. You'r not alone!
> 
> this is also a solution: http://djangosnippets.org/snippets/2445/
> 
> -- 
> 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: Comment Framework and Session Variables

2011-09-21 Thread Andres Reyes
One possible way would be to create your own template tag and use it instead
of the provided one. I did it recently and it's not that complicated, you
should use the code for the current one as an starting point and just extend
it to accept some custom parameter you provide, in this case the email
field.

Regards

2011/9/21 SixDegrees 

>
> I'm using the Django-supplied comment framework, and I would like to
> initialize the email field of the comment form with a value stored in a
> session variable. The forms, however, are created using template tags; they
> aren't instantiated in the view, for example, where I could easily provide
> the session value as part of the 'initial' dictionary. I don't see any way
> in the template to pass this value along so the form can make use of it.
> How
> can I do this?
> --
> View this message in context:
> http://old.nabble.com/Comment-Framework-and-Session-Variables-tp32503766p32503766.html
> Sent from the django-users mailing list archive at Nabble.com.
>
> --
> 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.
>
>


-- 
Andrés Reyes Monge
armo...@gmail.com
+(505)-8873-7217

-- 
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 template IndexError

2011-09-21 Thread Martin Tiršel

Hello,

I have this situation:

class SomeClass(object):
...
def __getitem__(self, key):
...
raise IndexError()

and now:

context['somevar'] = {'one': 1, }
context['anothervar'] = SomeClass()


in template:

{{ somevar.one }} - prints 1
{{ somevar.two }} - prints nothing, no exception raised
{{ anothervar.notexistentindex }} - raises IndexError and page doesn't  
load (debug info printed)


Does anybody knows why? In both cases IndexError exception is raised but  
first case doesn't stop page loading, the another stops and prints debug  
info. I need silent ignore. What is the difference between "native"  
IndexError and my IndexError?



Thanks,
Martin

--
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: DjangoCon US 2011 Videos

2011-09-21 Thread David Watson
Looks like they are online now http://blip.tv/djangocon

regards,

David


On Wed, Sep 21, 2011 at 2:21 PM, Jason Keene  wrote:

> I agree, was hoping these would already be up.  We should all tweet
> @nextdayvideo  see if we can elicit a
> response.
>
>
>
> On Wed, Sep 21, 2011 at 9:12 AM, Derek  wrote:
>
>> +2
>>
>> On Sep 21, 3:10 pm, "Cal Leeming [Simplicity Media Ltd]"
>>  wrote:
>> > +1
>> >
>> > On Wed, Sep 21, 2011 at 2:09 PM, Slafs  wrote:
>> > > I would be interested also in watching those videos
>> >
>> > > Regards
>> >
>> > >  --
>> > > 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/-/C0sVOMIzq3UJ.
>> >
>> > > 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.
>

-- 
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: DjangoCon US 2011 Videos

2011-09-21 Thread Marc Aymerich
On Wed, Sep 21, 2011 at 11:46 PM, David Watson  wrote:
> Looks like they are online now http://blip.tv/djangocon
> regards,
> David
>

Wow, great news!! I'm going to check it out right now :)

> On Wed, Sep 21, 2011 at 2:21 PM, Jason Keene  wrote:
>>
>> I agree, was hoping these would already be up.  We should all tweet
>> @nextdayvideo see if we can elicit a response.
>>
>>
>> On Wed, Sep 21, 2011 at 9:12 AM, Derek  wrote:
>>>
>>> +2
>>>
>>> On Sep 21, 3:10 pm, "Cal Leeming [Simplicity Media Ltd]"
>>>  wrote:
>>> > +1
>>> >
>>> > On Wed, Sep 21, 2011 at 2:09 PM, Slafs  wrote:
>>> > > I would be interested also in watching those videos
>>> >
>>> > > Regards
>>> >
>>> > >  --
>>> > > 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/-/C0sVOMIzq3UJ.
>>> >
>>> > > 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.
>
> --
> 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.
>



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



Re: DjangoCon US 2011 Videos

2011-09-21 Thread Shawn Milochik
On Wed, Sep 21, 2011 at 5:54 PM, Marc Aymerich  wrote:
> On Wed, Sep 21, 2011 at 11:46 PM, David Watson  
> wrote:
>> Looks like they are online now http://blip.tv/djangocon
>> regards,
>> David
>>
>
> Wow, great news!! I'm going to check it out right now :)
>


Awesome. They're not all there, but a bunch are.

-- 
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: DjangoCon US 2011 Videos

2011-09-21 Thread Cal Leeming [Simplicity Media Ltd]
http://blip.tv/djangocon/deployment-daemons-and-datacenters-5573370

This is quite interesting - props to Godwin for this

On Wed, Sep 21, 2011 at 10:56 PM, Shawn Milochik  wrote:

> On Wed, Sep 21, 2011 at 5:54 PM, Marc Aymerich 
> wrote:
> > On Wed, Sep 21, 2011 at 11:46 PM, David Watson 
> wrote:
> >> Looks like they are online now http://blip.tv/djangocon
> >> regards,
> >> David
> >>
> >
> > Wow, great news!! I'm going to check it out right now :)
> >
>
>
> Awesome. They're not all there, but a bunch are.
>
> --
> 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 template IndexError

2011-09-21 Thread Martin Tiršel
It seems, that Django handles methods and variables indexes differently.  
So I solved it this way:


e = IndexError()
e.silent_variable_failure = True
raise e

Martin


On Wed, 21 Sep 2011 23:36:58 +0200, Martin Tiršel   
wrote:



Hello,

I have this situation:

class SomeClass(object):
 ...
 def __getitem__(self, key):
 ...
 raise IndexError()

and now:

context['somevar'] = {'one': 1, }
context['anothervar'] = SomeClass()


in template:

{{ somevar.one }} - prints 1
{{ somevar.two }} - prints nothing, no exception raised
{{ anothervar.notexistentindex }} - raises IndexError and page doesn't  
load (debug info printed)


Does anybody knows why? In both cases IndexError exception is raised but  
first case doesn't stop page loading, the another stops and prints debug  
info. I need silent ignore. What is the difference between "native"  
IndexError and my IndexError?



Thanks,
Martin


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



TransactionMiddleware recommendation

2011-09-21 Thread Joseph Mou
I saw that the docs recommend using TransactionMiddleware, even though it's
not the default:
https://docs.djangoproject.com/en/dev/topics/db/transactions/

Why is this preferable over the default auto-commit behavior? I wasn't able
to find much more information when searching (mostly just bug reports).

Thanks,
Joe

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



User Registration -> Password not saving

2011-09-21 Thread Kurtis
Hey,

I've created my own User Registration FormView. Everything seems to
work great except the password is always saved as "!". I can change
that with the "password changer" in the admin section of the site. I
am using an alternative authentication backend, so I'm not sure if
that was causing problems. I went ahead and included the default
authentication backend as well (at the front of the list) but that
didn't seem to change things. I've included my code at the bottom. Any
help would be greatly appreciated! Also, if there's anything wierd
about my code, let me know. I'm still learning.

class SignUpFormView(FormView):

template_name = u'base.html'
form_class = SignUpForm
success_url = '/pages/getting_started'

def form_valid(self, form):

# Gather Data
email = form.cleaned_data['email']
firstName = form.cleaned_data['firstName']
lastName = form.cleaned_data['lastName']
password = form.cleaned_data['password']

# Create a Unique UserName from a Hash
userName_hash = hashlib.md5(email).hexdigest()
userName_hash = userName_hash[:30]

# Create the User
user = User.objects.create_user(userName_hash, email,
password)
user.set_password(password) # Duplicated in hopes of it
working.
user.first_name = firstName
user.last_name = lastName
user.is_active = True

# Save the User
user.save()

return super(SignUpFormView, self).form_valid(form)

def form_invalid(self, form):
return super(SignUpFormView, self).form_invalid(form)

class SignUpForm(forms.Form):

email = forms.EmailField(required = True, label = u'Email
Address')
firstName = forms.CharField(required = True)
lastName = forms.CharField(required = True)
password = PasswordField()
password_confirm = forms.CharField(label = u'Password
Confirmation',
widget = forms.PasswordInput(render_value =
False),
required = True)

# Custom Form Validation
def clean(self):

cleaned_data = self.cleaned_data
password = cleaned_data.get('password')
password_confirm = cleaned_data.get('password_confirm')

# Check Password Matches Confirmation
if password and password_confirm:
if password is not password_confirm:
raise forms.ValidationError(u'Your passwords do not
match.')

return self.cleaned_data

-- 
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: TransactionMiddleware recommendation

2011-09-21 Thread Christophe Pettus

On Sep 21, 2011, at 2:27 PM, Joseph Mou wrote:

> Why is this preferable over the default auto-commit behavior?

If you are certain that every single time you modify the database, you want an 
immediate commit (no object graphics, no possibility of dangling objects), the 
default behavior might work for you.  However, as soon as you start having 
interdependent objects, you probably need something more sophisticated.  
Discussion here:


http://thebuild.com/blog/2009/11/07/django-postgresql-and-transaction-management/
--
-- Christophe Pettus
   x...@thebuild.com

-- 
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: User Registration -> Password not saving

2011-09-21 Thread Kurtis
I didn't realize the code would come out so unreadable. It's also
posted here: http://dpaste.com/618619/

-- 
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: TransactionMiddleware recommendation

2011-09-21 Thread Joe Mou
Thanks, really interesting read.

On Wed, Sep 21, 2011 at 3:42 PM, Christophe Pettus  wrote:

>
> On Sep 21, 2011, at 2:27 PM, Joseph Mou wrote:
>
> > Why is this preferable over the default auto-commit behavior?
>
> If you are certain that every single time you modify the database, you want
> an immediate commit (no object graphics, no possibility of dangling
> objects), the default behavior might work for you.  However, as soon as you
> start having interdependent objects, you probably need something more
> sophisticated.  Discussion here:
>
>
> http://thebuild.com/blog/2009/11/07/django-postgresql-and-transaction-management/
> --
> -- Christophe Pettus
>   x...@thebuild.com
>
> --
> 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: Customizing forms html

2011-09-21 Thread Russell Keith-Magee
On Thu, Sep 22, 2011 at 2:19 AM, Jacob G  wrote:
> I'm trying to customize Django forms html based on three requirements:
> 1) Html output to match html given to me by a web site designer.
> 2) Automatically generate forms, so I don't have to duplicate html in
> templates.
> 3) Re-use as match of Django forms code as possible.
> For my first attempt, I'm working on an authentication form. So here's what
> I did:
> 1) Derive AuthenticationForm class so that I can create use derived classes
> for the CharFields
> 2) Derive CharField to set css class in widget_attrs
> 3) Derived ErrorList to use own custom html for errors
> Another problem came up: Django assumes that field errors should be
> displayed before the field label. However, I want to display the field error
> after the field's input (after a line break). It would seem that I would
> have to override BaseForm method _html_output, which I would like to avoid.
> Summary Question: Is there a simpler way to output field error html after
> field, rather than before field, without having to override _html_output?
> Thanks.

Yes - use a template.

Django's forms library includes some rendering capability, but that's
for scaffolding purposes. The intention is not to provide a completely
customizable way to generate HTML in code.

If Django's default form output doesn't meet your needs, then the
solution isn't to try and modify the code -- it's to modify the output
at the template level.

https://docs.djangoproject.com/en/1.3/topics/forms/#customizing-the-form-template

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.



Is there any particular reason why it's assumed you won't be performing a Max on a CharField?

2011-09-21 Thread Joshua Russo
Is there any particular reason why it's assumed you won't be performing a 
Max on a CharField? 

I tried to create the following QuerySet:

Document.objects.filter(documentType=1, 
event__eventType=3).annotate(event_date=Max('event__start_date'), 
subcommittee=Max('event__subcommittee__name')).order_by('subcommittee', 
'event_date')

I enforce this particular documentType to occur only once per Event, but in 
reality the Document - Event relation is many to many. That is why I 
performed a Max on the to go from Document to a FK relation of Event.

I really only ask out of curiosity. As far as SQL goes, this is completely 
legit and I plan on modifying Django and submitting a patch. (Unless there's 
a compelling reason not to)

-- 
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/-/nQfxnZlrOskJ.
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: changes to .py file is not reflected until server is restarted.

2011-09-21 Thread kenneth gonsalves
On Wed, 2011-09-21 at 19:37 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> Oh jeez - modpython, I've nfi how to make that work with the same
> approach. Maybe check mod_python docs??

apachectl graceful - no other way.
-- 
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.