These are chat archives for django/django
Someone help me please I'm using django rest framework
I have 2 models both linked to user:
class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) location = models.CharField(max_length=140) photo = models.CharField(default='', max_length=255) cover_photo = models.CharField(default='', max_length=255) ... class AllVideos(models.Model): title = models.CharField(unique=True, primary_key=True, editable=False, max_length=255) user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, related_name='videos') title_display = models.TextField(default='') ...
this is the serializer:
class AllVideosSerializer(serializers.ModelSerializer): class Meta: model = models.AllVideos fields = ('user', 'title', 'title_display', 'like', 'favorite', 'video_type', ...)
for user fields I want to change it
So user fields will be user profile
but it's not linked to user profile just linked to user table
USE_TZ=True? Check https://docs.djangoproject.com/en/1.10/ref/settings/#use-tz and https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-TIME_ZONE
I have a model like this
class Follow(models.Model): user = models.ForeignKey( User, related_name='user', on_delete=models.CASCADE ) followed_by = models.ForeignKey( User, related_name='followed_by', on_delete=models.CASCADE )
How can I get the queryset to return all the users that
user is being followed by?
And also how can I get the queryset to return all the users that
user is following?
Any suggestions would be really helpful.