Friday, October 30, 2015

Re: mssql databASE CONNECTION to Django

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+unsubscribe@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

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+unsubscribe@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

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+unsubscribe@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

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 <module>
    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 <module>
    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 <module>
    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 BaseDatabaseWrapper
from django.db.backends.base.client import BaseDatabaseClient
from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.backends.base.introspection import BaseDatabaseIntrospection
#from django.db.backends.base.introspection import FieldInfo, TableInfo
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.validation import BaseDatabaseValidation
from django.db.backends.util import CursorWrapper
from 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...
your help is much appreciated

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+unsubscribe@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/c2c7265d-6495-475b-b963-8d7c54ea9cec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: mssql databASE CONNECTION to Django

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 <module>
    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 <module>
    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 <module>
    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 BaseDatabaseWrapper
from django.db.backends.base.client import BaseDatabaseClient
from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.backends.base.introspection import BaseDatabaseIntrospection
#from django.db.backends.base.introspection import FieldInfo, TableInfo
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.validation import BaseDatabaseValidation
from django.db.backends.util import CursorWrapper
from 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...
your help is much appreciated

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+unsubscribe@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/f8e03eff-d288-44df-889f-6bfc97116cb8%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

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 <seanxu1984@gmail.com>:
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?

Regards,

Andréas

2015-10-30 7:45 GMT+01:00 Sean Xu <seanx...@gmail.com>:
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 <title>{% trans "String to translate" %}</title> 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 %}
     
<h3>{% trans "Swingtime Event Occurrence" %}</h3>
     
<h4>
         
<a href="{{ occurrence.event.get_absolute_url }}">{{ occurrence.title }}</a>
         
&ndash;
         
{% with occurrence.start_time as st  %}
         
<a href="{% url 'swingtime-daily-view' st.year st.month st.day %}">
           
{{ st|date:"l, F jS P" }}</a>
       
</h4>
        {% endwith %}
     <dl>
         <dt>{% trans "Event type:" %}</
dt>
         
<dd>{{ occurrence.event.event_type }}</dd>

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+unsubscribe@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/4c2d6bbe-c586-410c-8c61-338ecc01caf1%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+unsubscribe@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/CALXYUbk%3DT_izaRHvvPkxp8UUMN%2BLrLBz8n73s4i6GH4XaOJcig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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

okkk now i dont hv time whenever i get ill let u know


On 30 October 2015 at 17:20, Sean Xu <seanxu1984@gmail.com> 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 <seanx...@gmail.com>:
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+unsubscribe@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+unsubscribe@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/CADQRGB4zt1rgjjiv1tJ8xoF20A%2BKs5YWuafBzCOOevgb7U2sCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.