I need to create a static method for a model class like this. The line
Settore.objects.all()[0].id gives error  (
psycopg2.InternalError: current transaction is aborted) when creating
the tables at first syncdb. What's the correct way to do that?

~~~~~~~~~~~~~~~~~~~~~~~~~
class Settore(models.Model):
    nome = models.CharField(max_length=200, blank=False, null=False)
    email = models.EmailField()

    class Meta:

        verbose_name_plural = 'settori'
        ordering = ('nome',)
        get_latest_by = "nome"

    def __unicode__(self):
        return self.nome

    @staticmethod
    def get_default():
        try:
            return Settore.objects.all()[0].id
        except:
            return None
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com
http://www.linkedin.com/in/ronchialessandro

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to