Using filter_horizontal with InlineAdmin - should work, right?

2014-04-07 Thread Victor Hooi
Hi,

I'm hacking up a system to manage attendees at a camp.

I have a Person model (which might be better as a customer UserModel, still 
not sure).

There are multiple types of people - e.g. camp attendees, staff, 
supervisors etc.

Each person that is a camp attendee will also have an "Attendance" model 
associated with it (but other types of people will not have one).

If you think I'm better off modelling it a different way (e.g. abstract 
models, or some kind of inheritance), I'm open to suggestions.

This is my models.py fragment for Attendance:

class Attendance(models.Model):
> person = models.OneToOneField(Person)
> stream = models.ForeignKey(Stream)
> subjects = models.ManyToManyField(Subject)
> camp = models.ForeignKey(Camp)


This is my admin.py for Person:

class AttendanceInline(admin.TabularInline):
> model = Attendance 

 

class PersonAdmin(admin.ModelAdmin):
> date_hierarchy = 'date_of_birth'
> fieldsets = (
> ('Personal Details', {
> 'fields': ('first_name', 'middle_name', 'last_name', 'gender', 
> 'date_of_birth', 'passport_number', 'working_with_children_check', 'photo', 
> 'school', 'home_church')
> }),
> ('Contact Details', {
> 'fields': ('email', 'phone_number', 'postal_address', 
> 'home_address')
> }),
> ('Other - think of a better name', {
> 'fields': ('serving_church', 'supervisor', 'year_12')
> })
> )
> inlines = [
> AttendanceInline,
> ] 

 

admin.site.register(Person, PersonAdmin)


and my admin.py for Attendance:

class AttendanceAdmin(admin.ModelAdmin):
> filter_horizontal = ['subjects']



When I edit a Person model, I want to have an inline for Attendance, and in 
that, use a filter_horizontal widget for "subjects".

However, currently, AttendanceAdmin on it's own has the filter_horizontal, 
but the inline does not.

This ticket seems to imply it should work:

https://code.djangoproject.com/ticket/8292

hence I'm assuming I've wired up something wrong in the above - any 
thoughts?

Cheers,
Victor

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b11ccc5a-d021-46c0-9ca5-6f8b40154467%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Saving forms with ManyToMany relationships

2014-04-07 Thread Camilo Torres
Hello,

This works for me, saving the related objects in the many to many 
relationship. You can start from there to build yours:

models.py:

class Student(models.Model):
name = models.TextField()


class Course(models.Model):
name = models.TextField()
students = models.ManyToManyField(Student, related_name='courses')

forms.py.

class NewItemForm(ModelForm):

class Meta:
model = Course
fields = ('name', 'students')

view.py:

def create_item(request):
if request.method == 'POST':
form = NewItemForm(request.POST)
if form.is_valid():
form.save()
return HttpResponse('saved')
return HttpResponse('Form not valid')
else:
form = NewItemForm()
return render_to_response('testapp/create_item.html', {'form': 
form}, context_instance=RequestContext(request))


create_item.html:

{% csrf_token %}
{{ form.as_p }}





Regards,
Camilo

