Database migrations

2016-03-04 Thread raoul
Hi all,

I have been playing around with Django now for a couple of weeks

I have been adding apps to my project and one point of frustration is the 
migration. When there are PK and/or FK relations:
You are trying to add a non-nullable field 'user' to user without a 
default; we can't do that (the database needs something to populate 
existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows)
 2) Quit, and let me add a default in models.py

What I'm use to do is DROP the database and migrate it again. I know this 
is not the way to go, because if you are doing this in PROD you will loose 
all your data. I don't get the logic behind this. Some of you must have 
experience with making major change to you PROD web application. How did 
you made sure all the data is preserved?

Cheers,
Raoul

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b89feec8-ede0-4ed0-956e-45dab3963366%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: help with django-guardian

2016-03-04 Thread 'Tom Evans' via Django users
On Thu, Mar 3, 2016 at 10:58 PM, Joshua Chan
 wrote:
> First off, I am new to both django and python.
>
> I am extending an existing app. We have several admin.py files
>
> They all look like this:
>
> #!/usr/bin/env python
> # coding: utf-8
> from guardian.admin import GuardedModelAdmin
> from django.contrib import admin
>
>
> from devices import models
>
>
> class SomeModelAdmin(GuardedModelAdmin):
> pass
>
>
> admin.site.register(models.SomeModel, SomeModelAdmin)
>
> Everything has been working.
>
> I added my classes
>
> #!/usr/bin/env python
> # coding: utf-8
> from guardian.admin import GuardedModelAdmin
>
>
> from django.contrib import admin
> from common import models
>
>
> class MyModel1Admin(GuardedModelAdmin):
> pass
>
>
> admin.site.register(models.Model, MyModel1Admin)
>
>
> class MyModel2Admin(GuardedModelAdmin):
> pass
>
>
> admin.site.register(models.Model2, MyModel2Admin)
>
> This also works fine locally, but when we deploy it, it blows up on the
> import:
>
>> Traceback (most recent call last):
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
>> line 187, in __call__
>> self.load_middleware()
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/base.py",
>> line 47, in load_middleware
>> mw_instance = mw_class()
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/middleware/locale.py",
>> line 24, in __init__
>> for url_pattern in get_resolver(None).url_patterns:
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py",
>> line 365, in url_patterns
>> patterns = getattr(self.urlconf_module, "urlpatterns",
>> self.urlconf_module)
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py",
>> line 360, in urlconf_module
>> self._urlconf_module = import_module(self.urlconf_name)
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py",
>> line 40, in import_module
>> __import__(name)
>>   File "./sites/zpanel/urls.py", line 19, in 
>> admin.autodiscover()
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
>> line 29, in autodiscover
>> import_module('%s.admin' % app)
>>   File
>> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py",
>> line 40, in import_module
>> __import__(name)
>>   File "./common/admin.py", line 3, in 
>> from guardian.admin import GuardedModelAdmin
>> ImportError: No module named admin
>
>
>
> I am running 2.7.10 locally. The failing machine is running 2.7.6. I'm not
> sure how to switch my env around, but why would other admin.py files import
> guardian.admin correctly?

Is there a module adjacent to the failing admin.py named guardian?

Cheers

Tom

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1%2BLPxL5kjTM9QChS-KMBPJqo9ZjGpb7x-E7mvCBwCQ9Fw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.9 Apps aren't loaded yet

2016-03-04 Thread Larry Martell
On Wed, Mar 2, 2016 at 9:34 AM, Michal Petrucha
 wrote:
> On Wed, Mar 02, 2016 at 08:20:44AM -0500, Larry Martell wrote:
>> On Wed, Mar 2, 2016 at 7:37 AM, Michal Petrucha
>>  wrote:
>> > On Wed, Mar 02, 2016 at 07:05:53AM -0500, Larry Martell wrote:
>> >> I am developing a django app. I had the basic site running, but I had
>> >> not yet created any models. I created a model, and now the server
>> >> fails to start with "Apps aren't loaded yet"
>> >>
>> >> traceback below. Anyone know what I am doing wrong?
>> >
>> > The problem is that one of your applications (foo.app.scripts) imports
>> > models in its top-level __init__.py. This is not supported; for an
>> > explanation, you can read
>> > https://docs.djangoproject.com/en/1.9/ref/applications/#how-applications-are-loaded
>>
>> Thanks you very much for the quick reply. Is there some workaround for
>> this? What version was this issued introduced in? This code works in
>> 1.5.
>
> This is a result of making the initialization process of Django
> explicit in 1.7. The correct way of fixing errors like this is to
> untangle your imports, and remove anything that depends on models from
> top-level __init__.py in your all your application packages. You want
> to draw a boundary around all code that uses models, and make sure
> that none of it is imported before django.setup() has finished.
>
> For a quick and dirty workaround, you can always move the model import
> statements into the definitions of functions that require it; that
> way, the import is not executed until the function itself is called.

Thanks for the explanation. Unfortunately this app has some convoluted
code where is discovers the apps by looking for the __init_files.
Changing it will require a major reworking of a lot of code and my
client does not want to do that. So we will be downgrading to 1.6.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4UkapEDQRPyGTD%2Bn08rimNg6GTV5oPY9ifwGa3cvbWFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Renaming fields in values statements django 1.8

2016-03-04 Thread Jonty Needham
Is there a way to do it? I've seen the method with extra, but that doesn't
seem to work for me. Does the 1.8 ORM support this out of the box?

Thanks in advance.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANOQRbx2SfDM8j-PYVVyByG-DogdQEp9%2BNsQQM5H3rs_UC%3D6rA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Admin page missing icons

2016-03-04 Thread David Hou


Hi all,


I'm really new to Django and am just working through the tutorials right 
now.  I noticed that my admin page is missing some icons (circled in red 
below).  Inspecting the html at these locations shows that there is no icon 
being referenced here.  Is there something I'm missing in my installation 
or something?  I'm using Django 1.9.2


Thanks for the help!







-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64153a17-6a29-438b-8d8d-00b08a7b3172%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Web App for M. Tech Dissertation

2016-03-04 Thread Haruna Yakubu
Hello friends,
Please suggest me a simple project on Python and Django to do as my M. Tech 
dissertation.
thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/739d4e2c-db6a-4965-ba49-e32c2d413d7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Retrieve Specific Fields

2016-03-04 Thread venkatesh penchala
Hello,

I am new to Web Development and chose Django Framework based on very good 
reviews by my friends. I am following tutorials all over the docs. 
I have a requirement in mind to retrieve data from database which is very 
straight forward. But how do I retrieve specific results?

For example, 
I have a two models 'Functions' and 'Solutions' having a Many to Many 
relationship. 
When User selects "few" functions in the UI, I have to retrieve those 
specific functions along with their respective solutions.

Till Now I am successful in getting all the records or an individual record 
using Django Rest Framework. But now, I am struck about the above problem.

Any help would be appreciated.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/48ee8fc4-fdcd-4106-92a3-dfd1d9aede32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Strategies for apps dealing with large interdependent data sets

2016-03-04 Thread Larry Martell
I have to build an app that has many (~15) interdependent selection
fields that come from large datasets across multiple different types
of databases.

For example, field A might have 10 values in a drop down, and when the
user selects "FOO", then field B's drop down gets populated with 30
choices only applicable to "FOO". Then a selection in B of "BAR"
causes drop down C to get populated with 100 choices only applicable
to FOO/BAR. And so on.

The 2 ways I can think of to do this are:

1) each time a field is chosen send an ajax request to get the values
for the dependent fields

or

2) pull all the data when the page is initially rendered and do it all
on the browser without going back to the server

Obviously, the first will cause a lot of delay each time a field is
chosen, whereas the second will cause a big delay to first load the
page, but then it would be responsive after that.

What I am wondering is, are there any other strategies for a problem
like this? How have people here dealt with a situation like this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY43Y-E%3DDKHCM5M0_FUTR8CaLO2LMMgbxDQ40qfgAasmXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: help with django-guardian

2016-03-04 Thread Joshua Chan
There is a folder called guardian_migrations

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b882cf9-e0c9-4b69-a9d3-d7e7d3fd9870%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django for System Administration (Windows and Linux)

2016-03-04 Thread Edison Dungog
Hi Django Users,

Good Day.
Appreciate your assistance if you can point me a reference for a reusable 
app/s that I can use to do system administration such as installing and 
uninstalling software on local machine, listing installed programs on local 
machine, system information etc.
Thanks and have a nice day ahead!

Regards,
Edison

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/abd9ecc7-caca-4a3f-b45d-e4cc72234b90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: more than one field for aggregates? (ArrayAgg, StringAgg)

2016-03-04 Thread Tomasz Nowak
Hi Simon, thank you for your suggestion!
I managed to accomplish that for one column with custom ROW function and 
JSON version with JSON_AGG and JSON_BUILD_OBJECT.

However when using two such annotations the number of aggregated elements 
gets multiplied by the number of elements in the other relation.
I found a different way to get such aggregations independently: 
http://dba.stackexchange.com/a/130212/88817
but when I use extra(select={...}) the same SQL code is placed in GROUP BY 
clause, which results in:

ProgrammingError: could not identify an equality operator for type json

How to prevent adding this extra select to GROUP BY? Without it the query 
works well.

Best wishes
Tomasz


W dniu wtorek, 1 marca 2016 03:52:58 UTC+1 użytkownik Simon Charette 
napisał:
>
> Hi Tomasz,
>
> I suppose you could implement `ROW` as a custom expression[1] and use it in
> your `ArrayAgg` aggregate as follow:
>
> from django.contrib.postgres.aggregates import ArrayAgg
> from django.db.models import Expression
>
> class Row(Expression):
> template = 'ROW(%(expressions)s)'
>
> # ...
>
> MyModel.objects.aggregate(
> ArrayAgg(Row(F('field1'), F('field2'))),
> )
>
>
> Cheers,
> Simon
>
> [1] 
> https://docs.djangoproject.com/en/1.9/ref/models/expressions/#writing-your-own-query-expressions
>
> Le lundi 29 février 2016 19:31:15 UTC-5, Tomasz Nowak a écrit :
>>
>> Hi!
>>
>> Module django.contrib.postgres.aggregates provides classes for ARRAY_AGG 
>> and STRING_AGG PostgreSQL aggregates.
>>
>> Is it possible to provide more than one field to these aggregates? 
>> Like in SQL, where you can provide more fields ("row" is optional):
>>
>> ARRAY_AGG(row(table.field1, table.field2))
>>
>> Best wishes,
>> Tomasz
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c7c778b5-b72e-4604-be72-14d6db2e3d18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Renaming fields in values statements django 1.8

2016-03-04 Thread Simon Charette
Hi Jonty,

There's a ticket tracking the addition of this feature[1] but it has not 
been fixed yet.

Cheers,
Simon

[1] https://code.djangoproject.com/ticket/16735

Le vendredi 4 mars 2016 08:09:20 UTC-5, Jonty Needham a écrit :
>
> Is there a way to do it? I've seen the method with extra, but that doesn't 
> seem to work for me. Does the 1.8 ORM support this out of the box?
>
> Thanks in advance.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4cba1afd-4d66-4876-8e5f-c3a928c68166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Renaming fields in values statements django 1.8

2016-03-04 Thread Simon Charette
Hi Jonty,

There's a ticket tracking the addition of this feature[1] but it has not 
been fixed yet.

Cheers,
Simon

[1] https://code.djangoproject.com/ticket/16735

Le vendredi 4 mars 2016 08:09:20 UTC-5, Jonty Needham a écrit :
>
> Is there a way to do it? I've seen the method with extra, but that doesn't 
> seem to work for me. Does the 1.8 ORM support this out of the box?
>
> Thanks in advance.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53dc6819-2520-4f9f-b796-3cba65996d90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Development of web based image processing package

2016-03-04 Thread James Schneider
On Mar 3, 2016 3:54 PM, "Xristos Xristoou"  wrote:
>
> @james celeny support .grid raster image type  ?
>
>

Celery only handles the background task management, not the task itself. It
would be responsible for firing another script that would handle the image
manipulation, and reporting back to Django when the job is complete for the
user to view the results at a later time.

-James

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUQh7gxg9PeNgASQue9mA-ATKGbQ4zKdocbujJsC8oT5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: more than one field for aggregates? (ArrayAgg, StringAgg)

2016-03-04 Thread Simon Charette
Hi Thomasz,

Using extra() is a dead end as it's planned to be removed.

It's hard for me to guide you about how you should use the expression API 
with no
model definition or queryset.

Could you provide us with the set of model and the annotated querysets 
you're building?

The queryset's SQL representation would also be useful 
(str(queryset.query)).

Cheers,
Simon

Le vendredi 4 mars 2016 09:57:43 UTC-5, Tomasz Nowak a écrit :
>
> Hi Simon, thank you for your suggestion!
> I managed to accomplish that for one column with custom ROW function and 
> JSON version with JSON_AGG and JSON_BUILD_OBJECT.
>
> However when using two such annotations the number of aggregated elements 
> gets multiplied by the number of elements in the other relation.
> I found a different way to get such aggregations independently: 
> http://dba.stackexchange.com/a/130212/88817
> but when I use extra(select={...}) the same SQL code is placed in GROUP BY 
> clause, which results in:
>
> ProgrammingError: could not identify an equality operator for type json
>
> How to prevent adding this extra select to GROUP BY? Without it the query 
> works well.
>
> Best wishes
> Tomasz
>
>
> W dniu wtorek, 1 marca 2016 03:52:58 UTC+1 użytkownik Simon Charette 
> napisał:
>>
>> Hi Tomasz,
>>
>> I suppose you could implement `ROW` as a custom expression[1] and use it 
>> in
>> your `ArrayAgg` aggregate as follow:
>>
>> from django.contrib.postgres.aggregates import ArrayAgg
>> from django.db.models import Expression
>>
>> class Row(Expression):
>> template = 'ROW(%(expressions)s)'
>>
>> # ...
>>
>> MyModel.objects.aggregate(
>> ArrayAgg(Row(F('field1'), F('field2'))),
>> )
>>
>>
>> Cheers,
>> Simon
>>
>> [1] 
>> https://docs.djangoproject.com/en/1.9/ref/models/expressions/#writing-your-own-query-expressions
>>
>> Le lundi 29 février 2016 19:31:15 UTC-5, Tomasz Nowak a écrit :
>>>
>>> Hi!
>>>
>>> Module django.contrib.postgres.aggregates provides classes for ARRAY_AGG 
>>> and STRING_AGG PostgreSQL aggregates.
>>>
>>> Is it possible to provide more than one field to these aggregates? 
>>> Like in SQL, where you can provide more fields ("row" is optional):
>>>
>>> ARRAY_AGG(row(table.field1, table.field2))
>>>
>>> Best wishes,
>>> Tomasz
>>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5457b6bc-372d-4a45-b1ca-ffa9344384fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin page missing icons

2016-03-04 Thread aspellip
In your browser enable "network inspector" and reload page, you will see 
where is icon must locate. 

For example:

On Friday, March 4, 2016 at 3:16:37 PM UTC+2, David Hou wrote:
>
> Hi all,
>
>
> I'm really new to Django and am just working through the tutorials right 
> now.  I noticed that my admin page is missing some icons (circled in red 
> below).  Inspecting the html at these locations shows that there is no icon 
> being referenced here.  Is there something I'm missing in my installation 
> or something?  I'm using Django 1.9.2
>
>
> Thanks for the help!
>
>
> 
>
>
> 
>
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a59c4475-b911-4a3a-ac42-e4ade204746c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Database migrations

2016-03-04 Thread Daniel Roseman
What are you expecting to happen? The message is quite clear, and offers the 
only two possible options. Are neither of those suitable? Why not? What other 
action would you like to take?
-- 
DR.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4dfee0dc-0912-4913-8a6d-b360d442550b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django: ajax simple loading gif not working/ over-riding render to output page

2016-03-04 Thread aspellip
I'm using nginx + upload_progress module
On the HTML page for progress bar  I'm using iframe + ajax 
u can find a result here http://fex.cc





On Thursday, March 3, 2016 at 9:23:53 PM UTC+2, clarkso...@gmail.com wrote:
>
> Hoping that this network can help me out even though this is not strictly 
> django-related, otherwise can someone recommend a group other than stack 
> overflow that could help here?
>
> I have a functioning upload function implemented in django. The files 
> being handled are large making for a long waiting time and so I would like 
> to provide a "Please Wait/ Loading.../ GIF" on the page while the files are 
> loading.
>
> The HTML/Django that begins the uploading function is as follows:
>
> "showMessage()"/>
>
> The upload button is as follows (accompanied by a hidden div):
>
>  
>
>  
>
> I took some example code and tried to adapt it to the above HTML but it's 
> not showing up on the page at all during the loading time... and I have no 
> errors to follow.
>
> The ajax:
>
> function showMessage() {
> $('.up').show()// document.getElementById("up").innerHTML = "please 
> wait";}
>
> However my ajax code is not having any effect as the hidden div does not 
> appear after clicking "Upload".
>
> I am not at all familiar with Ajax/javascript and so while I understand 
> that I can see that I am able to set a function "showMessage" and then upon 
> clicking "Upload" the function will be called should render the hidden div 
> to the page until the output is complete and rendered to the output page.
>
> I should also mention that before I decided to use a GIF I successfully 
> managed to get a "Please wait" message to appear after clicking the 
> "Upload" button (this code is silenced in the "showMessage" function above.
>
> The problem is that the "Please Wait" message actually over-rides the 
> rendering to the output page and hence the results of the upload do not 
> display when processed.
>
> Hence overall I just want a hidden div to render to the input page until 
> the output is complete and in a way that will not conflict with the more 
> important, subsequent rendering to the output page.
>
> The syntax I'm using is not having any effect on the page so I'm hoping 
> someone can correct my misguided code.
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4c94ba7e-b07a-4cfa-82be-5dff6e5806ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem Django.19 upgrade and circular imports

2016-03-04 Thread Andres Osinski
The thing is that in my case, I have a model in the 'accounts' app which
inherits from a model in 'common', therefore I need the import to happen in
one's models.

I've tried this in Django 1.8 and I see the same behavior; therefore the
change occurs between the latest versions of 1.7 and 1.8. I'll try with
older versions in 1.8 and report back.

On Thu, Mar 3, 2016 at 10:11 PM, James Schneider 
wrote:

> On Thu, Mar 3, 2016 at 3:28 PM, Andres Osinski 
> wrote:
>
>> Hi everyone! I'm having an issue with circular imports in Django 1.9 that
>> I have not seen in my app, which had been running 1.7 before.
>>
>> I have a Django app in apps.common, which has its associated
>> apps.common.models too. No imports on __init__.py or anything of the sort.
>> When I my app in apps.account.models attempts to import
>> apps.common.models, it complains that said module does not exist.
>>
>> Putting a pdb set_trace() call at the top of apps.common.models and
>> apps.account.models shows that the former executes *before*
>> apps.account.models, so I fail to see how this could result in the posted
>> error.
>>
>> For the record, both apps use the new AppConfig scheme in their
>> corresponding apps.py file, and the import order in INSTALLED_APPS is:
>>
>> 'apps.common.CommonConfig',
>> 'apps.account.AccountConfig',
>> ...
>>
>> Has anyone else had a similar issue in this upgrade? Is there anything I
>> can do to diagnose the source of this?
>>
>
> Are you bringing in other functions in as part of your imports, or just
> other models? If you are only bringing in models for use with FK's and
> M2M's, then I would suggest referring to those models via their text path
> rather than using the Python class object directly. It avoids needing the
> import statement during the initial load (which avoids the circular import
> issue). See the end of this section about referring to models in other
> applications using a string rather than the real Python object (and make
> sure to remove the related import statements):
>
> https://docs.djangoproject.com/en/1.9/ref/models/fields/#foreignkey
>
> -James
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUWHXr6axqA5drrsMnR3%2B9d0D1wBHSK9wQwSmqs52xFAw%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andrés Osinski

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BxF-Py5x%3DYb1okC_rwP3xV4moo9nTsHgw6c_-ZJ2geBinQ8rQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Trouble Transitioning from SQLite to Postgres

2016-03-04 Thread TMC


I'm new, and I'm having an issue switching to my Django 1.9 database to 
Postgres. Having made the switch, all my unit tests pass just fine, and the 
site works exactly the way I want it to when I run it locally. However, my 
Selenium tests all fail at the login stage. It's odd--if I follow the steps 
of the Selenium tests, it works just fine.


Here are the Selenium tests on pastebin . When 
I use the sqlite database (settings ), all 
these tests pass. When I set postgres up and switched to it (django settings 
, pg_hba.conf ) 
The test_whether_login_works_with_django_client test passes. The 
test_whether_login_page_works test fails with this traceback 
. What happens is that the Selenium browser 
sends the login info to the login page, and gets redirected to the login 
page.


Here are some things I've ruled out:


1) The login credentials are correct. This is checked in two places. The 
log_user_in helper function in the Selenium tests tests the credentials 
directly using django.contrib.auth.authenticate on line 45 and following of 
the Selenium tests . In addition, the 
test_whether_login_works_with_django_test_client tests the credentials 
directly by sending them to the login view and testing whether the user is 
authenticated.


2) Django is able to write to and read from the postgres database. The unit 
tests I've set up for this pass, plus I can manually create users, login, 
save items, and retrieve items from the database using manage.py's 
runserver feature.


3) The problem is not with the login view, at least directly. If I switch 
back to the sqlite database, these tests pass just fine. (I've switched the 
settings back and forth several times.) Plus, I've manually tested the 
login page with my browser.


4) The problem doesn't result from an attempt to migrate data from the old 
sqlite database. I just set up the postgres database, ran makemigrations 
and migrate, and started with a brand new database.


I'm pretty stumped. I've got Selenium up to date with pip. I'm using python 
3.4. I posted on Stack Overflow, but nobody can figure it out.


Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4a6c1395-e50a-4d9d-8b19-51cbdd93965d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin page missing icons

2016-03-04 Thread Bruno Barbosa
Are you running django with DEBUG=False?
​​
Try run python.py manage.py collectstatic then reload page.

--
Bruno Barbosa
Web Developer
*brunobarbosa.com.br *

On Fri, Mar 4, 2016 at 4:13 PM,  wrote:

> In your browser enable "network inspector" and reload page, you will see
> where is icon must locate.
>
> For example:
>
> On Friday, March 4, 2016 at 3:16:37 PM UTC+2, David Hou wrote:
>>
>> Hi all,
>>
>>
>> I'm really new to Django and am just working through the tutorials right
>> now.  I noticed that my admin page is missing some icons (circled in red
>> below).  Inspecting the html at these locations shows that there is no icon
>> being referenced here.  Is there something I'm missing in my installation
>> or something?  I'm using Django 1.9.2
>>
>>
>> Thanks for the help!
>>
>>
>> 
>>
>>
>> 
>>
>>
>>
>> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a59c4475-b911-4a3a-ac42-e4ade204746c%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHxcCH6%2Bqym_8va8EHUSFYY%3DwBtQVLq%3DdSRLFmX3cSG0tHS5wg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


MultipleCharField

2016-03-04 Thread Rafael Macêdo
Sou iniciante em Django e gostaria de saber se há algum tipo de campo na 
classe Model semelhante ao MultipleChoiceField da classe Form.

Obrigado desde já.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/37eaa1f9-f50b-4bd6-a37a-67b5c7d6290e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Hello

2016-03-04 Thread direcoape
Hello I new in Django I would like to get some tutorials. I speak  
Spanish, is somobody here who speak spanish? please, help me about that



This message was sent using IMP, the Internet Messaging Program.



--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160304142552.63555kcv1s40utkw%40webmail.sld.cu.
For more options, visit https://groups.google.com/d/optout.


Re: Admin page missing icons

2016-03-04 Thread Bruno Barbosa
sorry, the correct command is: python manage.py collectstatic

--
Bruno Barbosa
Web Developer

On Fri, Mar 4, 2016 at 5:09 PM, Bruno Barbosa  wrote:

> Are you running django with DEBUG=False?
> ​​
> Try run python.py manage.py collectstatic then reload page.
>
> --
> Bruno Barbosa
> Web Developer
> *brunobarbosa.com.br *
>
> On Fri, Mar 4, 2016 at 4:13 PM,  wrote:
>
>> In your browser enable "network inspector" and reload page, you will see
>> where is icon must locate.
>>
>> For example:
>>
>> On Friday, March 4, 2016 at 3:16:37 PM UTC+2, David Hou wrote:
>>>
>>> Hi all,
>>>
>>>
>>> I'm really new to Django and am just working through the tutorials right
>>> now.  I noticed that my admin page is missing some icons (circled in red
>>> below).  Inspecting the html at these locations shows that there is no icon
>>> being referenced here.  Is there something I'm missing in my installation
>>> or something?  I'm using Django 1.9.2
>>>
>>>
>>> Thanks for the help!
>>>
>>>
>>> 
>>>
>>>
>>> 
>>>
>>>
>>>
>>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/a59c4475-b911-4a3a-ac42-e4ade204746c%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHxcCH7UEBiLbr-G%2BugqWBwYCMfZ0rdQbsjEzRwNCbbZHHgsaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Hello

2016-03-04 Thread Bruno Barbosa
I think that a good start point is the django official website
https://www.djangoproject.com/ and your intro tutorial:
https://docs.djangoproject.com/en/1.9/intro/

Also, you can see the Django spanish site: http://django.es/

--
Bruno Barbosa
Web Developer

On Fri, Mar 4, 2016 at 4:25 PM,  wrote:

> Hello I new in Django I would like to get some tutorials. I speak Spanish,
> is somobody here who speak spanish? please, help me about that
>
> 
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
> --
> Este mensaje le ha llegado mediante el servicio de correo electronico que
> ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema
> Nacional de Salud. La persona que envia este correo asume el compromiso de
> usar el servicio a tales fines y cumplir con las regulaciones establecidas
>
> Infomed: http://www.sld.cu/
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20160304142552.63555kcv1s40utkw%40webmail.sld.cu
> .
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHxcCH78Rd8h_0yRUYyobMCCjrQOnnMZinevct5JkY04BDZ40Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Hello

2016-03-04 Thread direcoape
I have been seeing it but I just have acces  
https://www.djangoproject.com/ and this one too  
https://docs.djangoproject.com/en/1.9/intro/


but just thouse one, I would like to get some tutorials but my big  
problem is my email, I can not get a file bigger than 2 mb  haha I  
live in Cuba





This message was sent using IMP, the Internet Messaging Program.



--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160304155718.1243858fs518g7n2%40webmail.sld.cu.
For more options, visit https://groups.google.com/d/optout.


Re: more than one field for aggregates? (ArrayAgg, StringAgg)

2016-03-04 Thread Tomasz Nowak
Hi!

I would like to create a JSON structure of chosen objects (animals) with 
corresponding events in one database hit.
The model represents animals and different types of events that happened to 
them:

class Animal(models.Model):
life_number = models.TextField(primary_key=True)
birthday = models.DateField(blank=True, null=True)

class 
Inseminacja(models.Model):  


cow = models.ForeignKey(Animal, models.DO_NOTHING, 
db_column='cow_life_number')
date = 
models.DateTimeField()  
 

number = 
models.IntegerField()   
   


class WynikBadania(models.Model):
  animal = models.ForeignKey(Animal, models.DO_NOTHING, 
db_column='anilifenumber')
  date_entered = models.DateTimeField(db_column='timestamp')

I use my JsonAgg and JsonBuildObject functions submitted to Trac at:
https://code.djangoproject.com/ticket/26327#no1

>>> qs = Animal.objects.filter(pk='PL005257066205').annotate(
ins  = 
JsonAgg(JsonBuildObject([F('inseminacja__date'),F('inseminacja__number')], 
output_field=CharField())), 
examinations = 
JsonAgg(JsonBuildObject([F('wynikbadania__date_entered')], 
output_field=CharField()))
  )

The resulting query naturally results in cartesian product of the events, 
which is exactly my problem:

>>> str(qs.query)

'SELECT 
"animal"."life_number", 
"animal"."birthday", 
JSON_AGG(JSON_BUILD_OBJECT(\'timestamp\',"wynikbadania"."timestamp")) 
AS "examinations", 

JSON_AGG(JSON_BUILD_OBJECT(\'date\',"inseminacja"."date",\'number\',"inseminacja"."number"))
 
AS "ins" 
FROM "animal" 
LEFT OUTER JOIN "wynikbadania" ON ("animal"."life_number" = 
"wynikbadania"."anilifenumber") 
LEFT OUTER JOIN "inseminacja" ON ("animal"."life_number" = 
"inseminacja"."cow_life_number") 
WHERE "animal"."life_number" = PL005257066205 
GROUP BY "animal"."life_number"'

>>> qs.values()

[{
  'examinations': [
{u'timestamp': u'2014-11-20T12:41:54'}, 
{u'timestamp': u'2014-11-20T12:41:54'}, 
{u'timestamp': u'2015-07-13T11:41:08.40319'}, 
{u'timestamp': u'2015-07-13T11:41:08.40319'}
  ], 
  'birthday': None, 
  'ins': [
{u'date': u'2013-11-16T15:00:00', u'number': 1}, 
{u'date': u'2013-12-09T10:00:00', u'number': 2}, 
{u'date': u'2013-11-16T15:00:00', u'number': 1}, 
{u'date': u'2013-12-09T10:00:00', u'number': 2}
  ], 
  'life_number': u'PL005257066205'
}]

I don't know exact SQL query that should be used.
Using DISTINCT is not possible, as "JSON_AGG(DISTINCT JSON_BUILD_OBJECT(" 
results in "ERROR:  could not identify an equality operator for type json".
Using GROUP BY "animal"."life_number", 
"wynikbadania"."timestamp","inseminacja"."date" naturally results in 4 
separate records.

Do you have any ideas?

Best wishes,
Tomasz



W dniu piątek, 4 marca 2016 18:51:51 UTC+1 użytkownik Simon Charette 
napisał:
>
> Hi Thomasz,
>
> Using extra() is a dead end as it's planned to be removed.
>
> It's hard for me to guide you about how you should use the expression API 
> with no
> model definition or queryset.
>
> Could you provide us with the set of model and the annotated querysets 
> you're building?
>
> The queryset's SQL representation would also be useful 
> (str(queryset.query)).
>
> Cheers,
> Simon
>
> Le vendredi 4 mars 2016 09:57:43 UTC-5, Tomasz Nowak a écrit :
>>
>> Hi Simon, thank you for your suggestion!
>> I managed to accomplish that for one column with custom ROW function and 
>> JSON version with JSON_AGG and JSON_BUILD_OBJECT.
>>
>> However when using two such annotations the number of aggregated elements 
>> gets multiplied by the number of elements in the other relation.
>> I found a different way to get such aggregations independently: 
>> http://dba.stackexchange.com/a/130212/88817
>> but when I use extra(select={...}) the same SQL code is placed in GROUP 
>> BY clause, which results in:
>>
>> ProgrammingError: could not identify an equality operator for type json
>>
>> How to prevent adding this extra select to GROUP BY? Without it the query 
>> works well.
>>
>> Best wishes
>> Tomasz
>>
>>
>> W dniu wtorek, 1 marca 2016 03:52:58 UTC+1 użytkownik Simon Charette 
>> napisał:
>>>
>>> Hi Tomasz,
>>>
>>> I suppose you could implement `ROW` as a custom expression[1] and use it 
>>> in
>>> your `ArrayAgg` aggregate as follow:
>>>
>>> from django.contrib.postgres.aggregates import ArrayAgg
>>> from django.db.models import Expression
>>>
>>> class Row(Expression):
>>> template = 'ROW(%(expressions)s)'
>>>
>>> # ...
>>>
>>> MyModel.objects.aggregate(
>>> ArrayAgg(Row(F('field1'), F('field2'))),
>>> )
>>>
>>>
>>> Cheers,
>>> Simon
>>>
>>> [1] 
>>> https://docs.djangoproject.com/en/1.9/ref/models/expressions/#writing-your-own-query-expressions
>>>
>>> Le lundi 29 février 2016 19:31:15 UTC-5, To

Re: Django Hello

2016-03-04 Thread Bruno Barbosa
But these tutorials are online.. you don't need download it..

--
Bruno Barbosa
Web Developer
*brunobarbosa.com.br *

On Fri, Mar 4, 2016 at 5:57 PM,  wrote:

> I have been seeing it but I just have acces https://www.djangoproject.com/
> and this one too https://docs.djangoproject.com/en/1.9/intro/
>
> but just thouse one, I would like to get some tutorials but my big problem
> is my email, I can not get a file bigger than 2 mb  haha I live in Cuba
>
>
>
> 
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
> --
> Este mensaje le ha llegado mediante el servicio de correo electronico que
> ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema
> Nacional de Salud. La persona que envia este correo asume el compromiso de
> usar el servicio a tales fines y cumplir con las regulaciones establecidas
>
> Infomed: http://www.sld.cu/
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20160304155718.1243858fs518g7n2%40webmail.sld.cu
> .
>
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHxcCH6n9h4qmRdMqOY%3DV4xHnQU-wLU7Ru5MDVfjm5dxZy5iBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble Transitioning from SQLite to Postgres

2016-03-04 Thread Mike Dewhirst

On 5/03/2016 7:35 AM, TMC wrote:

I'm new, and I'm having an issue switching to my Django 1.9 database to
Postgres. Having made the switch, all my unit tests pass just fine, and
the site works exactly the way I want it to when I run it locally.
However, my Selenium tests all fail at the login stage. It's odd--if I
follow the steps of the Selenium tests, it works just fine.


Here are the Selenium tests on pastebin
. When I use the sqlite database
(settings ), all these tests pass. When I
set postgres up and switched to it (django settings
, pg_hba.conf
) The
test_whether_login_works_with_django_client test passes. The
test_whether_login_page_works test fails with this traceback
. What happens is that the Selenium
browser sends the login info to the login page, and gets redirected to
the login page.


Here are some things I've ruled out:


This is a shot in the dark but it may be a timing issue. Each new 
version of Django (I think) increases the number of hashes of a password 
to delay login so it becomes expensive for brute force attacks. Can you 
test what the delay is?


Maybe Selenium isn't coping with that?

Don't know what the SQLite vs Postgres difference might be except SQLite 
is possibly a bit faster.


Mike




1) The login credentials are correct. This is checked in two places. The
log_user_in helper function in the Selenium tests tests the credentials
directly using django.contrib.auth.authenticate on line 45 and following
of the Selenium tests . In addition, the
test_whether_login_works_with_django_test_client tests the credentials
directly by sending them to the login view and testing whether the user
is authenticated.


2) Django is able to write to and read from the postgres database. The
unit tests I've set up for this pass, plus I can manually create users,
login, save items, and retrieve items from the database using
manage.py's runserver feature.


3) The problem is not with the login view, at least directly. If I
switch back to the sqlite database, these tests pass just fine.
(I've switched the settings back and forth several times.) Plus, I've
manually tested the login page with my browser.


4) The problem doesn't result from an attempt to migrate data from the
old sqlite database. I just set up the postgres database,
ran makemigrations and migrate, and started with a brand new database.


I'm pretty stumped. I've got Selenium up to date with pip. I'm using
python 3.4. I posted on Stack Overflow, but nobody can figure it out.


Thanks!

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/4a6c1395-e50a-4d9d-8b19-51cbdd93965d%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56D9FC24.6050908%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


I don't understand this error - Django 1.9

2016-03-04 Thread Becka R.
Hi, 

I'm building a pretty basic CRUD application for a community I'm part of.   
I'm now getting "ImportError: No module named [myappname]" when I run the 
server, and an operational error in the admin. 

I looked at the documentation, and followed the steps, but I'm not doing 
something correctly.  I'd like to 1) fix this, and 2) propose some changes 
to the docs to clarify this issue. 

My project is called "ladynerds" (We're a professional association for a 
bunch of women software engineers). 

Here's the documentation I'm following:

https://docs.djangoproject.com/en/1.9/ref/applications/

I'm using Django 1.9

*Here's my file structure:*

/ladynerds   (project file)
 /ladynerds  (app)
  __init__.py
  models.py
  forms.py
  settings.py
  urls.py
  views.py
  wsgi.py
  /static
  /templates
  

*Here's what I put into ladynerds/__init__.py:*


import apps

default_app_config = 'LadyNerds.apps.LadyNerdsConfig'


I've also tried using 'ladynerds.apps.LadyNerdsConfig'


*Here's what I put into ladynerds/apps.py:*

from django.apps import AppConfig

class LadyNerdsConfig(AppConfig):
name = "LadyNerds"
verbose_name = "LadyNerds"

*Here's my settings.py INSTALLED_APPS*


INSTALLED_APPS = (
'ladynerds.apps.LadyNerdsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ladynerds'
)


I'm getting:  ImportError: No module named LadyNerds

What am I missing?

And, thanks. 

Becka

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2e9e6959-0dc6-4cfb-9fe1-5aaf77db852f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: more than one field for aggregates? (ArrayAgg, StringAgg)

2016-03-04 Thread Simon Charette
Hi Thomasz,

I think this might be a bug in either your custom expressions or Django's
GROUP BY handling on PostgreSQL.

Can you try setting 
`django.db.backends.postgresql.features.DatabaseFeatures.allows_group_by_selected_pks`
to `False` and see if the appropriate GROUP BY clause is generated?

Meanwhile I'll have a look at both your custom expressions to try to 
identify
the bug.

Simon

Le vendredi 4 mars 2016 16:02:14 UTC-5, Tomasz Nowak a écrit :
>
> Hi!
>
> I would like to create a JSON structure of chosen objects (animals) with 
> corresponding events in one database hit.
> The model represents animals and different types of events that happened 
> to them:
>
> class Animal(models.Model):
> life_number = models.TextField(primary_key=True)
> birthday = models.DateField(blank=True, null=True)
>
> class 
> Inseminacja(models.Model):
>   
>
> cow = models.ForeignKey(Animal, models.DO_NOTHING, 
> db_column='cow_life_number')
> date = 
> models.DateTimeField()
>
>
> number = 
> models.IntegerField() 
>  
>
>
> class WynikBadania(models.Model):
>   animal = models.ForeignKey(Animal, models.DO_NOTHING, 
> db_column='anilifenumber')
>   date_entered = models.DateTimeField(db_column='timestamp')
>
> I use my JsonAgg and JsonBuildObject functions submitted to Trac at:
> https://code.djangoproject.com/ticket/26327#no1
>
> >>> qs = Animal.objects.filter(pk='PL005257066205').annotate(
> ins  = 
> JsonAgg(JsonBuildObject([F('inseminacja__date'),F('inseminacja__number')], 
> output_field=CharField())), 
> examinations = 
> JsonAgg(JsonBuildObject([F('wynikbadania__date_entered')], 
> output_field=CharField()))
>   )
>
> The resulting query naturally results in cartesian product of the events, 
> which is exactly my problem:
>
> >>> str(qs.query)
>
> 'SELECT 
> "animal"."life_number", 
> "animal"."birthday", 
> JSON_AGG(JSON_BUILD_OBJECT(\'timestamp\',"wynikbadania"."timestamp")) 
> AS "examinations", 
> 
> JSON_AGG(JSON_BUILD_OBJECT(\'date\',"inseminacja"."date",\'number\',"inseminacja"."number"))
>  
> AS "ins" 
> FROM "animal" 
> LEFT OUTER JOIN "wynikbadania" ON ("animal"."life_number" = 
> "wynikbadania"."anilifenumber") 
> LEFT OUTER JOIN "inseminacja" ON ("animal"."life_number" = 
> "inseminacja"."cow_life_number") 
> WHERE "animal"."life_number" = PL005257066205 
> GROUP BY "animal"."life_number"'
>
> >>> qs.values()
>
> [{
>   'examinations': [
> {u'timestamp': u'2014-11-20T12:41:54'}, 
> {u'timestamp': u'2014-11-20T12:41:54'}, 
> {u'timestamp': u'2015-07-13T11:41:08.40319'}, 
> {u'timestamp': u'2015-07-13T11:41:08.40319'}
>   ], 
>   'birthday': None, 
>   'ins': [
> {u'date': u'2013-11-16T15:00:00', u'number': 1}, 
> {u'date': u'2013-12-09T10:00:00', u'number': 2}, 
> {u'date': u'2013-11-16T15:00:00', u'number': 1}, 
> {u'date': u'2013-12-09T10:00:00', u'number': 2}
>   ], 
>   'life_number': u'PL005257066205'
> }]
>
> I don't know exact SQL query that should be used.
> Using DISTINCT is not possible, as "JSON_AGG(DISTINCT JSON_BUILD_OBJECT(" 
> results in "ERROR:  could not identify an equality operator for type json".
> Using GROUP BY "animal"."life_number", 
> "wynikbadania"."timestamp","inseminacja"."date" naturally results in 4 
> separate records.
>
> Do you have any ideas?
>
> Best wishes,
> Tomasz
>
>
>
> W dniu piątek, 4 marca 2016 18:51:51 UTC+1 użytkownik Simon Charette 
> napisał:
>>
>> Hi Thomasz,
>>
>> Using extra() is a dead end as it's planned to be removed.
>>
>> It's hard for me to guide you about how you should use the expression API 
>> with no
>> model definition or queryset.
>>
>> Could you provide us with the set of model and the annotated querysets 
>> you're building?
>>
>> The queryset's SQL representation would also be useful 
>> (str(queryset.query)).
>>
>> Cheers,
>> Simon
>>
>> Le vendredi 4 mars 2016 09:57:43 UTC-5, Tomasz Nowak a écrit :
>>>
>>> Hi Simon, thank you for your suggestion!
>>> I managed to accomplish that for one column with custom ROW function and 
>>> JSON version with JSON_AGG and JSON_BUILD_OBJECT.
>>>
>>> However when using two such annotations the number of aggregated 
>>> elements gets multiplied by the number of elements in the other relation.
>>> I found a different way to get such aggregations independently: 
>>> http://dba.stackexchange.com/a/130212/88817
>>> but when I use extra(select={...}) the same SQL code is placed in GROUP 
>>> BY clause, which results in:
>>>
>>> ProgrammingError: could not identify an equality operator for type json
>>>
>>> How to prevent adding this extra select to GROUP BY? Without it the 
>>> query works well.
>>>
>>> Best wishes
>>> Tomasz
>>>
>>>
>>> W dniu wtorek, 1 marca 2016 03:52:5

Re: more than one field for aggregates? (ArrayAgg, StringAgg)

2016-03-04 Thread Simon Charette
In order to make sure the bug doesn't lie in your expressions could you try
running the following queryset:

Animal.objects.filter(pk='PL005257066205').annotate(
inseminacja_cnt=Count('inseminacja'),
wynikbadania_cnt=Count('wynikbadania'),
)

If the results are `inseminacja_cnt=4` and `wynikbadania_cnt=4` I'm afraid 
you
might have hit a Django bug with multiple annotations over multi-valued
relationships.

Adding a `DISTINCT ON ('animal.life_number', 'wynikbadania.id', 
'inseminacja.id')`
might help you but I wouldn't be surprised if it affected performance badly.

You should be able to do that using the `distinct()` method:

Animal.objects.filter(pk='PL005257066205').annotate(
ins=JsonAgg(
JsonBuildObject(
[F('inseminacja__date'),F('inseminacja__number')], 
output_field=CharField()
)
),
examinations=JsonAgg(
JsonBuildObject(
[F('wynikbadania__date_entered')], output_field=CharField()
)
),
).distinct('life_number', 'inseminacja__id', 'wynikbadania__id')

Cheers,
Simon

Le vendredi 4 mars 2016 16:28:16 UTC-5, Simon Charette a écrit :
>
> Hi Thomasz,
>
> I think this might be a bug in either your custom expressions or Django's
> GROUP BY handling on PostgreSQL.
>
> Can you try setting 
> `django.db.backends.postgresql.features.DatabaseFeatures.allows_group_by_selected_pks`
> to `False` and see if the appropriate GROUP BY clause is generated?
>
> Meanwhile I'll have a look at both your custom expressions to try to 
> identify
> the bug.
>
> Simon
>
> Le vendredi 4 mars 2016 16:02:14 UTC-5, Tomasz Nowak a écrit :
>>
>> Hi!
>>
>> I would like to create a JSON structure of chosen objects (animals) with 
>> corresponding events in one database hit.
>> The model represents animals and different types of events that happened 
>> to them:
>>
>> class Animal(models.Model):
>> life_number = models.TextField(primary_key=True)
>> birthday = models.DateField(blank=True, null=True)
>>
>> class 
>> Inseminacja(models.Model):   
>>
>>
>> cow = models.ForeignKey(Animal, models.DO_NOTHING, 
>> db_column='cow_life_number')
>> date = 
>> models.DateTimeField()   
>> 
>>
>> number = 
>> models.IntegerField()
>>   
>>
>>
>> class WynikBadania(models.Model):
>>   animal = models.ForeignKey(Animal, models.DO_NOTHING, 
>> db_column='anilifenumber')
>>   date_entered = models.DateTimeField(db_column='timestamp')
>>
>> I use my JsonAgg and JsonBuildObject functions submitted to Trac at:
>> https://code.djangoproject.com/ticket/26327#no1
>>
>> >>> qs = Animal.objects.filter(pk='PL005257066205').annotate(
>> ins  = 
>> JsonAgg(JsonBuildObject([F('inseminacja__date'),F('inseminacja__number')], 
>> output_field=CharField())), 
>> examinations = 
>> JsonAgg(JsonBuildObject([F('wynikbadania__date_entered')], 
>> output_field=CharField()))
>>   )
>>
>> The resulting query naturally results in cartesian product of the events, 
>> which is exactly my problem:
>>
>> >>> str(qs.query)
>>
>> 'SELECT 
>> "animal"."life_number", 
>> "animal"."birthday", 
>> JSON_AGG(JSON_BUILD_OBJECT(\'timestamp\',"wynikbadania"."timestamp")) 
>> AS "examinations", 
>> 
>> JSON_AGG(JSON_BUILD_OBJECT(\'date\',"inseminacja"."date",\'number\',"inseminacja"."number"))
>>  
>> AS "ins" 
>> FROM "animal" 
>> LEFT OUTER JOIN "wynikbadania" ON ("animal"."life_number" = 
>> "wynikbadania"."anilifenumber") 
>> LEFT OUTER JOIN "inseminacja" ON ("animal"."life_number" = 
>> "inseminacja"."cow_life_number") 
>> WHERE "animal"."life_number" = PL005257066205 
>> GROUP BY "animal"."life_number"'
>>
>> >>> qs.values()
>>
>> [{
>>   'examinations': [
>> {u'timestamp': u'2014-11-20T12:41:54'}, 
>> {u'timestamp': u'2014-11-20T12:41:54'}, 
>> {u'timestamp': u'2015-07-13T11:41:08.40319'}, 
>> {u'timestamp': u'2015-07-13T11:41:08.40319'}
>>   ], 
>>   'birthday': None, 
>>   'ins': [
>> {u'date': u'2013-11-16T15:00:00', u'number': 1}, 
>> {u'date': u'2013-12-09T10:00:00', u'number': 2}, 
>> {u'date': u'2013-11-16T15:00:00', u'number': 1}, 
>> {u'date': u'2013-12-09T10:00:00', u'number': 2}
>>   ], 
>>   'life_number': u'PL005257066205'
>> }]
>>
>> I don't know exact SQL query that should be used.
>> Using DISTINCT is not possible, as "JSON_AGG(DISTINCT JSON_BUILD_OBJECT(" 
>> results in "ERROR:  could not identify an equality operator for type json".
>> Using GROUP BY "animal"."life_number", 
>> "wynikbadania"."timestamp","inseminacja"."date" naturally results in 4 
>> separate records.
>>
>> Do you have any ideas?
>>
>> Best wishes,
>> Tomasz
>>
>>
>>
>> W dniu piątek, 4 marca 2016 18:51:51 UTC+1 użytkownik Simon Charette 
>> napisał:
>>>
>>> Hi Thomasz,
>>>
>>> Using extra() i

Re: I don't understand this error - Django 1.9

2016-03-04 Thread Alex Heyden
If you get longer stacktraces back, those might help in identifying what
exactly is going wrong.

As a first pass cleanup, try:
* remove 'ladynerds' from the bottom of INSTALLED_APPS. You're already
including it up top
* change __init__.py to read "default_app_config =
'ladynerds.apps.LadyNerdsConfig'". No import apps, camel casing only at the
end.
* change the name field of the app config to "ladynerds" instead of
"LadyNerds" (but the verbose name should be fine)

On Fri, Mar 4, 2016 at 3:24 PM, Becka R.  wrote:

> Hi,
>
> I'm building a pretty basic CRUD application for a community I'm part of.
>   I'm now getting "ImportError: No module named [myappname]" when I run the
> server, and an operational error in the admin.
>
> I looked at the documentation, and followed the steps, but I'm not doing
> something correctly.  I'd like to 1) fix this, and 2) propose some changes
> to the docs to clarify this issue.
>
> My project is called "ladynerds" (We're a professional association for a
> bunch of women software engineers).
>
> Here's the documentation I'm following:
>
> https://docs.djangoproject.com/en/1.9/ref/applications/
>
> I'm using Django 1.9
>
> *Here's my file structure:*
>
> /ladynerds   (project file)
>  /ladynerds  (app)
>   __init__.py
>   models.py
>   forms.py
>   settings.py
>   urls.py
>   views.py
>   wsgi.py
>   /static
>   /templates
>
>
> *Here's what I put into ladynerds/__init__.py:*
>
>
> import apps
>
> default_app_config = 'LadyNerds.apps.LadyNerdsConfig'
>
>
> I've also tried using 'ladynerds.apps.LadyNerdsConfig'
>
>
> *Here's what I put into ladynerds/apps.py:*
>
> from django.apps import AppConfig
>
> class LadyNerdsConfig(AppConfig):
> name = "LadyNerds"
> verbose_name = "LadyNerds"
>
> *Here's my settings.py INSTALLED_APPS*
>
>
> INSTALLED_APPS = (
> 'ladynerds.apps.LadyNerdsConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'ladynerds'
> )
>
>
> I'm getting:  ImportError: No module named LadyNerds
>
> What am I missing?
>
> And, thanks.
>
> Becka
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2e9e6959-0dc6-4cfb-9fe1-5aaf77db852f%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYXmk3ib7KaHA9J%2B4Jnp-LozAfSOd0d79wW5cPUHL3k%3D1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django OVH

2016-03-04 Thread Cedric Vallee
To whom it may concern,

I followed my friends' advice and coded a website in Django, but now it 
seems virtually impossible to find documentation about how to host a Django 
website on 'classic' hosting servers like OVH.
Could you please tell me what I have to do so that my website appears when 
I type the URL, and not just a page with the folders I uploaded via 
Filezilla?

I thank you for your help.

Best regards

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/41bba2fa-f0fd-4480-9fb3-2774d988579f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: more than one field for aggregates? (ArrayAgg, StringAgg)

2016-03-04 Thread Tomasz Nowak
Hi Simon!
Thank you for your suggestions.

Indeed, I get {'wynikbadania_cnt': 4, 'inseminacja_cnt': 4}. 

Adding the 'DISTINCT ON' (just after the initial SELECT) results in a 
message that both ".id" columns "must appear in the GROUP BY clause or be 
used in an aggregate function".
On the other side, the qs.distinct(...) results in an error:

Traceback (most recent call last):
...
  File "django/db/models/sql/compiler.py", line 824, in execute_sql
sql, params = self.as_sql()
  File "django/db/models/sql/compiler.py", line 412, in as_sql
"annotate() + distinct(fields) is not implemented.")
NotImplementedError: annotate() + distinct(fields) is not implemented.

This happens on both 1.9.x branch and 1.10.0.alpha.

Best wishes,
Tomasz


W dniu piątek, 4 marca 2016 22:41:31 UTC+1 użytkownik Simon Charette 
napisał:
>
> In order to make sure the bug doesn't lie in your expressions could you try
> running the following queryset:
>
> Animal.objects.filter(pk='PL005257066205').annotate(
> inseminacja_cnt=Count('inseminacja'),
> wynikbadania_cnt=Count('wynikbadania'),
> )
>
> If the results are `inseminacja_cnt=4` and `wynikbadania_cnt=4` I'm afraid 
> you
> might have hit a Django bug with multiple annotations over multi-valued
> relationships.
>
> Adding a `DISTINCT ON ('animal.life_number', 'wynikbadania.id', '
> inseminacja.id')`
> might help you but I wouldn't be surprised if it affected performance 
> badly.
>
> You should be able to do that using the `distinct()` method:
>
> Animal.objects.filter(pk='PL005257066205').annotate(
> ins=JsonAgg(
> JsonBuildObject(
> [F('inseminacja__date'),F('inseminacja__number')], 
> output_field=CharField()
> )
> ),
> examinations=JsonAgg(
> JsonBuildObject(
> [F('wynikbadania__date_entered')], output_field=CharField()
> )
> ),
> ).distinct('life_number', 'inseminacja__id', 'wynikbadania__id')
>
> Cheers,
> Simon
>
> Le vendredi 4 mars 2016 16:28:16 UTC-5, Simon Charette a écrit :
>>
>> Hi Thomasz,
>>
>> I think this might be a bug in either your custom expressions or Django's
>> GROUP BY handling on PostgreSQL.
>>
>> Can you try setting 
>> `django.db.backends.postgresql.features.DatabaseFeatures.allows_group_by_selected_pks`
>> to `False` and see if the appropriate GROUP BY clause is generated?
>>
>> Meanwhile I'll have a look at both your custom expressions to try to 
>> identify
>> the bug.
>>
>> Simon
>>
>> Le vendredi 4 mars 2016 16:02:14 UTC-5, Tomasz Nowak a écrit :
>>>
>>> Hi!
>>>
>>> I would like to create a JSON structure of chosen objects (animals) with 
>>> corresponding events in one database hit.
>>> The model represents animals and different types of events that happened 
>>> to them:
>>>
>>> class Animal(models.Model):
>>> life_number = models.TextField(primary_key=True)
>>> birthday = models.DateField(blank=True, null=True)
>>>
>>> class 
>>> Inseminacja(models.Model):  
>>> 
>>>
>>> cow = models.ForeignKey(Animal, models.DO_NOTHING, 
>>> db_column='cow_life_number')
>>> date = 
>>> models.DateTimeField()  
>>>  
>>>
>>> number = 
>>> models.IntegerField()   
>>>
>>>
>>>
>>> class WynikBadania(models.Model):
>>>   animal = models.ForeignKey(Animal, models.DO_NOTHING, 
>>> db_column='anilifenumber')
>>>   date_entered = models.DateTimeField(db_column='timestamp')
>>>
>>> I use my JsonAgg and JsonBuildObject functions submitted to Trac at:
>>> https://code.djangoproject.com/ticket/26327#no1
>>>
>>> >>> qs = Animal.objects.filter(pk='PL005257066205').annotate(
>>> ins  = 
>>> JsonAgg(JsonBuildObject([F('inseminacja__date'),F('inseminacja__number')], 
>>> output_field=CharField())), 
>>> examinations = 
>>> JsonAgg(JsonBuildObject([F('wynikbadania__date_entered')], 
>>> output_field=CharField()))
>>>   )
>>>
>>> The resulting query naturally results in cartesian product of the 
>>> events, which is exactly my problem:
>>>
>>> >>> str(qs.query)
>>>
>>> 'SELECT 
>>> "animal"."life_number", 
>>> "animal"."birthday", 
>>> 
>>> JSON_AGG(JSON_BUILD_OBJECT(\'timestamp\',"wynikbadania"."timestamp")) AS 
>>> "examinations", 
>>> 
>>> JSON_AGG(JSON_BUILD_OBJECT(\'date\',"inseminacja"."date",\'number\',"inseminacja"."number"))
>>>  
>>> AS "ins" 
>>> FROM "animal" 
>>> LEFT OUTER JOIN "wynikbadania" ON ("animal"."life_number" = 
>>> "wynikbadania"."anilifenumber") 
>>> LEFT OUTER JOIN "inseminacja" ON ("animal"."life_number" = 
>>> "inseminacja"."cow_life_number") 
>>> WHERE "animal"."life_number" = PL005257066205 
>>> GROUP BY "animal"."life_number"'
>>>
>>> >>> qs.values()
>>>
>>> [{
>>>   'examinations': [
>>> {u'timestamp': u'2014-11-20T12:41:54'}, 
>>> {u'timestamp': u'2014-1

Re: Development of web based image processing package

2016-03-04 Thread Xristos Xristoou
if i want only raster processing for remote sensing and satellite images 
 ?how can i do with python ?python library for that ?


Τη Πέμπτη, 3 Μαρτίου 2016 - 7:47:56 μ.μ. UTC+2, ο χρήστης Neha Chhattani 
έγραψε:
>
> hello
> i want to create a website that will do image processing in real time. i 
> want to load large tiff images i.e. images used in remote sensing and 
> satellite images. I want to do processing on satellite images. is it 
> possible to do this processing in website using django? If yes, how to 
> start with? what are the requirements for this? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21ed4627-6fdd-4bcf-a49d-7c9e78a7358f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: more than one field for aggregates? (ArrayAgg, StringAgg)

2016-03-04 Thread Tomasz Nowak
After setting DatabaseFeatures.allows_group_by_selected_pks = False the 
"extra(select=...)" version still copies the expression to the "GROUP BY":

  GROUP BY (( SELECT json_agg(inseminacja.*) FROM inseminacja WHERE 
inseminacja.cow_life_number = animal.life_number )), ...


W dniu piątek, 4 marca 2016 22:28:16 UTC+1 użytkownik Simon Charette 
napisał:
>
> Hi Thomasz,
>
> I think this might be a bug in either your custom expressions or Django's
> GROUP BY handling on PostgreSQL.
>
> Can you try setting 
> `django.db.backends.postgresql.features.DatabaseFeatures.allows_group_by_selected_pks`
> to `False` and see if the appropriate GROUP BY clause is generated?
>
> Meanwhile I'll have a look at both your custom expressions to try to 
> identify
> the bug.
>
> Simon
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/042ebb01-4d40-4fba-9536-e4a1d478b7f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django OVH

2016-03-04 Thread Bob Gailer
On Mar 4, 2016 5:09 PM, "Cedric Vallee"  wrote:
>
> To whom it may concern,
>
> I followed my friends' advice and coded a website in Django, but now it
seems virtually impossible to find documentation about how to host a Django
website on 'classic' hosting servers like OVH.
According to the OVH website you can host anything you want including
python so I would presume one would start out installing Python then
installing Django and going from there .
> Could you please tell me what I have to do so that my website appears
when I type the URL, and not just a page with the folders I uploaded via
Filezilla?
> sounds like you've already installed Django?
Have you considered Python Anywhere? I have I've run django there with no
problem.
> I thank you for your help.
>
> Best regards
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/41bba2fa-f0fd-4480-9fb3-2774d988579f%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP1rxO4VoaeeZnZxePtEkO2yZ038N0L5GESUTvMVui-LhAAnxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Hello

2016-03-04 Thread Luis Zárate
In fat bellow says: I can send you some pdf split in files of 2mb.


Hola, si quiere puedo envíarle por email algunos tutoriales en pdf .

Yo uso linux por lo que puedo partirlos con split y Ud podrá unirlos con
cat.

Django se basa en python Ud conoce este lenguaje.

El viernes, 4 de marzo de 2016, Bruno Barbosa  escribió:
> But these tutorials are online.. you don't need download it..
> --
> Bruno Barbosa
> Web Developer
> brunobarbosa.com.br
> On Fri, Mar 4, 2016 at 5:57 PM,  wrote:
>>
>> I have been seeing it but I just have acces
https://www.djangoproject.com/ and this one too
https://docs.djangoproject.com/en/1.9/intro/
>>
>> but just thouse one, I would like to get some tutorials but my big
problem is my email, I can not get a file bigger than 2 mb  haha I live in
Cuba
>>
>>
>>
>> 
>> This message was sent using IMP, the Internet Messaging Program.
>>
>>
>>
>> --
>> Este mensaje le ha llegado mediante el servicio de correo electronico
que ofrece Infomed para respaldar el cumplimiento de las misiones del
Sistema Nacional de Salud. La persona que envia este correo asume el
compromiso de usar el servicio a tales fines y cumplir con las regulaciones
establecidas
>>
>> Infomed: http://www.sld.cu/
>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/20160304155718.1243858fs518g7n2%40webmail.sld.cu
.
>> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAHxcCH6n9h4qmRdMqOY%3DV4xHnQU-wLU7Ru5MDVfjm5dxZy5iBQ%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyMyvL3F8ji7ct5CTVbCWwXirK%2BHMN5rYdBmAzfpQCMgjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Hello

2016-03-04 Thread Luis Zárate
I am not in Cuba, but there are internet limitations (bandwidth)  and
restrictions (regional banned and site blacklist) expecially if servers are
in USA (not America), for this reason it is important to him download a
file.

El viernes, 4 de marzo de 2016, Luis Zárate  escribió:
> In fat bellow says: I can send you some pdf split in files of 2mb.
>
>
> Hola, si quiere puedo envíarle por email algunos tutoriales en pdf .
>
> Yo uso linux por lo que puedo partirlos con split y Ud podrá unirlos con
cat.
>
> Django se basa en python Ud conoce este lenguaje.
>
> El viernes, 4 de marzo de 2016, Bruno Barbosa 
escribió:
>> But these tutorials are online.. you don't need download it..
>> --
>> Bruno Barbosa
>> Web Developer
>> brunobarbosa.com.br
>> On Fri, Mar 4, 2016 at 5:57 PM,  wrote:
>>>
>>> I have been seeing it but I just have acces
https://www.djangoproject.com/ and this one too
https://docs.djangoproject.com/en/1.9/intro/
>>>
>>> but just thouse one, I would like to get some tutorials but my big
problem is my email, I can not get a file bigger than 2 mb  haha I live in
Cuba
>>>
>>>
>>>
>>> 
>>> This message was sent using IMP, the Internet Messaging Program.
>>>
>>>
>>>
>>> --
>>> Este mensaje le ha llegado mediante el servicio de correo electronico
que ofrece Infomed para respaldar el cumplimiento de las misiones del
Sistema Nacional de Salud. La persona que envia este correo asume el
compromiso de usar el servicio a tales fines y cumplir con las regulaciones
establecidas
>>>
>>> Infomed: http://www.sld.cu/
>>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/20160304155718.1243858fs518g7n2%40webmail.sld.cu
.
>>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAHxcCH6n9h4qmRdMqOY%3DV4xHnQU-wLU7Ru5MDVfjm5dxZy5iBQ%40mail.gmail.com
.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
> <
https://ci3.googleusercontent.com/proxy/pleYFBjRTaqPzwl0QWV68XGbm9_iKE548G9HnZip6o7gk46Dni4svLKWIxqanv21wf4L-oDTIVyWUviHHYQOxYJ_VR-E2QHnDRBqrtZefM09Bgx09obS9PzSCP77HVIAehvKQVoH7RXKVRwJcXB8ZhPlAlEmO_2MsbjN1bH8rF0L8O0qa_FTVnBaZA84NQjOjE3lH9ACs5sERtY=s0-d-e1-ft#https://docs.google.com/uc?export=download&id=0B4-s_Bgz_-NSN0V3b24zU25fMW8&revid=0B4-s_Bgz_-NSdy9OTkYzcDN6RGZITWl5amdqT3JxVnNVVSswPQ
>
>
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyOPhxVNUJe9jJdt8kdh-UeJ6Z7A9mB-hUK6DvgRYzGTkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create groups for users in Django

2016-03-04 Thread Luis Zárate
Años observation

Person.objects.create(name=request.user)

Lazy object is set but name is charfield.
M1is not saved.
form.save() create other group that is not used.



El jueves, 3 de marzo de 2016,  escribió:
> Hello!
>
> I have a problem, like in topic, with creating groups in django. I was
searching everywhere and nothing was so interested.
>
> What i want from this section: I would like to by filling a column with
the name of the group, formed a quite new group, on the occasion of adding
me as one of the members and preferably, as a leader, who can add other
users to the group.
>
> My problem: I did one form for name, and when i sending a request, i got
nothing, only the stie is re-loaded. I have some code but don;t know what
to do next..
>
> My code:
>
> models.py:
>
> class Person(models.Model):
>
> name = models.CharField(max_length=128)
>
> def __str__(self): # __unicode__ on Python 2
> return self.name
>
>
> class Group(models.Model):
> name = models.CharField(max_length=128)
> leader = models.CharField(max_length=50)
> members = models.ManyToManyField(Person, through='Membership')
>
> def __str__(self): # __unicode__ on Python 2
> return self.name
>
>
> class Membership(models.Model):
> person = models.ForeignKey(Person)
> group = models.ForeignKey(Group)
> date_joined = models.DateField()
> invite_reason = models.CharField(max_length=64)
>
> forms.py:
>
> class GroupForm(forms.ModelForm):
>
> class Meta:
> model = Group
> fields = ('name',)
>
> views.py:
>
> @login_required
> def groups(request):
>
> if request.method == "POST":
> form = GroupForm(request.POST)
> if form.is_valid():
>
> grupa = Group.objects.create(name="grupa")
> per = Person.objects.create(name=request.user)
> m1 = Membership(person=per, group=grupa, date_joined=(1999, 8, 8),
invite_reason="Needed programmer.")
> form.save()
>
>
> return render(request, 'groups.html', {'form':form})
>
> else:
> form = GroupForm()
>
> return render(request, 'groups.html', {'form': form})
>
> groups.html:
>
> {% block profile %}
>
> 
> 
> Create your new group !
> 
> {% csrf_token %}
> {{ form|crispy }}
> Go!
> 
> 
>
> {% endblock %}
>
> This is it... Can anyone could help me with that? I spend few days with
it and 0 progress.
>
> Thanks for any help!
>
> Damian
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/b71b3e7e-a168-4f1c-aaf7-655bdee86212%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyOH7A28WLKTQSjLzH8Ug1YSfG3hbjth%3DnNJB-L5WoY4HA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I don't understand this error - Django 1.9

2016-03-04 Thread Luis Zárate
Do not use the same name of the project in your apps.

It is possible to do what you are doing but really needs comprehension of
how python works and you need to do extra work to get ready.  So my
remendation is: start a clean project with other name and copy you app
folder. Put attention in what file are from settings and what is from app.

or better idea start again your app with clean project.



El viernes, 4 de marzo de 2016, Alex Heyden 
escribió:
> If you get longer stacktraces back, those might help in identifying what
exactly is going wrong.
> As a first pass cleanup, try:
> * remove 'ladynerds' from the bottom of INSTALLED_APPS. You're already
including it up top
> * change __init__.py to read "default_app_config =
'ladynerds.apps.LadyNerdsConfig'". No import apps, camel casing only at the
end.
> * change the name field of the app config to "ladynerds" instead of
"LadyNerds" (but the verbose name should be fine)
> On Fri, Mar 4, 2016 at 3:24 PM, Becka R.  wrote:
>>
>> Hi,
>> I'm building a pretty basic CRUD application for a community I'm part
of.   I'm now getting "ImportError: No module named [myappname]" when I run
the server, and an operational error in the admin.
>> I looked at the documentation, and followed the steps, but I'm not doing
something correctly.  I'd like to 1) fix this, and 2) propose some changes
to the docs to clarify this issue.
>> My project is called "ladynerds" (We're a professional association for a
bunch of women software engineers).
>> Here's the documentation I'm following:
>> https://docs.djangoproject.com/en/1.9/ref/applications/
>>
>> I'm using Django 1.9
>> Here's my file structure:
>> /ladynerds   (project file)
>>  /ladynerds  (app)
>>   __init__.py
>>   models.py
>>   forms.py
>>   settings.py
>>   urls.py
>>   views.py
>>   wsgi.py
>>   /static
>>   /templates
>>
>> Here's what I put into ladynerds/__init__.py:
>>
>> import apps
>> default_app_config = 'LadyNerds.apps.LadyNerdsConfig'
>>
>> I've also tried using 'ladynerds.apps.LadyNerdsConfig'
>>
>> Here's what I put into ladynerds/apps.py:
>> from django.apps import AppConfig
>> class LadyNerdsConfig(AppConfig):
>> name = "LadyNerds"
>> verbose_name = "LadyNerds"
>> Here's my settings.py INSTALLED_APPS
>>
>> INSTALLED_APPS = (
>> 'ladynerds.apps.LadyNerdsConfig',
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> 'ladynerds'
>> )
>>
>> I'm getting:  ImportError: No module named LadyNerds
>> What am I missing?
>> And, thanks.
>> Becka
>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/2e9e6959-0dc6-4cfb-9fe1-5aaf77db852f%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYXmk3ib7KaHA9J%2B4Jnp-LozAfSOd0d79wW5cPUHL3k%3D1Q%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyOWSm%2BN5_-hf1QGYC%2B09a17Ab4zdy9%2BBGgh3HWQ%2BdneCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.