do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-30 Thread fábio andrews rocha marques
Let's say i have a "register a new user" View and on this page, when the 
user forgets to inform a password or a username, i show a message to him on 
the same page saying "you forgot the password". The way i do this is by 
doing this(on my View.py in a function called cadastrarprofessor):

nomeusuario = request.POST['usuario'] #username
nomesenha = request.POST['senha'] #password
nomeemail = request.POST['email'] #email

if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe um usuário", 
'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 
'nomeusuariocadastro':nomeusuario})

And my template for this page(cadastro.html) is like this:

Cadastro

{% csrf_token %}
Usuário: 
{% if nomeusuariocadastro %}

{% else %}

{% endif %}


... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)





{% csrf_token %}

{% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
sucesso!{% endif %}
{% if error_message %}{{ error_message }}{% endif %}

So, every time the user forgets to mention a username or email or password 
in this screen, i use render to redirect the user to the same page but this 
time displaying a error_message. Let's say he did forget to fill the 
textfield with a username... he goes back to the same page and sees the 
error message. After that, let's say everything is right and he finally 
registers a new user, he sees "cadastro realizado com sucesso"(sucessfully 
registered new user) and stays on the same page. But when he goes back a 
page(pressing "back" on the browser), instead of going back to the page 
before the cadastro.html, he goes back to the same page cadastro.html but 
displaying the error message for the "you forgot to mention your username". 
I don't want him to go back to the same page with error message, i want to 
make him go back to my main menu. 
Is there a better approach to display error messages on the same page 
instead of using return render like this:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False,
 'error_message': "informe um usuário", 'nomeemailcadastro':nomeemail,
'nomesenhacadastro':nomesenha})
?

-- 
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/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: QuerySet.extra and ticket #28756

2017-10-30 Thread Tim Graham
You aren't using Value correctly -- it's not for wrapping raw SQL. 
https://docs.djangoproject.com/en/dev/ref/models/expressions/#value-expressions

What I was trying to suggest is that you write your own expression class 
that generates the FIELD(...) SQL.
https://docs.djangoproject.com/en/dev/ref/models/expressions/#writing-your-own-query-expressions

