pre_save signal called twice when adding model to db & change to instance object during pre_save don't get saved

2008-05-08 Thread Alen Ribic
e reference passed through the do_negative_amount() function to be modifiable. Its a pre_save signal / step. Maybe I'm missing something. Regards, -Alen Ribic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Dj

Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic
ry) -Alen On May 6, 8:05 pm, Alen Ribic <[EMAIL PROTECTED]> wrote: > So something like this should do it: > > from django.db import models > from django.db.models import signals > from django.dispatch import dispatcher > > def send_entry_created_email(): >

Re: customer serial numbers

2008-05-06 Thread Alen Ribic
forloop.counter like so: {% for item in items %} {{ forloop.counter }} {% endfor %} Regards, -Alen Ribic On May 6, 8:39 pm, "Ramdas S" <[EMAIL PROTECTED]> wrote: > I know this sounds silly, but I am just not able to figure out a way to > generate a custom serial n

Re: Sorting Drop-down fields on Admin site

2008-05-06 Thread Alen Ribic
It actually like this, sorry...to trigger happy today :) class Composer(models.Model): name = models.CharField(max_length=20) class Meta: ordering = ['name'] class Chart(models.Model): composer = models.ForeignKey(Composer) -Alen Ribic On May 6, 9:20 pm,

Re: Sorting Drop-down fields on Admin site

2008-05-06 Thread Alen Ribic
*correction: Need probably a comma at the end of the order tuple unless you use a list instead: class Chart(models.Model): composer = models.ForeignKey(Composer) class Meta: ordering = ('composer',) --Alen Ribic On May 6, 9:17 pm, Alen Ribic <[EMAIL PROTECTED]&

Re: Sorting Drop-down fields on Admin site

2008-05-06 Thread Alen Ribic
You should be able to do it like so: class Chart(models.Model): composer = models.ForeignKey(Composer) class Meta: ordering = ('composer') Regards, -Alen Ribic PS check out: http://www.djangoproject.com/documentation/models/ordering/ On May 6, 8:48 pm, "

Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic
=signals.post_save, sender=Entry) Regards, -Alen On May 6, 7:41 pm, Jashugan <[EMAIL PROTECTED]> wrote: > On May 6, 10:40 am, Alen Ribic <[EMAIL PROTECTED]> wrote: > > > > > Not to sure though how one registers these signals. > > This seems somewhat > com

Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic
for newly created models): > > if self.pk == None: >             self.slots_available = self.storage_unit_type.total_slots >             self.position = 1 > > On May 6, 10:00 am, Alen Ribic <[EMAIL PROTECTED]> wrote: > > > At this moment, to my knowledge, the only way to do this is by >

Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic
*correction: I was thinking of ModelForm instead of Model. It should be self.pk instead. if self.pk is None: # new model else: # existing model -Alen On May 6, 7:25 pm, Jashugan <[EMAIL PROTECTED]> wrote: > On May 6, 10:20 am, Alen Ribic <[EMAIL PROTECTED]> wrote: >

Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic
> Is there a way I can specify that > this code should run only when a model is first saved? in save() method, you can check if this is a new model like so: if self.instance.pk is None: # new model else: # existing model Regards, -Alen Ribic On May 6, 7:00 pm, Alen Ribic &

Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic
-developers/browse_thread/thread/c28da166daeea23c -Alen Ribic On May 6, 6:50 pm, Jashugan <[EMAIL PROTECTED]> wrote: > I'd like to set some attributes to some default values before the > model is created. Here's what I have so far: > >     slots_available = mo