Hi Greg,

On Jul 2, 5:29 pm, "Grzegorz Dostatni" <[EMAIL PROTECTED]> wrote:
> I'm writing a django application (postgresql db) that needs to deal with
> input both from GUI (webserver) and commandline (parsing text input).
>
> I've got a model defined where I explicitly define the id field using:
>
>     id = models.AutoField(primary_key = True)
>
> When I'm creating a new entry, is there a method available to find the next
> value in the sequence? I know the sql for that, I'm trying to see if there
> is a function within django that does it. I'd rather not have sql statements
> with hardcoded values (sequence name) included in my python code (unless I
> absolutely have to).

The idea behind an AutoField is that the database assigns that field
the next value from a sequence upon INSERT. You don't have to set that
value yourself and normally shouldn't have to care what that value is
going to be prior to the object being saved to the DB.

Can you describe the use-case that requires you to know the next value
in the sequence before you save a new instance of your object?

-Rajesh D
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to