Is anything being done to fix get_nodes_by_type for IfEqualNode and IfChangedNode?

2009-10-26 Thread Stephen Sundell

I see this ticket: Ticket #6510.  What if they just used the function
from IfNode?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



ManyRelatedManager signals

2009-09-22 Thread Stephen Sundell

Is there a reason not to have a signal before and after creating an
entry into a ManyToMany table.  I have a piece of code i need to call
when this relationship is created.  I don't know of any signal that
exists already, so I created my own.  Thought it might be an
interesting feature to add, unless theres a reason its not there.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Deleting an object deletes objects with nullable foreignkeys pointing at it

2009-07-27 Thread Stephen Sundell

I have revision 10865, and use postgresql.  I've noticed that with
models like this:

class Edition(models.Model):
  name = models.CharField(max_length=25)

class Email(models.Model)
  edition = models.ForeignKey(Edition,null=True,blank=True)

If I delete an edition (edition.delete()), it deletes all the emails
associated with it.  I thought it was just supposed to set the foreign
key to null.  Am I wrong in my thinking or doing something incorrect?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Filtering with respect to a related objects field

2009-02-05 Thread Stephen Sundell

Say I have a model like this:

class Photo(models.Model):
name = models.CharField(max_length=25)
user = models.ForeignKey(User,related_name='photos')
image = models.ImageField()
site = models.ForeignKey(Site,related_name='site_photos')
objects = CurrentSiteManager()

I've noticed that if I try to filter users on whether or not they have
a photo with a certain name it doesn't restrict photos to those on the
current site.  The query 'User.objects.filter
(photos__name="photo_name")' looks like this:

('SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name",
"auth_user"."email", "auth_user"."password",
"auth_user"."is_staff", "auth_user"."is_active",
"auth_user"."is_superuser", "auth_user"."last_login",
"auth_user"."date_joined"
FROM "auth_user"
INNER JOIN "photos_photo" ON ("auth_user"."id" =
"photos_photo"."user_id")
WHERE "photos_photo"."name" = %s ', ('photo_name',))

I think it should look like this:

'SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name",
"auth_user"."email", "auth_user"."password",
"auth_user"."is_staff", "auth_user"."is_active",
"auth_user"."is_superuser", "auth_user"."last_login",
"auth_user"."date_joined"
FROM "auth_user"
INNER JOIN "photos_photo" ON ("auth_user"."id" =
"photos_photo"."user_id")
WHERE ("photos_photo"."name" = %s
AND "photos_photo"."site_id" = %s )', ('photo_name',1))

Is this done on purpose?  There may be a reason for it that I don't
understand.  Is there a way that default managers can be taken into
consideration when filtering through related fields?  I don't know
exactly how this is supposed to work, is this the desired behavior?

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



Re: Related Manager created using SiteManager with the site field not named 'site' causes error

2009-01-30 Thread Stephen Sundell

I was looking though some examples of code others have done to get
around this.  What if the SiteManager looked like this:

class CurrentSiteManager(models.Manager):
def __init__(self, field_name='site'):
super(CurrentSiteManager, self).__init__()
if self.__class__.__name__ == 'RelatedManger':
self.__filed_name =
self.model._default_manager.__field_name
else:
self.__field_name = field_name
self.__is_validated = False



On Jan 27, 5:09 pm, Stephen Sundell <stephen.sund...@gmail.com> wrote:
> If I create a model such as this:
>
> class Profile(models.Model):
>     user = models.ForeignKey('django.contrib.auth.User')
>     my_site = models.ForeignKey('django.contrib.sites.Site')
>     objects = CurrentSiteManager('my_site')
>
> when I try to do the query:
>
>     user.profile_set.all()
>
> where user is an instance of the User model, I get an error like this:
>
>    RelatedManager couldn't find a field named site in Profile
>
> It seems that when a foreignkey creates the reverse related manager it
> doesn't grab the arguments passed to the default manager for that
> object.  Does anyone know a way to get around this or if there is a
> fix in django1.1?
>
> Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Related Manager created using SiteManager with the site field not named 'site' causes error

2009-01-27 Thread Stephen Sundell

If I create a model such as this:

class Profile(models.Model):
user = models.ForeignKey('django.contrib.auth.User')
my_site = models.ForeignKey('django.contrib.sites.Site')
objects = CurrentSiteManager('my_site')

when I try to do the query:

user.profile_set.all()

where user is an instance of the User model, I get an error like this:

   RelatedManager couldn't find a field named site in Profile

It seems that when a foreignkey creates the reverse related manager it
doesn't grab the arguments passed to the default manager for that
object.  Does anyone know a way to get around this or if there is a
fix in django1.1?

Thanks in advance

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