These are chat archives for django/django

12th
Aug 2016
mark
@thenewidealism_twitter
Aug 12 2016 02:54
could anyone help me displaying the profile picture of the users who posted, and commented? right now i can only get the profile picture for logged in user. http://192.241.153.25:8000
MinJae Kwon
@mingrammer
Aug 12 2016 06:14
do you have api for getting a user data? (any users)
mark
@thenewidealism_twitter
Aug 12 2016 06:48
yes i do, but for some reason it’s throwing me errors : http://192.241.153.25:8000/api/users/profile/
class ProfileView(views.APIView):
    permission_classes = (
        permissions.AllowAny,
    ) #or permissions.IsAuthenticated

    def post(self,serializer):
        profile=Profile(user=self.request.user,
            profile_image=self.request.FILES['profile_image'])
        profile.save()
        return response.Response(status=status.HTTP_204_NO_CONTENT)

    def get(self, request, format=None):
        username = request.query_params['username']
        profile = Profile.objects.get(user__username=username)
        return response.Response(profile.profile_image.url)
MinJae Kwon
@mingrammer
Aug 12 2016 06:50
where is 'username' parameter?
on request
mark
@thenewidealism_twitter
Aug 12 2016 06:51
this is all i got
from django.contrib.auth.models import User

# Create your models here.
class Profile(models.Model):
        user=models.OneToOneField(User)
        profile_image= models.ImageField(upload_to='profile')
to be honest i have no idea.
MinJae Kwon
@mingrammer
Aug 12 2016 06:53
it seems like 'username' parameter is not in 'request'
mark
@thenewidealism_twitter
Aug 12 2016 06:53
what do you suggest that i do?
MinJae Kwon
@mingrammer
Aug 12 2016 06:54
/api/users/<username>/profile form is common
mark
@thenewidealism_twitter
Aug 12 2016 06:54
um okay..
MinJae Kwon
@mingrammer
Aug 12 2016 06:55
/api/users is getting all users
/api/users/<username> is getting a user
if you want to display the user's profile image on posts list or comments list, you could create api for getting all users who written posts or comments. like /api/posts/<post_id>/comments. and response of this api would like this comments: [{wrote_username: <username>, wrote_user_profile_img: <img_url>, content: <comment content>, ...}, ...]
mark
@thenewidealism_twitter
Aug 12 2016 07:01
let me pm you.
Anahit Sarao
@s3nu
Aug 12 2016 07:16
Hey everyone, can i ask a cookiecutter-django question here or is this the wrong chat for that?
Anahit Sarao
@s3nu
Aug 12 2016 08:03
Never mind figured it out
Ferdellans
@Ferdellans
Aug 12 2016 11:57
hi there!
is this good idea to use tornado (for chat etc) in django project?
mark
@thenewidealism_twitter
Aug 12 2016 12:10
what is tornado?
Ferdellans
@Ferdellans
Aug 12 2016 12:10
mark
@thenewidealism_twitter
Aug 12 2016 12:12
i eventually need to integrate chat system to the django
*too
Ferdellans
@Ferdellans
Aug 12 2016 12:14
i found alot of tornado examples, but realy good example django+tornado i did ton find....
so, maybe pple have sove problems with django+tornado apps, or idk
Helton Costa
@heltucosta
Aug 12 2016 12:51
anyone ever used the render_to_string shortcut ?
Helton Costa
@heltucosta
Aug 12 2016 12:57
I’m trying to retrieve a file I upload to my MEDIA folder and use it with the render_to_string function, but it seems to only look for static templates, can I change it’s route ?