Re: How to handle invalid deleted forms in formsets

2010-08-10 Thread Tomi Pieviläinen

> What version of Django? This sounds a lot like:

Latest (installed by making pip require django>=1.2).

> http://code.djangoproject.com/ticket/11801

It isn't. The problem is not that I'm not getting
formset.deleted_forms, I am. The problem is that these deleted forms
also go to the cleaned_data, which breaks down because the deleted
forms do not validate, thus they don't have form.cleaned_data that the
formset tries to access.

But what can I do with the fs.deleted_forms? If I try to remove them
from the fs.forms before accessing fs.cleaned_data, the access will
break with array out of bounds, as mentioned.

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



Re: Django 1.1.1's Feed only display the latest item

2010-08-10 Thread Tomi Pieviläinen
As mentioned in the IRC channel, the feed did indeed display two
items, but because it was invalid markup (based on W3) Safari didn't
show them properly.

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



How to handle invalid deleted forms in formsets

2010-08-09 Thread Tomi Pieviläinen
(Using formset_factory, if that makes a difference)

If the user fills a form in formset incompletely and then marks it for
deletion, my form handling dies horribly. The deleted forms prevent
formset.cleaned_data from working as they don't validate and thus the
form doesn't have a cleaned_data attribute. If I try to iterate over
formset.deleted_forms and delete the forms from formset.forms, then
formset.cleaned_data crashes due to index out of range.

How should I be handling these invalid forms the user didn't want
anyway?

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



Re: Calculate distance between 2 latitude/longitude Point

2010-07-29 Thread Tomi Pieviläinen
> *
> In [45]: Point(40.96312364002175,
> -5.661885738372803).distance(Point(40.96116097790996, -5.66283792257309))
> Out[45]: 0.0021814438604553388

The results are what you get from the db. The thing is, you can't
assume that the distance in degrees is the same everywhere, so you
can't use a simple formula like multiplying by the circumference at
equator. Instead let the db do the work for you by telling what
coordinate system your input is and what do you want as output. Good
examples can be found in PostGIS (Postgresql with GIS) documentation:

http://postgis.refractions.net/documentation/manual-1.5/ST_Distance.html

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



Re: sqlite3 backend error

2010-05-17 Thread Tomi Pieviläinen
This is due to having a virtualenv created in a previous version of
Ubuntu. Recreate the virtualenv under Lucid, and you should be fine.

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



Re: Custom methods for ManyToManyManager

2007-11-20 Thread Tomi Pieviläinen

> I've been hacking some filtering for related managers, have a look at
> the BoxManager 
> here:http://django-pm.googlecode.com/svn/trunk/myproject/pm/models.py

Thanks for food for thoughts. Looking at your code got me thinking and
in the end my problem was really simple. I was using the examples in
the documentation a bit too literarily and tried:

def get_query_set(self):
return super(MaleManager,
self).get_query_set().filter(sex='M')

while I shouldn't use super but just self.get_query_set() which
returns the filtered set.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom methods for ManyToManyManager

2007-11-16 Thread Tomi Pieviläinen

Hi group,

Is it possible to have custom filtering methods for MTMManagers? More
precisely I'd like to be able to use user.received_messages.new in my
templates. I can define a custom manager for my Message model with a
custom new method, but unfortunately this returns all new messages in
the system, not just the ones that belong to current user even if I
use it through the MTMManager.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to get normal iteritems from a MultiValueDict?

2007-02-24 Thread Tomi Pieviläinen

While the __get__ function gives same results as a dict would,
iteritems() doesn't. I'd like to use my GET/POST values in a function
that uses iteritems, but it outputs even single values as lists.

Is there a nice way to transform MultiValueDict into a normal dict, or
the iteritems?


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