On Monday, April 7, 2014 7:51:30 PM UTC-4:30, Jason S wrote:
>
> Hi Camilo,
> I really appreciate your response.
> I had another go at this last night, particularly trying to use the 
> add(component()) snippet.
>
> To respond to your notes:
> 1. I simplified and used a find-replace to replace the model names which 
> is likely why it dosn't compile, sorry about that. Mine compiles and i'm 
> happy to PM you the code if you'd like.
> 2. I have very limited programming experience at this point and my project 
> is the cumulation of experimentation, examples and documentation i've 
> read... I believe your saying I don't need to use the "instance"s?
> 3. Good point, thank you.
> 4. I've added the lines which try to ensure the m2m relationships are 
> added, such as  
> new_item.category.add(new_item)
> new_item.components.add(new_item)
> during my attempts to get the form to save the many to many data.
>
> What i'm trying to do is create a basic form which allows a user to fill 
> in the name, desc, img, category and component fields
> When they save this form, i'd like the "item" to be saved (which is 
> happening) as well as the user, category and component data to be 
> associated to the item.
> Currently only the user is being associated to the item when I complete 
> the form and save it.
>
> Once I can do that, i'll move on to using widgets to make the category 
> field a drop down and the component field/s tick boxes and continue adding 
> form validation etc but i've been stuck on this saving issue for some time.
>
> Thanks again for your time and help. 
>
>
>
> On Monday, 7 April 2014 10:58:21 UTC+12, Camilo Torres wrote:
>>
>> On Saturday, April 5, 2014 10:12:36 PM UTC-4:30, Jason S wrote:
>>>
>>> I've seen quite a few examples showing various ways to create a form 
>>> using manytomany relationships and save the data, but i'm still missing a 
>>> key piece of the puzzle.
>>> I've created a form and it "works", meaning the form creates a new Item 
>>> object and associates the user.
>>> However i'm not sure how to go about saving the item category and item 
>>> components selected in the form.
>>>
>>> I've tried quite a few things over the last week and i know its quite 
>>> easy, but just haven't quite gotten there yet and would appreciate some 
>>> guidance.
>>>
>>> FORM:
>>> class NewItemForm(ModelForm):
>>>
>>> class Meta:
>>> model = Item
>>> fields = ('name', 'desc', 'img','category','components')
>>>
>>> def save(self, user, component commit = True):
>>> """Append the component list to the item"""
>>> new_item = super(NewItemForm, self).save(commit = Fals
>>>
>>> if commit:
>>> new_item.save()
>>> #new_item.save_m2m()
>>> new_item.user.add(user)
>>> if component != "none":
>>> new_item.category.add(new_item)
>>> new_item.components.add(new_item)
>>>
>>> return new_item
>>>
>>> VIEW:
>>> def create_item(request):
>>>
>>> if request.method == "POST":
>>> form = NewItemForm(request.POST, instance=item())
>>> if form.is_valid():
>>> form.save(request.user, "none")
>>> return HttpResponseRedirect(reverse('nav.views.dashboard'))
>>> else:
>>> form = CategoryForm(instance=item())
>>> return render_to_response('objects/create_item.html', 
>>> {'item_Form': form}, context_instance=RequestContext(request))
>>>
>>> MODEL:
>>> class Item(models.Model):
>>> # 
>>> def __unicode__(self):  # Python 3: def __str__(self):
>>> return self.name
>>>
>>> name  = models.CharField(max_length=32)
>>> desc  = models.CharField(max_length=254)
>>> img   = models.CharField(max_length=32)
>>> user  = models.ManyToManyField(User) 
>>> components = models.ManyToManyField(component)
>>> category  = models.ManyToManyField(Category)
>>>
>> Hello,
>>
>> 1. This code does not compiles, only to note in case you already didn't 
>> tested
>>
>> 2

Re: Django Dynamic Formsets

2014-04-07 Thread Venkatraman S
Have you tried the jquery formset - works like a breeze for me.


On Mon, Apr 7, 2014 at 10:43 PM, Leandro Alves  wrote:

> Hi,
>
> I wonder if anyone knows of any example of django-dynamic-formsets [1]
> that works with Django 1.6?
>
> So far all I found on the internet are over 3 years old and they don't
> work with Django version 1.6.
>
> I am willing to pay for any example that works if necessary. :)
>
> Thanks in advance,
>
> Leandro
>
>
> [1] - https://code.google.com/p/django-dynamic-formset/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7tdFRV9FkLVKSa%2Bbac84OxkEQD0eBF4_fR-98A1vC66%3DXiAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Saving forms with ManyToMany relationships

2014-04-07 Thread Jason S
Hi Camilo,
I really appreciate your response.
I had another go at this last night, particularly trying to use the 
add(component()) snippet.

