internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: nautobot/nautobot

Issue:
Browsable API should have same style as the rest of the site
<!--
    NOTE: This template is for use by maintainers only. Please do not submit
    an issue using this template unless you have been specifically asked to
    do so.
-->
### Proposed Changes

I propose that we update browsable API template to look and feel like the base so that we get branding, menu bar, login, dark mode support, etc.

<!-- Provide justification for the proposed change(s). -->
### Justification

Consistency, style, look, feel, UX. It's a quick fix that makes using Nautobot feel more consistent.


Discussion:

Resolving patch:
diff --git a/nautobot/core/settings.py b/nautobot/core/settings.py
--- a/nautobot/core/settings.py
+++ b/nautobot/core/settings.py
@@ -283,14 +283,14 @@
     "django_tables2",
     "django_prometheus",
     "mptt",
-    "rest_framework",
     "social_django",
     "taggit",
     "timezone_field",
     "nautobot.core.apps.NautobotConstanceConfig",  # overridden form of "constance" AppConfig
     "nautobot.core",
-    "django.contrib.admin",  # Needs to after `nautobot.core` to so templates can be overridden
-    "django_celery_beat",  # Needs to after `nautobot.core` to so templates can be overridden
+    "django.contrib.admin",  # Must be after `nautobot.core` for template overrides
+    "django_celery_beat",  # Must be after `nautobot.core` for template overrides
+    "rest_framework",  # Must be after `nautobot.core` for template overrides
     "db_file_storage",
     "nautobot.circuits",
     "nautobot.dcim",


Test patch:
Repository: nautobot/nautobot

Issue:
CustomField default value populated in filterform
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Python version: 3.8
* Nautobot version: 1.3.2

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. Create CustomField with a default value (quick testing with site object)
2. Load target object's list/table view
3. FilterForm on right side is pre-populated with default value and not set to an empty value.

<!-- What did you expect to happen? -->
### Expected Behavior
Filterforms should not be pre-populated on initial load when query params are not passed in

<!-- What happened instead? -->
### Observed Behavior
Default value is pre-populated but not applied as a filter to the page.


Discussion:

Resolving patch:
diff --git a/nautobot/extras/forms.py b/nautobot/extras/forms.py
--- a/nautobot/extras/forms.py
+++ b/nautobot/extras/forms.py
@@ -601,10 +601,10 @@ def __init__(self, *args, **kwargs):
             field_name = "cf_{}".format(cf.name)
             if cf.type == "json":
                 self.fields[field_name] = cf.to_form_field(
-                    set_initial=True, enforce_required=False, simple_json_filter=True
+                    set_initial=False, enforce_required=False, simple_json_filter=True
                 )
             else:
-                self.fields[field_name] = cf.to_form_field(set_initial=True, enforce_required=False)
+                self.fields[field_name] = cf.to_form_field(set_initial=False, enforce_required=False)
 
 
 #


Test patch:
Repository: nautobot/nautobot

Issue:
UnboundLocalError when rendering multi select custom field column
### Environment
* Python version: 3.6
* Nautobot version: 1.2.9

### Steps to Reproduce
1. Create a multi select custom field for dcim device
2. Browse to the device list view
3. Add the multi select field as a column
4. Reload the page

### Expected Behavior
The device list should render the multi select column

### Observed Behavior
UnboundLocalError: local variable 'template' referenced before assignment

### Fix
Move line 372 in utilities/tables.py `template = ""` above ~line 371 `if value:`~ line 368.

https://github.com/nautobot/nautobot/blob/develop/nautobot/utilities/tables.py#L368

