If you really want to have a separate table for Tag, You can do this:

class CurrentTag(models.Model):
    tag = models.OneToOneField(Tag, primary_key=True)
    def __unicode__(self):
        return self.tag

On Nov 20, 12:10 am, JE <thegeni...@gmail.com> wrote:
> Thanks for the replies.
> I simplified the problem a bit by deciding it will be easier to have
> some extra validation code in a separate admin view to do what I need
> it to and removed the CurrentTag table, similar to what Rainy has
> said.
>
> On Nov 18, 4:59 pm, Rainy <andrei....@gmail.com> wrote:
>
>
>
>
>
>
>
> > On Nov 18, 9:04 am, JE <thegeni...@gmail.com> wrote:
>
> > > Hi,
>
> > > I'm pretty new to Django so feel free to laugh if something's
> > > horrendously wrong here that I haven't spotted.
>
> > > I'm trying to use a field from a foreign key as a primary key in
> > > another model, but have no idea how to do this.
> > > The idea is to have a table called Tag (columns called tagname and
> > > tagversion, which create a composite primary key using the
> > > unique_together option in the metadata).
>
> > Why not just have a boolean column 'current' or 'active'
> > in Tag model, instead of a separate table? On save,
> > if it's changed inactive->active, all other tags are set
> > to be inactive.  -ak

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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