I am trying to use Django-recurrence module. Without the javascript_catalog under "setting up internationalization" according to instruction :
# If you already have a js_info_dict dictionary, just add
# 'recurrence' to the existing 'packages' tuple.
js_info_dict = {
'packages': ('recurrence', ),
}
# jsi18n can be anything you like here
urlpatterns = patterns(
'',
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
)
All I see even before internationalization, is below: - The upper part of the reccurrence "javascript-image" is not showing. The green text part(Add Rule and Add date) is the only thing showing:
+Add rule+Add date
What I am expecting according to documentation is shown below:
app/urls.py
js_info_dict = {
'packages': ('recurrence', ),
}
urlpatterns = patterns(#'',
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
url(r'^room/$', CreateConfRoom_Sch.as_view(), name='CreateConfRoom_Sch'),
app/forms.py
class ScheduleConfRoom(ModelForm):
class Meta:
model = Schedule
fields = ('name', 'room', 'message', 'recurrences',)
widgets = {
'message': Textarea(attrs={'cols': 25, 'rows': 6}),
}
app/views.py
class CreateConfRoom_Sch(CreateView):
form_class = ScheduleConfRoom
template_name = "schedule.html"
success_url = '/'
app/models.py
class Schedule(models.Model):
name = models.CharField(max_length=30, default='Example')
room = models.ForeignKey(Room) # default='Empty')
message = models.CharField(max_length=918)
recurrences = RecurrenceField()
schedule.html
<form method="POST" action="{% url 'upload_file' %}" >
{% csrf_token %}
{{ form.media }}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
Please help!!! What did I do wrong? The error in the subject shows when I have the javascript_catalog in the urls.py. But When I don't have it, only "+Add Rule +Add date" shows.
AttributeError at /schedule/room/
'str' object has no attribute 'resolve'
Request Method: GET
Request URL: http://192.168.1.199:8000/schedule/room/
Django Version: 1.8.13
Exception Type: AttributeError
Exception Value: 'str' object has no attribute 'resolve'
Exception Location: /usr/local/lib/python3.4/site-packages/django/core/urlresolvers.py in resolve, line 367
Python Executable: /usr/local/bin/python3.4
Python Version: 3.4.4
Traceback Switch to copy-and-paste view
/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py in get_response
resolver_match = resolver.resolve(request.path_info)
...
▶ Local vars
/usr/local/lib/python3.4/site-packages/django/core/urlresolvers.py in resolve
sub_match = pattern.resolve(new_path)
...
▶ Local vars
/usr/local/lib/python3.4/site-packages/django/core/urlresolvers.py in resolve
sub_match = pattern.resolve(new_path)
...
▶ Local vars
First Trace
urlconf 'mal.urls'
middleware_method <bound method SecurityMiddleware.process_request of <django.middleware.security.SecurityMiddleware object at 0x8091b7a20>>
response None
resolver <RegexURLResolver 'mal.urls' (None:None) ^/>
self <django.core.handlers.wsgi.WSGIHandler object at 0x80836cc88>
Second trace
pattern <RegexURLResolver <module 'app.urls' from '/usr/home/msg/code/mal/app/urls.py'> (None:None) ^schedule/>
sub_tried None
new_path 'schedule/room/'
match <_sre.SRE_Match object; span=(0, 1), match='/'>
path '/schedule/room/'
tried [[<RegexURLResolver <RegexURLPattern list> (admin:admin) ^admin/>],
[<RegexURLResolver <module 'allauth.urls' from '/usr/home/msg/code/mal/allauth/urls.py'> (None:None) ^accounts/>],
[<RegexURLResolver <module 'app.urls' from '/usr/home/msg/code/mal/app/urls.py'> (None:None) ^upload/>]]
self <RegexURLResolver 'mal.urls' (None:None) ^/>
Third Trace
pattern 'app.views'
new_path 'room/'
match <_sre.SRE_Match object; span=(0, 9), match='schedule/'>
path 'schedule/room/'
sub_match None
tried [[<RegexURLPattern None ^jsi18n/$>]]
self <RegexURLResolver <module 'app.urls' from '/usr/home/msg/code/mal/app/urls.py'> (None:None) ^schedule/>
The locals
information of your traceback shows it tried to use the following string as a match pattern:
pattern 'app.views'
That string was taken from the urlpatterns
sequence in your app/urls.py
file, which you only posted part of.
In addition, you forgot the url
function on the first rule:
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
# ^ no url
That makes it just a tuple, and the first element is then expected to be a regular expression. Add in the url
call:
urlpatterns = patterns(#'',
url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
url(r'^room/$', CreateConfRoom_Sch.as_view(), name='CreateConfRoom_Sch'),
You'll need to fix all your rules however.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.