These are chat archives for django/django

30th
Aug 2016
Abhishek Baliyan
@abhishekdevinfo
Aug 30 2016 03:12
@anacrust @ajbeach2 Thanks for the info
Pawel Stepak
@PawelStepak
Aug 30 2016 09:14
Hi guys, I'm writing unittest for an API that uses python requests, it needs to have django runserver ip address in order to get it working. My question is, how can I get IP address that was used in django runserver setup ?
Andrew Backer
@awbacker
Aug 30 2016 09:48
Have you tried mocking the request/response using the mock library?
that would be my first route. I don't know that the unit tests actually spin up a full web server like runserver does
Andrew Backer
@awbacker
Aug 30 2016 10:45
Does anyone know how to tell if the Admin is in change vs list mode inside a function on the model admin? I have one function I'd like to show on list and on change (its read only), but I want to show less info in list. I'd rather not have 2 functions, if I can tell inside a single one which mode i'm in, since the mode is just a flag to another function.
Samson Paul Jr.
@SamsonPaulJr
Aug 30 2016 22:25
Hello @/all
This message was deleted
Miguel
@miguel550
Aug 30 2016 22:27
I think you need to execute it first @samsonpaul
Samson Paul Jr.
@SamsonPaulJr
Aug 30 2016 22:31
@miguel550 How is that?
Stephen Ohimor
@ohimors
Aug 30 2016 22:33
Could not resolve URL for hyperlinked relationship using view name "player-detail". You may have failed to include the related model in your API, or incorrectly configured the lookup_field attribute on this field.
why does django expect *-detail for a view name
Samson Paul Jr.
@SamsonPaulJr
Aug 30 2016 22:40
my_list = {
    'user0': 400,
    'user1': 25500,
    'user2': 77000
    }

def calculate_tax(my_list):
  t_tax = 0
  for key in my_list:
    if key in range(0, 1000):
      t_tax = 0

    elif key in range(1000, 10000):
      t_tax = t_tax + (key * 0.1)

    elif key in range(10000, 20200):
      t_tax = t_tax + (key * 0.15)

    elif key in range(20200, 20500):
      t_tax = t_tax + (key * 0.2)

    else:
      t_tax = t_tax
  #return t_tax

  print my_list[key], t_tax
@miguel550 Sorry it was out, here it is