These are chat archives for django/django

Dec 2016
Simon Frid
Dec 05 2016 04:28
@confusedpublic here's an simplier layer on top of channels
@flyboy1565 same, take a look at that same repo
Ismael Venegas Castelló
Dec 05 2016 05:45
Hello guys!
Do you think PyCarm pro IDE is worth for django programming?
Dec 05 2016 08:50

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

Dec 05 2016 08:56
Hey guys anyone help me figure this out?
File "/usr/lib/python2.7/importlib/", line 37, in import_module
ImportError: No module named urls
Mohammadreza Kasaiee
Dec 05 2016 12:18
Hi, i think you don't have any python module (a file with .py format) in correct path with urls name or may be import it from incorrect path
Maksym L
Dec 05 2016 14:52
hey guys! how to save datetime with UTC to postgres? I have a problem when my datetime object is in UTC, but it inserts to DB as my local time
Shakib Hossain
Dec 05 2016 18:51

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.

Pami Ketolainen
Dec 05 2016 19:29
@shakib609 users following user X: User.objects.filter(followed_by__user=X)
@shakib609 users followed by user X: User.objects.filter(user__followed_by=X)
though, not 100% sure I got that right, but something along those lines
Pami Ketolainen
Dec 05 2016 19:35
the user field and it having related name user makes it a bit ambiguous