Show a ManyToManyField as Checkboxes in Django Admin

From this answer it seems like it is possible to use ModelAdmin.formfield_overrides to override the ManyToManyField to use CheckBoxSelectMultiple: from django.db import models from django.contrib import admin from django.forms import CheckboxSelectMultiple class MyModelAdmin(admin.ModelAdmin): formfield_overrides = { models.ManyToManyField: {‘widget’: CheckboxSelectMultiple}, } I haven’t tried it and am merely quoting from the source, but it seems plausible. … Read more

Django Admin ManyToManyField

Hmm, I don’t think you want inlines here. You want to be using the Django admin’s filter_horizontal: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_horizontal class ProfileAdmin(UserAdmin) filter_horizontal = (‘opetest’,) That will give you the widget that you’re describing, used to add/remove Groups on the User Change page. Ok, based on your edits, updated answer – basically, what we have is a … Read more

Django migration error :you cannot alter to or from M2M fields, or add or remove through= on M2M fields

I stumbled upon this and although I didn’t care about my data much, I still didn’t want to delete the whole DB. So I opened the migration file and changed the AlterField() command to a RemoveField() and an AddField() command that worked well. I lost my data on the specific field, but nothing else. I.e. … Read more

Direct assignment to the forward side of a many-to-many set is prohibited. Use emails_for_help.set() instead

You need to get the User object and then add it to emails_for_help field. You can’t add an object to ManyToManyField when creating an instance. Have a look at the doc. class Set_user(FormView): template_name=”pkm_templates/set_up_user.html” form_class = Set_User_Form success_url=”/thanks/” def form_valid(self, form): org = form.cleaned_data.get(‘organization’) emails = form.cleaned_data.get(“share_email_with”) users = User.objects.filter(email__in=emails) instance = Setupuser.objects.create(organization=org) for user … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)