Hi, I'm still very much a noob for django... as I'm a systems guy for my day job... as my problem will illustrate...
Im not sure how I should go about this really... I've tired several ways and I've been looking through the archives and browsing the web for the last two days.... I'm trying to to be able to link IP addresses to a Host name but the Address also needs to belong to the Network... a Host can have more than one Address and the Network will have more than one address... I'm not sure how to go about doing this... I've been looking at inlineformsets lately... but I don't quite know how to relate the examples to what I'm trying to do... Here's what I have... -- Models -- class Host(models.Model): name = models.CharField(max_length=64) ipaddress = models.ManyToManyField(Address, blank=True, null=True) class Address(models.Model): address = models.IPAddressField() network = models.ForeignKey(Network) class Network(models.Model): network = models.IPAddressField() mask = models.PositiveSmallIntegerField(max_length=2, choices=CIDR_CHOICES) -- Form -- class assignIpForm(forms.ModelForm): name = forms.ModelChoiceField(Host.objects.order_by('name',) widget=forms.Select()) address = forms.Charfield(widget=forms.HiddenInput()) network_id = forms.CharField(widget=forms.HiddenInput()) class Meta: model = Address fields = ['name', 'address','network_id'] -- View -- * Address is comming from the URL selected from a table printing out the IP range(ie: networks)... def assign_ip(request,address): networks = Network.objects.order_by('network',) for net in networks: if ipaddr.IPv4(address + "/32") in ipaddr.IPv4(net.network + "/" + str(net.mask)): network_id = net.id if request.method == 'POST': form = assignIpForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/networks') else: form = assignIpForm() else: form = assignIpForm() return render_to_response('systems/assign_ip.html', { 'address': address, 'forms': form, }) Any pointers as to what I should be looking for would be greatly appreciated... -Mitch Anderson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---