田中と申します。
djangoの管理画面でのtimestampにてわからないことがありまして質問させていただきます。
下記のような Django のモジュール知っている方いらしたらご紹介いただけないでしょうか
1 管理画面でtimestampの日付の範囲でデータを CSV に吐き出しをしたい。
2 管理画面のUIにカレンダーが出てきて区間を指定できるような方法が望ましいです。
上記を解決するモジュールありませんでしょうか 。
ご存知でしたら教えていただけると幸いです 。
宜しくお願い致します。
import csvfrom django.contrib import adminfrom django.http.response import HttpResponsefrom rangefilter.filter import DateRangeFilterfrom .models import Bookdef export_as_csv(modeladmin, request, queryset):meta = modeladmin.model._metafield_names = [field.name for field in meta.fields]response = HttpResponse(content_type='text/csv')response['Content-Disposition'] = f'attachment; filename={meta.label_lower}.csv'writer = csv.writer(response)writer.writerow(field_names)for obj in queryset:writer.writerow([getattr(obj, field) for field in field_names])return responseexport_as_csv.short_description = "CSVエクスポート"class BookAdmin(admin.ModelAdmin):list_filter = (('published_at', DateRangeFilter),)actions = (export_as_csv,)admin.site.register(Book, BookAdmin)
2019/02/22 16:49、Jun Tanaka <tna...@gmail.com>のメール:
--
----------------- http://djangoproject.jp/ -----------------
You received this message because you are subscribed to the Google Groups "django-ja" group.
To post to this group, send email to djan...@googlegroups.com
To unsubscribe from this group, send email to django-ja-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-ja
---
このメールは Google グループのグループ「django-ja」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには django-ja+...@googlegroups.com にメールを送信してください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。