ValueError at /api/list/ invalid literal for int() with base 10: '35/like'

2018-08-09 Thread mounikesh mintu
hey guys when i tried to like  a post in drf i have got in to an error 

models.py

class status(models.Model):
user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE, 
null=False)
# user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)

content=models.TextField(blank=True,null=True)

image=models.ImageField(upload_to="upload",null=True,blank=True)
updated=models.DateTimeField(auto_now=True)
time=models.DateTimeField(auto_now_add=True)

likes=models.ManyToManyField(settings.AUTH_USER_MODEL,blank=True,related_name='post_likes')

def __str__(self):
return self.content

serilaizers

serializers.py

class statusSerializer(serializers.ModelSerializer):
# user_name = serializers.ReadOnlyField(source='user.username')
user=UserPublicSerializer(read_only=True)
# rating=RatingSerializer(required=False)
# rating=RatingSerializer()

class Meta:
model=status
fields=['id','user','content','image','likes']

views.py

@api_view(['POST'])def LikesApi(self,request,id):
# status = get_object_or_404(id=request.POST.get('id', ''))
status = get_object_or_404(id=id)

status.likes.add(request.user)
serializer = statusSerializer(status)
return Response(serializer.data, status=status.HTTP_201_CREATED)

i have tried both the ways with regards of that question from stack

@api_view(['POST'])def LikesApi(self,request,id):
serializer=statusSerializer(data=request.DATA)
if serializer.is_valid():

serializer.object.content_object=get_object_or_404(status,id=request.POST.get('id',
 ''))
serializer.object.likes.add(request.user)
serializer.save()
return  RestResponse(serializer.data, status=status.HTTP_201_CREATED)
return RestResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

here is my urls.py

urlpatterns = [
# url(r'^$/', StatusListSearchApi.as_view()),
url(r'^list/', StatusListSearchApi.as_view()),
url(r'^user/', UserPost.as_view()),

url(r'^like/(?P\d+)/$',LikesApi),

post objects are present in my api/list/ url

http://127.0.0.1:8000/api/list/like?id=35

when i fired this url i cant see any incremination of likes in my 
browasable api detailview

http://127.0.0.1:8000/api/like?id=35

tried this as well but rather got a page not found 404 error

but when i tried 

this url pattern

http://127.0.0.1:8000/api/list/?id=35/like

i have got that value error 

please can anyone help me

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a64dbbfd-ace5-4186-9c2b-801c66bd7804%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: error in coding

2018-07-25 Thread mounikesh mintu
post your urls patterns

On Wed, Jul 25, 2018 at 5:40 PM, Rohit Sharma 
wrote:

> I am very new to Django. I have started a project and created my first app
> but whenever i start editing the app i always get this error. i have
> attached the screenshot of the error.
> please help me out in a simple way.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/9004ed7c-6b33-4b06-8a2a-d733e3b14e0f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN2ZND-RM43f7HErh%2BKY4LAx%2Bb%2BQXJOp%3DmCHLVjDGm%3DRnE7wGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django groups and specialpermissions

2017-12-07 Thread mounikesh mintu
Can any one guide me in this is there any way to create django groups where 
there should be a group admin who can control the activity of the group and 
cand add members and themembers can share any kind of photos within the group 
and the other members outside the group cant view/access the photos/media 
Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5ab4d20d-f580-4a97-ad4a-82cd2bc73efd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.