Thursday, June 1, 2017

Django bugfix release: 1.11.2

Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2017/jun/01/bugfix-release/

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/45ab39ab-cc38-467d-97bc-c8c39f971c8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

django-admin makemessages PermissionError [WindError 32] and OsError [Errno 22]

Hi,

I am using custom fabric script to make .po-files for i18n.

The problem is, "django-admin makemessages" keeps on crashing. It also leaves undeleted .html.py files. I can reproduce this error also by using plain "django-admin makemessages -l pt". 

I think this problem in Windows-specific. I am using 64-bit Windows 10, Django 1.11, Fabric3 1.13.1.post1, and Windows Powershell 5.1.14393.1198.

Any help would be appreciated.

Br,

np

"Minimal working example":
 - Crashed on third try. Sometimes it complains about "locale\django.pot" being used by another process, too. Fourth try worked fine.

(<my_project>) PS C:\Users\<User>\Dropbox\<my_project>\site\src\<my_project>\templates\bases> django-admin makemessages -l pt
processing locale pt
(<my_project>) PS C:\Users\<User>\Dropbox\<my_project>\site\src\<my_project>\templates\bases> django-admin makemessages -l pt
processing locale pt
(<my_project>) PS C:\Users\<User>\Dropbox\<my_project>\site\src\<my_project>\templates\bases> django-admin makemessages -l pt
Traceback (most recent call last):
  File "C:\Users\<User>\Miniconda3\Lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\<User>\Miniconda3\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python\VirtualEnv\<my_project>\Scripts\django-admin.exe\__main__.py", line 9, in <module>
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 360, in handle
    potfiles = self.build_potfiles()
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 402, in build_potfiles
    self.process_files(file_list)
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 499, in process_files
    self.process_locale_dir(locale_dir, files)
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 594, in process_locale_dir
    build_file.cleanup()
  File "c:\python\virtualenv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 157, in cleanup
    os.unlink(self.work_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '.\\base.html.py'
(<my_project>) PS C:\Users\<User>\Dropbox\<my_project>\site\src\<my_project>\templates\bases>

Real-usage example

Fabric code:
def translate(appfolder=None):
    """
    Use django-admin makemessages to make .po files

    INPUTS:
        folder: pathlib.Path object for the folder where to start.
            Used for recursion. (in normal usage, no 'folder' parameter
            is provided.)
    """
    forbidden = ('__pycache__', 'migrations', 'locale', 'utils', 'static')
    if not appfolder:
        appfolder = Path(__file__).parent.parent / '<my_project>'
    for item in appfolder.iterdir():
        if item.is_dir() and (item.name not in forbidden):
            if not (item / 'locale').exists():
                (item / 'locale').mkdir()
                print('Created {}'.format(str((item / 'locale'))))
            print('Running makemessages in {}'.format(str(item)))
            os.chdir(str(item))

            os.system("python {django_admin} makemessages -l fi".format(
                django_admin = django_admin
                ))

            translate(appfolder=item)

Traceback:
- Some files before and after these errors did not produce any errors.

Running makemessages in C:\Users\<User>\Dropbox\<my_project>\site\src\<my_project>\templates
Traceback (most recent call last):
  File "C:\Python\VirtualEnv\<my_project>\Scripts\django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 360, in handle
    potfiles = self.build_potfiles()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 402, in build_potfiles
    self.process_files(file_list)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 499, in process_files
    self.process_locale_dir(locale_dir, files)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 594, in process_locale_dir
    build_file.cleanup()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 157, in cleanup
    os.unlink(self.work_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '.\\account\\account_inactive.html.py'
Running makemessages in C:\Users\<User>\Dropbox\<my_project>\site\src\<my_project>\templates\account
Traceback (most recent call last):
  File "C:\Python\VirtualEnv\<my_project>\Scripts\django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 360, in handle
    potfiles = self.build_potfiles()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 417, in build_potfiles
    with io.open(potfile, 'w', encoding='utf-8') as fp:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\<User>\\Dropbox\\<my_project>\\site\\src\\<my_project>\\templates\\account\\email\\locale\\django.pot'
Running makemessages in C:\Users\<User>\Dropbox\<my_project>\site\src\<my_project>\templates\account\email
Traceback (most recent call last):
  File "C:\Python\VirtualEnv\<my_project>\Scripts\django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 360, in handle
    potfiles = self.build_potfiles()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 402, in build_potfiles
    self.process_files(file_list)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 499, in process_files
    self.process_locale_dir(locale_dir, files)
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 594, in process_locale_dir
    build_file.cleanup()
  File "C:\Python\VirtualEnv\<my_project>\lib\site-packages\django\core\management\commands\makemessages.py", line 157, in cleanup
    os.unlink(self.work_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '.\\email_confirmation_message.txt.py'

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ce301ad9-1584-468e-9fef-9e81ef9473b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Possible bug - Incorrect escaping in Django SQL query

Hi,
I came across an issue yesterday. Post on stackoverflow

On further investigation today, I think I found the source of the issue. It's this line. The parameters which are escaped here are never reverted back to the original form.
I tested a dirty fix by converting all '%%s' to '%s' and the query worked. Should I submit a bug? Has it been submitted already?

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aa6fee76-1d7f-4b17-a540-4384ca23e595%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pyinotify and runserver performance with django channels in docker for mac

Not sure what exactly wrog here, but installing pyinotify not helps to lower CPU usage in docker on mac OS. As i understand after googling installing of `pyinotify` helps in case of running dev server with `runserver` manage command for general django configuration (without channels, but i not checked it because i need channels), but looks like it's changes nothing when you use `runserver` with `channels`.

What i've made — i've created docker (using latest docker for mac) container with image ubuntu/xenial x64 to execute project. And each page (even in admin panel) loads extremely long (about couple of minutes). If i use `--noreload` option it works fast (couple of seconds or less for page load). I mean loading without cache. I've checked in docker container with `inotifywait` and looks like signals works correctly for file changes, but project works slow even with installed `pyinotify` globally and in project virtual environment.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/61650182-e93b-4a68-ade8-58c3ea18ef31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Is it possible to swap 1.8 and 1.10/1.11 Admin static files

On Wednesday 31 May 2017 12:15:31 Mike Dewhirst wrote:

> Haven't actually communicated our decision but I'll just see if they

> are willing to fund the development involved in staying on an

> out-of-date and soon-to-be-unsupported system we'll hire someone to

> do that.

>

> I think.

>

> Haven't done any research on best practice in this area. Happy to let

> you know what happens ;)

 

I would start with the financials involved. Then provide two alternatives:

1) Address the usibility concerns he has, using template overrides.

2) Opt to install a completely different, well-maintained admin theme free of charge. It is less annoying to start fresh, then to adjust to slightly different placement / look of something that looks like the old. The latter triggers muscle memory that no longer works.

 

--

Melvyn Sopacua

Re: django.db.utils.OperationalError: server closed the connection unexpectedly

Thank you Antonis,
Yeah, We have installed postgresql-8.4.20-7.el6.x86_64

Now we are checking the permission. Will touch you once it done.

Thanks,

Bobby Paul
On Wednesday, May 31, 2017 at 5:14:29 PM UTC+5:30, Bobby Paul wrote:
Dear All,

I am getting this error message while trying to install psql database.

 File "setup.py", line 18, in <module>
    execute_from_command_line(['manage.py','migrate'])
  File "/usr/local/bin/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/local/bin/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/bin/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/bin/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/local/bin/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 93, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/migrations/loader.py", line 191, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
    self.ensure_schema()
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/backends/base/base.py", line 162, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/backends/base/base.py", line 135, in _cursor
    self.ensure_connection()
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
    self.connect()
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
    self.connect()
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/bin/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/local/bin/lib/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
==========
DATABASES_DEFAULT = {

        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'litdb',
        'USER': 'root',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '80',
}

How to sort this issue?

Kind Regards
Bobby Paul

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/92514ce1-503c-4904-8da7-857dd70e10cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: count from multiple tables in a single query?

On Wednesday 31 May 2017 12:13:48 'Abraham Varricatt' via Django users wrote:

 

> If I want to get the total count from both tables it can be done like

> this,

>

> author_count = Author.objects.count()

> publisher_count = Publisher.objects.count()

>

> My concern is that this results in two different queries to the

> database. Can it be done with a single query call?

 

Why is that a concern? This isn't the kind of thing to optimize. Query optimization is about loops and relations. Not about getting information you need - it comes at a price. Have you timed what you could save?

--

Melvyn Sopacua