Wednesday, March 29, 2017

From SQL to Django Queryset API

Hi all.
My name's Mauro and I working on a DB (SQLite3 now and Postgres in the future).

I have a table Movimento with the fields
anno integer,impianto integer,dare decimal(10,2),avere decimal(10,2)

BY hands I can run

SELECT anno,impianto, sum(dare), sum(avere) FROM movimento 
GROUP BY anno,impianto
ORDER BY anno,impianto 

With django Api I write

Movimento.objects.values('anno','impianto').annotate(dare=Sum('dare), avere=Sum('avere))

And I get the same beaviour.

Now I need to translate the following SQL script

SELECT anno,impianto, sum(dare), sum(avere), sum(dare-avere)
FROM movimento 
GROUP BY anno,impianto
ORDER BY anno,impianto 

into django API queryset.

Is it possible todo this in one row?

Cna you give me some idea to solve this translaion?

Finally I'll render the results into a table.

Best regards,
   MZ

--
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/f9efbb30-9065-410d-b46b-55e2d8f1271c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django bug database



On Wednesday, 29 March 2017 14:32:27 UTC+2, Tim Graham wrote:

Thank you. You are too kind :-)

Warm Regards
Lelanthran Manickum
 

--
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/6e372509-ef33-42d8-9563-869be34c137c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Executing DB-Queries during import



Am Mittwoch, 22. März 2017 19:20:43 UTC+1 schrieb Tim Graham:
Correct, module level queries should be avoided. Django might try to add some detection to warn about or prohibit that, see https://groups.google.com/d/topic/django-developers/7JwWatLfP44/discussion.


I understand db queries at module-level (aka "import time") should not happen.

When I am allowed to do db queries.

Is it advisable to execute db queries in my AppConfig ready signal handler?

Use case: I want to add URL patterns which get collected from db rows.


--
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/2faead72-9d96-4ec7-85c2-8d5f8e9b8945%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django bug database

I think https://code.djangoproject.com/wiki/OpenData would help.

On Wednesday, March 29, 2017 at 7:13:56 AM UTC-4, Lelanthran Manickum wrote:
Hi all,

I'm doing a research paper on bugs (and the nature of bugs). As Django is one of the larger and more stable Python projects I thought the Django bug database would be a good source of data. Is it at all possible to download a dump of the Django bug database for offline data-mining?

Warm Regards,
Lelanthran Manickum

--
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/57c13a36-c1e8-4911-a530-b546f5e25909%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Django bug database

Hi all,

I'm doing a research paper on bugs (and the nature of bugs). As Django is one of the larger and more stable Python projects I thought the Django bug database would be a good source of data. Is it at all possible to download a dump of the Django bug database for offline data-mining?

Warm Regards,
Lelanthran Manickum

--
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/9b1f9235-c047-4413-ab3a-2d069b94ee04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Django 10.6 throws 'mbcs codec error' on Windows 10 machine in autoload.py

Hi to all,

I am trying to get started with Django. So  installing Django through pip and following the tutorial on the project's website, I first created a "mysite" project and now try to run "
python manage.py runserver". However, this gives me following error:

C:\mysite>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\User\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\User\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\User\Anaconda3\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\User\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 58, in execute
super(Command, self).execute(*args, **options)
File "C:\Users\User\Anaconda3\lib\site-packages\django\core\management\base.py", line 345, in execute
output = self.handle(*args, **options)
File "C:\Users\User\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 97, in handle
self.run(**options)
File "C:\Users\User\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 106, in run
autoreload.main(self.inner_run, None, options)
File "C:\Users\User\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 333, in main
reloader(wrapped_main_func, args, kwargs)
File "C:\Users\User\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 304, in python_reloader
exit_code = restart_with_reloader()
File "C:\Users\User\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 290, in restart_with_reloader
exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character


Does anyone know th ereason for this error and how to fix it?

Thanks a lot.

--
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/2269a709-c132-4935-85cb-6a59e2907a9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tuesday, March 28, 2017

python-social-auth-django for Twitter

I'm using python-social-auth-django. I' trying to login with Twitter. It works. But some symbols are added to my nickname. Why is it happening?

--
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/0512ea7d-d2b7-4687-8357-e1fea0611769%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.