[x] prevent saving an ip address which is not part of the specified subnet, test saving ip 192.168.1.1 on subnet 10.0.0.0/24, add a similar test for ipv6 too
[x] how do you specify the network on a subnet? We need to validate that the prefix inserted is valid as well. I think you could add two fields to the subnet model: network and prefix, network can be a generic ip address field, and prefix an integer, before saving you need to validate these two fields (clean) by trying to create a network object with the ipaddress library, and if anything fails raise a ValidationError
[x] what happens if a user tries to save the same ip twice?
[x] what happens if a user tries to save the same subnet twice?
[x] what happens if a user tries to create a subnet that overlaps with an existing one?
The last one is particularly tricky and we may not be able to implement it quickly with the current setup. Focus on addressing all the previous points in #11.
We should add some basic model validation:
192.168.1.1
on subnet10.0.0.0/24
, add a similar test for ipv6 tooclean
) by trying to create a network object with the ipaddress library, and if anything fails raise aValidationError