Create several proxy models: class SharedBlog(Blog): class Meta: proxy = True verbose_name = 'shared blog' And override the get_queryset() method of the ModelAdmin: class SharedBlogAdmin(admin.ModelAdmin): def get_queryset(self, request): qs = super(SharedBlogAdmin, self).get_queryset(request) return qs.filter(shared=True) admin.site.register(SharedBlog, SharedBlogAdmin) ...
django,nginx,django-admin,django-imagekit,imagekit
Solution found. I was missing some libraries. apt-get install libjpeg-dev and reinstalling pillow fixed the error!...
Django makes this easy. Subclass ModelAdmin, add a custom method and then tell the Admin how to use it. Here's a sample admin.py: from django.contrib import admin from .models import Vendor class VendorAdmin(admin.ModelAdmin): readonly_fields = ['example_link'] def example_link(self, obj): return '<a href="{}">link text</a>'.format(obj.get_link()) # however you generate the link example_link.allow_tags...
python,django,django-models,django-admin
Maybe Inline Formsets is what you are looking for. Look at the docs for info and example.
python,django,django-models,django-admin
Easy school_name = "your school name" Students_in_school = Student.objects.filter(grade__school__name = school_name) Sorry I wrote this on Bus...
django,django-admin,foreign-key-relationship
You can do the following: models.py (example): model B(models.Model): name = models.CharField(max_length=20) model A(models.Model): field1 = models.CharField(max_length=20) Bkey = models.ForeignKey(B) admin.py from django.core import urlresolvers class AAdmin(admin.ModelAdmin): list_display = ["field1","link_to_B"] def link_to_B(self, obj): link=urlresolvers.reverse("admin:yourapp_B_change", args=[obj.B.id]) return u'<a href="%s">%s</a>' % (link,obj.B.name) link_to_B.allow_tags=True Replace yourapp with the name of your app....
Use the backward relation: X.number_of_people = X.people_set.all().count() ...
django,django-forms,django-admin
The most simple way is to implement author selection as a form with submit type GET and check the request.GET inside ModelAdmin class <form method="GET"> <select name="author"> <option>An author</option> </select> </form> def get_queryset(self, request): author = request.GET['author'] qs = super(BooksList, self).get_queryset(request) return qs.filter(author=author) ...
You can create custom view in the ModelAdmin or even in the admin site so there is no need to create an additional app.
python,django,django-admin,django-users
I suggest you try disabling simple_autocomplete. There appears to be a similar issue with django-ajax-selects.
django,django-admin,many-to-many,django-multiwidget
The only way I found was to use a new view for managing participants in the admin and add a link to it by overriding the default edit template.
django,django-models,django-admin
Your data in your database is incosistent with the choices. If you remove the choices field it should show the first strings in the choices iterable - it should show "d" and not "Display". The first element ist what is stored in the database (docu) So either you change the...
django,django-models,django-admin
I don't have enough reputation to add a comment, so I'll write here, even if this is not a real answer. It looks there's an open ticket on this topic: lookup_allowed fails to consider dynamic list_filter You can use two different workarounds to quickly solve this problem until it will...
twitter-bootstrap,django-admin,summernote
My bad. The summernote guide explicitly say that thing : from django_summernote.admin import SummernoteModelAdmin # Apply summernote to all TextField in model. class SomeModelAdmin(SummernoteModelAdmin): And i thought any field with text are TextField (so i thought CharField was a TextField...) Thank you all....
django,django-models,django-forms,django-admin
class ServiceForm(forms.ModelForm): class Meta: fields = '__all__' model = Service multi_work_place = MyMultiValueField() def save(self, commit=True): service = super(ServiceForm, self).save(commit=False) service.member_id = service.member.pk # here is the key command service.save() if self.cleaned_data['multi_work_place']: work_place = WorkPlace(**{ 'city': self.cleaned_data['multi_work_place'][0], 'street': self.cleaned_data['multi_work_place'][1], }) # when there is brand new object is created, there...
django,django-models,django-admin,django-authentication,django-custom-user
Try doing this might help def create_user(self,email, password=None,**kwargs): OR check these links might help you what you want. link1 link2...
python,django,django-admin,django-admin-filters
Firstly, you can use the applications api to get a list of models in your app, rather than inspecting the module's __dict__ In Django 1.8+, you can get a list of field names for a model using Model._meta.get_fields method. I've excluded the automatically generated id field, and you might find...
django,django-models,django-admin
Have you looked at this: https://docs.djangoproject.com/en/1.7/topics/db/models/#extra-fields-on-many-to-many-relationships and this: django: how does manytomanyfield with through appear in admin?...
python,django,angularjs,django-admin
as_view() returns the view function which you should call with the request parameter: def add_view(self, request, form_url='', extra_context=None): return ContractAdminView.as_view()(request) To add any custom view to the ModelAdmin you should override the ModelAdmin.get_urls() method. And to match with the admin layout UI your template can extend the admin/base_site.html template: {%...
django,django-admin,django-grappelli
Finally all I had to do is sign out and log in again to see the changes.
django,django-admin,django-modeltranslation
I think vt_title_en__gt= can do the job. Any non-empty string is greater than "".
python,django,django-models,django-admin,inline-formset
Don't use the inline for the tags. Regular M2M field will work in admin just fine. For more adequate M2M widget add the filter_horizontal property: class QuestionAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['text', 'tags']}), ] filter_horizontal = ['tags'] ... To create a Tag from the QuestionAdmin press the green +...
You can do that by overriding the admin css. You basically have to .vDateField , .vTimeField elements. Create a template admin/change_form.html in your templates folder. Add the following lines to that file {% extends "admin/change_form.html" %} {% block extrastyle %} .vDateField, .vTimeField{ display:block; } {% endblock %} Django picks up...
django,nginx,static,django-templates,django-admin
It looks like your STATIC_ROOT doesn't match the nginx's location /static/ alias. You're missing /var/
If I understand you correctly, you want to make a custom Admin Action? If so, start with the Django documentation for it. Then Have a look at these two use cases: Admin Action with parameters Admin Action with intermediate pages ...
I don't think you need to separately register the NoteInline admin template. Just register the PersonAdmin template and that should include your NoteInline
When you develop your own admin views, you should take a look into django´s decorators @login_required and @user_passes_test, and also the permission system. So you can handle what your user are able to do and what not. Have a look into the Django Docs https://docs.djangoproject.com/en/1.8/topics/auth/default/ Hope this helps....
python,django,django-models,django-forms,django-admin
Maybe I did not describe clearly. but djang-nested-inline helps a lot. This allows we edit foreignkey's foreignkey in same page and nested for deep level....
I assume that your app is called app and question field of the Answer model is named question :-) from django.core.urlresolvers import reverse class QuestionAdmin(admin.ModelAdmin): list_display = ['question', 'date', 'view_answers'] def view_answers(self, obj): url = reverse("admin:app_answer_changelist") return '<a href="%s?question=%d">View answers</a>' % (url, obj.pk) view_answers.short_description = 'View answers' view_answers.allow_tags = True...
python,django,django-admin,django-grappelli
Remove: # Proxy the static assests for the Django Admin panel location /static/admin { alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/; } from your nginx conf. It overrides Django's way of finding static files for apps and breaks Grappelli. Remember to reload nginx afterwards....
javascript,python,twitter-bootstrap,django-admin,postgis
Two problems were describ and sorry for the poor lisibility. So here some answers : 1 - The DateField and Timefield seems to be issued and this will be fix : Fix 168 (last update 3 days ago) 2 - My PointField show up correctly after adding this options to...
Change your model / admin / form like this class Transaction(models.Model): card_name = models.CharField() card_number = models.CharField(max_length=40) expire_date = models.DateTimeField() card_code = models.CharField(max_length=10) class TransactionForm(forms.ModelForm): card_number = CreditCardField(required=True) expiry_date = ExpiryDateField(required=True) card_code = VerificationValueField(required=True) class Meta: model = Transaction fields = "__all__" class TransactionAdmin(admin.ModelAdmin): form = TransactionForm...
You need to register the admin class as well as the model. admin.site.register(MyModel, MyModelAdmin) ...
Ok, very interesting... found it and feeling foolish now. I put some prints throughout the Django admin and core code and discovered that my problem was coming from within the call... `related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)` found inside django/contrib/admin/widgets.py. reverse() in an effort to craft the URL for my...
This is an area where we're struggling with as well. Your example is quite suitable for sorting, as you limit the list to a single language using .translated(..). To sort things, you can follow the standard ModelAdmin logic, where the list is filtered: class MyAdmin(admin.ModelAdmin): list_display = ('title_column', ...) def...
django,django-models,django-admin,django-views
You can try like this: Journey.objects.all().order_by('schedule__journey') The format for querying child model field/reverse lookup is like this: ParentModel.objects.all().order_by('lowercase_child_modelname__fieldname)') For details, check here: https://docs.djangoproject.com/en/1.7/topics/db/queries/#lookups-that-span-relationships...
You can output the name in the list using the ModelAdmin's method with the defined admin_order_field property: class ModelClassAdmin(admin.ModelAdmin): list_display = ('get_name', 'email') def get_name(self, obj): return obj.name get_name.short_description = 'name' get_name.admin_order_field = 'nickname' ...
Ended up ditching save_as all together and wrote an admin action that properly copies all the fields I need... actions = ['duplicate'] from copy import deepcopy def duplicate(self, request, queryset): for obj in queryset: obj_copy = deepcopy(obj) obj_copy.id = None obj_copy.save() for question in obj.question_set.all(): question_copy = deepcopy(question) question_copy.id =...
If you have to just call on template the do_a_thing this should work. {% if model.object_name == 'Schedule' %} <a href="{{ model.do_a_thing }}" class="custom-class">{% trans 'Do a thing' %}</a> {% endif %} And in model class Schedule(models.Model): active = models.BooleanField(default=True, null=False) price = models.DecimalField(max_digits=10, decimal_places=2, null=False) price_percent_lower = models.DecimalField(max_digits=2, decimal_places=1,...
jquery,django,django-forms,django-admin
The way the widget is written initializes it only on page load, so additional widgets that you add do NOT get initialized. The way to handle this is to link into the "added" event generated by the django dynamic formets. The following code I think will only work if you...
python,django,django-models,django-admin,exclude
I was using Django 1.6 which did not support overriding the get_fields method. Updated to 1.7 and this method worked perfectly.
python,django,django-models,django-admin
Assuming you're using the stock User class, "Users" isn't a field on that class, so that won't work. I think using users__username as a search field will work, but have not tested....
python,django,django-models,django-forms,django-admin
Select2 is very handy to deal with such situation. You may check packages for Select2 integration with Django. django-select2 and django-easy-select2 both are good option to consider....
django,django-admin,django-settings
Make sure you have added 'django.contrib.sites' to your INSTALLED_APPS, then run migrate to create the required table. python manage.py migrate ...
django,templates,django-admin,customization
change_form.html contains the following url tag: {% url 'admin:app_list' app_label=opts.app_label %} So you should pass the opts variable to the template context: data = {'test': 'test', 'opts': MyModel._meta} UPDATE: The change_form.html template uses the {% submit_row %} template tag which requires some other context variables so the data dictionary should...
javascript,jquery,ajax,django,django-admin
In a similar situation I did the following (now adapted to your model): models class Person(models.Model): name = models.CharField(max_length=20) def __unicode__(self): return self.name def get_name(self): return self.name class Contract(models.Model): person = models.ForeignKey(Person) #person hired contract_mod = models.OneToOneField('self', blank = True, null = True) contract_name = models.CharField(max_length=20) #just for testing def...
In your list_display, add userprofile list_display = ('email', 'first_name', 'last_name','userprofile') ...
python,django,django-models,django-admin,django-custom-user
REQUIRED_FIELD = ['username'] Should change to: REQUIRED_FIELDS = ['username'] ...
Try this class PageAdmin(admin.ModelAdmin): form = PageModelForm inlines = [FileInLine] def get_formsets_with_inlines(self, request, obj=None): for inline in self.get_inline_instances(request, obj): if isinstance(inline, FileInLine) and obj is None: continue yield inline.get_formset(request, obj), inline https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_formsets_with_inlines...
You could use custom changeform template: See https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/change_form.html And override: {% block after_field_sets %} <your button goes here> {% endblock %} Documentation: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates...
Something like this should work: from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User class UserCreateForm(UserCreationForm): class Meta: model = User fields = ('username', 'first_name' , 'last_name', ) class UserAdmin(UserAdmin): add_form = UserCreateForm prepopulated_fields = {'username': ('first_name' , 'last_name', )} add_fieldsets = (...
The model is saved in the ModelAdmin.save_model() method. You can unregister the default admin for the User model and register with your own ModelAdmin with overriden save_model(): from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User class MyUserAdmin(UserAdmin): def save_model(self, request, obj, form, change): # do whatever you want. # obj...
python,django,django-admin,django-admin-actions
If you want to make the field read-only during creation you should do it the other way round: def get_readonly_fields(self, request, obj=None): if obj is None: return ['headline '] return [] ...
python,django,python-2.7,django-admin
I have found the answer myself by referencing this link Inline Form Validation in Django The complete solution is: forms.py class StaffInLineFormSet(forms.models.BaseInlineFormSet): def clean(self): count = 0 for form in self.forms: try: if form.cleaned_data.get('is_team_coord') is True: count += 1 except AttributeError: pass if count == 0: raise forms.ValidationError('You must choose...
In django 1.8 you should add arguments to you command: class Command(BaseCommand): ... def add_arguments(self, parser): parser.add_argument('username') parser.add_argument('password') add_argument() method of argparse is documented here. UPDATE: By default arguments are passed in the options parameter so the handle() method should look like this: def handle(self, *args, **options): username = options['username']...
python,django,django-models,django-admin,exclude
I had a previous method suggested of overriding the get_fields method. This method did not work at all originally because I was using Django 1.6.2 version and this did not support overriding the get_fields method. I upgraded to 1.7 , and overriding the get_fields worked
django,django-admin,django-users,user-object
Only If your User object need more than primary attributes like Nick Name, Skype or Phone No, etc... whatever. In this case you can extend to use your own User object by creating ... class Profile(Model): user = models.ForeignKey(User) nike_name = models.CharField(max_length=200) For more details User Object...
django,django-models,django-forms,django-admin,manytomanyfield
The answer suggested by @GwynBleidD is showing error that list_display can not have manytomany field. however I got a workaround by removing those five fields from the list. Now it's working.
Create a method which will return the desired fields and add the name of this method to the list_display: class ContributionAdmin(admin.ModelAdmin): list_display = ('id','nlcc','subscriber','application_number', 'date','receipt_number','amount', 'status') def application_number(self, obj): return obj.subscriber.application_number application_number.short_description = "Subscriber's Application Number" UPDATE: If you want to see the name and the application_number in the select...
django,django-admin,django-modeladmin
As for me it's better to override changelist_view method of admin.ModelAdmin: class EntityModelAdmin(admin.ModelAdmin): list_display = ('name', 'barcode', 'short_code', ) list_editable = ('barcode', 'short_code', ) @csrf_protect_m def changelist_view(self, request, extra_context=None): """ The 'change list' admin view for this model. Overrided only for add support of edit/view mode switcher. """ ...parent code......
django,django-models,django-admin
I believe you are looking for admin.InlineModelAdmin.fk_name. (https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin.fk_name)
python,django,sqlite,django-admin,django-admin-filters
I found out the answer. If you are filtering on one reverse ForeignKey relationship (apps__category in this case) everything works fine. But I forgot to mention that I am combining two filters at the right side of Django admin page - the other one is also a reverse ForeignKey -...
Ok what I did that worked was using from django.core.validators import MaxValueValidator: id_student = models.PositiveIntegerField(primary_key=True, validators=[MaxValueValidator(9999999999)]) Cheers....
python,django,django-models,django-admin,django-admin-tools
Permissions on a model can be managed dynamically in ModelAdmin. Override the methods has_add-permission, has_change_permission and has_delete_permission. class MyModelAdmin(admin.ModelAdmin): def has_add_permission(self,request): # if request satisfies conditions: # return True #else: # return False Same goes for other two methods. This works for superusers also. If you revoke all three permissions...
django,django-models,django-admin
This is what you should have in admins.py: from django.contrib import admin from models import Author, Book class BookInline(admin.StackedInline): model = Book class AuthorAdmin(admin.ModelAdmin): inlines = [ BookInline ] admin.site.register(Author, AuthorAdmin) admin.site.register(Book) You probably forgot to include 'AuthorAdmin' in this line: admin.site.register(Author, AuthorAdmin) ...
python,django,django-models,django-admin
Figured it out (w the help of AbhiP!) Python int typecasting was the main culprit. Stupid problem to have! Below is what worked, and allowed me to not save the calculated field (but display it and make it act like a field in the model): @property def yield_num(self): if self.starts...
First, give your button a unique name: {% if show_save_as_draft %} <input type="submit" value="{% trans 'Save as draft' %}" class="default" name="_save_as_draft" /> {% endif %} Then, in your ModelAdmin you can override the save_model() method: class MyModelAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): if '_save_as_draft' in request.POST.keys(): # Do your...
One way is to write a custom template tag that will fetch data from the db and render the output however you want it. https://docs.djangoproject.com/en/1.7/howto/custom-template-tags/#writing-custom-template-tags Potential drawbacks are that the database query will be run every single time your Django-admin index page is requested. A better way would be to...
The short answer is no. For more details, just read this ticket
python,django,ubuntu,django-admin
You have misspelled startproject as startprojekt. Try: django-admin startproject mysite ...
In Python, sets are unordered. You can try return [(ac, ac) for ac in sorted(act)] ...
django,django-models,django-admin
Try: when_first_upload = models.DateTimeField(default=datetime.datetime.now) You need the callable itself, not the result returned by it....
python,django,django-admin,foreign-keys
Use the InlineModelAdmin: class BookInline(admin.TabularInline): model = Book class PersonAdmin(admin.ModelAdmin): inlines = [BookInline] ...
django,database,django-templates,django-admin
You can't override ModelAdmin.get_queryset() because it is used in the edit/delete views. So you have to inherit ChangeList class and override get_queryset() in it: from django.contrib import messages from django.contrib.admin.views.main import ChangeList class MyChangeList(ChangeList): def get_queryset(self, request): queryset = super(MyChangeList, self).get_queryset(request) if not request.GET.get('q', ''): messages.add_message(request, messages.INFO, 'Start typing.') queryset...
The import is not available in Django 1.8. You can give it a try and import related from the original source. Change batchimport/utils.py like: from django.db.models import get_model from django.db.models.fields import AutoField, related If that works, please also notify the author of django-batchimport!...
You need to add app_label to Meta class of MyUser. class MyUser(AbstractUser): pass class Meta: app_label = 'auth' Official documentation on app_label....
The images field on your BlogWidgetCarousel is a ManyToManyField, which returns a queryset of Image objects. So, first, you need to see if you have any image instances to display, and then grab the first one, or whichever you want to use: class Image(models.Model): . . . def thumb(self): return...
django,django-models,foreign-keys,django-admin
Update The code I posted earlier was wrong! I didn't read your models too carefully. Sorry about that. If you want to create CharacterSeries and CharacterUniverse while you create/edit the Character, you could do this: from django.contrib import admin from .models import Character, CharacterUniverse, CharacterSeries # No need to define...
python,django,django-models,django-admin
You should define the admin in the market/admin.py file instead of market/__init__.py.
django,django-models,django-forms,django-admin
Well, I'll show my a bit dirty way to achieve this. I've overrided/created changeform_view of admin.ModelAdmin and corresponding functions/templates: get_rel_fieldsets, change_form.html maybe something else... The code below is designed for use with categories, which can inherit some parameters from ancestors (shown as ro) and specify themselves parameters (shown as rw)....
What exactly I guess , you are trying to get name of foreign key field related to particular modeladmin . you should use save_formset fields in ModelAdmin , and find the foreign key name here. all_formset_forms = formset.forms This will return all inline forms of current form you are trying...
python,django,django-models,django-admin
Then in this case the super class Question should be an abstract class: class Question(models.Model): question_package = models.ManyToManyField(QuestionPackage, blank=True) name = models.CharField(max_length=128) answer = models.TextField() class Meta: abstract = True https://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes More info here Django Admin Interface Does Not Use Subclass's __unicode__()...
django,django-forms,django-admin,django-filter
Generally speaking I would say that it's better to create a custom view for this purpose (in a public section of the site). But if you prefer to use admin then you can try get_queryset method. For example if you want to show all posts to admins and their own...
ajax,django,python-3.x,django-admin
Its definitely possible to have dynamic fields in django admin using javascript. For a good example, I would suggest django-smart-selects and django-admin-flexselect. https://github.com/digi604/django-smart-selects https://github.com/runekaagaard/django-admin-flexselect...
django,django-admin,django-permissions,django-wsgi
Your Apache user does not have the rights needed to write to your database. Modify your settings.py so that it shows an absolute path for your database, for example: DATABASE_NAME = '/var/www/dashboardapp/whatever/path/db.sqlite3' Then type the following commands at the Linux prompt to set the correct privileges: chown www-data /var/www/dashboardapp/whatever/path/ chown...
django,csv,django-admin,django-admin-actions
Couple of ways to do this. You can use django-report-builder which is a pretty neat tool. Other ways are using custom views to admin site (check Django AdminPlus), overwrite queryset and use custom admin action etc....
django,django-admin,django-1.7
The ModelAdmin.change_view() method has a different signature: def change_view(self, request, object_id, form_url='', extra_context=None): extra = extra_context or {} extra['filter_form'] = FilterForm() return super(ProcessAdmin, self).change_view(request, object_id, form_url, extra_context=extra) ...
python,django,django-forms,django-admin,django-authentication
phew, I had to add something like this: AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) ...
What if you try to sort it: queryset.order_by('group').first() Or get the latest('group') or earliest('group') value. You may also find usable reverse() or -group for descending direction, or [:2] for multiple values....
python,django,django-models,django-admin
There's nowhere to save is_active to, since you haven't assigned a database field to it. You should change the is_active in your model to: is_active = models.BooleanField(default=False) ...
python,django,orm,django-admin
Django by itself doesn't provide access to the database-level users / groups / permissions, because it doesn't make much sense for a typical web application where all connections will be made with the same database user (the one defined in settings.DATABASES). Note that it's not a shortcoming be really the...
python,django,django-models,django-admin
Adding brand to prepopulated_fields dictionary only returns id not str/unicode value. class ProductAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('brand', 'name',)} One way to do is adding save_model method ModelAdmin from django.utils.text import slugify class ProductAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): # don't overwrite manually set slug if form.cleaned_data['slug'] == "": obj.slug...
django,django-forms,django-admin
Here is a simple example. If your model.py looks like: class YourCategory(models.Model): category_name = models.CharField(max_length=100) def __unicode__(self): return self.category_name class YourModel(models.Model): name = models.CharField(max_length=100) included_categories = models.ManyToManyField(Category) def __unicode__(self): return self.name You override in the admin the field you want as multiplechoice: class YourModelForm(forms.ModelForm): included_categories = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple(),...
python,django,django-models,django-forms,django-admin
Override the form's __init__ method and set the initial property of the field: class YourModelForm(forms.ModelForm): extra_field = forms.CharField() def __init__(self, *args, **kwargs): super(YourModelForm, self).__init__(*args, **kwargs) initial = '%s*rnd' % self.instance.pk if self.instance.pk else 'new' self.fields['extra_field'].initial = initial ...
You can override the default form for the TopicAdmin and set a required queryset for the creator field: class TopicForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(TopicForm, self).__init__(*args, **kwargs) self.fields['creator'].queryset = User.objects.filter(is_superuser=True) class TopicAdmin(admin.ModelAdmin): form = TopicForm ... But may be the raw_id_fields attribute of the ModelAdmin is the better option for...