Re: ManyToMany quick question

2014-04-01 Thread antialiasis
I don't know why you're calling a ManyToManyField to Products a country name, but you shouldn't get a country_name field - the Imports table will contain all the data needed to associate countries with products. What exactly do you want to be stored in the country_name field on the Countries

Re: Saving models with NOT NULL ForeignKeys referencing each other

2014-01-22 Thread antialiasis
It didn't occur to me that this could be done with transactions, but in retrospect it seems obvious. Thanks for the quick response. On Tuesday, January 21, 2014 12:43:28 PM UTC, Russell Keith-Magee wrote: > > > On Tue, Jan 21, 2014 at 6:54 PM, antialiasis <antia...@gmail.com > &

Saving models with NOT NULL ForeignKeys referencing each other

2014-01-21 Thread antialiasis
Hi, I just bumped into this issue. Say I have the following models: class Foo(models.Model): bar = models.ForeignKey('Bar', related_name='foos') class Bar(models.Model): default_foo = models.ForeignKey(Foo, related_name='+') Basically, the idea is that each bar has many foos, but one

Re: Adding Objects to Query Set

2013-12-16 Thread antialiasis
Rather than fetching ProjectMember.objects.filter(member=request.user), you want to fetch Project.objects.filter(projectmember_set__member=request.user). That will get you Project objects rather than ProjectMember objects. On Monday, December 16, 2013 1:47:13 PM UTC, Vibhu Rishi wrote: > > Hi

Re: Save the user from one model to the another model

2013-12-03 Thread antialiasis
I believe what Aamu Padi is getting at is that he doesn't want to do this in the view at all. He just wants it to happen *whenever* a Message is created. That's a textbook use case for signals. On Tuesday, December 3, 2013 1:14:50 PM UTC, Timothy W. Cook wrote: > > On Tue, Dec 3, 2013 at 9:56

Re: Save the user from one model to the another model

2013-12-03 Thread antialiasis
This seems like a job for signals. Register a post_save signal for the Message class, something like this: from django.db.models.signals import post_save from django.dispatch import receiver from myapp.models import Message, Thread

Re: Have browsers broken post-redirect-get? best practice now?

2013-10-01 Thread antialiasis
You should still be able to use the back button; it just shouldn't try to post the data again if you do so. Are you getting a prompt about resending post data, or are you just talking about being able to use the back button at all? If the latter, that's exactly what should happen. Breaking the

ManyToMany intermediary models with no required extra fields

2013-09-23 Thread antialiasis
Say you have a model with a ManyToManyField to another model: class Band(models.Model): ... members = models.ManyToManyField('Person') And now, say you decide that you want to use a custom intermediary model for the relationship, *without any required extra fields*. This could happen