question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AutoOneToOne doesn't work

See original GitHub issue

System

OS: Linux Python: 3.5.1 Django: 1.9.5 Annoying: 0.9.0

Example

From README.md.

from annoying.fields import AutoOneToOneField

class MyProfile(models.Model):
    user = AutoOneToOneField(User, primary_key=True)
    home_page = models.URLField(max_length=255, blank=True)
    icq = models.IntegerField(blank=True, null=True)

Description

I have try your example but it doesnt’t work. I have no error messages. The field works lika a regular OneToOne field.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
arthuriocommented, Aug 4, 2016

@pymarco I’m just seing this but AutoOneToOneField won’t create a related object unless you try to access it.

a = Alpha.objects.create()
Beta.objects.count()
# 0
a.beta
# <Beta: Beta object>
Beta.objects.count()  # 1
0reactions
arthuriocommented, Feb 8, 2019

@albrnick You want to put the AutoOneToOneField on the CrmCategoryStatsList model instead:

class CrmCategoryStatsList(models.Model):
    category = AutoOneToOneField(...)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Django AutoOneToOneField migration and existing entries
You need to do this in three stages. Firstly, add the one-to-one with null=True and create a migration. Then, create a data migration...
Read more >
Using Django OneToOneFields to Create UserProfiles
The Django OneToOneField raises exceptions if the related model doesn't exist. ... This of course won't work if your related model has fields...
Read more >
django-annoying - PyPI
AutoOneToOne field - Creates related object on first call if it doesn't exist yet. ... You can also run “python setup.py install”, ...
Read more >
T4 Models | Linq To DB (aka linq2db)
Configuring schema load process. Use the following initialization before you call the LoadMetadata() method. All schema load functionality configured using ...
Read more >
debian-watch-does-not-check-gpg-signature
This watch file does not specify a means to verify the upstream tarball using a cryptographic signature. ... bioperl-run ... django-auto-one-to-one.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found