To respond to your notes:
1. I simplified and used a find-replace to replace the model names which is 
likely why it dosn't compile, sorry about that. Mine compiles and i'm happy 
to PM you the code if you'd like.
2. I have very limited programming experience at this point and my project 
is the cumulation of experimentation, examples and documentation i've 
read... I believe your saying I don't need to use the "instance"s?
3. Good point, thank you.
4. I've added the lines which try to ensure the m2m relationships are 
added, such as  
new_item.category.add(new_item)
new_item.components.add(new_item)
during my attempts to get the form to save the many to many data.

What i'm trying to do is create a basic form which allows a user to fill in 
the name, desc, img, category and component fields
When they save this form, i'd like the "item" to be saved (which is 
happening) as well as the user, category and component data to be 
associated to the item.
Currently only the user is being associated to the item when I complete the 
form and save it.

Once I can do that, i'll move on to using widgets to make the category 
field a drop down and the component field/s tick boxes and continue adding 
form validation etc but i've been stuck on this saving issue for some time.

Thanks again for your time and help. 



On Monday, 7 April 2014 10:58:21 UTC+12, Camilo Torres wrote:
>
> On Saturday, April 5, 2014 10:12:36 PM UTC-4:30, Jason S wrote:
>>
>> I've seen quite a few examples showing various ways to create a form 
>> using manytomany relationships and save the data, but i'm still missing a 
>> key piece of the puzzle.
>> I've created a form and it "works", meaning the form creates a new Item 
>> object and associates the user.
>> However i'm not sure how to go about saving the item category and item 
>> components selected in the form.
>>
>> I've tried quite a few things over the last week and i know its quite 
>> easy, but just haven't quite gotten there yet and would appreciate some 
>> guidance.
>>
>> FORM:
>> class NewItemForm(ModelForm):
>>
>> class Meta:
>> model = Item
>> fields = ('name', 'desc', 'img','category','components')
>>
>> def save(self, user, component commit = True):
>> """Append the component list to the item"""
>> new_item = super(NewItemForm, self).save(commit = Fals
>>
>> if commit:
>> new_item.save()
>> #new_item.save_m2m()
>> new_item.user.add(user)
>> if component != "none":
>> new_item.category.add(new_item)
>> new_item.components.add(new_item)
>>
>> return new_item
>>
>> VIEW:
>> def create_item(request):
>>
>> if request.method == "POST":
>> form = NewItemForm(request.POST, instance=item())
>> if form.is_valid():
>> form.save(request.user, "none")
>> return HttpResponseRedirect(reverse('nav.views.dashboard'))
>> else:
>> form = CategoryForm(instance=item())
>> return render_to_response('objects/create_item.html', 
>> {'item_Form': form}, context_instance=RequestContext(request))
>>
>> MODEL:
>> class Item(models.Model):
>> # 
>> def __unicode__(self):  # Python 3: def __str__(self):
>> return self.name
>>
>> name  = models.CharField(max_length=32)
>> desc  = models.CharField(max_length=254)
>> img   = models.CharField(max_length=32)
>> user  = models.ManyToManyField(User) 
>> components = models.ManyToManyField(component)
>> category  = models.ManyToManyField(Category)
>>
> Hello,
>
> 1. This code does not compiles, only to note in case you already didn't 
> tested
>
> 2. In your view: why do you instantiate a different form for POST request 
> and any other kind of requests: NewItemForm in one case, CategoryForm in 
> the rest.
>
> 3. In your view: You are using the string "none" instead the built-in 
> None. I recommend you to use Python built-in None.
>
> 4. ModelForm's save method actually saves the related many to many data. 
> Why are you doing these?
> new_item.category.add(new_item)
> new_item.components.add(new_item)
>
> You are adding a Item where a component and a Category is expected. This 
> does not make sense. You add(new_item) where you should be add(component()) 
> or something.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/33f75be6-615b-4556-a470-3be430074c85%40googlegro

Re: Inlines in admin

2014-04-07 Thread Marc Aymerich
On Mon, Apr 7, 2014 at 3:04 PM, Emanuel  wrote:
> Hi all!
>
> I'm have the following models:
>
> Class A(models.Model):
>  pass
>
>
> Class Z(models.Model):
> pass
>
>
> Class B(models.Model):
>   a = models.ForeignKey(a)
>   z = models.ForeignKey(Z)
>
>def __unicode__(self):
>   return self.z
>
>
> Class C(models.Model):
>  b = models.ForeignKey(B)
>
>
> I Want in the admin add A,B and C objects.
>
> I know how to put inline objects of B in A. Everything works as expected.
> But I want to create new C's in the same page. Something like having C as an
> Inline of B, beeing B an Inline of A. It could appear all in popups...

nested inlines are not currently supported. A work around can be using
a readonly field on B inline that points to a B change view with C
inlines


class BInline(admin.TabularInline):
model = B
readonly_fields = ('c_link',)

def c_link(self, instance):
  if not instance.pk:
return ''
  url = reverse('admin:app_c_change', args=(instance.pk,))
  popup = 'onclick="return showAddAnotherPopup(this);"'
  return '%s' % (url, popup, instance)
 c_link.allow_tags=True


class CInline(admin.TabularInline):
 model = C


class AModelAdmin(admin.ModelAdmin):
 inlines = [BInline]


class BModelAdmin(admin.ModelAdmin):
inlines = [Cinline]

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BDCN_srZGQGGt827YMJkj2YeNAau37idZ5_Se-Ts7E5vDo3pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I register to get access to the IRC Channel?

2014-04-07 Thread Nathan McCorkle
or just use freenode webchat

On Wed, Apr 2, 2014 at 1:59 PM, Aaron C. de Bruyn  wrote:
> Take a look at this:
>
> http://www.wikihow.com/Register-a-User-Name-on-Freenode
>
> If you still get stuck, let us know.
>
> -A
>
>
> On Wed, Apr 2, 2014 at 1:43 PM, John Draper  wrote:
>>
>> I go to Adium --> File --> irc.freenode.net
>> see screenshot
>>
>> I put in my nickname, hostname, and password.
>>
>> I get this   See 2nd screenshot...
>>
>> So what do I do next?I tried double clicking the item, and it just
>> goes back to the
>> first screenshot you see.   I tried Option-click,  Control-click, Command
>> click.
>>
>> But there is nothing I can do,  to bring up the channel?
>> I tried file --> new chat - that didnt work
>> I tried Status --> irc.freenode.net --> Available - that didnt work.
>>
>> And I don't see anything else,  that could give me any clue on how to join
>> the #django channel.
>>
>> HELP
>>
>> is there anyone out there who can "lead me by the hand" and help a fellow
>> Django beginner ask for help
>> over IRC?I'm on Fuze...   get the app...   http://fuze.com.   Send me
>> your Email, I invite you to the Conference
>> and we can screen share.   Skype used to be able to do that,  but not
>> since M$ bastardized it.
>>
>> John
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/b03812e1-6e34-4c1a-87c3-a0a0fd722eba%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEE%2BrGrJpdXA07UB-cJr%2B0eNMCQ-yk_egHQRSoWLtp%3D0xDJsJg%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
-Nathan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B82U9JCRTS0%3D8GxoLMVT8i8BG2JMsbV6ZnYB_efQ2Z3aPCY-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Done. :)