On Monday, October 30, 2017 at 3:25:29 PM UTC-4, Brandon wrote:
>
> In my original ticket (https://code.djangoproject.com/ticket/28756) I 
> explained this:
>
> I have reoccurring situation, when in a view.py function I need a queryset 
> ordered by a set of identifiers. The order of those identifiers is 
> dependent on factors outside of my control. Essentially in my view I am 
> using modelformset_factory to generate a modelformset, then the usage of 
> that modelformset instance requires queryset. It is that final queryset 
> that must be ordered by the identifier whose order is externally determined.
> So I use the .extra( ) function like below:
>
> quali_results = ToxicologyCaseQualitativeResult.objects.filter(case_id=
> case.id).select_related('test').order_by('test__name')
>
> field_list = ["AMPHS","BARB","BNZ","BE","Ecstasy","METH","6AM","PCP","THC"
> ] #Usually populated via retrieval of user settings.
> if len(field_list) > 0:
> field_list = field_list + [q.test.identifier for q in quali_results] 
> fields = '"'+'","'.join(str(field) for field in field_list)+'"'
> field_sql = "FIELD(`identifier`,"+fields+")"
> quali_results = quali_results.extra(select={'field_sql' : field_sql}, 
> order_by=['field_sql'])
>
> quali_resultfs = QualitativeResultFormset(queryset=quali_results, prefix=
> 'quali_results')
>
>
> This was closed by Tim Graham stating that I should be using "Query 
> Expression ", 
> which is fine. So the code became this:
>
> from django.db.models import Value, CharField
>
> quali_results = ToxicologyCaseQualitativeResult.objects.filter(case_id=
> case.id).select_related('test')
>
> field_list = ["AMPHS","BARB","BNZ","BE","Ecstasy","METH","6AM","PCP","THC"
> ] #Usually populated via retrieval of user settings.
> if len(field_list) > 0:
> field_list = field_list + [q.test.identifier for q in quali_results] 
> fields = '"'+'","'.join(str(field) for field in field_list)+'"'
> field_sql = "FIELD(`identifier`,"+fields+")"
> quali_results = quali_results.order_by(Value("FIELD(`identifier`,"+
> fields+")",output_field=CharField()))
>
> quali_resultfs = QualitativeResultFormset(queryset=quali_results, prefix=
> 'quali_results')
>
> Which I agree is could be seen as better, and it doesn't use the 
> Querset.extra( ) method. The only problem is that it doesn't work.
>
> The first method generates this SQL:
> SELECT (FIELD(`identifier`,"AMPHS","BARB","BNZ","BE","Ecstasy","METH",
> "6AM","PCP","THC","AMPHS","BARB","BNZ","THC","BE","Ecstasy","METH","6AM",
> "PCP")) AS `field_sql`, `toxicology_toxicologycasequalitativeresult`.`id`, 
> `toxicology_toxicologycasequalitativeresult`.`case_id`, 
> `toxicology_toxicologycasequalitativeresult`.`test_id`, 
> `toxicology_toxicologycasequalitativeresult`.`detection`, 
> `toxicology_toxicologycasequalitativeresult`.`result`, 
> `toxicology_toxicologycasequalitativeresult`.`concentration`, 
> `toxicology_toxicologycasequalitativeresult`.`outcome`, 
> `toxicology_toxicologycasequalitativeresult`.`cutoff`, 
> `toxicology_toxicologycasequalitativeresult`.`units`, 
> `toxicology_toxicologycasequalitativeresult`.`comments`, 
> `toxicology_toxicologyqualitativetestreference`.`id`, 
> `toxicology_toxicologyqualitativetestreference`.`panel_id`, 
> `toxicology_toxicologyqualitativetestreference`.`enabled`, 
> `toxicology_toxicologyqualitativetestreference`.`name`, 
> `toxicology_toxicologyqualitativetestreference`.`identifier`, 
> `toxicology_toxicologyqualitativetestreference`.`analyte_id`, 
> `toxicology_toxicologyqualitativetestreference`.`LOB`, 
> `toxicology_toxicologyqualitativetestreference`.`LOD`, 
> `toxicology_toxicologyqualitativetestreference`.`LOQ`, 
> `toxicology_toxicologyqualitativetestreference`.`ULOL`, 
> `toxicology_toxicologyqualitativetestreference`.`expression`, 
> `toxicology_toxicologyqualitativetestreference`.`true_result`, 
> `toxicology_toxicologyqualitativetestreference`.`false_result`, 
> `toxicology_toxicologyqualitativetestreference`.`true_outcome`, 
> `toxicology_toxicologyqualitativetestreference`.`false_outcome`, 
> `toxicology_toxicologyqualitativetestreference`.`concentration`, 
> `toxicology_toxicologyqualitativetestreference`.`cutoff`, 
> `toxicology_toxicologyqualitativetestreference`.`units`, 
> `toxicology_toxicologyqualitativetestreference`.`method`, 
> `toxicology_toxicologyqualitativetestreference`.`description` FROM 
> `toxicology_toxicologycasequalitativeresult` INNER JOIN 
> `toxicology_toxicologyqualitativetestreference` ON (
> `toxicology_toxicologycasequalitativeresult`.`test_id` = 
> `t

QuerySet.extra and ticket #28756

2017-10-30 Thread Brandon
In my original ticket (https://code.djangoproject.com/ticket/28756) I 
explained this:

I have reoccurring situation, when in a view.py function I need a queryset 
ordered by a set of identifiers. The order of those identifiers is 
dependent on factors outside of my control. Essentially in my view I am 
using modelformset_factory to generate a modelformset, then the usage of 
that modelformset instance requires queryset. It is that final queryset 
that must be ordered by the identifier whose order is externally determined.
So I use the .extra( ) function like below:

quali_results = ToxicologyCaseQualitativeResult.objects.filter(case_id=case.
id).select_related('test').order_by('test__name')

field_list = ["AMPHS","BARB","BNZ","BE","Ecstasy","METH","6AM","PCP","THC"] 
#Usually 
populated via retrieval of user settings.
if len(field_list) > 0:
field_list = field_list + [q.test.identifier for q in quali_results] 
fields = '"'+'","'.join(str(field) for field in field_list)+'"'
field_sql = "FIELD(`identifier`,"+fields+")"
quali_results = quali_results.extra(select={'field_sql' : field_sql}, 
order_by=['field_sql'])

quali_resultfs = QualitativeResultFormset(queryset=quali_results, prefix=
'quali_results')


This was closed by Tim Graham stating that I should be using "Query 
Expression ", 
which is fine. So the code became this:

from django.db.models import Value, CharField

quali_results = ToxicologyCaseQualitativeResult.objects.filter(case_id=case.
id).select_related('test')

field_list = ["AMPHS","BARB","BNZ","BE","Ecstasy","METH","6AM","PCP","THC"] 
#Usually 
populated via retrieval of user settings.
if len(field_list) > 0:
field_list = field_list + [q.test.identifier for q in quali_results] 
fields = '"'+'","'.join(str(field) for field in field_list)+'"'
field_sql = "FIELD(`identifier`,"+fields+")"
quali_results = quali_results.order_by(Value("FIELD(`identifier`,"+
fields+")",output_field=CharField()))

quali_resultfs = QualitativeResultFormset(queryset=quali_results, prefix=
'quali_results')

Which I agree is could be seen as better, and it doesn't use the 
Querset.extra( ) method. The only problem is that it doesn't work.

The first method generates this SQL:
SELECT (FIELD(`identifier`,"AMPHS","BARB","BNZ","BE","Ecstasy","METH","6AM",
"PCP","THC","AMPHS","BARB","BNZ","THC","BE","Ecstasy","METH","6AM","PCP")) 
AS `field_sql`, `toxicology_toxicologycasequalitativeresult`.`id`, 
`toxicology_toxicologycasequalitativeresult`.`case_id`, 
`toxicology_toxicologycasequalitativeresult`.`test_id`, 
`toxicology_toxicologycasequalitativeresult`.`detection`, 
`toxicology_toxicologycasequalitativeresult`.`result`, 
`toxicology_toxicologycasequalitativeresult`.`concentration`, 
`toxicology_toxicologycasequalitativeresult`.`outcome`, 
`toxicology_toxicologycasequalitativeresult`.`cutoff`, 
`toxicology_toxicologycasequalitativeresult`.`units`, 
`toxicology_toxicologycasequalitativeresult`.`comments`, 
`toxicology_toxicologyqualitativetestreference`.`id`, 
`toxicology_toxicologyqualitativetestreference`.`panel_id`, 
`toxicology_toxicologyqualitativetestreference`.`enabled`, 
`toxicology_toxicologyqualitativetestreference`.`name`, 
`toxicology_toxicologyqualitativetestreference`.`identifier`, 
`toxicology_toxicologyqualitativetestreference`.`analyte_id`, 
`toxicology_toxicologyqualitativetestreference`.`LOB`, 
`toxicology_toxicologyqualitativetestreference`.`LOD`, 
`toxicology_toxicologyqualitativetestreference`.`LOQ`, 
`toxicology_toxicologyqualitativetestreference`.`ULOL`, 
`toxicology_toxicologyqualitativetestreference`.`expression`, 
`toxicology_toxicologyqualitativetestreference`.`true_result`, 
`toxicology_toxicologyqualitativetestreference`.`false_result`, 
`toxicology_toxicologyqualitativetestreference`.`true_outcome`, 
`toxicology_toxicologyqualitativetestreference`.`false_outcome`, 
`toxicology_toxicologyqualitativetestreference`.`concentration`, 
`toxicology_toxicologyqualitativetestreference`.`cutoff`, 
`toxicology_toxicologyqualitativetestreference`.`units`, 
`toxicology_toxicologyqualitativetestreference`.`method`, 
`toxicology_toxicologyqualitativetestreference`.`description` FROM 
`toxicology_toxicologycasequalitativeresult` INNER JOIN 
`toxicology_toxicologyqualitativetestreference` ON (
`toxicology_toxicologycasequalitativeresult`.`test_id` = 
`toxicology_toxicologyqualitativetestreference`.`id`) WHERE 
`toxicology_toxicologycasequalitativeresult`.`case_id` = 239 ORDER BY 
`field_sql` ASC

The second method generates this SQL:
SELECT `toxicology_toxicologycasequalitativeresult`.`id`, 
`toxicology_toxicologycasequalitativeresult`.`case_id`, 
`toxicology_toxicologycasequalitativeresult`.`test_id`, 
`toxicology_toxicologycasequalitativeresult`.`detection`, 
`toxicology_toxicologycasequalitativeresult`.`result`, 
`toxicology_toxicologycasequalitativeresult`.`concentration`, 
`toxicology_toxicologycasequalitativeresult`.`ou

Re: how to create path for sqlite3 in django? I'm unable to access my database.

2017-10-30 Thread Etienne Robillard

Hi,

you may need to install sqlite3 for windows and set your PATH to the 
directory where sqlite3 executable is found.


Etienne


Le 2017-10-30 à 03:52, bonagiri abhishek a écrit :

C:\Users\admin\cricwebsite>python manage.py dbshell
CommandError: You appear not to have the 'sqlite3' program installed 
or on your path.

Can anyone please explain me the problem?
I'm unable to access the database as it is showing the above CommandError.
--
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/e9a5e8c3-02b7-45f4-9fcd-6e7f5edd8ea5%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Etienne Robillard
tkad...@yandex.com
http://www.isotopesoftware.ca/

--
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/e4e6d0d9-25ea-aeb3-8bf6-25c5efca77c8%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


channels working in runserver but "Still in CONNECTING state" then "ERR_CONNECTION_TIMED_OUT" in production

2017-10-30 Thread Adam

Hello,

I am following "getting started" in the django channel docs as well as 
"django channels form the ground up" 
https://artandlogic.com/2016/06/django-channels-ground-part-2/  tutorial in 
the django,  using REDIS, NGINX and GUNICORN on digital ocean. 

Based on console errors in the browser, I used this code  modified from 
modified from the docs to test the channel in my browser (JavaScript):

socket = new WebSocket("wss://" + window.location.host + ":8001/chat");

Then the rest is copied directly:

socket.onopen = function() {
socket.send("hello world");
}

// Call onopen directly if socket is already open
if (socket.readyState == WebSocket.OPEN) socket.onopen();

 As the title states, the JavaScript test works on the run server -   
python manage.py runserver 0.0.0.0:8000 but not o the production server.

Here is the terminal response to the run server command:

Performing system checks...

System check identified no issues (0 silenced).
October 30, 2017 - 10:40:10
Django version 1.11, using settings 'dojos.settings'
Starting Channels development server at http://0.0.0.0:8000/
Channel layer default (channels_panel.apps.DebugChannelLayer)
Quit the server with CONTROL-C.
2017-10-30 10:40:10,203 - INFO - worker - Listening on channels 
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-10-30 10:40:10,205 - INFO - worker - Listening on channels 
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-10-30 10:40:10,206 - INFO - worker - Listening on channels 
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-10-30 10:40:10,208 - INFO - server - HTTP/2 support not enabled 
(install the http2 and tls Twisted extras)
2017-10-30 10:40:10,208 - INFO - server - Using busy-loop synchronous mode 
on channel layer
2017-10-30 10:40:10,209 - INFO - server - Listening on endpoint 
tcp:port=8000:interface=0.0.0.0
2017-10-30 10:40:10,210 - INFO - worker - Listening on channels 
http.request, websocket.connect, websocket.disconnect, websocket.receive

And then to the JavaScript test:

[2017/10/30 10:41:07] HTTP GET /favicon.ico 200 [0.24, 75.82.191.111:35111]
[2017/10/30 10:41:16] WebSocket HANDSHAKING /chat/ [75.82.191.111:47589]
[2017/10/30 10:41:16] WebSocket CONNECT /chat/ [75.82.191.111:47589]


On the production server, here is the console error:

VM381:1 Uncaught DOMException: Failed to execute 'send' on 'WebSocket': 
Still in CONNECTING state.
at :1:8
(anonymous) @ VM381:1
VM379:1 WebSocket connection to 'wss://joinourstory.com:8001/chat' failed: 
Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT 

These things seem to be relevant:

SETTINGS.PY copied exactly tutorial:

REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost')

CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [("localhost", 6379)],
},
"ROUTING": "dojos.routing.channel_routing",
},
}


 ROUTING.PY and CONSUMERS.PY copied exactly from the docs.

Here is the supervisor configuration:


[program:dojos]
command=/home/adam/dojos/bin/gunicorn_start
user=adam
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/adam/logs/gunicorn-error.log

[program:server_workers]
command=/home/adam/dojos/venv/bin/python /home/adam/dojos/manage.py 
runworker
directory=/home/adam/dojos
user=adam
autostart=true
autorestart=true
redirect_stderr=true
stopasgroup=true

[program:server_interface]
command=/home/adam/dojos/venv/bin/daphne -b 127.0.0.1 -p 8001 
dojos.asgi:channel_layer
directory=/home/adam/dojos
autostart=true
autorestart=true
stopasgroup=true
user=adam

This seems to be working as this is the response to sudo supervisorctl 
status:

dojosRUNNING   pid 27834, uptime 0:22:29
server_interface RUNNING   pid 27835, uptime 0:22:29
server_workers   RUNNING   pid 27836, uptime 0:22:29

Here is the nginx config file (NOTE I HAVE TO USE SSL)

# Enable upgrading of connection (and websocket proxying) depending on the
# presence of the upgrade field in the client request header
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

# Create an upstream alias to where we've set daphne to bind to
upstream dojos {
server 127.0.0.1:8001;
}

server {
listen 80;

server_name joinourstory.com www.joinourstory.com;

return 301 https://$server_name$request_uri;
}

server {

listen 443 ssl;

server_name joinourstory.com www.joinourstory.com;

ssl on;

ssl_certificate /etc/nginx/ssl/chainedcert.crt;
ssl_certificate_key  /etc/nginx/ssl/josserver.key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers REDACTED

location = /favicon.ico { access_log off; log_not_found off; }

location /static/ {
 root /home/adam/dojos;
}

location /media/ {
  root 

Re: Creating a server problem

2017-10-30 Thread James Schneider
On Oct 30, 2017 9:09 AM, "md fahad"  wrote:

Hey I am just new to django
i have a problem using the term "from django.http import HttpResponce it is
showing error to it
so plz help me out


Check your spelling:

from django.http import HttpResponse

-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%2BciWBNtoEKdxBiFfF6F2N4dyx6OfaToA2WC%2BU9b3LbPfJaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Creating a server problem

2017-10-30 Thread md fahad
Hey I am just new to django 
i have a problem using the term "from django.http import HttpResponce it is 
showing error to it
so plz help me out

-- 
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/64797518-44d8-481e-aa3a-5a1c5a5f3f8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I am new in django

2017-10-30 Thread Anish Chapagain
Hi, 
Please follow tutorials on djangoproject.com and simpleisbetterthancomplex.com



Sent from my iPhone

> On Oct 30, 2017, at 20:46, cjacque...@gmail.com wrote:
> 
> Hi !
> 
> I liked it : https://tutorial.djangogirls.org/en/
> 
> Le lundi 30 octobre 2017 15:45:49 UTC+1, Rafael Mauricio Builes Marin a écrit 
> :
>> 
>> Hi everybody, I would like to know what is the best way for learn to use 
>> Django and how mach knowledge of django I need.
>> Thank you 
>> 
>> El contenido de este mensaje y sus anexos son únicamente para el uso del 
>> destinatario y pueden contener información  clasificada o reservada. Si 
>> usted no es el destinatario intencional, absténgase de cualquier uso, 
>> difusión, distribución o copia de esta comunicación.
> 
> -- 
> 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/985da0eb-313d-4385-b9fe-296007c33aac%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/DD0D2333-7E64-40F3-A45A-8E8DEE37D0EF%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I am new in django

2017-10-30 Thread cjacquemet
Hi !

I liked it : https://tutorial.djangogirls.org/en/

Le lundi 30 octobre 2017 15:45:49 UTC+1, Rafael Mauricio Builes Marin a 
écrit :
>
> Hi everybody, I would like to know what is the best way for learn to use 
> Django and how mach knowledge of django I need.
> Thank you 
>
> El contenido de este mensaje y sus anexos son únicamente para el uso del 
> destinatario y pueden contener información  clasificada o reservada. Si 
> usted no es el destinatario intencional, absténgase de cualquier uso, 
> difusión, distribución o copia de esta comunicación.

-- 
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/985da0eb-313d-4385-b9fe-296007c33aac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I am new in django

2017-10-30 Thread Rafael Mauricio Builes Marin
Hi everybody, I would like to know what is the best way for learn to use 
Django and how mach knowledge of django I need.
Thank you 

-- 
El contenido de este mensaje y sus anexos son únicamente para el uso del 
destinatario y pueden contener información  clasificada o reservada. Si 
usted no es el destinatario intencional, absténgase de cualquier uso, 
difusión, distribución o copia de esta comunicación.

-- 
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/1b254e75-2e8a-4066-b609-301e31fc2163%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 11 ImproperlyConfigured: AUTH_USER_MODEL refers to model 'authex.UserProfile' that has not been installed

2017-10-30 Thread cjacquemet
Ok, i finally found where the problem was : the admin class (UserAdmin) of 
my custom user class was in models.py and must be in admin.py.

I found the solution here : 
https://stackoverflow.com/questions/45783147/django-lookuperror-app-accounts-doesnt-have-a-user-model

-- 
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/d8576cab-0218-4c7a-9935-a2d17b842b83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how to create path for sqlite3 in django? I'm unable to access my database.

2017-10-30 Thread bonagiri abhishek
C:\Users\admin\cricwebsite>python manage.py dbshell
CommandError: You appear not to have the 'sqlite3' program installed or on 
your path.
Can anyone please explain me the problem?
I'm unable to access the database as it is showing the above CommandError.

-- 
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/e9a5e8c3-02b7-45f4-9fcd-6e7f5edd8ea5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


TruncHour with tzinfo throws AmbiguousTimeError

2017-10-30 Thread Vincent T.
I have a model with a datetime field that is filled with UTC datetime 
values (time_aware)

I am trying to aggregate data by hours on another timezone 
('Europe/Paris'). Last sunday at 2am there has been the day-saving-time 
impact to local time.

pytz.exceptions.AmbiguousTimeError: 2017-10-29 02:00:00

The problem is that there is no way to tell django that is_dst is True

here is my query:

additional_data = query \

.annotate(

hour=TruncHour(

'datetime',

tzinfo=pytz.timezone(thermostat.structure.timezone),

output_field=DateTimeField())) \

.values('hour') \

.annotate(

heat=Avg(Case(When(heating=True, then=1), default=0), 
output_field=FloatField()),

cool=Avg(Case(When(cooling=True, then=1), default=0), 
output_field=FloatField())) \

.values(

'hour',

'heat',

'cool')


Do you have some ideas how I could workaround this issue?

-- 
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/5ce88fb8-4491-42cd-bf73-8ac73186c901%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANNOUNCE] Django-livestore 1.0-beta1 is out

2017-10-30 Thread Etienne Robillard

Hi guys,

I'm pleased to announce the first beta release of Django-livestore 1.0!

Django-livestore is a fork of the Satchmo framework to develop ecommerce 
web applications in Django.


This release is for developers only. It is not suitable for production use.

Whats new:

- Python 3.5.3 support and bugfixes.

Download:

- 
http://www.isotopesoftware.ca/pub/livestore/django-livestore-1.0-beta1.tar.xz


- https://bitbucket.org/tkadm30/livestore/

For support, please ask a question to django-hotsa...@googlegroups.com

Best regards,

Etienne

--
Etienne Robillard
tkad...@yandex.com
http://www.isotopesoftware.ca/

--
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/1e31050d-0a6d-d3d7-84f4-46eeb19f0693%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 11 ImproperlyConfigured: AUTH_USER_MODEL refers to model 'authex.UserProfile' that has not been installed

2017-10-30 Thread cjacquemet
An additional information : the settings.py was generated with Django 1.9.7

Le lundi 30 octobre 2017 08:35:44 UTC+1, cjacq...@gmail.com a écrit :
>
>
> Yes, there is my INSTALLED_APPS (it was ok with Django 1.10) :
>
> INSTALLED_APPS = [
> #django
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> 'django.contrib.flatpages',
> 'django.contrib.humanize',
> #third-parties
> 'bootstrapform',
> 'django_bleach',
> 'django_tables2',
> 'easy_thumbnails',
> 'emoticons',
> 'form_utils',
> 'mathfilters',
> 'tinymce',
> #assoweb
> 'airfield',
> 'authex',
> 'blog',
> 'challenge',
> 'core',
> 'django_resource',
> 'files',
> 'help',
> 'mailing',
> 'questionnaire',
> 'section',
> 'treasury',
> 'year',
> ]
>
>
> And later :
>
> AUTH_USER_MODEL = 'authex.UserProfile'
>
>
> Thanks for helping. :)
>
> Le lundi 30 octobre 2017 07:56:48 UTC+1, James Schneider a écrit :
>>
>>   File "/Library/Python/2.7/site-packages/django/contrib/auth/forms.py", 
>>> line 22, in 
>>> UserModel = get_user_model()
>>>   File 
>>> "/Library/Python/2.7/site-packages/django/contrib/auth/__init__.py", line 
>>> 198, in get_user_model
>>> "AUTH_USER_MODEL refers to model '%s' that has not been installed" % 
>>> settings.AUTH_USER_MODEL
>>> django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to 
>>> model 'authex.UserProfile' that has not been installed
>>>
>>>
>>> Any ideas ? Thanks !
>>>
>>>
>> Does INSTALLED_APPS in your settings.py file contain an entry 
>> for 'authex'? 
>>
>> -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/bb671a1c-fa4d-4938-888f-dab8984bc1e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 11 ImproperlyConfigured: AUTH_USER_MODEL refers to model 'authex.UserProfile' that has not been installed

2017-10-30 Thread cjacquemet

Yes, there is my INSTALLED_APPS (it was ok with Django 1.10) :

INSTALLED_APPS = [
#django
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'django.contrib.humanize',
#third-parties
'bootstrapform',
'django_bleach',
'django_tables2',
'easy_thumbnails',
'emoticons',
'form_utils',
'mathfilters',
'tinymce',
#assoweb
'airfield',
'authex',
'blog',
'challenge',
'core',
'django_resource',
'files',
'help',
'mailing',
'questionnaire',
'section',
'treasury',
'year',
]


And later :

AUTH_USER_MODEL = 'authex.UserProfile'


Thanks for helping. :)

Le lundi 30 octobre 2017 07:56:48 UTC+1, James Schneider a écrit :
>
>   File "/Library/Python/2.7/site-packages/django/contrib/auth/forms.py", 
>> line 22, in 
>> UserModel = get_user_model()
>>   File 
>> "/Library/Python/2.7/site-packages/django/contrib/auth/__init__.py", line 
>> 198, in get_user_model
>> "AUTH_USER_MODEL refers to model '%s' that has not been installed" % 
>> settings.AUTH_USER_MODEL
>> django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to 
>> model 'authex.UserProfile' that has not been installed
>>
>>
>> Any ideas ? Thanks !
>>
>>
> Does INSTALLED_APPS in your settings.py file contain an entry 
> for 'authex'? 
>
> -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/37b729c3-f096-45bb-aab0-a7328d133585%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: MultipleChoiceField records down choices as a list, but CharField converts them to a list?

2017-10-30 Thread James Schneider
On Thu, Oct 26, 2017 at 7:54 AM, Jack  wrote:

> I have a model field for choosing multiple options.  Here is the code for
> models and forms:
>
> *models.py:*
> CONDO_APARTMENT = 'Condo Apartment'
> DETACHED_HOUSE = 'Detached House'
> SEMI_DETACHED = 'Semi-detached'
> TOWNHOUSE = 'Townhouse'
>
> PROPERTY_TYPE = (
> (CONDO_APARTMENT, 'Condo Apartment'),
> (DETACHED_HOUSE, 'Detached House'),
> (SEMI_DETACHED, 'Semi-detached'),
> (TOWNHOUSE, 'Townhouse'),
> )
>
> property_type = models.CharField(max_length=50, help_text="You can
> select more than 1 option")
>
>
> *forms.py:*
> property_type = forms.MultipleChoiceField(widget=forms.SelectMultiple,
> choices=BuyerListing.PROPERTY_TYPE)
>
>
> Let's assume the selected choices were 'Condo Apartment' and
> 'Semi-detached'.  The value stored on my database is this - ['Condo
> Apartment', 'Semi-detached']
>


Given your model definition, that means that a Python list object was
converted to a string and stored in a single database field, which means
that you no longer have a list, you have a Python string that looks like a
list.

If your model can have multiple values associated to a single object for a
single field, consider a M2M relationship with a table containing all of
the available options.



>
> Now this is in a list format, which makes sense, but it seems to have been
> converted to a string.  When I try to call on property_type in a .html
> document...
>
> {% for property in model.property_type %}
> {{ property }}
> {% endfor %}
>


This is slightly confusing. Is 'model' a context variable that you are
providing in your view? I'm assuming this refers to the object being pulled
from the DB. If that's the case, then this code is roughly equivalent to
the following:

for x in "['Condo ap'":
print(x)


You likely just need {{ model.property_type }} given your model definition.



>
> The result is displayed in singular characters, like this:
>
> [
> '
> C
> o
> n
> d
> o
>
> a
> p
>


Happens a lot in templates when they go too deep with the {% for %} tags.



> .. and so on.  Instead I want the result to be the values in the list,
> like this:
>
> Condo apartment
> Semi-detached
>
> How do I do this?  I tried experimenting with different model field types
> but CharField seems like the only appropriate one for MultipleChoiceField.
>


I think you're intermixing Model fields and Form fields, both of which have
very different functions. I did the same thing when I first started with
Django:

https://docs.djangoproject.com/en/1.11/ref/models/fields/
https://docs.djangoproject.com/en/1.11/ref/forms/fields/

These are not interchangeable as they have different purposes.

It's not necessarily clear what you are trying to do. Your template code
indicates one thing, and your textual description another.

According to your template code, you are simply displaying a static
unordered list of text blurbs on the page, no form elements involved. From
your other descriptions,  you are trying to display a select form control
with multiple options in it. A bit more guidance here would result in a
better answer.

-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%2BciVDYn%2B1x4%2BF3bDu1rc%2B0pbj%2BVyZFtUXGJm9inNdZ6i2rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.