[Answered ]-How change the size of the foreign key field in django admin?

1👍

#forms.py

from django.forms import ModelForm,TextInput,Select
from django.models import FullName

class FullNameForm(ModelForm):
    class Meta:
    model= FullName #Your Model Name
    fields = '__all__'

    

    widgets = {
        'first_name': TextInput(attrs={'size': '50'})),
        'last_name': Select(attrs={'size': '50'}))
    }

And in admin.py

from django.contrib import admin
from .models import FullName
from .forms import FullNameForm

class NameAdmin(admin.ModelAdmin):
    form = FullNameForm

admin.site.register(FullName, NameAdmin)

Leave a comment