Re: Translation is not working for Template even though po and mo files are created
Sorry, ~/django-swingtime/django-swingtime-master/demo should be the project path where project level translation files were generated under ~/django-swingtime/django-swingtime-master/demo/locale. The project level locale files should also be recognized, right? The application path should be ~/django-swingtime/django-swingtime-master/demo/karate. Br Sean On Sunday, November 1, 2015 at 6:09:02 PM UTC+8, Andréas Kühne wrote: > > Hi Sean, > > That's interesting. You shouldn't have to add the locale paths explicitly. > Good that it's wokring, but as long as you put the locale files in a > directory named locale under each app and also under the project, it should > just work (as long as all apps are included in the config). Just check so > that you follow the correct way of setting up a project. > > Regards, > > Andréas > > 2015-11-01 4:27 GMT+01:00 Sean Xu: > >> The translation for my template finally gets to work after I explicitly >> have LOCALE_PATHS configured in settings.py! >> Thanks very much for providing the hint :) >> >> Actually the models and template come from different applications: >> >> ~/django-swingtime/django-swingtime-master/swingtime # Models come from >> this swingtime application where translation worked. >> >> ~/django-swingtime/django-swingtime-master/demo # Templates come from >> this demo application where translation didn't work previously. (I'm >> running the server from demo folder actually... >> '~/django-swingtime/django-swingtime-master/demo> python manage.py runserver >> ') >> It's weird demo was not recognized while swingtime was recognized for >> translation, though. >> >> Br >> Sean >> >> On Friday, October 30, 2015 at 9:47:53 PM UTC+8, Andréas Kühne wrote: >>> >>> Hmmm >>> >>> I'm a bit at a loss here. But does Django know where to find the .mo >>> files? Is it only your template that isn't getting translated, because you >>> said that the form itself is? >>> >>> Regards, >>> >>> Andréas >>> >>> 2015-10-30 12:45 GMT+01:00 Sean Xu : >>> Now I have corrected the orders of each Middleware class and removed the duplicated SessionMiddleware: MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) I also added django.core.context_processors.i18n as one of the context processors. (I just realized that I'm using Django version 1.7 something so django.template.context_processors.i18n should really be django.core.context_processors.i18n). But unfortunately the translation for my template still does not work :( On Friday, October 30, 2015 at 7:27:36 PM UTC+8, Sean Xu wrote: > > Hi Andréas, > > Thanks very much for providing the help. > Currently the middleware classes are configured like this: > > MIDDLEWARE_CLASSES = ( > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.middleware.locale.LocaleMiddleware', > 'django.contrib.messages.middleware.MessageMiddleware', > ) > > I guess the order of these middleware is not correct because > LocaleMiddleware should come before CommonMiddleware. > > I have LANGUAGES defined in settings.py like this: > from django.utils.translation import ugettext_lazy as _ > > ... > LANGUAGES = ( > ('zh', _('Chinese')), > ('en', _('English')), > ) > And I don't have django.template.context_processors.i18n defined for > TEMPLATE_CONTEXT_PROCESSORS in settings.py. Do I need to add this i18n > context processor to settings.py? > > Br > Sean > > On Friday, October 30, 2015 at 6:07:21 PM UTC+8, Andréas Kühne wrote: >> >> Hi, >> >> Have you made sure that you have activated the languages you want in >> your application? >> Also, how is the current language being selected? >> See: >> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference >> >> Regards, >> >> Andréas >> >> 2015-10-30 7:45 GMT+01:00 Sean Xu : >> >>> Hi, >>> >>> I'm learning Django Translation using django-swingtime with Django >>> 1.7.9 installed. >>> I followed the official docs and embedded my string to translate >>> with {% trans "String to translate" %} in my Template >>> and >>> managed to create both the po and mo files successfully. >>> But, the page is still shown up in
jquery and django template
I basically have the database entries in the namespace of my template.I basically need to get the filter i want to apply on the databse entry using data available from user selection(using jquery).Any suggestions on how i can achieve this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0586c80e-30dd-4e08-b805-80094a8e7e04%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Jquery and templates
I basically want to run a jquery script that gets data of an html tag and then use that value to query the database.Any suggestions would be very helpful! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2790c31b-11f7-4ab4-b971-75be965a3e1f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Wherenode?
thanks a lot! On Wednesday, October 28, 2015 at 11:09:27 PM UTC+5:30, Tim Graham wrote: > > GitHub has a nice feature that allows you to search a repository: > > https://github.com/django/django/search?utf8=%E2%9C%93=WhereNode > > On Wednesday, October 28, 2015 at 1:32:40 PM UTC-4, varun naganathan wrote: >> >> Can anybody please explain what a django WhereNode is? Also provide any >> possible references/docs if available including its implementation in the >> source code! Thanks. >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5f4b1a77-6ab7-4731-851d-2856b1ebce04%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
model Field subclass + validation
Hi folks, I asked a question on StackOverflow and I don't know if it will get any answers because it is quite specific. I would like to subclass a JSONField implementation to add some custom validation logic and don't really know where to start. I would really appreciate if anyone could help out by either answering here or on SO. Here is the full question text: https://stackoverflow.com/questions/33460690/django-models-add-validation-to-custom-field Best, Luke -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5636656C.6060401%40riseup.net. For more options, visit https://groups.google.com/d/optout.
How do I let forms.models.ModelChoiceField.queryset relate on request.user?
User should see only choices related to him in a ModelChoiceField. Do I need a fresh form per request? What would be the best approach? Thanks, Axel --- PGP-Key:29E99DD6 ☀ +49 160 9945 7889 ☀ computing @ chaos claudius -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/728C3EDF-62BB-4450-920B-BB7376417D9C%40Chaos1.DE. For more options, visit https://groups.google.com/d/optout.
Re: Django templates
The templates work on any platform, try Django cookie cutter! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9bf391d4-aba5-4dfd-ba1a-2000e88771b2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Django bootstrap3_datetime widget in admin site doesn't pass form data
I'm trying to replace the standard AdminSplitDateTime widget in my admin site for better functionality (basically I want to display only 'available' dates in my calender which I couldn't find how to do with the default picker). I decided to use the bootstrap3_datetime widget. After overriding my field to use the new widget, it doesn't seem to be transferred into the 'clean' method (isn't in self.cleaned_data) for validation. *models.py* publish_time = models.DateTimeField('Date to publish') *admin.py* class MyForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) bad_dates = [] #populating bad_dates with application logic def clean(self): # This will always return None when using the new widget. # When working with the default widget, I have the correct value. publish_time = self.cleaned_data.get('publish_time', None) publish_time = forms.DateTimeField(widget=DateTimePicker(options= {"format": "DD-MM- HH:mm", "startDate": timezone.now().strftime('%Y-%m-%d'), "disabledDates": bad_dates, }) class MyModelAdmin(admin.ModelAdmin): form = MyForm admin.site.register(MyModel, MyModelAdmin) HTML-wise, the widget works well and the text field is populated with the correct date (and with the 'bad_dates' disabled). The problem is that it seems it isn't saved on the form. I also tried initializing the widget in the init method by doing: self.fields['publish_time'].widget = DateTimePicker(options=...) But the result was the same. I've analysed the POST request that is sent using each of the widgets. In the default admin widget, I see that it generates two fields: "publish_time_0" (for date) and "publish_time_1" (for time). In the bootstrap3 widget, only a single "publish_time" field is sent. I'm assuming that the admin site understands that the field is a DateTimeField (from models), looks for id_0 and id_1 and that's why it fails. Does that make sense? Is there anyway around it? Thanks a lot! Ilia -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/21215bea-1acb-4f95-b77e-9c00601be69c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Translation is not working for Template even though po and mo files are created
Hi Sean, That's interesting. You shouldn't have to add the locale paths explicitly. Good that it's wokring, but as long as you put the locale files in a directory named locale under each app and also under the project, it should just work (as long as all apps are included in the config). Just check so that you follow the correct way of setting up a project. Regards, Andréas 2015-11-01 4:27 GMT+01:00 Sean Xu: > The translation for my template finally gets to work after I explicitly > have LOCALE_PATHS configured in settings.py! > Thanks very much for providing the hint :) > > Actually the models and template come from different applications: > > ~/django-swingtime/django-swingtime-master/swingtime # Models come from > this swingtime application where translation worked. > > ~/django-swingtime/django-swingtime-master/demo # Templates come from > this demo application where translation didn't work previously. (I'm > running the server from demo folder actually... > '~/django-swingtime/django-swingtime-master/demo> python manage.py runserver > ') > It's weird demo was not recognized while swingtime was recognized for > translation, though. > > Br > Sean > > On Friday, October 30, 2015 at 9:47:53 PM UTC+8, Andréas Kühne wrote: >> >> Hmmm >> >> I'm a bit at a loss here. But does Django know where to find the .mo >> files? Is it only your template that isn't getting translated, because you >> said that the form itself is? >> >> Regards, >> >> Andréas >> >> 2015-10-30 12:45 GMT+01:00 Sean Xu : >> >>> Now I have corrected the orders of each Middleware class and removed the >>> duplicated SessionMiddleware: >>> MIDDLEWARE_CLASSES = ( >>> 'django.contrib.sessions.middleware.SessionMiddleware', >>> 'django.middleware.locale.LocaleMiddleware', >>> 'django.middleware.common.CommonMiddleware', >>> 'django.contrib.auth.middleware.AuthenticationMiddleware', >>> 'django.contrib.messages.middleware.MessageMiddleware', >>> ) >>> I also added django.core.context_processors.i18n as one of the context >>> processors. (I just realized that I'm using Django version 1.7 something so >>> django.template.context_processors.i18n should really be >>> django.core.context_processors.i18n). >>> But unfortunately the translation for my template still does not work :( >>> >>> On Friday, October 30, 2015 at 7:27:36 PM UTC+8, Sean Xu wrote: Hi Andréas, Thanks very much for providing the help. Currently the middleware classes are configured like this: MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) I guess the order of these middleware is not correct because LocaleMiddleware should come before CommonMiddleware. I have LANGUAGES defined in settings.py like this: from django.utils.translation import ugettext_lazy as _ ... LANGUAGES = ( ('zh', _('Chinese')), ('en', _('English')), ) And I don't have django.template.context_processors.i18n defined for TEMPLATE_CONTEXT_PROCESSORS in settings.py. Do I need to add this i18n context processor to settings.py? Br Sean On Friday, October 30, 2015 at 6:07:21 PM UTC+8, Andréas Kühne wrote: > > Hi, > > Have you made sure that you have activated the languages you want in > your application? > Also, how is the current language being selected? > See: > https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference > > Regards, > > Andréas > > 2015-10-30 7:45 GMT+01:00 Sean Xu : > >> Hi, >> >> I'm learning Django Translation using django-swingtime with Django >> 1.7.9 installed. >> I followed the official docs and embedded my string to translate with >> {% trans "String to translate" %} in my Template and >> managed >> to create both the po and mo files successfully. >> But, the page is still shown up in English. >> Note: the translation works just fine for my models. >> >> Partly of the template I was using can be found from below: >> {% extends "base.html" %} >> {% load url from future %} >> {% load i18n %} >> {% block title %}Event Occurrence{% endblock %} >> {% block main_content %} >> {% trans "Swingtime Event Occurrence" %} >> >> {{ >> occurrence.title }} >> >> {% with occurrence.start_time as st %} >> >> {{ st|date:"l, F jS P" }} >> >> {%