Thanks!!!


On Monday, April 7, 2014 9:42:53 PM UTC+2, Gladson Simplício Brito wrote:
>
> Okay, send email here:
>
> gla...@immensa.com.br 
>
>
> 2014-04-07 15:24 GMT-04:00 Leandro Alves >:
>
>> Brother, I think I have tried all of those already and some other around 
>> the internet... 
>> I couldn't find anyone that works with Django 1.6. 
>>
>> I will send you an email with what I need, ok? :)
>>
>> Thanks again!
>>
>> Leandro
>>
>>
>>
>> On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito wrote:
>>
>>> Try these:
>>> https://pypi.python.org/pypi?%3Aaction=search&term=formset&submit=search
>>>
>>> If not, tell your need.
>>> :D
>>>
>>>
>>> 2014-04-07 14:16 GMT-04:00 Leandro Alves :
>>>
 Yes.. I have tried that one as well.. but the example still doesn't 
 work... =/

 Any freelance available for this? 

 Thanks for the feedback!

 Leandro


 On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
 gladso...@gmail.com> wrote:

> The project was migrated to another repository:
>
> https://github.com/elo80ka/django-dynamic-formset
>  
>
> 2014-04-07 13:13 GMT-04:00 Leandro Alves :
>
>>  Hi, 
>>
>> I wonder if anyone knows of any example of django-dynamic-formsets 
>> [1] that works with Django 1.6?
>>
>> So far all I found on the internet are over 3 years old and they 
>> don't work with Django version 1.6. 
>>
>> I am willing to pay for any example that works if necessary. :)
>>
>> Thanks in advance, 
>>
>> Leandro
>>
>>
>> [1] - https://code.google.com/p/django-dynamic-formset/
>>  
>> -- 
>> You received this message because you are subscribed to the Google 
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to django-users...@googlegroups.com.
>>
>> To post to this group, send email to django...@googlegroups.com.
>>
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%
>> 40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/_sfhHrcDJBs/unsubscribe.
>  To unsubscribe from this group and all its topics, send an email to 
> django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
>
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_
> rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

  -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django-users...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.

 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%
 3DuQKiXTxafvkw%40mail.gmail.com
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/02005c60-1be6-427d-9d12-6c8b83811b39%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You receiv

