Repository: netbox-community/netbox

Issue:
Ability to search by DNS when 'Assigning new IP' address to device
### Environment
* Python version: 3.7.3 
* NetBox version: 2.6.6 

### Proposed Functionality
When assigning an IP address to an interface that exists on the device pagevia the green "+" sign you are presented with a page with two options, 'new' and 'assign IP'. 

We have all usable address in IPAM, so would 'assign' one. In the 'Assign an IP Address' page there is only the option to search via IP address and not DNS. Many of the infra would like the ability to search for an applicable IP address via DNS name and not IP address.

<!--
    Convey an example use case for your proposed feature. Write from the
    perspective of a NetBox user who would benefit from the proposed
    functionality and describe how.
--->
### Use Case
Other non network team members should be able to update their IP address details of their infrastructure and wish to use DNS rather than IP address

<!--
    Note any changes to the database schema necessary to support the new
    feature. For example, does the proposal require adding a new model or
    field? (Not all new features require database changes.)
--->
### Database Changes
No known changes required.

<!--
    List any new dependencies on external libraries or services that this new
    feature would introduce. For example, does the proposal require the
    installation of a new Python package? (Not all new features introduce new
    dependencies.)
-->
### External Dependencies
No known changes required.


Discussion:
This issue has been closed as it does not conform to one of the [provided templates](https://github.com/digitalocean/netbox/issues/new/choose) as required by the [contributing guide](https://github.com/digitalocean/netbox/blob/master/CONTRIBUTING.md). If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).
Issue has been updated with a fuller description of the functionality required
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

Rescuing this one from stalebot as it should be trivial to implement.

Resolving patch:
diff --git a/netbox/ipam/forms.py b/netbox/ipam/forms.py
--- a/netbox/ipam/forms.py
+++ b/netbox/ipam/forms.py
@@ -933,7 +933,7 @@ class Meta:
 
 
 class IPAddressAssignForm(BootstrapMixin, forms.Form):
-    vrf = forms.ModelChoiceField(
+    vrf_id = forms.ModelChoiceField(
         queryset=VRF.objects.all(),
         required=False,
         label='VRF',
@@ -942,8 +942,9 @@ class IPAddressAssignForm(BootstrapMixin, forms.Form):
             api_url="/api/ipam/vrfs/"
         )
     )
-    address = forms.CharField(
-        label='IP Address'
+    q = forms.CharField(
+        required=False,
+        label='Search',
     )
 
 
diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py
--- a/netbox/ipam/tables.py
+++ b/netbox/ipam/tables.py
@@ -373,7 +373,7 @@ class IPAddressAssignTable(BaseTable):
 
     class Meta(BaseTable.Meta):
         model = IPAddress
-        fields = ('address', 'vrf', 'status', 'role', 'tenant', 'parent', 'interface', 'description')
+        fields = ('address', 'dns_name', 'vrf', 'status', 'role', 'tenant', 'parent', 'interface', 'description')
         orderable = False
 
 
diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py
--- a/netbox/ipam/views.py
+++ b/netbox/ipam/views.py
@@ -756,13 +756,12 @@ def post(self, request):
 
         if form.is_valid():
 
-            queryset = IPAddress.objects.prefetch_related(
+            addresses = IPAddress.objects.prefetch_related(
                 'vrf', 'tenant', 'interface__device', 'interface__virtual_machine'
-            ).filter(
-                vrf=form.cleaned_data['vrf'],
-                address__istartswith=form.cleaned_data['address'],
-            )[:100]  # Limit to 100 results
-            table = tables.IPAddressAssignTable(queryset)
+            )
+            # Limit to 100 results
+            addresses = filters.IPAddressFilter(request.POST, addresses).qs[:100]
+            table = tables.IPAddressAssignTable(addresses)
 
         return render(request, 'ipam/ipaddress_assign.html', {
             'form': form,


Test patch: