django-admin

Using Django Admin Actions to send bulk emails

こ雲淡風輕ζ 提交于 2020-01-22 15:32:32
问题 I'm looking for a way to send bulk emails to users from a Django Admin Action. This is what I have thus far: class MyUserAdmin(UserAdmin): list_display = ['username', 'email', 'first_name', 'last_name', 'is_active', staff] list_filter = ['groups', 'is_staff', 'is_superuser', 'is_active'] actions = ['send_EMAIL'] def send_EMAIL(self, request, queryset): from django.core.mail import send_mail for i in queryset: if i.email: send_mail('Subject here', 'Here is the message.', 'from@example.com',[i

Django Grappelli Tabular Inline add new row TinyMCE textfield not editable

早过忘川 提交于 2020-01-22 13:39:25
问题 I am using django Grappelli skin for my project. I have a ModelAdmin with tabular inline function. I use extra = 0 to prevent auto insert blank row, when the page is loaded. It works fine. Now, when I click on the + sign to insert new row, the row is loaded, but the tinymce textfield is not editable. Anyone know what is the reasons and how to solve this problem? After reading the document: http://django-grappelli.readthedocs.org/en/latest/customization.html#using-tinymce I notice: Using

Adding a Log entry for an action by a user in a Django App

巧了我就是萌 提交于 2020-01-22 07:09:42
问题 I need to create a log entry for changes made by a user to the database via the views in my django application. I have enabled the django-admin module and I can retrieve the logs of the changes made using the admin interface like this: from django.contrib.admin.models import LogEntry from django.contrib.contenttypes.models import ContentType recentActions = LogEntry.objects.all() for each in recentActions: print 'Action:', each.action_flag.__str__() print 'Message:', each.object_repr print

Adding a Log entry for an action by a user in a Django App

有些话、适合烂在心里 提交于 2020-01-22 07:09:38
问题 I need to create a log entry for changes made by a user to the database via the views in my django application. I have enabled the django-admin module and I can retrieve the logs of the changes made using the admin interface like this: from django.contrib.admin.models import LogEntry from django.contrib.contenttypes.models import ContentType recentActions = LogEntry.objects.all() for each in recentActions: print 'Action:', each.action_flag.__str__() print 'Message:', each.object_repr print

Adding a Log entry for an action by a user in a Django App

孤者浪人 提交于 2020-01-22 07:09:03
问题 I need to create a log entry for changes made by a user to the database via the views in my django application. I have enabled the django-admin module and I can retrieve the logs of the changes made using the admin interface like this: from django.contrib.admin.models import LogEntry from django.contrib.contenttypes.models import ContentType recentActions = LogEntry.objects.all() for each in recentActions: print 'Action:', each.action_flag.__str__() print 'Message:', each.object_repr print

Django - How to save m2m data via post_save signal?

妖精的绣舞 提交于 2020-01-19 05:13:25
问题 (Django 1.1) I have a Project model that keeps track of its members using a m2m field. It looks like this: class Project(models.Model): members = models.ManyToManyField(User) sales_rep = models.ForeignKey(User) sales_mgr = models.ForeignKey(User) project_mgr = models.ForeignKey(User) ... (more FK user fields) ... When the project is created, the selected sales_rep , sales_mgr , project_mgr , etc User s are added to members to make it easier to keep track of project permissions. This approach

Django - How to save m2m data via post_save signal?

陌路散爱 提交于 2020-01-19 05:12:05
问题 (Django 1.1) I have a Project model that keeps track of its members using a m2m field. It looks like this: class Project(models.Model): members = models.ManyToManyField(User) sales_rep = models.ForeignKey(User) sales_mgr = models.ForeignKey(User) project_mgr = models.ForeignKey(User) ... (more FK user fields) ... When the project is created, the selected sales_rep , sales_mgr , project_mgr , etc User s are added to members to make it easier to keep track of project permissions. This approach

Django: why the manytomany choice box only has on side

社会主义新天地 提交于 2020-01-15 20:11:57
问题 I have extended the group model, where I added some manytomany fields, and in the admin page, it likes this: However, what I expected is this: Here is how I implemented the m2m field: class MyGroup(ProfileGroup): mobile = models.CharField(max_length = 15) email = models.CharField(max_length = 15) c_annotates = models.ManyToManyField(Annotation, verbose_name=_('annotation'), blank=True, null=True) c_locations = models.ManyToManyField(Location, verbose_name=_('locations'), blank=True, null=True

Django admin, override dropdown with selection from popup window

自作多情 提交于 2020-01-15 11:07:40
问题 In a one-to-many relationship, how can I override the drop-down menu in the change-form to be able to select value from popup window, specially when dropdown could hold a pretty long list which may slowdown the page load. 回答1: Just found the answer: raw_id_fields is a list of fields you would like to change into an Input widget for either a ForeignKey or ManyToManyField: class ArticleAdmin(admin.ModelAdmin): raw_id_fields = ("newspaper",) https://docs.djangoproject.com/en/1.6/ref/contrib

Permission denied in Django makemessages

断了今生、忘了曾经 提交于 2020-01-15 10:13:18
问题 I'm trying to add i8n into a Django app, but when I execute: (venv) user@machine:~/path/to/repo$ django-admin makemessages -l es The next error is thrown: PermissionError: [Errno 13] Permission denied: './venv/lib/python3.5/site-packages/Jinja2-2.9.5.dist-info/LICENSE.txt.py' But if I use it with manage.py instead of django-admin it works correctly. In django documentation they recommend to use django-admin. Any ideas? 回答1: Django's doc does not really "recommand" to use django-admin instead