Re: Django Dynamic Formsets

2014-04-07 Thread Gladson Simplício Brito
Okay, send email here:

glad...@immensa.com.br


2014-04-07 15:24 GMT-04:00 Leandro Alves :

> Brother, I think I have tried all of those already and some other around
> the internet...
> I couldn't find anyone that works with Django 1.6.
>
> I will send you an email with what I need, ok? :)
>
> Thanks again!
>
> Leandro
>
>
>
> On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito wrote:
>
>> Try these:
>> https://pypi.python.org/pypi?%3Aaction=search&term=formset&submit=search
>>
>> If not, tell your need.
>> :D
>>
>>
>> 2014-04-07 14:16 GMT-04:00 Leandro Alves :
>>
>>> Yes.. I have tried that one as well.. but the example still doesn't
>>> work... =/
>>>
>>> Any freelance available for this?
>>>
>>> Thanks for the feedback!
>>>
>>> Leandro
>>>
>>>
>>> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
>>> gladso...@gmail.com> wrote:
>>>
 The project was migrated to another repository:

 https://github.com/elo80ka/django-dynamic-formset


 2014-04-07 13:13 GMT-04:00 Leandro Alves :

>  Hi,
>
> I wonder if anyone knows of any example of django-dynamic-formsets [1]
> that works with Django 1.6?
>
> So far all I found on the internet are over 3 years old and they don't
> work with Django version 1.6.
>
> I am willing to pay for any example that works if necessary. :)
>
> Thanks in advance,
>
> Leandro
>
>
> [1] - https://code.google.com/p/django-dynamic-formset/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
>
> To post to this group, send email to django...@googlegroups.com.
>
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%
> 40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

  --
 You received this message because you are subscribed to a topic in the
 Google Groups "Django users" group.
 To unsubscribe from this topic, visit https://groups.google.com/d/
 topic/django-users/_sfhHrcDJBs/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 django-users...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.

 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_
 rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com
 .

 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%
>>> 3DuQKiXTxafvkw%40mail.gmail.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/02005c60-1be6-427d-9d12-6c8b83811b39%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to djang

Odd error using Formwizard

2014-04-07 Thread Griffin Caprio
Hi,

I have a form wizard view with 2 required forms & 1 optional form in it. 
I'm seeing an occasional error during submission. Here's my named forms:

