title: Using OneToOneField in Django
body: <p>I'm realized some models in application:</p>
  
  <pre><code>from django.db import models
  
  class Commentary(models.Model):
      user_id = models.ForeignKey(User)
      created_date = models.DateField()
      comment = models.TextField()
  
  class Role(models.Model):
      role_name = models.CharField(max_length=25)
  
  class User(models.Model):
      login = models.CharField(max_length=50)
      password = models.CharField(max_length=50)
      address = models.CharField(max_length=255)
      phone = models.CharField(max_length=25)
      postcode = models.CharField(max_length=25)
      email = models.EmailField()
      role_id = models.OneToOneField(Role)
  </code></pre>
  
  <p>After that typed in console "python manage.py makemigration mainws" for making migrations in my database, however, taken stacktrace with error. If looking in <a href="https://docs.djangoproject.com/en/1.7/topics/db/examples/one_to_one/" rel="nofollow">django documentation for one-to-one example</a>, we can see the similarity with him, but without option <code>primary_key=True</code>.  How can I fix this or maybe better using <code>ForeignKey</code> with <code>unique=True</code> for this issue, or something other? </p>
  
  <p>Stacktrace:</p>
  
  <pre><code>=&gt; python manage.py makemigration mainws
  Traceback (most recent call last):
    File "manage.py", line 10, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
      utility.execute()
    File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
      django.setup()
    File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
      apps.populate(settings.INSTALLED_APPS)
    File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
      app_config.import_models(all_models)
    File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
      self.models_module = import_module(models_module_name)
    File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
      __import__(name)
    File "/Users/savicvalera/code/lab8/website/mainws/models/__init__.py", line 1, in &lt;module&gt;
      from . import Commentary, MailList, Product, Provider, Rate, Review, Role, Sale, ShoppingCart, Status, Supplies, User
    File "/Users/savicvalera/code/lab8/website/mainws/models/Commentary.py", line 11, in &lt;module&gt;
      from . import Product, User
    File "/Users/savicvalera/code/lab8/website/mainws/models/User.py", line 14, in &lt;module&gt;
      class User(models.Model):
    File "/Users/savicvalera/code/lab8/website/mainws/models/User.py", line 21, in User
      role_id = models.OneToOneField(Role,to_field='id')
    File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1799, in __init__
      super(OneToOneField, self).__init__(to, to_field, OneToOneRel, **kwargs)
    File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1612, in __init__
      assert isinstance(to, six.string_types), "%s(%r) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT)
  AssertionError: OneToOneField(&lt;module 'mainws.models.Role' from '/Users/savicvalera/code/lab8/website/mainws/models/Role.pyc'&gt;) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string u'self'
  </code></pre>