I have a django
project with a custom user model.
I have this Subscriptions
model that uses the custom user model as its foreign key.
class Subscriptions(models.Model):
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
app_subscriptions = models.CharField(max_length=100)
def __str__(self):
return self.app_subscriptions
But if I try to retreive all users app_subscriptions
with ..app_subscriptions_set.all()
it always returns with the following error:
AttributeError: 'CustomUser' object has no attribute 'app_subscriptions_set'
I have the same type of model in use here:
from django.db import models
class Software(models.Model):
name = models.CharField(max_length=50)
def __str__(self):
return self.name
class Version(models.Model):
version = models.CharField(max_length=50)
software = models.ForeignKey(Software, on_delete=models.CASCADE)
def __str__(self):
return self.version
And on this model I have no issues querying for all software versions with ...version_set.last()
.
Anyone have any ideas? Thank you in advance.