![Capture](https://user-images.githubusercontent.com/84326667/175339688-9a43451e-55f2-41f6-b4d4-8ec15f959308.PNG)


Discussion:

Resolving patch:
diff --git a/nautobot/utilities/tables.py b/nautobot/utilities/tables.py
--- a/nautobot/utilities/tables.py
+++ b/nautobot/utilities/tables.py
@@ -365,13 +365,14 @@ def render(self, record, bound_column, value):
         if value is None:
             return self.default
 
+        template = ""
         if self.customfield.type == CustomFieldTypeChoices.TYPE_BOOLEAN:
             template = render_boolean(value)
         elif self.customfield.type == CustomFieldTypeChoices.TYPE_MULTISELECT:
-            if value:
-                template = ""
-                for v in value:
-                    template += format_html('<span class="label label-default">{}</span> ', v)
+            if not value:
+                return self.default
+            for v in value:
+                template += format_html('<span class="label label-default">{}</span> ', v)
         elif self.customfield.type == CustomFieldTypeChoices.TYPE_SELECT:
             template = format_html('<span class="label label-default">{}</span>', value)
         elif self.customfield.type == CustomFieldTypeChoices.TYPE_URL:


Test patch:
Repository: nautobot/nautobot

Issue:
[1.4] Jobs Result Filter - Error when Search field "Status" is empty
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Python version: 3.9
* Nautobot version: e02bb08e6c2a (v1.4.0rc1)

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. Open Job Results Page
2. Filter a "Job"
3. Klick "Apply"

<!-- What did you expect to happen? -->
### Expected Behavior
The Job Results table should be populated with selected entries

<!-- What happened instead? -->
### Observed Behavior

Error message:
> Invalid filters were specified:
>     * status
>           * Select a valid choice. is not one of the available choices.

When selecting for e.g. "Completed" for the status, it's working fine


Discussion:
Thanks for the report! This appears to be a pre-existing issue that is uncovered by the addition of `STRICT_FILTERING` as a default setting in 1.4.

Resolving patch:
diff --git a/nautobot/extras/forms/forms.py b/nautobot/extras/forms/forms.py
--- a/nautobot/extras/forms/forms.py
+++ b/nautobot/extras/forms/forms.py
@@ -949,10 +949,10 @@ class JobResultFilterForm(BootstrapMixin, forms.Form):
             api_url="/api/users/users/",
         ),
     )
