Re: install gettext tools 0.15

2015-10-30 Thread Ramiro Morales
On Fri, Oct 30, 2015 at 5:59 PM, Dariusz Mysior wrote:
> I do this and I have msfgmt is not recognized as an internal or external
> command, operable program or a batch file.

Then you'll need to identify, among the directories created by the
installation of gettext tools, which is the one that contains
msgfmt.exe. That's the one you need to add to the PATH env var.

>
> W dniu piątek, 30 października 2015 21:33:52 UTC+1 użytkownik Dariusz Mysior
> napisał:
>>
>> I use Windows 8 Python 3.4 Django 1.8 and I try
>>
>> I set settings and add: USE_I18N = True
>>
>> add to MIDDLEWARE_CLASSES django.middleware.locale.LocaleMiddleware
>>
>> like in describe in link below
>>
>>
>> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#gettext-on-windows
>>
>> I download gettext-runtime_0.18.1.1-1_win64 and
>> gettext-tools_0.18.1.1-1_win64 extract to C:\Program Files\gettext-utils add
>> path like in link to Control Panel > System > Advanced > Environment
>> Variables and when I write to terminal C:\Python34\ownsite>manage.py
>> compilemessages I had info :(
>>
>> CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15
>> or newer installed.
>>
>> What can I do more??? I have lost a few days on
>

-- 
Ramiro Morales
@ramiromorales

-- 
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/CAO7PdF-1ZGuAQV3pOHWLOeLnj_nS7Tue8KSFRR%3DgMrXDyD35VQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: install gettext tools 0.15

2015-10-30 Thread Dariusz Mysior
I do this and I have msfgmt is not recognized as an internal or external 
command, operable program or a batch file.

W dniu piątek, 30 października 2015 21:33:52 UTC+1 użytkownik Dariusz 
Mysior napisał:
>
> I use Windows 8 Python 3.4 Django 1.8 and I try
>
> I set settings and add: USE_I18N = True
>
> add to MIDDLEWARE_CLASSES django.middleware.locale.LocaleMiddleware
>
> like in describe in link below
>
>
> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#gettext-on-windows
>
> I download gettext-runtime_0.18.1.1-1_win64 and 
> gettext-tools_0.18.1.1-1_win64 extract to C:\Program Files\gettext-utils 
> add path like in link to Control Panel > System > Advanced > Environment 
> Variables and when I write to terminal C:\Python34\ownsite>manage.py 
> compilemessages I had info :( 
>
> CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15 
> or newer installed.
>
> What can I do more??? I have lost a few days on
>

-- 
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/11f5728d-5ad6-4c65-9761-facf8ddcd260%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: install gettext tools 0.15

2015-10-30 Thread Ramiro Morales
On Fri, Oct 30, 2015 at 5:33 PM, Dariusz Mysior  wrote:
> I use Windows 8 Python 3.4 Django 1.8 and I try
>
> I set settings and add: USE_I18N = True
>
> add to MIDDLEWARE_CLASSES django.middleware.locale.LocaleMiddleware
>
> like in describe in link below
>
> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#gettext-on-windows
>
> I download gettext-runtime_0.18.1.1-1_win64 and
> gettext-tools_0.18.1.1-1_win64 extract to C:\Program Files\gettext-utils add
> path like in link to Control Panel > System > Advanced > Environment
> Variables and when I write to terminal C:\Python34\ownsite>manage.py
> compilemessages I had info :(
>
> CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15
> or newer installed.
>
> What can I do more??? I have lost a few days on

Make sure you can execute msgfmt.exe from any path on your system.
That will indicate the directory where it is located has actually and
correctly been added to the PATH environment variable.

For example, open a Command prompt window and type msfgmt.

This is more a general Windows system admin topic.

-- 
Ramiro Morales
@ramiromorales

-- 
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/CAO7PdF-K2XNuxa4cGkp4hmq8mtDL%3DvDY4f22zK7LHgCiXr%3DPtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


install gettext tools 0.15

2015-10-30 Thread Dariusz Mysior


I use Windows 8 Python 3.4 Django 1.8 and I try

I set settings and add: USE_I18N = True

add to MIDDLEWARE_CLASSES django.middleware.locale.LocaleMiddleware

like in describe in link below

https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#gettext-on-windows

I download gettext-runtime_0.18.1.1-1_win64 and 
gettext-tools_0.18.1.1-1_win64 extract to C:\Program Files\gettext-utils 
add path like in link to Control Panel > System > Advanced > Environment 
Variables and when I write to terminal C:\Python34\ownsite>manage.py 
compilemessages I had info :( 

CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15 
or newer installed.

What can I do more??? I have lost a few days on

-- 
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/a8d67475-b471-4683-aeaf-aa43e9d547e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Does the bulk delete check the permissions correctly?

2015-10-30 Thread Tim Graham
I think there are a number of open tickets related to this. See 
https://code.djangoproject.com/ticket/23869 and the first comment that 
links to related issues. Feel free to offer a patch if you are able.

On Friday, October 30, 2015 at 3:04:21 PM UTC-4, Szymon Pyżalski wrote:
>
> Hello! 
>
> According to the documentation, the behaviour of has_delete_permission 
> should look like this: 
>
> If obj is None, should return True or False to indicate whether deleting 
> objects of this type is permitted in general (e.g., False will be 
> interpreted as meaning that the current user is not permitted to delete 
> any object of this type). 
>
> I was amazed therefore when I saw that when this method returns True for 
> object=None, the *any bulk delete is possible*. This leads to a very 
> nonintuitive situation, where it is impossible to delete an object 
> directly, but it is possible to include it in a bulk to delete. Is it 
> the desired behaviour? Is it possible to check permissions for all 
> objects in bulk? If no, there should be a big fat warning about it in 
> the documentation. 
>
> Greetings 
> Szymon 
>

-- 
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/1184f95b-8931-4d58-a108-fbe2d6b384f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Does the bulk delete check the permissions correctly?

2015-10-30 Thread Szymon Pyzalski
Hello!

According to the documentation, the behaviour of has_delete_permission
should look like this:

If obj is None, should return True or False to indicate whether deleting
objects of this type is permitted in general (e.g., False will be
interpreted as meaning that the current user is not permitted to delete
any object of this type).

I was amazed therefore when I saw that when this method returns True for
object=None, the *any bulk delete is possible*. This leads to a very
nonintuitive situation, where it is impossible to delete an object
directly, but it is possible to include it in a bulk to delete. Is it
the desired behaviour? Is it possible to check permissions for all
objects in bulk? If no, there should be a big fat warning about it in
the documentation.

Greetings
Szymon

-- 
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/5633B5A2.1010207%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: mssql databASE CONNECTION to Django

2015-10-30 Thread Sid
np...but thanks for your time

-- 
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/0f860fa9-7fa0-4045-aa09-92bc7eb3cf73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mssql databASE CONNECTION to Django

2015-10-30 Thread Tim Graham
Sorry, I haven't used the library myself and can't provide any additional 
help.

On Friday, October 30, 2015 at 10:31:35 AM UTC-4, Sid wrote:
>
> sorry tim I know I am asking a dumb question...can you please tell me what 
> is the best way to make it work please if possibe...because I am struck 
> form last 2 days
>

-- 
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/28279fb0-be9c-47bc-b4de-1080a6b5c759%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mssql databASE CONNECTION to Django

2015-10-30 Thread Sid
sorry tim I know I am asking a dumb question...can you please tell me what 
is the best way to make it work please if possibe...because I am struck 
form last 2 days

-- 
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/440c0480-4b24-4495-bb57-ac47a6a00f55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mssql databASE CONNECTION to Django

2015-10-30 Thread Tim Graham
Please read the documentation: 
https://django-mssql.readthedocs.org/en/latest/quickstart.html

On Friday, October 30, 2015 at 9:53:42 AM UTC-4, Sid wrote:
>
> so which version will be compatible...
>
> On Friday, October 30, 2015 at 7:54:26 AM UTC-4, Tim Graham wrote:
>>
>> django-mssql doesn't support Django 1.8 yet:
>>
>> https://django-mssql.readthedocs.org/en/latest/changelog.html
>>
>> On Thursday, October 29, 2015 at 9:36:38 PM UTC-4, Sid wrote:
>>>
>>> *Hi all,*
>>> I am trying to connect database which is in server to django, but it is 
>>> showing many errors like(platform i am using M visual studio)
>>>
>>> *Traceback (most recent call last):*
>>>   File "C:\Users\speesary\Desktop\programs\learn\learn\manage.py", line 
>>> 17, in 
>>> execute_from_command_line(sys.argv)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\core\management\__init__.py",
>>>  
>>> line 351, in execute_from_command_line
>>> utility.execute()
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\core\management\__init__.py",
>>>  
>>> line 325, in execute
>>> django.setup()
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\__init__.py",
>>>  
>>> line 18, in setup
>>> apps.populate(settings.INSTALLED_APPS)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\apps\registry.py",
>>>  
>>> line 108, in populate
>>> app_config.import_models(all_models)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\apps\config.py",
>>>  
>>> line 198, in import_models
>>> self.models_module = import_module(models_module_name)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\importlib\__init__.py",
>>>  
>>> line 37, in import_module
>>> __import__(name)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\contrib\auth\models.py",
>>>  
>>> line 41, in 
>>> class Permission(models.Model):
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\base.py",
>>>  
>>> line 139, in __new__
>>> new_class.add_to_class('_meta', Options(meta, **kwargs))
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\base.py",
>>>  
>>> line 324, in add_to_class
>>> value.contribute_to_class(cls, name)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\options.py",
>>>  
>>> line 250, in contribute_to_class
>>> self.db_table = truncate_name(self.db_table, 
>>> connection.ops.max_name_length())
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\__init__.py",
>>>  
>>> line 36, in __getattr__
>>> return getattr(connections[DEFAULT_DB_ALIAS], item)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\utils.py",
>>>  
>>> line 240, in __getitem__
>>> backend = load_backend(db['ENGINE'])
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\utils.py",
>>>  
>>> line 111, in load_backend
>>> return import_module('%s.base' % backend_name)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\importlib\__init__.py",
>>>  
>>> line 37, in import_module
>>> __import__(name)
>>>   File 
>>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\backends\sqlserver_ado\base.py",
>>>  
>>> line 5, in 
>>> from django.db.backends import BaseDatabaseWrapper, 
>>> BaseDatabaseFeatures, BaseDatabaseValidation, BaseDatabaseClient
>>> ImportError: cannot import name BaseDatabaseWrapper
>>> The Python REPL process has exited
>>>
>>> code in my *settings.py*
>>> *PACKAGES ADDED:*
>>> *from django.db.backends.base.base import BaseDatabaseWrapperfrom 
>>> django.db.backends.base.client import BaseDatabaseClientfrom 
>>> django.db.backends.base.creation import BaseDatabaseCreationfrom 
>>> django.db.backends.base.features import BaseDatabaseFeaturesfrom 
>>> django.db.backends.base.introspection import BaseDatabaseIntrospection#from 
>>> django.db.backends.base.introspection import FieldInfo, TableInfofrom 
>>> django.db.backends.base.operations import BaseDatabaseOperationsfrom 
>>> django.db.backends.base.schema import BaseDatabaseSchemaEditorfrom 
>>> django.db.backends.base.validation import BaseDatabaseValidationfrom 
>>> django.db.backends.util import CursorWrapperfrom os import path*
>>>
>>> 'default': {
>>> 'ENGINE': 

Re: mssql databASE CONNECTION to Django

2015-10-30 Thread Sid
so which version will be compatible...

On Friday, October 30, 2015 at 7:54:26 AM UTC-4, Tim Graham wrote:
>
> django-mssql doesn't support Django 1.8 yet:
>
> https://django-mssql.readthedocs.org/en/latest/changelog.html
>
> On Thursday, October 29, 2015 at 9:36:38 PM UTC-4, Sid wrote:
>>
>> *Hi all,*
>> I am trying to connect database which is in server to django, but it is 
>> showing many errors like(platform i am using M visual studio)
>>
>> *Traceback (most recent call last):*
>>   File "C:\Users\speesary\Desktop\programs\learn\learn\manage.py", line 
>> 17, in 
>> execute_from_command_line(sys.argv)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\core\management\__init__.py",
>>  
>> line 351, in execute_from_command_line
>> utility.execute()
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\core\management\__init__.py",
>>  
>> line 325, in execute
>> django.setup()
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\__init__.py",
>>  
>> line 18, in setup
>> apps.populate(settings.INSTALLED_APPS)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\apps\registry.py",
>>  
>> line 108, in populate
>> app_config.import_models(all_models)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\apps\config.py",
>>  
>> line 198, in import_models
>> self.models_module = import_module(models_module_name)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\importlib\__init__.py",
>>  
>> line 37, in import_module
>> __import__(name)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\contrib\auth\models.py",
>>  
>> line 41, in 
>> class Permission(models.Model):
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\base.py",
>>  
>> line 139, in __new__
>> new_class.add_to_class('_meta', Options(meta, **kwargs))
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\base.py",
>>  
>> line 324, in add_to_class
>> value.contribute_to_class(cls, name)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\options.py",
>>  
>> line 250, in contribute_to_class
>> self.db_table = truncate_name(self.db_table, 
>> connection.ops.max_name_length())
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\__init__.py",
>>  
>> line 36, in __getattr__
>> return getattr(connections[DEFAULT_DB_ALIAS], item)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\utils.py",
>>  
>> line 240, in __getitem__
>> backend = load_backend(db['ENGINE'])
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\utils.py",
>>  
>> line 111, in load_backend
>> return import_module('%s.base' % backend_name)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\importlib\__init__.py",
>>  
>> line 37, in import_module
>> __import__(name)
>>   File 
>> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\backends\sqlserver_ado\base.py",
>>  
>> line 5, in 
>> from django.db.backends import BaseDatabaseWrapper, 
>> BaseDatabaseFeatures, BaseDatabaseValidation, BaseDatabaseClient
>> ImportError: cannot import name BaseDatabaseWrapper
>> The Python REPL process has exited
>>
>> code in my *settings.py*
>> *PACKAGES ADDED:*
>> *from django.db.backends.base.base import BaseDatabaseWrapperfrom 
>> django.db.backends.base.client import BaseDatabaseClientfrom 
>> django.db.backends.base.creation import BaseDatabaseCreationfrom 
>> django.db.backends.base.features import BaseDatabaseFeaturesfrom 
>> django.db.backends.base.introspection import BaseDatabaseIntrospection#from 
>> django.db.backends.base.introspection import FieldInfo, TableInfofrom 
>> django.db.backends.base.operations import BaseDatabaseOperationsfrom 
>> django.db.backends.base.schema import BaseDatabaseSchemaEditorfrom 
>> django.db.backends.base.validation import BaseDatabaseValidationfrom 
>> django.db.backends.util import CursorWrapperfrom os import path*
>>
>> 'default': {
>> 'ENGINE': 'django.db.backends.sqlserver_ado'  ,   
>> 
>>  #'django.db.backends.sqlserver_ado'
>> 'NAME': 'Siddharth',
>> 'USER': 'SCGLOBAL\speesary@ALMDATA',
>> 'PASSWORD': '',
>> 'HOST': '127.0.0.1',
>> 

Re: Translation is not working for Template even though po and mo files are created

2015-10-30 Thread Andreas Kuhne
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" }}
 
 {% endwith %}
  
  {% trans "Event type:" %}
  {{ occurrence.event.event_type }}

 The subroutine to render my Template is:

 #---
 def occurrence_view(
 request,
 event_pk,
 pk,
 template='swingtime/occurrence_detail.html',
 form_class=forms.SingleOccurrenceForm
 ):
 '''
 View a specific occurrence and optionally handle any updates.

 Context parameters:

 ``occurrence``
 the occurrence object keyed by ``pk``


 ``form``
 a form object for updating the occurrence
 '''

 occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=
 event_pk)
 if request.method == 'POST':
 form = form_class(request.POST, instance=occurrence)
 if form.is_valid():
 form.save()
 return http.HttpResponseRedirect(request.path)
 else:
 form = form_class(instance=occurrence)

 return render(request, template, {'occurrence': occurrence, 'form':
 form})

 And the url configuration associated with the Template reads:
 url(
 r'^events/(\d+)/(\d+)/$',
 views.occurrence_view,
 name='swingtime-occurrence'
 ),

 Could some one help me solve this problem?
 Thanks very much

Re: Translation is not working on ModelForm when widget is specified for form field

2015-10-30 Thread Sinwar Prem
okkk now i dont hv time whenever i get ill let u know


On 30 October 2015 at 17:20, Sean Xu  wrote:

> Hi Andréas,
>
> I have now applied your second approach and now the field names get
> translated into Chinese as expected...
> Thanks so much.
>
> On Friday, October 30, 2015 at 6:12:21 PM UTC+8, Andréas Kühne wrote:
>>
>> Hi,
>>
>> The problem is that you are redifining the fields, the fields then don't
>> get any labels (because you haven't specified them). You can achieve what
>> you want in two ways:
>>
>> Either add the following to your modelform:
>> start_time = forms.DateTimeField(label=_("start time"),
>> widget=SplitDateTimeWidget)
>> end_time = forms.DateTimeField(label=_("end time"),
>> widget=SplitDateTimeWidget)
>>
>> But I would much rather remove the start_time / end_time definitions in
>> your model form and instead add this under the "class Meta:" heading:
>> widgets = {
>> 'start_time': SplitDateTimeWidget,
>> 'end_time': SplitDateTimeWidget,
>> }
>>
>> That way you don't have to add the labels once more, but just use them
>> from the model instead.
>>
>> Regards,
>>
>> Andréas
>>
>> 2015-10-30 7:21 GMT+01:00 Sean Xu :
>>
>>> Hi,
>>>
>>> I was learning Django Translation using django-swingtime as project with
>>> Django 1.7.9 installed.
>>> And I found out when Non-default widgets was originally specified for
>>> form fields, the preferred language did not show up from my Firefox browser.
>>> The problem has gone when these widgets were removed.
>>> I'm not sure if this is a bug of Django or was there anything I did
>>> wrong.
>>>
>>> Note: po and mo file can be created correctly with or without the
>>> widgets in place.
>>>
>>> You can find the Model definition from below:
>>> class Occurrence(models.Model):
>>> '''
>>> Represents the start end time for a specific occurrence of a master
>>> ``Event``
>>> object.
>>> '''
>>> start_time = models.DateTimeField(_('start time'))
>>> end_time = models.DateTimeField(_('end time'))
>>> event = models.ForeignKey(Event, verbose_name=_('event'), editable=
>>> False)
>>> notes = GenericRelation(Note, verbose_name=_('notes'))
>>>
>>>
>>> objects = OccurrenceManager()
>>>
>>>
>>>
>>> #===
>>> class Meta:
>>> verbose_name = _('occurrence')
>>> verbose_name_plural = _('occurrences')
>>> ordering = ('start_time', 'end_time')
>>>
>>>
>>> And the ModelForm is defined as follows:
>>> class SingleOccurrenceForm(forms.ModelForm):
>>> '''
>>> A simple form for adding and updating single Occurrence attributes
>>>
>>>
>>> '''
>>>
>>>
>>> start_time = forms.DateTimeField(widget=SplitDateTimeWidget)
>>> end_time = forms.DateTimeField(widget=SplitDateTimeWidget)
>>> # Translation works if these 2 lines get removed
>>>
>>>
>>>
>>> #===
>>> class Meta:
>>> model = Occurrence
>>> if FIELDS_REQUIRED:
>>> fields = "__all__"
>>>
>>>
>>> Br
>>> Sean
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/52a50110-4c9d-4f71-9ebf-6ade058fa47e%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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/d350c903-7285-4932-8c9f-0c5c1a4407f4%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 

Re: return values from static files to django admin

2015-10-30 Thread dc
bump!!

On Thursday, October 29, 2015 at 11:40:32 PM UTC-4, dc wrote:
>
> I have declared a charfield 'choice_text' in one of my models. I want to 
> convert it to a dropdown box in django admin. The choices in the dropdown 
> list depend on user input to a textbox defined in another model class. I 
> have a javascript (declared  as Media class inside a ModelAdmin class) that 
> reads user input in the textbox. But I am unable to this choice list back 
> from .js file to django admin. How do I do that? Thanks in advance.
>
> I have tried this.
>
> *models.py*
> class Routing(models.Model):
> choice_text = models.CharField(_('Choices'), max_length=100, 
> default="(any)", null=False)
>
> *admin.py*
> class AdminRoutingInlineForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
> super(AdminRoutingInlineForm, self).__init__(*args, **kwargs)
> CHOICES = [('a', 'any'),('b', 'blah'),] * // override this 
> with choices from populate_dropdown.js (code below)*
> self.fields['choice_text'].choices = CHOICES
>
> class RoutingInlineAdmin(StackedInline):
> form = AdminRoutingInlineForm
> fields = (('choice_text', 'next'),)
> model = Routing
>
>
> class FormModelAdmin(ModelAdmin):
> inlines = [RoutingInlineAdmin]
>
> class Media:
> js= ("sforms/admin/populate_dropdown.js",)
>
>
> *populate_dropdown.js*
> (function($) {
> $(document).ready(function() {
>
> $("[id^=id_fields-][id$=_options_0]").each(function(){ *  // 
> user input from this field will be used as choices*
> choices = '(any),' + $(this).val().split("\n");
> alert(choices);
> 
> *// send this choices back to admin.py and override CHOICES 
> in AdminRoutingInlineForm class*
> });  
> });
>  
>
>
>

-- 
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/ea61e786-51c3-4d98-86fc-b49695cfcb03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mssql databASE CONNECTION to Django

2015-10-30 Thread Tim Graham
django-mssql doesn't support Django 1.8 yet:

https://django-mssql.readthedocs.org/en/latest/changelog.html

On Thursday, October 29, 2015 at 9:36:38 PM UTC-4, Sid wrote:
>
> *Hi all,*
> I am trying to connect database which is in server to django, but it is 
> showing many errors like(platform i am using M visual studio)
>
> *Traceback (most recent call last):*
>   File "C:\Users\speesary\Desktop\programs\learn\learn\manage.py", line 
> 17, in 
> execute_from_command_line(sys.argv)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\core\management\__init__.py",
>  
> line 351, in execute_from_command_line
> utility.execute()
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\core\management\__init__.py",
>  
> line 325, in execute
> django.setup()
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\__init__.py",
>  
> line 18, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\apps\registry.py",
>  
> line 108, in populate
> app_config.import_models(all_models)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\apps\config.py",
>  
> line 198, in import_models
> self.models_module = import_module(models_module_name)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\importlib\__init__.py",
>  
> line 37, in import_module
> __import__(name)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\contrib\auth\models.py",
>  
> line 41, in 
> class Permission(models.Model):
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\base.py",
>  
> line 139, in __new__
> new_class.add_to_class('_meta', Options(meta, **kwargs))
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\base.py",
>  
> line 324, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\models\options.py",
>  
> line 250, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\__init__.py",
>  
> line 36, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\utils.py",
>  
> line 240, in __getitem__
> backend = load_backend(db['ENGINE'])
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\utils.py",
>  
> line 111, in load_backend
> return import_module('%s.base' % backend_name)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\importlib\__init__.py",
>  
> line 37, in import_module
> __import__(name)
>   File 
> "C:\Users\speesary\AppData\Local\Continuum\Anaconda\lib\site-packages\django-1.8.5-py2.7.egg\django\db\backends\sqlserver_ado\base.py",
>  
> line 5, in 
> from django.db.backends import BaseDatabaseWrapper, 
> BaseDatabaseFeatures, BaseDatabaseValidation, BaseDatabaseClient
> ImportError: cannot import name BaseDatabaseWrapper
> The Python REPL process has exited
>
> code in my *settings.py*
> *PACKAGES ADDED:*
> *from django.db.backends.base.base import BaseDatabaseWrapperfrom 
> django.db.backends.base.client import BaseDatabaseClientfrom 
> django.db.backends.base.creation import BaseDatabaseCreationfrom 
> django.db.backends.base.features import BaseDatabaseFeaturesfrom 
> django.db.backends.base.introspection import BaseDatabaseIntrospection#from 
> django.db.backends.base.introspection import FieldInfo, TableInfofrom 
> django.db.backends.base.operations import BaseDatabaseOperationsfrom 
> django.db.backends.base.schema import BaseDatabaseSchemaEditorfrom 
> django.db.backends.base.validation import BaseDatabaseValidationfrom 
> django.db.backends.util import CursorWrapperfrom os import path*
>
> 'default': {
> 'ENGINE': 'django.db.backends.sqlserver_ado'  ,   
> 
>  #'django.db.backends.sqlserver_ado'
> 'NAME': 'Siddharth',
> 'USER': 'SCGLOBAL\speesary@ALMDATA',
> 'PASSWORD': '',
> 'HOST': '127.0.0.1',
> 'PORT':'',
> 'OPTIONS': {
>  
> 'driver':'SQL Server Native Client 11.0',
> 'MARS_Connection': True,
> can anyone please tell me the procedure how to do it. it will be very 
> helpful...
> 

Re: Translation is not working on ModelForm when widget is specified for form field

2015-10-30 Thread Sean Xu
Hi Andréas,

I have now applied your second approach and now the field names get 
translated into Chinese as expected...
Thanks so much.

On Friday, October 30, 2015 at 6:12:21 PM UTC+8, Andréas Kühne wrote:
>
> Hi,
>
> The problem is that you are redifining the fields, the fields then don't 
> get any labels (because you haven't specified them). You can achieve what 
> you want in two ways:
>
> Either add the following to your modelform:
> start_time = forms.DateTimeField(label=_("start time"), 
> widget=SplitDateTimeWidget)
> end_time = forms.DateTimeField(label=_("end time"), 
> widget=SplitDateTimeWidget)
>
> But I would much rather remove the start_time / end_time definitions in 
> your model form and instead add this under the "class Meta:" heading:
> widgets = {
> 'start_time': SplitDateTimeWidget,
> 'end_time': SplitDateTimeWidget,
> }
>
> That way you don't have to add the labels once more, but just use them 
> from the model instead.
>
> Regards,
>
> Andréas
>
> 2015-10-30 7:21 GMT+01:00 Sean Xu :
>
>> Hi,
>>
>> I was learning Django Translation using django-swingtime as project with 
>> Django 1.7.9 installed.
>> And I found out when Non-default widgets was originally specified for 
>> form fields, the preferred language did not show up from my Firefox browser.
>> The problem has gone when these widgets were removed.
>> I'm not sure if this is a bug of Django or was there anything I did wrong.
>>
>> Note: po and mo file can be created correctly with or without the widgets 
>> in place.
>>
>> You can find the Model definition from below:
>> class Occurrence(models.Model):
>> '''
>> Represents the start end time for a specific occurrence of a master 
>> ``Event``
>> object.
>> '''
>> start_time = models.DateTimeField(_('start time'))
>> end_time = models.DateTimeField(_('end time'))
>> event = models.ForeignKey(Event, verbose_name=_('event'), editable=
>> False)
>> notes = GenericRelation(Note, verbose_name=_('notes'))
>>
>>
>> objects = OccurrenceManager()
>>
>>
>> 
>> #===
>> class Meta:
>> verbose_name = _('occurrence')
>> verbose_name_plural = _('occurrences')
>> ordering = ('start_time', 'end_time')
>>
>>
>> And the ModelForm is defined as follows:
>> class SingleOccurrenceForm(forms.ModelForm):
>> '''
>> A simple form for adding and updating single Occurrence attributes
>>
>>
>> '''
>>
>>
>> start_time = forms.DateTimeField(widget=SplitDateTimeWidget)
>> end_time = forms.DateTimeField(widget=SplitDateTimeWidget)
>> # Translation works if these 2 lines get removed
>>
>>
>> 
>> #===
>> class Meta:
>> model = Occurrence
>> if FIELDS_REQUIRED:
>> fields = "__all__"
>>
>>
>> Br
>> Sean
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/52a50110-4c9d-4f71-9ebf-6ade058fa47e%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/d350c903-7285-4932-8c9f-0c5c1a4407f4%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

2015-10-30 Thread 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" }}
>>> 
>>> {% endwith %}
>>>  
>>>  {% trans "Event type:" %}
>>>  {{ occurrence.event.event_type }}
>>>
>>> The subroutine to render my Template is:
>>>
>>> #---
>>> def occurrence_view(
>>> request,
>>> event_pk,
>>> pk,
>>> template='swingtime/occurrence_detail.html',
>>> form_class=forms.SingleOccurrenceForm
>>> ):
>>> '''
>>> View a specific occurrence and optionally handle any updates.
>>> 
>>> Context parameters:
>>> 
>>> ``occurrence``
>>> the occurrence object keyed by ``pk``
>>>
>>>
>>> ``form``
>>> a form object for updating the occurrence
>>> '''
>>>   
>>> occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk
>>> )
>>> if request.method == 'POST':
>>> form = form_class(request.POST, instance=occurrence)
>>> if form.is_valid():
>>> form.save()
>>> return http.HttpResponseRedirect(request.path)
>>> else:  
>>> form = form_class(instance=occurrence)
>>> 
>>> return render(request, template, {'occurrence': occurrence, 'form': 
>>> form})
>>>
>>> And the url configuration associated with the Template reads:
>>> url(
>>> r'^events/(\d+)/(\d+)/$', 
>>> views.occurrence_view, 
>>> name='swingtime-occurrence'
>>> ),
>>>
>>> Could some one help me solve this problem?
>>> Thanks very much
>>>
>>> Br
>>> Sean
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at 

Re: Translation is not working for Template even though po and mo files are created

2015-10-30 Thread Sean Xu
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" }}
>> 
>> {% endwith %}
>>  
>>  {% trans "Event type:" %}
>>  {{ occurrence.event.event_type }}
>>
>> The subroutine to render my Template is:
>>
>> #---
>> def occurrence_view(
>> request,
>> event_pk,
>> pk,
>> template='swingtime/occurrence_detail.html',
>> form_class=forms.SingleOccurrenceForm
>> ):
>> '''
>> View a specific occurrence and optionally handle any updates.
>> 
>> Context parameters:
>> 
>> ``occurrence``
>> the occurrence object keyed by ``pk``
>>
>>
>> ``form``
>> a form object for updating the occurrence
>> '''
>>   
>> occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk)
>> if request.method == 'POST':
>> form = form_class(request.POST, instance=occurrence)
>> if form.is_valid():
>> form.save()
>> return http.HttpResponseRedirect(request.path)
>> else:  
>> form = form_class(instance=occurrence)
>> 
>> return render(request, template, {'occurrence': occurrence, 'form': 
>> form})
>>
>> And the url configuration associated with the Template reads:
>> url(
>> r'^events/(\d+)/(\d+)/$', 
>> views.occurrence_view, 
>> name='swingtime-occurrence'
>> ),
>>
>> Could some one help me solve this problem?
>> Thanks very much
>>
>> Br
>> Sean
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/a45afc10-97ad-4574-b541-14ff67e892cd%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/20d057f4-bad2-4dc2-9827-43451cf5f832%40googlegroups.com.
For more options, visit 

Re: Translation is not working on ModelForm when widget is specified for form field

2015-10-30 Thread Andreas Kuhne
Hi,

The problem is that you are redifining the fields, the fields then don't
get any labels (because you haven't specified them). You can achieve what
you want in two ways:

Either add the following to your modelform:
start_time = forms.DateTimeField(label=_("start time"),
widget=SplitDateTimeWidget)
end_time = forms.DateTimeField(label=_("end time"),
widget=SplitDateTimeWidget)

But I would much rather remove the start_time / end_time definitions in
your model form and instead add this under the "class Meta:" heading:
widgets = {
'start_time': SplitDateTimeWidget,
'end_time': SplitDateTimeWidget,
}

That way you don't have to add the labels once more, but just use them from
the model instead.

Regards,

Andréas

2015-10-30 7:21 GMT+01:00 Sean Xu :

> Hi,
>
> I was learning Django Translation using django-swingtime as project with
> Django 1.7.9 installed.
> And I found out when Non-default widgets was originally specified for form
> fields, the preferred language did not show up from my Firefox browser.
> The problem has gone when these widgets were removed.
> I'm not sure if this is a bug of Django or was there anything I did wrong.
>
> Note: po and mo file can be created correctly with or without the widgets
> in place.
>
> You can find the Model definition from below:
> class Occurrence(models.Model):
> '''
> Represents the start end time for a specific occurrence of a master
> ``Event``
> object.
> '''
> start_time = models.DateTimeField(_('start time'))
> end_time = models.DateTimeField(_('end time'))
> event = models.ForeignKey(Event, verbose_name=_('event'), editable=
> False)
> notes = GenericRelation(Note, verbose_name=_('notes'))
>
>
> objects = OccurrenceManager()
>
>
>
> #===
> class Meta:
> verbose_name = _('occurrence')
> verbose_name_plural = _('occurrences')
> ordering = ('start_time', 'end_time')
>
>
> And the ModelForm is defined as follows:
> class SingleOccurrenceForm(forms.ModelForm):
> '''
> A simple form for adding and updating single Occurrence attributes
>
>
> '''
>
>
> start_time = forms.DateTimeField(widget=SplitDateTimeWidget)
> end_time = forms.DateTimeField(widget=SplitDateTimeWidget)
> # Translation works if these 2 lines get removed
>
>
>
> #===
> class Meta:
> model = Occurrence
> if FIELDS_REQUIRED:
> fields = "__all__"
>
>
> Br
> Sean
>
> --
> 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/52a50110-4c9d-4f71-9ebf-6ade058fa47e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALXYUbk9CudRVfTWP4Pj95HSaO0Opa4SfK%3DHtaP%3DPbEOVoNSwA%40mail.gmail.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

2015-10-30 Thread Andreas Kuhne
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" }}
> 
> {% endwith %}
>  
>  {% trans "Event type:" %}
>  {{ occurrence.event.event_type }}
>
> The subroutine to render my Template is:
>
> #---
> def occurrence_view(
> request,
> event_pk,
> pk,
> template='swingtime/occurrence_detail.html',
> form_class=forms.SingleOccurrenceForm
> ):
> '''
> View a specific occurrence and optionally handle any updates.
>
> Context parameters:
>
> ``occurrence``
> the occurrence object keyed by ``pk``
>
>
> ``form``
> a form object for updating the occurrence
> '''
>
> occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk)
> if request.method == 'POST':
> form = form_class(request.POST, instance=occurrence)
> if form.is_valid():
> form.save()
> return http.HttpResponseRedirect(request.path)
> else:
> form = form_class(instance=occurrence)
>
> return render(request, template, {'occurrence': occurrence, 'form':
> form})
>
> And the url configuration associated with the Template reads:
> url(
> r'^events/(\d+)/(\d+)/$',
> views.occurrence_view,
> name='swingtime-occurrence'
> ),
>
> Could some one help me solve this problem?
> Thanks very much
>
> Br
> Sean
>
> --
> 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/a45afc10-97ad-4574-b541-14ff67e892cd%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALXYUbmv0-OXa9Br%2BLKVbSB68CsG8M9Z0M%3DU0PzSAZ3%3DTMCJZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Translation is not working on ModelForm when widget is specified for form field

2015-10-30 Thread Sean Xu
Hi,

I was learning Django Translation using django-swingtime as project with 
Django 1.7.9 installed.
And I found out when Non-default widgets was originally specified for form 
fields, the preferred language did not show up from my Firefox browser.
The problem has gone when these widgets were removed.
I'm not sure if this is a bug of Django or was there anything I did wrong.

Note: po and mo file can be created correctly with or without the widgets 
in place.

You can find the Model definition from below:
class Occurrence(models.Model):
'''
Represents the start end time for a specific occurrence of a master 
``Event``
object.
'''
start_time = models.DateTimeField(_('start time'))
end_time = models.DateTimeField(_('end time'))
event = models.ForeignKey(Event, verbose_name=_('event'), editable=False
)
notes = GenericRelation(Note, verbose_name=_('notes'))


objects = OccurrenceManager()



#===
class Meta:
verbose_name = _('occurrence')
verbose_name_plural = _('occurrences')
ordering = ('start_time', 'end_time')


And the ModelForm is defined as follows:
class SingleOccurrenceForm(forms.ModelForm):
'''
A simple form for adding and updating single Occurrence attributes


'''


start_time = forms.DateTimeField(widget=SplitDateTimeWidget)
end_time = forms.DateTimeField(widget=SplitDateTimeWidget)
# Translation works if these 2 lines get removed



#===
class Meta:
model = Occurrence
if FIELDS_REQUIRED:
fields = "__all__"


Br
Sean

-- 
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/52a50110-4c9d-4f71-9ebf-6ade058fa47e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Translation is not working for Template even though po and mo files are created

2015-10-30 Thread 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" }}

{% endwith %}
 
 {% trans "Event type:" %}
 {{ occurrence.event.event_type }}

The subroutine to render my Template is:
#---
def occurrence_view(
request,
event_pk,
pk,
template='swingtime/occurrence_detail.html',
form_class=forms.SingleOccurrenceForm
):
'''
View a specific occurrence and optionally handle any updates.

Context parameters:

``occurrence``
the occurrence object keyed by ``pk``


``form``
a form object for updating the occurrence
'''
  
occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk)
if request.method == 'POST':
form = form_class(request.POST, instance=occurrence)
if form.is_valid():
form.save()
return http.HttpResponseRedirect(request.path)
else:  
form = form_class(instance=occurrence)

return render(request, template, {'occurrence': occurrence, 'form': form
})

And the url configuration associated with the Template reads:
url(
r'^events/(\d+)/(\d+)/$', 
views.occurrence_view, 
name='swingtime-occurrence'
),

Could some one help me solve this problem?
Thanks very much

Br
Sean

-- 
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/a45afc10-97ad-4574-b541-14ff67e892cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.