Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneToOneField that's a primary key causes AttributeError #164

Closed
KevinGrahamFoster opened this issue Apr 2, 2015 · 4 comments
Closed

OneToOneField that's a primary key causes AttributeError #164

KevinGrahamFoster opened this issue Apr 2, 2015 · 4 comments

Comments

@KevinGrahamFoster
Copy link
Contributor

I've found an issue with a model containing a one to one field that's also the primary key (ie the object should have the same primary key as the one it's related to).

class Foo(TimeStampedModel):
    history = HistoricalRecords()
    farf = models.OneToOneField(Farf, primary_key=True)

When running make migrations, I get this issue:

  File ".../simple_history/models.py", line 291, in do_related_class
    field = self.get_field(other, cls)
  File "..../simple_history/models.py", line 256, in get_field
    field = self.get_one_to_one_field(to_field, other)
  File ".../simple_history/models.py", line 241, in get_one_to_one_field
    temp_field = self.__class__(to_field.rel.to._meta.object_name)
AttributeError: 'unicode' object has no attribute '_meta'

Note that the primary key I am using in object Farf is a UUIDField, which I guess is why it's appearing as 'unicode', although I am using the postgres version of this field. It's quite possible that it's some special case of using a field like this. I haven't tried it with a standard integer field. Am using Django 1.7.7 and PostgreSQLUUIDField from django extensions as the primary key in object Farf.

@macro1
Copy link
Collaborator

macro1 commented Apr 4, 2015

This should be fixed with the changes coming in #160. I think we will be removing use of our CustomForeignKey completely.

@macro1
Copy link
Collaborator

macro1 commented Apr 17, 2015

@KevinGrahamFoster: If you have some time, could you check if this is still an issue with 1.6.0?

@KevinGrahamFoster
Copy link
Contributor Author

Will do.

@KevinGrahamFoster
Copy link
Contributor Author

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants