Greetings all, I'm working on a project, and I didn't like the default solid grey lines in each form-row, so I extended the change_form.html to remove them. However, in doing so, the autocomplete select2 field broke (raw_id_fields breaks as well). I've been looking for a workaround on this issue, and I don't know if it's a bug or not. If anyone has a workaround, I would appreciate hearing what it is (though I would prefer not to modify any files in the Django package). And, if anyone wants to replicate the issue, I've included a test case below, but please let me know if I forgot anything.
Any thoughts or help is greatly appreciated. Regards, Jason *Autocomplete_fields with **extended** change_form.html test* 1. Install Python (I have version 3.7.2 64 bit installed on Windows 10 Pro). 2. Run the following commands in your working directory: a. mkdir djangotest. b. cd bugtest c. python -m venv venv d. .\venv\scripts\activate e. django-admin startproject bugtest . f. python manage.py startapp testing g. python manage.py migrate 3. Update installed apps settings in .\djangotest\bugtest\settings.py INSTALLED_APPS = [ 'testing.apps.TestingConfig', # leave default apps... ] 4. Change .\djangotest\testing\models.py to the following: from django.db import models class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question_text class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) def __str__(self): return self.choice_text 5. Change .\djangotest\testing\admin.py to the following: from .models import Question, Choice class QuestionAdmin(admin.ModelAdmin): ordering = ['pub_date'] search_fields = ['question_text'] class ChoiceAdmin(admin.ModelAdmin): autocomplete_fields = ['question'] #raw_id_fields = ('question',) admin.site.register(Question, QuestionAdmin) admin.site.register(Choice, ChoiceAdmin) 6. Run the following commands: a. python manage.py migrate b. python manage.py makemigrations testing c. python manage.py migrate testing d. python manage.py createsuperuser (enter in info for testing superuser). e. python manage.py runserver 7. Open http://127.0.0.1:8000/admin/testing/choice/add/ in browser (I'm using Chrome version 73.0.3683.103 (Official Build) (64-bit)). 8. Verify that the foreign key field (question) is working as expected. 9. Create the following directories: .\djangotest\testing\templates, .\djangotest\testing\templates\admin 10. Create change_form.html file in .\djangotest\testing\templates\admin with the following information: {% extends "admin/change_form.html" %} {% block extrahead %} <style> .form-row { border-bottom: none; } </style> {% endblock %} 11. Reload http://127.0.0.1:8000/admin/testing/choice/add/ in browser. 12. Verify that foreign key field (question) is not working as expected. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e8a43eae-2f3c-4d6a-848b-02e3cce11ab1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.