These are chat archives for django/django

12th
Apr 2016
gmwill92
@gmwill92
Apr 12 2016 05:24
@mpachas thanks, do you know where can I find detailed documentation for best practices?
mpachas
@mpachas
Apr 12 2016 05:27
@gmwill92 Two Scoops of Django is a must, imo
Alexey Rogachev
@arogachev
Apr 12 2016 06:01
This message was deleted
This message was deleted
Zeeshan Asgar
@asgarzee
Apr 12 2016 06:09
hi guys. Currently i m working on django restframework. I want to overide 403 authentication error and instead of 403 i want o display my error code for ex: 900.
any suggestions on how to do that.
Filip Figiel
@megapctr
Apr 12 2016 06:32
:worried:
Zeeshan Asgar
@asgarzee
Apr 12 2016 06:33
@megapctr any help
Filip Figiel
@megapctr
Apr 12 2016 06:34
I'd understand if you wanted to return 404 instead of 403
900 left me speechless
Zeeshan Asgar
@asgarzee
Apr 12 2016 06:35
I am making my own error codes standard for the api
Filip Figiel
@megapctr
Apr 12 2016 06:36
okay
I don't think you can do this globally
Zeeshan Asgar
@asgarzee
Apr 12 2016 06:36
So it's not possible?
Filip Figiel
@megapctr
Apr 12 2016 06:38
your problem is about drf, so you should seek help here https://github.com/tomchristie/django-rest-framework#documentation--support
IIRC you can override some exceptions
however, I'd stay away from custom error codes - the standard ones are a standard for a reason
Zeeshan Asgar
@asgarzee
Apr 12 2016 06:40
@megapctr okay. thanks.
Filip Figiel
@megapctr
Apr 12 2016 06:40
consider sticking to standard codes unless you have a very specific case
Zeeshan Asgar
@asgarzee
Apr 12 2016 06:40
okay
Filip Figiel
@megapctr
Apr 12 2016 06:40
good luck
Zeeshan Asgar
@asgarzee
Apr 12 2016 06:41
:)
samkurma
@samkurma
Apr 12 2016 08:46
hi, how can i change the values storing in auth_user table to another table
Bruno F Souza
@varnion
Apr 12 2016 11:58
@adc82 thanks ;)
sumit sinha
@sumitsinha91
Apr 12 2016 13:15
hello
help me
can anyone explain me about setup
class WaybillSingleFetchTest(TestCase):

    def setUp(self):
        self.url = settings.BASE_URL + "wabn/fetch/"
        self._token = self._get_auth_token()
        self._headers = {'Authorization': "Token %s" % self._token}

    def _get_auth_token(self):
        # Through API
        return '35c7144d48961db0456e2c8f3cc8699878b5a7da'

    def test_without_authentication(self):  # Without authentication should return 403
        resp = requests.get(self.url)
        self.assertEqual(resp.status_code, 403)
        # print "Test case passed ..."

    def test_with_authentication(self):  # With authentication should return a unique waybill no
        resp = requests.get(self.url, headers=self._headers)
        # import ipdb; ipdb.set_trace()
        self.assertTrue('wabn' in resp.json())
        # print "Test case passed ..."
please help me its very difcult to understand me setup process
that how setup process will work above is code and i want to understand how i will use unittest
can anyone hel me
Michal Haták
@Twista
Apr 12 2016 14:37
setUp is executed before every test case and in that case is just variable assignment. what do you want to understand ? @sumitsinha91
basically because self.url is created(assigned) in that method, you can use it in test case (request.get(self.url))