You need to think things through a bit more carefully. It seems like you're randomly assigning things without really having any idea of what you're doing.
This code:
S = Sdr_Layer(layer_name="Test")
instantiates a new Sdr_Layer object, with the name "Test".
This line:
S.layer_attribute_name=test_mapping
tries to do something very strange, which is to assign a dictionary to your CharField. You can do that, but it will be converted to a string on save.
Now, none of this code would throw a "not_null error on layer_id", because layer_id is a field on the Test model, which you don't even use in this code. So, there must be code you're not showing us. Also, there is a reason why Python prints the full traceback on an error: it's useful debugging information, not random cruft. Post it too.
FWIW, I suspect you wanted to do this:
t = Test(**layer_mapping)
t.layer_id = S
t.save()
--
DR.