On Jul 4, 12:14 pm, AnaReis <[EMAIL PROTECTED]> wrote:
> Hi again,
> Thanks for the suggestion, but this still isn't working... the
> difference between this module and the others that I have already made
> is that (besides the fact that the others actually work) this one
> involves a table with two primary keys. If it had just one I bet there
> would be no problem.

And you'd win that bet! I should have noticed the two PKs in your
model.

Here's the thing: Django allows only one PK field per object. You
should remove the two primary_key=True attributes altogether from your
model (letting Django create a PK id field for you.) Then, use the
unique_together clause to make the database enforce that the pair
(level_name, instrument_name) is always unique. That clause is defined
in your Meta class like this:

unique_together = (('level_name', 'instrument_name'),) # Note that
this is a nested tuple

For added measure you can add a db_index=True to your formerly primary
key fields to make querying over them faster.

Don't forget to wipe out the model entirely from your DB table
(assuming you are in development mode with despensible test data) and
then syncdb to recreate everything.


--~--~---------~--~----~------------~-------~--~----~
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