1👍
✅
Take a look to this code:
>>> import random
>>> random.randint(1,1000)
320
>>> random.randint(1,1000)
153
>>> def r( n=random.randint(1,1000) ):
... print n
...
>>> r()
543
>>> r() #<------ n not re-evaluate
543
>>> r() #<------ n not re-evaluate
543
as you can see, parm n
is only evaluated one time.
In your code:
def gs_add_channel(gs, band, gs_ch_id, modulations=None,
bitrates=AvailableBitrates.objects.all()):
bitrates
is only evaluated one time, that means than you can delete bitrates from database but values will be remain in bitrates
parm. This raise foreign key error because is trying to insert a value that is not in database. Fix it as you do with modulations
parameter.
Source:stackexchange.com