by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    JohnnyBDude
    @JohnnyBDude
    Hello!
    I am having trouble with newlines in json, maybe you would know what is wrong
    i am creating some custom using json.dumps(dataset, indent=3, sort_keys=True, encoding="utf-8")
    where dataset is a dictionary that i want dumped into json
    there are \n characters in json reponse instead of actual newlines
    JohnnyBDude
    @JohnnyBDude
    i have no idea what is wrong and it is slowly driving me crazy, so i would be really happy if you could point me to the right direction:)
    sumit sinha
    @sumitsinha91
    hello friends
    how to test rest of api
    i am new on this
    Yanik Koval
    @yanikkoval
    hi, is there a clean way to get model instances list for current user?
    I know I can get user name from context, but where I should change queryset, in views, right?
    Anatoly
    @Sindbag
    hey, is there a way to make instance out of serializer without calling .save() method ?
    broken serializer tries to write to db while loading object, that a bit confusing, but at the moment i am not able to fix serializer itself
    JohnnyBDude
    @JohnnyBDude
    You mean like creating new object without saving to db? You could subclass save method do do exactly what you need - without calling model. Create. Or implement you custom method If you prefer to leave serializer.save intact.
    I mean subclass the serializer and override save method.
    Anatoly
    @Sindbag
    thanks, I think that would help
    sukianto
    @sukianto
    Hi, I'm using django rest framework and django-rest-auth for login
    But django-rest-auth can't detect is_staff
    So I copy-paste the code to my views and add some code, I think that's not good cause repeating the code, is there any proper way to do this?
    JohnnyBDude
    @JohnnyBDude
    Try subclassing the rest-auth views, overriding yout methods And calling super to call implementation from superclass:) That might do the job
    Sorrz for thr quick answer, i am writing from mobile And i am in quitr ahurry
    sukianto
    @sukianto
    Ok, thanks will search about it, no problem
    thanks so much :)
    JohnnyBDude
    @JohnnyBDude
    You Re welcome. Just write if you get stuck.
    sukianto
    @sukianto
    Ok :+1:
    sukianto
    @sukianto
    Wow, that's very nice, sorry I'm very basic on this so need confirmation, is my code good?
    import rest_auth.registration.views
    class AdminLogin(rest_auth.registration.views.LoginView):
        """Admin login"""
        def post(self, request, *args, **kwargs):
            user = authenticate(
                email=self.request.data["email"],
                password=self.request.data["password"]
            )
            if not user.is_staff:
                msg = 'User account is not staff.'
                raise exceptions.ValidationError(msg)
    
            super(AdminLogin, self).post(request, *args, **kwargs)
    
            return self.get_response()
    but don't texting on drive
    sukianto
    @sukianto
    Guys I have a code, that I want to save from serializer to model serializer can someone help me?
    Thanks :)
    class DeviceSerializer(serializers.ModelSerializer):
        """
        Serializer for Device model.
        """
    
        class Meta:
            model = models.Device
            fields = ('user', 'reg_id', 'type', 'is_active')
    
    
    class DeviceRegisterSerializer(serializers.Serializer):
        """
        Serializer for registering device
        """
        reg_id = serializers.CharField(required=True, write_only=True, max_length=152, min_length=152)
        type = serializers.CharField(required=True, write_only=True, max_length=7)
    
        device = DeviceSerializer()
    
        def validate_type(self, value):
            if not (value == 'android') | (value == 'ios') | (value == 'website'):
                msg = 'The type of device is not recognized.'
                raise ValidationError(msg)
    
            return value
    
        def validate(self, attrs):
            return attrs
    
        def save(self):
            self.device.save()
    Keith Fitzgerald
    @ghostrocket
    hello everyone
    anyone here?
    JohnnyBDude
    @JohnnyBDude
    Yup, hello
    Keith Fitzgerald
    @ghostrocket
    oh hey thanks. so i need to upgrade a project to django 1.10
    it's currently running DRF 2
    upgraded DRF right now is a bit of a massive nightmare due to all the changes
    JohnnyBDude
    @JohnnyBDude
    Yeah me too:D
    Keith Fitzgerald
    @ghostrocket
    wondering if there's any solution to use V2 with 1.10
    JohnnyBDude
    @JohnnyBDude
    I am using v3 though
    I have no idea, sorry
    Keith Fitzgerald
    @ghostrocket
    np. thanks for acknowledging me haha!
    JohnnyBDude
    @JohnnyBDude
    Try asking on stackoverflow, this Channel seems to be rather dead:)
    Keith Fitzgerald
    @ghostrocket
    @JohnnyBDude -- fyi, i forked DRF and updated the version-2.4.x to work with Django-1.10
    JohnnyBDude
    @JohnnyBDude
    :D a way to go I Guess
    Renato Marinho
    @renatomarinho
    This message was deleted
    Renato Marinho
    @renatomarinho
    This message was deleted
    Christopher Hanes
    @cshanes
    Hello, can someone help me with posting data to a model that has an ArrayField? I'm having the same issue as this two year old unanswered Stack Overflow post: https://stackoverflow.com/questions/38709138/django-rest-framework-doesnt-accept-arrayfield-post
    Christopher Hanes
    @cshanes
    nevermind, it was a Postman issue..
    Trusty Man
    @TrustyMan
    Hello, everyone
    Could you help me with django?
    I got an error on receiving post request.
    I'm sending https request to the django rest api server
    but the error occured
    Drakun
    @DRAKUN
    hi
    Mohammadhadi Dodangeh
    @hadi2d
    hi