DONATE_FORMS = [("donate", DonateFormItemInformation), ("delivery", 
DonateFormDeliveryMethod), ("about", DonateFormAbout)]

My URL entry:

login_required(DonateWizard.as_view(DONATE_FORMS, 
condition_dict=DONATE_CONDITION_DICT)),

My condition dictionary:

DONATE_CONDITION_DICT = {'about': show_donor_about_form}

Finally the condition itself:

def show_donor_about_form(wizard):
return wizard.request.user.is_authenticated() and not 
wizard.request.user.has_donor_profile()

The error I'm getting is:

ValueError: u'about' is not in list 

The odd part is that the in the logs for this error, I'm seeing the form 
data for 'about'. So the user is getting to the form, entering data, & 
submitting it, then the error occurs. I can't reproduce this reliably. 
After digging into the django source, looks like the get_form_list method 
regenerates the form_list every step. So could the condition return true 
before the form is display, then suddenly return false after the form 
submission?

Any help is appreciated.

Thanks,
Griffin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c69da2ed-8d22-47a2-b5de-d5e021dd6069%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Brother, I think I have tried all of those already and some other around 
the internet... 
I couldn't find anyone that works with Django 1.6. 

I will send you an email with what I need, ok? :)

Thanks again!

Leandro



On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito wrote:
>
> Try these:
> https://pypi.python.org/pypi?%3Aaction=search&term=formset&submit=search
>
> If not, tell your need.
> :D
>
>
> 2014-04-07 14:16 GMT-04:00 Leandro Alves >:
>
>> Yes.. I have tried that one as well.. but the example still doesn't 
>> work... =/
>>
>> Any freelance available for this? 
>>
>> Thanks for the feedback!
>>
>> Leandro
>>
>>
>> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
>> gladso...@gmail.com > wrote:
>>
>>> The project was migrated to another repository:
>>>
>>> https://github.com/elo80ka/django-dynamic-formset
>>>  
>>>
>>> 2014-04-07 13:13 GMT-04:00 Leandro Alves 
>>> >:
>>>
  Hi, 

 I wonder if anyone knows of any example of django-dynamic-formsets [1] 
 that works with Django 1.6?

 So far all I found on the internet are over 3 years old and they don't 
 work with Django version 1.6. 

 I am willing to pay for any example that works if necessary. :)

 Thanks in advance, 

 Leandro


 [1] - https://code.google.com/p/django-dynamic-formset/
  
 -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django-users...@googlegroups.com .

 To post to this group, send email to 
 django...@googlegroups.com
 .
 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/django-users/_sfhHrcDJBs/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/02005c60-1be6-427d-9d12-6c8b83811b39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Gladson Simplício Brito
Try these:
https://pypi.python.org/pypi?%3Aaction=search&term=formset&submit=search

If not, tell your need.
:D


2014-04-07 14:16 GMT-04:00 Leandro Alves :

> Yes.. I have tried that one as well.. but the example still doesn't
> work... =/
>
> Any freelance available for this?
>
> Thanks for the feedback!
>
> Leandro
>
>
> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
> gladsonbr...@gmail.com> wrote:
>
>> The project was migrated to another repository:
>>
>> https://github.com/elo80ka/django-dynamic-formset
>>
>>
>> 2014-04-07 13:13 GMT-04:00 Leandro Alves :
>>
>>>  Hi,
>>>
>>> I wonder if anyone knows of any example of django-dynamic-formsets [1]
>>> that works with Django 1.6?
>>>
>>> So far all I found on the internet are over 3 years old and they don't
>>> work with Django version 1.6.
>>>
>>> I am willing to pay for any example that works if necessary. :)
>>>
>>> Thanks in advance,
>>>
>>> Leandro
>>>
>>>
>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>>
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/_sfhHrcDJBs/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKN-GttOeoeS30xggcY6MnkUAXRTpPJvpuixAfqJ3oyAoL5DRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Yes.. I have tried that one as well.. but the example still doesn't work...
=/