-    status = forms.ChoiceField(
-        choices=add_blank_choice(JobResultStatusChoices),
+    status = forms.MultipleChoiceField(
+        choices=JobResultStatusChoices,
         required=False,
-        widget=StaticSelect2(),
+        widget=StaticSelect2Multiple(),
     )
 
 


Test patch:
Repository: nautobot/nautobot

Issue:
Editing a Location doesn't retrieve parent
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Python version: 3.10
* Nautobot version: 1.4.1

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. Create a location and a child location (e.g. Building, Floor).
2. Edit the child location (e.g. Floor)
3. Observe the parent field.

<!-- What did you expect to happen? -->
### Expected Behavior
The parent location should be retrieved and displayed in the parent field box.

<!-- What happened instead? -->
### Observed Behavior
The parent location is not retrieved and if one hits the update button regardless a warning is issued to select a parent location and the update is denied.


Discussion:

Resolving patch:
diff --git a/nautobot/dcim/forms.py b/nautobot/dcim/forms.py
--- a/nautobot/dcim/forms.py
+++ b/nautobot/dcim/forms.py
@@ -466,7 +466,6 @@ class LocationForm(NautobotModelForm, TenancyForm):
     parent = DynamicModelChoiceField(
         queryset=Location.objects.all(),
         query_params={"child_location_type": "$location_type"},
-        to_field_name="slug",
         required=False,
     )
     site = DynamicModelChoiceField(queryset=Site.objects.all(), required=False)


Test patch:
Repository: nautobot/nautobot

Issue:
Napalm Configuration Does Not Match Documentation
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Nautobot version (Docker tag too if applicable): 1.4.X
* Python version: 3.8
* Database platform, version: NA
* Middleware(s): NA

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. Deploy Nautobot with Napalm user pass & timeout in environment as specified [here](https://docs.nautobot.com/projects/core/en/stable/configuration/optional-settings/#napalm_username)
2. Attempt to use Napalm with configured ENV credentials

<!-- What did you expect to happen? -->
### Expected Behavior
The three settings are loaded into the django.conf.settings

<!-- What happened instead? -->
### Observed Behavior
The three settings inherit default and must be specified in nautobot_config caused by [this](https://github.com/nautobot/nautobot/blob/v1.4.5/nautobot/core/settings.py#L84-L86).

May be related to #2393


Discussion:

Resolving patch:
diff --git a/nautobot/core/settings.py b/nautobot/core/settings.py
--- a/nautobot/core/settings.py
+++ b/nautobot/core/settings.py
@@ -81,9 +81,9 @@
 
 # Napalm
 NAPALM_ARGS = {}
-NAPALM_PASSWORD = ""
-NAPALM_TIMEOUT = 30
-NAPALM_USERNAME = ""
+NAPALM_PASSWORD = os.getenv("NAUTOBOT_NAPALM_PASSWORD", "")
+NAPALM_TIMEOUT = int(os.getenv("NAUTOBOT_NAPALM_TIMEOUT", "30"))
+NAPALM_USERNAME = os.getenv("NAUTOBOT_NAPALM_USERNAME", "")
 
 # Plugins
 PLUGINS = []


Test patch:
Repository: nautobot/nautobot

Issue:
wrong link from circuit types to circuit
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Nautobot version (Docker tag too if applicable):  eee34d7bc54d (v1.4.5)
* Python version: 3.10
* Database platform, version: postgresql 14
* Middleware(s):

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. Create circuit type
2. Create circuit of above circuit type
3. Go to Circuit Types
4. Click one circuit type
5. Click number of circuits belonging to circuit type

<!-- What did you expect to happen? -->
### Expected Behavior
redirect to `circuits/circuits/?type=XXX`

<!-- What happened instead? -->
### Observed Behavior
redirects to `circuits/circuits/?circuit_type=XXX`
which shows an "Invalid filters were specified" error


Discussion:

Resolving patch:
diff --git a/nautobot/circuits/tables.py b/nautobot/circuits/tables.py
--- a/nautobot/circuits/tables.py
+++ b/nautobot/circuits/tables.py
@@ -12,10 +12,13 @@
 from .models import Circuit, CircuitType, Provider, ProviderNetwork
 
 CIRCUIT_TERMINATION_PARENT = """
+{% load helpers %}
 {% if value.provider_network %}
-<a href="{{ value.provider_network.get_absolute_url }}">{{ value.provider_network }}</a>
+{{ value.provider_network|hyperlinked_object }}
 {% elif value.site %}
-<a href="{{ value.site.get_absolute_url }}">{{ value.site }}</a>
+{{ value.site|hyperlinked_object }}
+{% else %}
+{{ None|placeholder }}
 {% endif %}
 """
 


Test patch:
Repository: nautobot/nautobot

Issue:
Support unix socket Redis connections in parse_redis_connection
### As ...

Isabella - Infrastructure Owner

### I want ...

to be able to use Redis cache via a unix socket connection that than a TCP connection

### So that ...

I can share sockets between docker containers rather than exposing ports (which is tricky to corporate environment)

### I know this is done when...

- I am able to start and run Nautobot with configuration for a unix socket and the application fully functions

### Optional - Feature groups this request pertains to.

- [ ] Automation
- [ ] Circuits
- [ ] DCIM
- [ ] IPAM
- [ ] Misc (including Data Sources)
- [ ] Organization
- [ ] Plugins (and other Extensibility)
- [ ] Security (Secrets, etc)
- [ ] Image Management
- [ ] UI/UX
- [ ] Documentation
- [ ] Other (not directly a platform feature)

### Database Changes

None

### External Dependencies

None


Discussion:

Resolving patch:
diff --git a/nautobot/core/settings_funcs.py b/nautobot/core/settings_funcs.py
--- a/nautobot/core/settings_funcs.py
+++ b/nautobot/core/settings_funcs.py
@@ -72,7 +72,9 @@ def parse_redis_connection(redis_database):
     """
     # The following `_redis_*` variables are used to generate settings based on
     # environment variables.
-    redis_scheme = "rediss" if is_truthy(os.getenv("NAUTOBOT_REDIS_SSL", "false")) else "redis"
+    redis_scheme = os.getenv("NAUTOBOT_REDIS_SCHEME")
+    if redis_scheme is None:
+        redis_scheme = "rediss" if is_truthy(os.getenv("NAUTOBOT_REDIS_SSL", "false")) else "redis"
     redis_host = os.getenv("NAUTOBOT_REDIS_HOST", "localhost")
     redis_port = int(os.getenv("NAUTOBOT_REDIS_PORT", "6379"))
     redis_username = os.getenv("NAUTOBOT_REDIS_USERNAME", "")
@@ -85,4 +87,7 @@ def parse_redis_connection(redis_database):
     if redis_username or redis_password:
         redis_creds = f"{redis_username}:{redis_password}@"
 
-    return f"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}"
+    if redis_scheme == "unix":
+        return f"{redis_scheme}://{redis_creds}{redis_host}?db={redis_database}"
+    else:
+        return f"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}"


Test patch:
Repository: nautobot/nautobot

Issue:
Increase VLAN `name`'s `max_length` to 255
Platforms such as Junos allow for VLAN names up to 255 characters long (https://www.juniper.net/documentation/us/en/software/junos/multicast-l2/topics/ref/statement/vlans-bridging-qfx-series.html#vlans-statement__d38584e1038). We should support this.


Discussion:

Resolving patch:
diff --git a/nautobot/ipam/migrations/0009_alter_vlan_name.py b/nautobot/ipam/migrations/0009_alter_vlan_name.py
new file mode 100755
--- /dev/null
+++ b/nautobot/ipam/migrations/0009_alter_vlan_name.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.16 on 2023-01-26 19:03
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("ipam", "0008_prefix_vlan_vlangroup_location"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="vlan",
+            name="name",
+            field=models.CharField(db_index=True, max_length=255),
+        ),
+    ]
diff --git a/nautobot/ipam/models.py b/nautobot/ipam/models.py
--- a/nautobot/ipam/models.py
+++ b/nautobot/ipam/models.py
@@ -1168,7 +1168,7 @@ class VLAN(PrimaryModel, StatusModel):
     vid = models.PositiveSmallIntegerField(
         verbose_name="ID", validators=[MinValueValidator(1), MaxValueValidator(4094)]
     )
-    name = models.CharField(max_length=64, db_index=True)
+    name = models.CharField(max_length=255, db_index=True)
     tenant = models.ForeignKey(
         to="tenancy.Tenant",
         on_delete=models.PROTECT,


Test patch:
diff --git a/nautobot/ipam/tests/test_api.py b/nautobot/ipam/tests/test_api.py
--- a/nautobot/ipam/tests/test_api.py
+++ b/nautobot/ipam/tests/test_api.py
@@ -546,7 +546,7 @@ def setUpTestData(cls):
         cls.create_data = [
             {
                 "vid": 4,
-                "name": "VLAN 4",
+                "name": "VLAN 4 with a name much longer than 64 characters to verify that we increased the limit",
                 "group": vlan_groups[0].pk,
                 "status": "active",
                 "site": vlan_groups[0].site.pk,
diff --git a/nautobot/ipam/tests/test_views.py b/nautobot/ipam/tests/test_views.py
--- a/nautobot/ipam/tests/test_views.py
+++ b/nautobot/ipam/tests/test_views.py
@@ -356,7 +356,7 @@ def setUpTestData(cls):
             "site": vlangroups[1].site.pk,
             "group": vlangroups[1].pk,
             "vid": 999,
-            "name": "VLAN999",
+            "name": "VLAN999 with an unwieldy long name since we increased the limit to more than 64 characters",
             "tenant": None,
             "status": status_reserved.pk,
             "role": roles[1].pk,
Repository: nautobot/nautobot

Issue:
Remove legacy `manage.py` 
<!--
    NOTE: This template is for use by maintainers only. Please do not submit
    an issue using this template unless you have been specifically asked to
    do so.
-->
### Proposed Changes

Simply remove `manage.py` from the project root.

<!-- Provide justification for the proposed change(s). -->
### Justification

This was left there initially in v1.0.0 as a fallback, however it is absolutely no longer needed.


Discussion:

Resolving patch:
diff --git a/manage.py b/manage.py
deleted file mode 100755
--- a/manage.py
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-
-from nautobot.core.cli import main
-
-
-if __name__ == "__main__":
-    main()


Test patch:
Repository: nautobot/nautobot

Issue:
Add index on ObjectChange -time
### As ...

Patti - Platform Admin

### I want ...

A DB index to be created on `ObjectChange` `-time`

### So that ...

The query used to used on the home page to find the 15 most recent records is optimized and does not take an inordinate amount of time to process, with large `ObjectChange` datasets.

### I know this is done when...

- The homepage loads quickly with 1 million+ object change records

### Optional - Feature groups this request pertains to.



### Database Changes

- Add index `ObjectChange` `-time`

### External Dependencies

_No response_


Discussion:
Durring analysis, it is likely also worth removing the join on the user table, since `ObjectChnage` already caches the `user_name` locally to cover cases where the user is deleted later.

Resolving patch:
diff --git a/nautobot/extras/homepage.py b/nautobot/extras/homepage.py
--- a/nautobot/extras/homepage.py
+++ b/nautobot/extras/homepage.py
@@ -14,7 +14,7 @@ def get_job_results(request):
 
 def get_changelog(request):
     """Callback function to collect changelog for panel."""
-    return ObjectChange.objects.restrict(request.user, "view").select_related("user", "changed_object_type")[:15]
+    return ObjectChange.objects.restrict(request.user, "view")[:15]
 
 
 layout = (
diff --git a/nautobot/extras/migrations/0056_objectchange_add_reverse_time_idx.py b/nautobot/extras/migrations/0056_objectchange_add_reverse_time_idx.py
new file mode 100644
--- /dev/null
+++ b/nautobot/extras/migrations/0056_objectchange_add_reverse_time_idx.py
@@ -0,0 +1,17 @@
+# Generated by Django 3.2.18 on 2023-03-10 21:50
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("extras", "0055_configcontext_dynamic_groups"),
+    ]
+
+    operations = [
+        migrations.AddIndex(
+            model_name="objectchange",
+            index=models.Index(fields=["-time"], name="extras_objectchange_rtime_idx"),
+        ),
+    ]
diff --git a/nautobot/extras/models/change_logging.py b/nautobot/extras/models/change_logging.py
--- a/nautobot/extras/models/change_logging.py
+++ b/nautobot/extras/models/change_logging.py
@@ -134,6 +134,10 @@ class Meta:
                 name="extras_objectchange_double_idx",
                 fields=["request_id", "changed_object_type_id"],
             ),
+            models.Index(
+                name="extras_objectchange_rtime_idx",
+                fields=["-time"],
+            ),
         ]
 
     def __str__(self):


Test patch: