如何使用Django-Bootstrap-Calendar添加日历事件? [英] How to add calendar events with Django-Bootstrap-Calendar?

查看:185
本文介绍了如何使用Django-Bootstrap-Calendar添加日历事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Django-Bootstrap-Calendar( https://github.com/sandlbn/django-bootstrap -calendar )是此日历应用程序的Django实现: http://bootstrap-calendar.azurewebsites .net /

Django-Bootstrap-Calendar (https://github.com/sandlbn/django-bootstrap-calendar) is a Django implementation of this calendar application: http://bootstrap-calendar.azurewebsites.net/

但是,我不知道如何通过Django向日历添加事件。 非Django启动日历非常简单,您只需将事件添加到要加载的JSON文件中即可。

However, I can't figure out how to add events to the calendar via Django. The "non-Django" bootstrap calendar is rather simple, you just add events to the JSON file that gets loaded.

这里有人将事件添加到Django-Bootstrap-Calendar中之前?我通过电子邮件给该项目的作者发送了电子邮件,但是他从未回复过我。

Has anyone here added events to Django-Bootstrap-Calendar before? I emailed the author of the project, however, he never responded to me.

我对问题发现的最接近的帖子是:获取可用于Django的bootstrap-calendar组件。但是,作者想出了如何

The closest post I found to my question is here: Getting a bootstrap-calendar component to work with Django However, the author figured out how to add entries to the non-Django calendar only.

编辑:我想出了如何通过管理面板添加事件。
在models.py中,只需添加:

I figured out how to add events via the Admin panel. In models.py, you simply add:

###Admin
class CalendarEventAdmin(admin.ModelAdmin):
    list_display = ["title", "url", "css_class", "start", "end"]
    list_filler = ["title"]

admin.site.register(CalendarEvent,CalendarEventAdmin)

然后,您可以在管理面板中添加事件(最终,我希望非管理员用户和匿名访问者能够在日历上注册事件。)

Then, in the admin panel you can add events (ultimately, I want non-admin users and anonymous visitors to be able to register events on the Calendar.)

但是,这揭示了一个更大的问题:日历不会显示。

However, this reveals a larger problem: the calendar doesn't display.

编辑2:现在通过添加

{% load bootstrap_calendar %}
{% bootstrap_calendar_css %}
{% bootstrap_calendar_js language="template" %}
{% bootstrap_calendar_init language="template" %}
<!-- {% bootstrap_controls 'optional-css-classes' %} -->
{% bootstrap_calendar 'optional-css-classes' %} 

到我的index.html文件。但是,日历不会显示使用管理面板创建的事件。

to my index.html file. However, the calendar doesn't display the event(s) created with the Admin Panel.

推荐答案

简单地放置

{% bootstrap_calendar_init language="template" %}

之后

{% bootstrap_calendar 'optional-css-classes' %} 

这篇关于如何使用Django-Bootstrap-Calendar添加日历事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