Any freelance available for this?

Thanks for the feedback!

Leandro


On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
gladsonbr...@gmail.com> wrote:

> The project was migrated to another repository:
>
> https://github.com/elo80ka/django-dynamic-formset
>
>
> 2014-04-07 13:13 GMT-04:00 Leandro Alves :
>
>> Hi,
>>
>> I wonder if anyone knows of any example of django-dynamic-formsets [1]
>> that works with Django 1.6?
>>
>> So far all I found on the internet are over 3 years old and they don't
>> work with Django version 1.6.
>>
>> I am willing to pay for any example that works if necessary. :)
>>
>> Thanks in advance,
>>
>> Leandro
>>
>>
>> [1] - https://code.google.com/p/django-dynamic-formset/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/_sfhHrcDJBs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: very light weight django task queues

2014-04-07 Thread VidJa Hunter
thanks guys,

i'm going to try a few, but django-pq looks very promising.

cheers,

Vid





On Mon, Apr 7, 2014 at 1:53 AM, Russell Keith-Magee  wrote:

> Hi,
>
> Another option to throw onto the pile:
>
> https://github.com/bretth/django-pq
>
> This was recommended to me by Jannis Leidel (jezdez), who used it on
> caniusepython3.com.
>
> Yours,
> Russ Magee %-)
>
>
>
> On Sun, Apr 6, 2014 at 6:33 PM, TinyJaguar  wrote:
>
>> I've been using both django-huey and celery as task queues with varying
>> success in other projects.
>> see (https://www.djangopackages.com/grids/g/workers-queues-tasks/)
>>
>> Most of the task queues are redis based. They seem to be overkill for our
>> current situation and add another layer of system maintenance (i.e a redis
>> instance) and we want/need to have a minimum of packages on our micro
>> instances (currently just django, postgres, nginx and a few tiny packages)
>>
>> Our typical background tasks occur once or twice a week! and may take
>> about 30 minutes to a few hours to process.
>> What I'm looking for is a very very simple task queue that does not use
>> redis or any other 'external' database. Just a bunch of tables in the
>> current app's database would be fine.
>>
>> what would you suggest?
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/22067995-cdb5-42ed-bb9e-4d8a80b2fc4d%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/TZw6meNxujc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJxq84_QqCSgyFShDec2%3Dx_NE1YXAPaz0Dx36RTkzx7QCzaM%2Bw%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO9%3DStKZnLxV%2BPZSyoBmw-XMqdzg9QZMf49AzQvbCp5959Pohw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Gladson Simplício Brito
The project was migrated to another repository:

https://github.com/elo80ka/django-dynamic-formset


2014-04-07 13:13 GMT-04:00 Leandro Alves :

> Hi,
>
> I wonder if anyone knows of any example of django-dynamic-formsets [1]
> that works with Django 1.6?
>
> So far all I found on the internet are over 3 years old and they don't
> work with Django version 1.6.
>
> I am willing to pay for any example that works if necessary. :)
>
> Thanks in advance,
>
> Leandro
>
>
> [1] - https://code.google.com/p/django-dynamic-formset/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Hi, 

I wonder if anyone knows of any example of django-dynamic-formsets [1] that 
works with Django 1.6?

So far all I found on the internet are over 3 years old and they don't work 
with Django version 1.6. 

I am willing to pay for any example that works if necessary. :)

Thanks in advance, 

Leandro


[1] - https://code.google.com/p/django-dynamic-formset/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: User constantly being logged out when using a site with 2 tabs open

2014-04-07 Thread Venkatraman S
Have you set any middleware that allows only one session at a time?


On Mon, Apr 7, 2014 at 6:48 PM, Mark Steadman  wrote:

> Hi. Don't know if this is specific to Django, but my site is the only one
> I've experienced this with, and I don't think I'm doing anything special
> with session data (just using the old-school database backend).
>
> When a user logs in (in tab A) and opens a new tab (tab B) on the same
> domain, the cookie carries over to the second tab. However, if the user
> clicks a link in tab B, then either refreshes tab A or clicks a link in
> that tab, he's instantly logged out.
>
> I've been Googling around the issue for ages but have had no luck, so
> would really appreciate anyone's help. Apologies if this is a really
> fundamental thing.
>
> Many thanks,
> -Mark
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d2c5985b-83f8-4e24-b5c9-844fb9a24813%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7tdFR0_zhhbn%3Ddb9WMbAsXwePashBwUD436d5AM9%3DcZ4E0dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


User constantly being logged out when using a site with 2 tabs open

2014-04-07 Thread Mark Steadman
Hi. Don't know if this is specific to Django, but my site is the only one 
I've experienced this with, and I don't think I'm doing anything special 
with session data (just using the old-school database backend).

When a user logs in (in tab A) and opens a new tab (tab B) on the same 
domain, the cookie carries over to the second tab. However, if the user 
clicks a link in tab B, then either refreshes tab A or clicks a link in 
that tab, he's instantly logged out.

I've been Googling around the issue for ages but have had no luck, so would 
really appreciate anyone's help. Apologies if this is a really fundamental 
thing.

Many thanks,
-Mark

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d2c5985b-83f8-4e24-b5c9-844fb9a24813%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inlines in admin

2014-04-07 Thread Emanuel
Hi all!

I'm have the following models:

Class A(models.Model):
 pass


Class Z(models.Model):
pass


Class B(models.Model):
  a = models.ForeignKey(a)
  z = models.ForeignKey(Z)

   def __unicode__(self):
  return self.z


Class C(models.Model):
 b = models.ForeignKey(B)


I Want in the admin add A,B and C objects.

I know how to put inline objects of B in A. Everything works as expected. 
But I want to create new C's in the same page. Something like having C as 
an Inline of B, beeing B an Inline of A. It could appear all in popups...

I dont want the user have to select B when adding C. If it was all in the 
same page I always have object A present and user just have to add C, 
without having trouble in knowing what it was B in the first place

Thanks


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f5febfe3-5940-44d0-a2e8-049a2c833376%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to create complex Left JOIN in Django

2014-04-07 Thread Shoaib Ijaz


I am trying to create multi Model Left join using django

Here is my model

class LookupTiming(models.Model):
day = models.CharField(max_length=7)
time_1 = models.TimeField()
time_2 = models.TimeField()

class Meta:
db_table = u'lookup_timing'
class Streets(models.Model):
name = models.CharField(max_length=50)
point = models.GeometryField(null=True, blank=True)
objects = models.GeoManager()

class Meta:
db_table = u'streets'

def __unicode__(self):
return '%s' % self.name

class StreetTimings(models.Model):
street= models.ForeignKey(Streets)
lookuptiming = models.ForeignKey(LookupTiming)
class Meta:
db_table = u'street_timings'

This is query that i have created

Streets.objects.filter(streettimings_*isnull=True).filter(streettimings*
_lookuptiming__isnull=True).values('id')

This is sql output of above query

SELECT "streets"."id" FROM "streets"
LEFT OUTER JOIN "street_timings" ON ( "streets"."id" = 
"street_timings"."street_id" ) 
LEFT OUTER JOIN "street_timings" T3 ON ( "streets"."id" = T3."street_id" )
WHERE ("street_timings"."id" IS NULL AND T3."lookuptiming" IS NULL)

But i want following query

select st.id from streets st
LEFT JOIN street_timings timing on timing.street_id = st.id 
LEFT JOIN lookup_timing lt on lt.id = timing.lookuptiming_id 

So problem is that, the django query total ignore *lookuptiming* Model. I 
want to create following joins

Streets(id) = StreetTimings (street_id)

LookupTiming (id) = StreetTimings (lookuptiming_id)

How can i create left join for multiple models?

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/50df8abf-f539-4c08-8211-d40a35e43cc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.