Control PhoneNumber Format in SQL

2018-05-15 Thread tango ward
Hi,

I am currently migrating database from MySQL to PostgreSQL. I have already
migrated some of the data but I can't pull the data for my phonenumber
field.

I have a model:

class BasePerson(TimeStampedModel):
 phone_number = PhoneNumberField(max_length=50, verbose_name=_(u'phone
number'), blank=True)


The data for phone number that I am migrating doesn't have country code. I
would like to know if I can control this in SQL? I want to determine first
if the number has country code in it, if it doesn't then I will add the
country code on the number before INSERTING it to the destination database.
I am using psycopg2 for my script.


Any suggestion will be highly appreciated.


Thanks,
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/CAA6wQL%2Bf%3DkBHowTs-J3%3DQxwR2UFMZq1Jk3d-%2BWMnDPsK1rr%3D0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Frontend

2018-05-15 Thread Chekib Gmt
Hello,
  I would like to know if the django framework can replace javascript (the 
frameworks Angular js or React) in Frontend development and are there any 
robust frameworks that can be combined with django to develop a whole 
website with only python language (backend + frontend).

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/e46fbbd0-f6c8-43b0-86ec-7b95049970bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Required Full Stack Developers

2018-05-15 Thread pranay reddy
Location:Bangalore
Experience:0-1 year
Skills: Python,Django and UI design
Responsibilities: able to analyse the concept and  Make Django models with 
different types of relations.

*If anyone plz sent updated CV  to pranai.re...@ekatechserv.com*

-- 
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/f0de29eb-020e-450d-bcd3-7535efa23400%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to operate with two models in one view?

2018-05-15 Thread Anton Smirnov


I have two models: "Sensors" with information about its and "Measurments" .

class Sensor(models.Model):
date_start = models.DateField()
Latitude =  models.DecimalField(max_digits=18, decimal_places=15)
Longitude = models.DecimalField(max_digits=18, decimal_places=15)

def __str__(self):
return 'id:%s / %s' % (self.id, self.date_start)
class Measurment(models.Model):
sens = models.ForeignKey(Sensor, on_delete=models.PROTECT)
time_of_measurment = models.DateTimeField()
humidity = models.PositiveSmallIntegerField()
temperature1 = models.DecimalField(max_digits=5, decimal_places=2)
temperature2 = models.DecimalField(max_digits=5, decimal_places=2)
temperature3 = models.DecimalField(max_digits=5, decimal_places=2)

def __str__(self):
return 'sens_id:%s, time:%s' % (self.sens.id, self.time_of_measurment)

>From each sensor I serially recive measurments. On the page, it is 
necessary to display the sensor data and the one latest measurement data 
from the "Measurments" model corresponding for each sensor.

for displaying sensors data I used ListView:

view:

from .models import Sensor, Measurmentclass SenorsListView(generic.ListView):
model = Sensor, Measurment
context_object_name = 'sensors_list'
template_name = 'sensors_list.html'
queryset = Sensor.objects.all().order_by('-date_start')

template "sensors_list.html":

{% extends "base_generic.html" %}{% block content %}
Sensors List
{% if sensors_list %}

  
ID sens
Date of install
Latitude
Longitude
Data from last measurments
  
  {% for sensor in sensors_list %}
  
{{sensor.id}}
{{sensor.date_start}}
   {{sensor.Latitude}}
{{sensor.Longitude}}
{{}}
  
  {% endfor %}

{% else %}
  There are no sensors in the DB.
{% endif %} {% endblock %}

But dont know How to display data about last measurments. I think need 
using aggregate to calculate last_time how Max(time_of_measurment) for each 
id_sens. And then get it whith filter(sens=id_sens, time_of_measurment = 
last_time )

How it can be done right?

-- 
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/75f85eb9-0a7d-45cf-b50d-00add6a8cf51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to operate with two models in one view

2018-05-15 Thread Anton Smirnov


There are two models "Sensors" with information about them and 
"Measurments" .

class Sensor(models.Model):
date_start = models.DateField()
Latitude =  models.DecimalField(max_digits=18, decimal_places=15)
Longitude = models.DecimalField(max_digits=18, decimal_places=15)

def __str__(self):
return 'id:%s / %s' % (self.id, self.date_start)
class Measurment(models.Model):
sens = models.ForeignKey(Sensor, on_delete=models.PROTECT)
time_of_measurment = models.DateTimeField()
humidity = models.PositiveSmallIntegerField()
temperature1 = models.DecimalField(max_digits=5, decimal_places=2)
temperature2 = models.DecimalField(max_digits=5, decimal_places=2)
temperature3 = models.DecimalField(max_digits=5, decimal_places=2)

def __str__(self):
return 'sens_id:%s, time:%s' % (self.sens.id, self.time_of_measurment)

>From each sensor I serially recive measurments. On the page, it is 
necessary to display the sensor data and the latest measurement data from 
the "Measurments" model corresponding for each sensor.

for displaying data about sensor I used ListView:

view:

from .models import Sensor, Measurmentclass SenorsListView(generic.ListView):
model = Sensor, Measurment
context_object_name = 'sensors_list'
template_name = 'sensors_list.html'
queryset = Sensor.objects.all().order_by('-date_start')

template "sensors_list.html":

{% extends "base_generic.html" %}{% block content %}
Sensors List
{% if sensors_list %}

  
ID sens
Date of install
Latitude
Longitude
Data from last measurments
  
  {% for sensor in sensors_list %}
  
{{sensor.id}}
{{sensor.date_start}}
   {{sensor.Latitude}}
{{sensor.Longitude}}
{{}}
  
  {% endfor %}

{% else %}
  There are no sensors in the DB.
{% endif %} {% endblock %}

But dont know How to display data about last measurments. I think need 
using aggregate to calculate max of time_of_measurment for each id_sens.

How it can be done?

-- 
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/9250b3a0-eab8-4259-8cf6-00fb17975b18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Frontend

2018-05-15 Thread Vinicius Assef
Hi.

No, Django cannot replace javascript. Django works in the backend.

There are some projects bringing Python to browser. One of them is
brython. Certainly there are others, too.



On 15 May 2018 at 07:48, Chekib Gmt  wrote:
> Hello,
>   I would like to know if the django framework can replace javascript (the
> frameworks Angular js or React) in Frontend development and are there any
> robust frameworks that can be combined with django to develop a whole
> website with only python language (backend + frontend).
>
> 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/e46fbbd0-f6c8-43b0-86ec-7b95049970bd%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/CAFmXjSB9X_fh%3DC7LY02XW6addqq4yyiKaaBVdG21iHQ8x_7mxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Frontend

2018-05-15 Thread Chekib Gmt
 Thank you Vinicius

2018-05-15 12:39 GMT+01:00 Vinicius Assef :

> Hi.
>
> No, Django cannot replace javascript. Django works in the backend.
>
> There are some projects bringing Python to browser. One of them is
> brython. Certainly there are others, too.
>
>
>
> On 15 May 2018 at 07:48, Chekib Gmt  wrote:
> > Hello,
> >   I would like to know if the django framework can replace javascript
> (the
> > frameworks Angular js or React) in Frontend development and are there any
> > robust frameworks that can be combined with django to develop a whole
> > website with only python language (backend + frontend).
> >
> > 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/e46fbbd0-
> f6c8-43b0-86ec-7b95049970bd%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/CAFmXjSB9X_fh%3DC7LY02XW6addqq4yyiKaaBVdG21i
> HQ8x_7mxg%40mail.gmail.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/CALo2WfvgAcwig4igGF7O98W4ta9%3DLCNz7xhnnBVDhJ30cYzDew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django 2.0 tutorial :: exception:: application labels are not unique.

2018-05-15 Thread Paolo Chilosi
As new to Django I am learning following the tutorial carefully. When I 
reached the point of making the migration for the polls app I executed 
(from the PyCharm terminal) the command:

(venv) C:\Users\Paolo\PycharmProjects\mysite>python manage.py makemigration 
polls

and then I obtained the following exception messages 

Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
t__.py", line 371, in execute_from_command_line
utility.execute()
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
t__.py", line 347, in execute
django.setup()
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\__init__.py",
 
line 24
, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\apps\registry.py",
 
line 93, in populate
"duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't 
unique, duplicates: polls
(venv) C:\Users\Paolo\PycharmProjects\mysite>

I reviewed carefully the code and restarted the tutorial several times , 
all the times having the same problem.

ANY SUGGESTION?? 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/653a7dd7-b330-4062-86b2-3fa06598008a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: django 2.0 tutorial :: exception:: application labels are not unique.

2018-05-15 Thread Matthew Pava
Though I’ve never seen that error, I’m guessing that maybe you added ‘polls’ to 
your INSTALLED_APPS setting more than once.  Simply remove the extra references 
to it.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Paolo Chilosi
Sent: Tuesday, May 15, 2018 6:52 AM
To: Django users
Subject: django 2.0 tutorial :: exception:: application labels are not unique.

As new to Django I am learning following the tutorial carefully. When I reached 
the point of making the migration for the polls app I executed (from the 
PyCharm terminal) the command:

(venv) C:\Users\Paolo\PycharmProjects\mysite>python manage.py makemigration 
polls

and then I obtained the following exception messages

Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
t__.py", line 371, in execute_from_command_line
utility.execute()
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
t__.py", line 347, in execute
django.setup()
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\__init__.py",
 line 24
, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\apps\registry.py",
 line 93, in populate
"duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, 
duplicates: polls
(venv) C:\Users\Paolo\PycharmProjects\mysite>

I reviewed carefully the code and restarted the tutorial several times , all 
the times having the same problem.

ANY SUGGESTION?? 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/653a7dd7-b330-4062-86b2-3fa06598008a%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/1e6238fce8ad4f4fbb9706fda6390236%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: django 2.0 tutorial :: exception:: application labels are not unique.

2018-05-15 Thread Sidyvan Fernandes de Andrade
 python manage.py makemigrations polls

2018-05-15 8:51 GMT-03:00 Paolo Chilosi :

> As new to Django I am learning following the tutorial carefully. When I
> reached the point of making the migration for the polls app I executed
> (from the PyCharm terminal) the command:
>
> (venv) C:\Users\Paolo\PycharmProjects\mysite>python manage.py
> makemigration polls
>
> and then I obtained the following exception messages
>
> Traceback (most recent call last):
>   File "manage.py", line 15, in 
> execute_from_command_line(sys.argv)
>   File "C:\Users\Paolo\PycharmProjects\mysite\venv\
> lib\site-packages\django\core\management\__ini
> t__.py", line 371, in execute_from_command_line
> utility.execute()
>   File "C:\Users\Paolo\PycharmProjects\mysite\venv\
> lib\site-packages\django\core\management\__ini
> t__.py", line 347, in execute
> django.setup()
>   File "C:\Users\Paolo\PycharmProjects\mysite\venv\
> lib\site-packages\django\__init__.py", line 24
> , in setup
> apps.populate(settings.INSTALLED_APPS)
>   File "C:\Users\Paolo\PycharmProjects\mysite\venv\
> lib\site-packages\django\apps\registry.py", line 93, in populate
> "duplicates: %s" % app_config.label)
> django.core.exceptions.ImproperlyConfigured: Application labels aren't
> unique, duplicates: polls
> (venv) C:\Users\Paolo\PycharmProjects\mysite>
>
> I reviewed carefully the code and restarted the tutorial several times ,
> all the times having the same problem.
>
> ANY SUGGESTION?? 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/653a7dd7-b330-4062-86b2-3fa06598008a%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/CAEj13RBSLXjLkQVS8desv%2BQuUGo4c7shwkNbF1%3DvmHbmSykAiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to operate with two models in one view

2018-05-15 Thread Fidel Leon
When you are using models related by a Foreign Key, by default you have
access to the "children" models from the parent model. For example, your
Sensor model gets a "measurment_set" property just because of such foreign
key:

>>> dir(Sensor.objects.all()[0])
>
> [other properties, '*measurment_set*', [more properties]
>
>
>
which means you can access your measurements from a Sensor model:

>>> sensor = Sensor.objects.all()[0]
> >>> sensor
> 
> >>> sensor.measurment_set.all()
> ,
> ]>
>

You can change the default name in the ForeignKey field declaration, using
the *related_name* parameter.

You can also access the children from the templates:

Sensors List
>
> {% if sensors_list %}
>
> 
>
>   
>
> ID sens
>
> Date of install
>
> Latitude
>
> Longitude
>
> Data from last measurments
>
>   
>
>   {% for sensor in sensors_list %}
>
>   
>
> {{sensor.id}}
>
> {{sensor.date_start}}
>
>{{sensor.Latitude}}
>
> {{sensor.Longitude}}
>
> {% *with sensor.measurment_set.all.0 as last_measurment* %}
>
> {{ last_measurment.temperature1 }}{{
>> last_measurment.temperature2 }}{{ last_measurment.temperature3
>> }}
>
> {% endwith %}
>
>   
>
>   {% endfor %}
>
> 
>
> {% else %}
>
>   There are no sensors in the DB.
>
> {% endif %}
>
>
Using *with* limits your children to a single item, and telling the
template *all.0* you refer to the FIRST measurement for such sensor. The
only thing you need to do is tell the Measurment model to list itself by
time_of_measurment *reversed*, so the "first" object in the list will be
the latest measurement:


> class Measurment(models.Model):
> 
> class Meta:
> ordering = ['-time_of_measurment',]


The way I have done it is a bit hacky (and I guess there are cleaner ways
to do it, using get_context or similars), but hey!


El mar., 15 may. 2018 a las 13:21, Anton Smirnov (<
antonsmirnov1...@gmail.com>) escribió:

> There are two models "Sensors" with information about them and
> "Measurments" .
>
> class Sensor(models.Model):
> date_start = models.DateField()
> Latitude =  models.DecimalField(max_digits=18, decimal_places=15)
> Longitude = models.DecimalField(max_digits=18, decimal_places=15)
>
> def __str__(self):
> return 'id:%s / %s' % (self.id, self.date_start)
> class Measurment(models.Model):
> sens = models.ForeignKey(Sensor, on_delete=models.PROTECT)
> time_of_measurment = models.DateTimeField()
> humidity = models.PositiveSmallIntegerField()
> temperature1 = models.DecimalField(max_digits=5, decimal_places=2)
> temperature2 = models.DecimalField(max_digits=5, decimal_places=2)
> temperature3 = models.DecimalField(max_digits=5, decimal_places=2)
>
> def __str__(self):
> return 'sens_id:%s, time:%s' % (self.sens.id, self.time_of_measurment)
>
> From each sensor I serially recive measurments. On the page, it is
> necessary to display the sensor data and the latest measurement data from
> the "Measurments" model corresponding for each sensor.
>
> for displaying data about sensor I used ListView:
>
> view:
>
> from .models import Sensor, Measurmentclass SenorsListView(generic.ListView):
> model = Sensor, Measurment
> context_object_name = 'sensors_list'
> template_name = 'sensors_list.html'
> queryset = Sensor.objects.all().order_by('-date_start')
>
> template "sensors_list.html":
>
> {% extends "base_generic.html" %}{% block content %}
> Sensors List
> {% if sensors_list %}
> 
>   
> ID sens
> Date of install
> Latitude
> Longitude
> Data from last measurments
>   
>   {% for sensor in sensors_list %}
>   
> {{sensor.id}}
> {{sensor.date_start}}
>{{sensor.Latitude}}
> {{sensor.Longitude}}
> {{}}
>   
>   {% endfor %}
> 
> {% else %}
>   There are no sensors in the DB.
> {% endif %} {% endblock %}
>
> But dont know How to display data about last measurments. I think need
> using aggregate to calculate max of time_of_measurment for each id_sens.
>
> How it can be done?
>
> --
> 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/9250b3a0-eab8-4259-8cf6-00fb17975b18%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Fidel Leon
fi...@flm.cat
Phone: +34 622 26 44 92

-- 
You received this message because you are subscribed to the Google Groups 
"Djan

Re: django 2.0 tutorial :: exception:: application labels are not unique.

2018-05-15 Thread Paolo Chilosi
Mattew,
thank for the prompt answer. 
In effects, for some reason the app was preset 2 times in the 
INSTALLED_APPS list, also if I am sure I added it only once at the 
beginning of the list. Maybe django added it again at the end of the list. 
I will watch this behavior and let the list know.
Problem solved



On Tuesday, May 15, 2018 at 9:43:39 AM UTC-4, Matthew Pava wrote:

> Though I’ve never seen that error, I’m guessing that maybe you added 
> ‘polls’ to your INSTALLED_APPS setting more than once.  Simply remove the 
> extra references to it.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Paolo Chilosi
> *Sent:* Tuesday, May 15, 2018 6:52 AM
> *To:* Django users
> *Subject:* django 2.0 tutorial :: exception:: application labels are not 
> unique.
>
>  
>
> As new to Django I am learning following the tutorial carefully. When I 
> reached the point of making the migration for the polls app I executed 
> (from the PyCharm terminal) the command:
>
>  
>
> (venv) C:\Users\Paolo\PycharmProjects\mysite>python manage.py 
> makemigration polls
>
>  
>
> and then I obtained the following exception messages 
>
>  
>
> Traceback (most recent call last):
>   File "manage.py", line 15, in 
> execute_from_command_line(sys.argv)
>   File 
> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
> t__.py", line 371, in execute_from_command_line
> utility.execute()
>   File 
> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
> t__.py", line 347, in execute
> django.setup()
>   File 
> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\__init__.py",
>  
> line 24
> , in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\apps\registry.py",
>  
> line 93, in populate
> "duplicates: %s" % app_config.label)
> django.core.exceptions.ImproperlyConfigured: Application labels aren't 
> unique, duplicates: polls
>
> (venv) C:\Users\Paolo\PycharmProjects\mysite>
>
>  
>
> I reviewed carefully the code and restarted the tutorial several times , 
> all the times having the same problem.
>
>  
>
> ANY SUGGESTION?? 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...@googlegroups.com .
> To post to this group, send email to djang...@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/653a7dd7-b330-4062-86b2-3fa06598008a%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/d0685aa9-f404-4fca-b97f-b72c97045f9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 2.0 tutorial :: exception:: application labels are not unique.

2018-05-15 Thread Paolo Chilosi
thanks for pointing out about the typo. However this was not the cause of 
the exception. Look to my previous answer.

On Tuesday, May 15, 2018 at 9:44:57 AM UTC-4, Sidyvan Fernandes de Andrade 
wrote:
>
> python manage.py makemigrations polls 
>
> 2018-05-15 8:51 GMT-03:00 Paolo Chilosi 
> >:
>
>> As new to Django I am learning following the tutorial carefully. When I 
>> reached the point of making the migration for the polls app I executed 
>> (from the PyCharm terminal) the command:
>>
>> (venv) C:\Users\Paolo\PycharmProjects\mysite>python manage.py 
>> makemigration polls
>>
>> and then I obtained the following exception messages 
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 15, in 
>> execute_from_command_line(sys.argv)
>>   File 
>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
>> t__.py", line 371, in execute_from_command_line
>> utility.execute()
>>   File 
>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
>> t__.py", line 347, in execute
>> django.setup()
>>   File 
>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\__init__.py",
>>  
>> line 24
>> , in setup
>> apps.populate(settings.INSTALLED_APPS)
>>   File 
>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\apps\registry.py",
>>  
>> line 93, in populate
>> "duplicates: %s" % app_config.label)
>> django.core.exceptions.ImproperlyConfigured: Application labels aren't 
>> unique, duplicates: polls
>> (venv) C:\Users\Paolo\PycharmProjects\mysite>
>>
>> I reviewed carefully the code and restarted the tutorial several times , 
>> all the times having the same problem.
>>
>> ANY SUGGESTION?? 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...@googlegroups.com .
>> To post to this group, send email to django...@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/653a7dd7-b330-4062-86b2-3fa06598008a%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/fffe2c47-a057-4dbb-9f8c-718b3abb8939%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to retrieve existing data of mongodb database in Django

2018-05-15 Thread gomahesh5
I am new to Django started developing the application  but got a problem in 
retrieving the data from already existing data which looks like this below.
   
   
   
  
 {"_id":"5ad72e80bdd7ad184031ab2d","name":"john","country":"usa","place":"xyz"} 
{"_id":"5ad72ec6bdd7ad184031ab2e","name":"ron","country":"canada","place":"ABC"}
  
 
 
The code in the django look like this


from mongoengine import *
from django.shortcuts import render
from django.contrib.auth.models import User

 
class demo_data(DynamicDocument):
meta = {

'index_background':True,
'collection':'demo_data',
}
name = StringField(max_length=100)
country = StringField(max_length=100)
place = StringField(max_length=150)

connone = 
connect(host='mongodb://myusername:mypassw...@example.com/databasename?replicaSet=rs0')


def test_extract(request):

connone = demo_data()
dt_view = connone._data

print(dt_view)
return render(request,"extract.html",{"dt":dt_view}) 

My  code in extract.html   
 


the data relating to collection {{dt}}



  

And the output which i got after running is this 
   
the data relating to collection {'name': None, 'country': None, 
'place': None, 'id': None}

Can anyone please help me out from this situation 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/9dc0e170-6a1c-46d0-84be-7385158ea59e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Managing multiple user types in Django

2018-05-15 Thread Frankline
Hello Everyone,

I am developing an API based on Django Rest Framework
. Currently I have 4 user types i.e.
Buyer, Merchant, Insurer, and Admin.

The system I'm developing has an *API endpoint* and a *Dashboard* view.

Each of the above user types have different fields and may need to login to
the system at one point, so having one user model is the best way to go.
Note that, a user can only be of one type.

However, only the merchant will be actively using the API endpoint.

My question is then, how will I be able to manage the different user types
in the system?

My current options are:

1.

   1. class BaseUser(AbstractBaseUser):
   2. ...
   3.
   4. class Buyer(BaseUser):
   5. ...
   6.


   1. class Merchant(BaseUser):
   2. ...
   3.


   1. class Insurer(BaseUser):
   2. ...


2.


   1. from django.db import models
   2. from django.contrib.auth.models import User
   3.
   4. class Buyer(models.Model):
   5. user = models.OneToOneField(User)
   6.
   7. class Merchant(models.Model):
   8. user = models.OneToOneField(User)
   9.


   1. class Insurer(models.Model):
   2. user = models.OneToOneField(User)



   1. ...


Which is the most optimal way of handling this?

   1.

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


Re: Invalid HTTP_HOST header: 'testserver'. You may need to add 'testserver' to ALLOWED_HOSTS.

2018-05-15 Thread Avitab Ayan Sarmah
hi Andreas,

On Sunday, May 13, 2018 at 4:12:09 PM UTC+5:30, Andréas Kühne wrote:
>
> Hi,
>
> The error is pretty self explanatory. When the test client calls the 
> django server it uses the hostname of testserver. This works while testing 
> and also in development mode as long as you have DEBUG=True in your 
> settings file.
>
> If you have changed that to False, django will look in the list of 
> ALLOWED_HOSTS in the settings file (which should be set to the hostnames 
> that your server allows) - but you shouldn't require it for testing. 
>
> If you have set DEBUG to False and set the ALLOWED_HOSTS setting to the 
> production server and want to test something with the django test client 
> you can initialize the client with the following statement:
>
> client = Client(SERVER_NAME='www.example.com') 
>
> and change to the correct server name.
>
> Regards,
>
> Andréas
>
> 2018-05-13 9:02 GMT+02:00 Avitab Ayan Sarmah  >:
>
>> Hi all,
>> while going through the dajngo tutorial i stuck while executing a 
>> code i.e., mentioned below. It is shoeing "Invalid HTTP_HOST header: 
>> 'testserver'. You may need to add 'testserver' to ALLOWED_HOSTS.".
>>
>>
>> the code is written in python manage.py shell.i.e.,
>>
>> PS C:\Users\AVITABAYAN\mysite> python manage.py shell
>> Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit 
>> (AMD64)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>> (InteractiveConsole)
>> >>> from django.test import Client
>> >>> #...
>> >>> client = Client()
>> >>> #...
>> >>> response = client.get('/')
>> Invalid HTTP_HOST header: 'testserver'. You may need to add 'testserver' 
>> to ALLOWED_HOSTS.
>>
>> please find what is error and comment.Thank you
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/53313ac7-6840-4ee9-b49b-804f91a045d4%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/0816123f-719d-40b1-a9db-0c06626b1dfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 2.0 tutorial :: exception:: application labels are not unique.

2018-05-15 Thread James Farris
Just to note: Django doesn’t change the settings.py file, it only
references it so it knows what configurations to load.

On Tue, May 15, 2018 at 7:27 AM Paolo Chilosi 
wrote:

> thanks for pointing out about the typo. However this was not the cause of
> the exception. Look to my previous answer.
>
>
> On Tuesday, May 15, 2018 at 9:44:57 AM UTC-4, Sidyvan Fernandes de Andrade
> wrote:
>
>> python manage.py makemigrations polls
>>
>> 2018-05-15 8:51 GMT-03:00 Paolo Chilosi :
>>
> As new to Django I am learning following the tutorial carefully. When I
>>> reached the point of making the migration for the polls app I executed
>>> (from the PyCharm terminal) the command:
>>>
>>> (venv) C:\Users\Paolo\PycharmProjects\mysite>python manage.py
>>> makemigration polls
>>>
>>> and then I obtained the following exception messages
>>>
>>> Traceback (most recent call last):
>>>   File "manage.py", line 15, in 
>>> execute_from_command_line(sys.argv)
>>>   File
>>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
>>> t__.py", line 371, in execute_from_command_line
>>> utility.execute()
>>>   File
>>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\core\management\__ini
>>> t__.py", line 347, in execute
>>> django.setup()
>>>   File
>>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\__init__.py",
>>> line 24
>>> , in setup
>>> apps.populate(settings.INSTALLED_APPS)
>>>   File
>>> "C:\Users\Paolo\PycharmProjects\mysite\venv\lib\site-packages\django\apps\registry.py",
>>> line 93, in populate
>>> "duplicates: %s" % app_config.label)
>>> django.core.exceptions.ImproperlyConfigured: Application labels aren't
>>> unique, duplicates: polls
>>> (venv) C:\Users\Paolo\PycharmProjects\mysite>
>>>
>>> I reviewed carefully the code and restarted the tutorial several times ,
>>> all the times having the same problem.
>>>
>>> ANY SUGGESTION?? 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/653a7dd7-b330-4062-86b2-3fa06598008a%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/fffe2c47-a057-4dbb-9f8c-718b3abb8939%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/CAE-E-_0H_HB1o-wb9TqssPQWJ%3Dk%3DhubEysUk9fVHf3fHqvcz%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Managing multiple user types in Django

2018-05-15 Thread Vijay Khemlani
I would make a UserType table and have a foreign key from your user model
to it, or maybe just have an enumerated type in your user model depending
on how much custom logic there is to each user type.

On Tue, May 15, 2018 at 11:50 AM Frankline  wrote:

> Hello Everyone,
>
> I am developing an API based on Django Rest Framework
> . Currently I have 4 user types
> i.e. Buyer, Merchant, Insurer, and Admin.
>
> The system I'm developing has an *API endpoint* and a *Dashboard* view.
>
> Each of the above user types have different fields and may need to login
> to the system at one point, so having one user model is the best way to go.
> Note that, a user can only be of one type.
>
> However, only the merchant will be actively using the API endpoint.
>
> My question is then, how will I be able to manage the different user types
> in the system?
>
> My current options are:
>
> 1.
>
>1. class BaseUser(AbstractBaseUser):
>2. ...
>3.
>4. class Buyer(BaseUser):
>5. ...
>6.
>
>
>1. class Merchant(BaseUser):
>2. ...
>3.
>
>
>1. class Insurer(BaseUser):
>2. ...
>
>
> 2.
>
>
>1. from django.db import models
>2. from django.contrib.auth.models import User
>3.
>4. class Buyer(models.Model):
>5. user = models.OneToOneField(User)
>6.
>7. class Merchant(models.Model):
>8. user = models.OneToOneField(User)
>9.
>
>
>1. class Insurer(models.Model):
>2. user = models.OneToOneField(User)
>
>
>
>1. ...
>
>
> Which is the most optimal way of handling this?
>
>1.
>
>
>
>
> --
> 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/CAEAUGdVwB_RrOP_s9Oj5fe6AoOXJ9qpPLUKpE%2BbAO_NLGMRn6g%40mail.gmail.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/CALn3ei0xcocCdB-TF%2BFGyjutV7hFELpiqsbc6jnscVz4OijVww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


adding notification feature

2018-05-15 Thread Gaurav Sharma
Hello everybody,

i want to add django notification feature in my simple hello world python  
program, like whenever i run python file it show notification helloworld

Here is the snippet which i got in django notification from github.

Generating notifications is probably best done in a separate signal.


from django.db.models.signals import post_save
from notifications.signals import notify
from myapp.models import MyModel

def my_handler(sender, instance, created, **kwargs):
notify.send(instance, verb='was saved')

post_save.connect(my_handler, sender=MyModel)

To generate an notification anywhere in your code, simply import the notify 
signal and send it with your actor, recipient, and verb.

from notifications.signals import notify 
notify.send(user, recipient=user, verb='you reached level 10') 

  
i m not able to understand what is separate signal. and where i have to 
define it, and how to pass argument in notify.send()
 i am new to django..needed 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/f2cc4aec-cc3f-4df9-8275-6bbba050935e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Want to change value of foreignkey's foreginkey

2018-05-15 Thread mansi thakkar
Hello everyone, 

In my project, I have a flow like this. I have product table which is 
associated with product_line table  with foreign key which is associated 
with brand table with foreign key. Now I have displayed all the columns of 
table product in my admin site but what I want is if I click a particular 
product I want brand names as dropdown. Here is attached picture of it. As 
I have highlighted the vfield Pl which is basically product_line. I want 
brand same as product_line (Pl). Please reply me as soon as possible. I 
just have two days to finish this task .


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/c7ea2d98-574c-4807-814f-5356beed4544%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Message from a django beginner user

2018-05-15 Thread Francis F. Massaquoi, Jr.
Hi, I'm Francis F. Massaquoi, Jr. with great interest in learning django 
2.0, which is the latest version, I have been searching on youtube for a 
channel that have the latest version tutorial, I have not really find one, 
can someone please help me with a pdf or website, where I can learn django 
to the best, I have been reading some pdf, I have the basic knowledge, but 
I need to advance my knowledge. Or if you can connect with me on skype, 
this is my skype username: francisfmassaquoijr, or if you have a skype 
group, you can please add me, or give me your skype username...

Your urgent response will highly be appreciated. 

Thanks to the admin for accepting me..

We do it the django way, because it's the best way to web app 
development.

-- 
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/e22ff629-023d-41dc-bb08-7d0d0f87fd42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


New to Python

2018-05-15 Thread Mo El
Hi there,

I`m new to python and i have been watching a lot of tutorials regarding web 
scraping using python, and my question is what is the best library to use, 
and can someone help me to understand how to write a scrapped data to an 
HTML, say i scrapped some data from a website and i wanted to write that 
data to another page to view or use using python as well.

Your help is very much 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/c97a930a-8691-4b8f-adb3-a067adc278ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels client not consuming

2018-05-15 Thread LEEPS Lab
We have an issue implementing django channels in an oTree project (
http://otree.readthedocs.io/en/latest/)

Currently we are forced to use django channels version 0.17.3 due to the 
restriction inside of oTree, so it is possible that we are dealing with 
version issues.

However, we have an issue implementing a message.reply_channel response 
where we are successfully adding messages to the reply channel queue, but 
our client is not consuming these messages to the point of a 

asgiref.inmemory.ChannelLayer.ChannelFull:

Our client code creates the usual websocket consuming scheme

window.onload = function () {
var ws_scheme = window.location.protocol == "https:" ? "wss" : 
"ws";
var socket = new WebSocket(ws_scheme + '://' + 
window.location.host + "/hft/{{group.id}}/{{player.id}}/");
console.log(ws_scheme + '://' + window.location.host + 
"/hft/{{group.id}}/{{player.id}}/");

// Handle any errors that occur.
socket.onerror = function (error) {
console.log('WebSocket Error: ' + error);
};

// Show a connected message when the WebSocket is opened.
socket.onopen = function (event) {
console.log('connected to oTree');
};
// Handle messages sent by the server.
socket.onmessage = function (event) {
// var obj = jQuery.parseJSON(event.data);
// role = obj.state;
console.log("Received a message");
};
// Show a disconnected message when the WebSocket is closed.
socket.onclose = function (event) {
console.log('disconnected from oTree');
};


currently the socket.onmessage function is never called.

Our consumer code looks like this:

class SubjectConsumer(JsonWebsocketConsumer):

def raw_connect(self, message, group_id, player_id):
Group(group_id).add(message.reply_channel)
log.info('Player %s is connected to Group %s.' % (player_id, 
group_id))
self.connect(message, player_id)

def connect(self, message, player_id):
player = Player.objects.get(id=player_id)
player.channel = message.reply_channel
player.save()

def raw_receive(self, message, group_id, player_id):
msg = json.loads(message.content['text'])
player = Player.objects.get(id=player_id)
player.receive_from_client(msg)

def raw_disconnect(self, message, group_id, player_id):
log = 'Player %s  disconnected from Group %s.' % (player_id, 
group_id)
logging.info(log)
Group(group_id).discard(message.reply_channel)

def send(self, msg, chnl):
Channel(chnl).send(msg)

def broadcast(self, msg, chnl):
Group(chnl).send(msg)

Usually we will save the reply_channel after connecting with the consumer 
to a player object that will send a message when finished processing 
received data from the client. We have already checked that the channels 
names are correct, and that no errors are thrown in relation to the type of 
our data and how we're sending it. 

We believe our routing is correct since we can receive data from the 
client, but here is what we have

channel_routing += [
route_class(SubjectConsumer, 
path=r"^/hft/(?P\w+)/(?P\w+)/"),
route_class(InvestorConsumer, 
path=r"^/hft_investor/(?P\w+)/"),
route_class(JumpConsumer, path=r"^/hft_jump/(?P\w+)/")
]

We get the error after we successfully send several messages from the 
consumer's send function but do not receive any on our client websockets. 
We assume that they are sending correctly because we continue execution 
after SubjectConsumer.send() and the queue eventually fills.

2018-05-15 10:43:06,813 - ERROR - worker - Error processing message with 
consumer oTree_HFT_CDA.consumers.SubjectConsumer:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/channels/worker.py", line 
120, in run
consumer(message, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/channels/generic/base.py", 
line 31, in __init__
self.dispatch(message, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/channels/generic/base.py", 
line 69, in dispatch
return self.get_handler(message, **kwargs)(message, **kwargs)
  File "/home/leeps/oTree_HFT_CDA/oTree_HFT_CDA/consumers.py", line 29, in 
raw_receive
Channel(str(message.reply_channel)).send({'a':'b'})
  File "/usr/local/lib/python3.5/dist-packages/channels/channel.py", line 
38, in send
self.channel_layer.send(self.name, content)
  File "/usr/local/lib/python3.5/dist-packages/asgiref/inmemory.py", line 
50, in send
raise self.ChannelFull(channel)
asgiref.inmemory.ChannelLayer.ChannelFull: websocket.send!haCXgRqE
websocket.send!haCXgRqE
2018-05-15 10:43:07,019 - ERROR - worker - Error processing message with 
consumer oTree_HFT_CDA.consumers.SubjectConsumer:
Traceback (most recent call last):
 

Standard approach

2018-05-15 Thread Mike Dewhirst
This list gets a lot of new people joining. They come from all cultures 
and degrees of general competence. And list members have always made 
them welcome and try to help as much as possible.


I would say to beginners - without thinking too hard - that the best 
place to begin is the excellent Django documentation.  Read "Getting 
started" https://docs.djangoproject.com/en/1.11/intro/ followed by "What 
to read next" https://docs.djangoproject.com/en/1.11/intro/whatsnext/


However, there are many non-native-english speakers who find reading any 
documentation just one extra hurdle instead of an open gate. When I see 
such a request for help in getting started I admire the courage displayed.


Maybe we need more than a standardised docs approach. Perhaps a wiki 
would help to display stable advice for different groups of beginners. 
There have been some particularly illuminating threads in this list 
revealing the merits of different beginner approaches. The Django blog 
might be a permanent location for such threads. Maybe there already is a 
spot for accumulated beginner wisdom?


There are lots of other resources and recent beginners are probably the 
most competent to advise.


I really don't know because I don't have much of a problem reading docs. 
And it is a while since I was a beginner.


Just thinking about this, the tutorial project might be valuable as a 
real project frozen at a seriously simple level so that beginners can 
browse the source and read the docstrings and comments. A  comment in 
code might also carry a link to the documentation. Beginners who have 
trouble with documentation should still be able to figure out the actual 
code.


Mike

--
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/5391efeb-930c-0413-7d6f-33bcc38a3847%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Message from a django beginner user

2018-05-15 Thread Gerald Brown
The best way to learn it is o jump in and start using it.  Django has a 
good tutorial on-line @ 
https://docs.djangoproject.com/en/2.0/intro/tutorial01/.  When you have 
problems Google and this Group are your friends.


Goo luck.


On 05/16/2018 01:39 AM, Francis F. Massaquoi, Jr. wrote:
Hi, I'm Francis F. Massaquoi, Jr. with great interest in learning 
django 2.0, which is the latest version, I have been searching on 
youtube for a channel that have the latest version tutorial, I have 
not really find one, can someone please help me with a pdf or website, 
where I can learn django to the best, I have been reading some pdf, I 
have the basic knowledge, but I need to advance my knowledge. Or if 
you can connect with me on skype, this is my skype username: 
francisfmassaquoijr, or if you have a skype group, you can please add 
me, or give me your skype username...


Your urgent response will highly be appreciated.

Thanks to the admin for accepting me..

We do it the django way, because it's the best way to web app 
development.

--
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/e22ff629-023d-41dc-bb08-7d0d0f87fd42%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/24c2685c-376f-d895-b51b-2447bbf77903%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels client not consuming

2018-05-15 Thread Andrew Godwin
Hi,

I'm afraid you're using incredibly old versions of Channels and the bugs
you're encountering are almost certainly fixed in more recent releases. I'm
not sure there's much I can do.

Andrew

On Tue, 15 May 2018, 13:01 LEEPS Lab,  wrote:

> We have an issue implementing django channels in an oTree project (
> http://otree.readthedocs.io/en/latest/)
>
> Currently we are forced to use django channels version 0.17.3 due to the
> restriction inside of oTree, so it is possible that we are dealing with
> version issues.
>
> However, we have an issue implementing a message.reply_channel response
> where we are successfully adding messages to the reply channel queue, but
> our client is not consuming these messages to the point of a
>
> asgiref.inmemory.ChannelLayer.ChannelFull:
>
> Our client code creates the usual websocket consuming scheme
>
> window.onload = function () {
> var ws_scheme = window.location.protocol == "https:" ? "wss" :
> "ws";
> var socket = new WebSocket(ws_scheme + '://' +
> window.location.host + "/hft/{{group.id}}/{{player.id}}/");
> console.log(ws_scheme + '://' + window.location.host + "/hft/{{
> group.id}}/{{player.id}}/");
>
> // Handle any errors that occur.
> socket.onerror = function (error) {
> console.log('WebSocket Error: ' + error);
> };
>
> // Show a connected message when the WebSocket is opened.
> socket.onopen = function (event) {
> console.log('connected to oTree');
> };
> // Handle messages sent by the server.
> socket.onmessage = function (event) {
> // var obj = jQuery.parseJSON(event.data);
> // role = obj.state;
> console.log("Received a message");
> };
> // Show a disconnected message when the WebSocket is closed.
> socket.onclose = function (event) {
> console.log('disconnected from oTree');
> };
>
>
> currently the socket.onmessage function is never called.
>
> Our consumer code looks like this:
>
> class SubjectConsumer(JsonWebsocketConsumer):
>
> def raw_connect(self, message, group_id, player_id):
> Group(group_id).add(message.reply_channel)
> log.info('Player %s is connected to Group %s.' % (player_id,
> group_id))
> self.connect(message, player_id)
>
> def connect(self, message, player_id):
> player = Player.objects.get(id=player_id)
> player.channel = message.reply_channel
> player.save()
>
> def raw_receive(self, message, group_id, player_id):
> msg = json.loads(message.content['text'])
> player = Player.objects.get(id=player_id)
> player.receive_from_client(msg)
>
> def raw_disconnect(self, message, group_id, player_id):
> log = 'Player %s  disconnected from Group %s.' % (player_id,
> group_id)
> logging.info(log)
> Group(group_id).discard(message.reply_channel)
>
> def send(self, msg, chnl):
> Channel(chnl).send(msg)
>
> def broadcast(self, msg, chnl):
> Group(chnl).send(msg)
>
> Usually we will save the reply_channel after connecting with the consumer
> to a player object that will send a message when finished processing
> received data from the client. We have already checked that the channels
> names are correct, and that no errors are thrown in relation to the type of
> our data and how we're sending it.
>
> We believe our routing is correct since we can receive data from the
> client, but here is what we have
>
> channel_routing += [
> route_class(SubjectConsumer,
> path=r"^/hft/(?P\w+)/(?P\w+)/"),
> route_class(InvestorConsumer,
> path=r"^/hft_investor/(?P\w+)/"),
> route_class(JumpConsumer, path=r"^/hft_jump/(?P\w+)/")
> ]
>
> We get the error after we successfully send several messages from the
> consumer's send function but do not receive any on our client websockets.
> We assume that they are sending correctly because we continue execution
> after SubjectConsumer.send() and the queue eventually fills.
>
> 2018-05-15 10:43:06,813 - ERROR - worker - Error processing message with
> consumer oTree_HFT_CDA.consumers.SubjectConsumer:
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.5/dist-packages/channels/worker.py", line
> 120, in run
> consumer(message, **kwargs)
>   File "/usr/local/lib/python3.5/dist-packages/channels/generic/base.py",
> line 31, in __init__
> self.dispatch(message, **kwargs)
>   File "/usr/local/lib/python3.5/dist-packages/channels/generic/base.py",
> line 69, in dispatch
> return self.get_handler(message, **kwargs)(message, **kwargs)
>   File "/home/leeps/oTree_HFT_CDA/oTree_HFT_CDA/consumers.py", line 29, in
> raw_receive
> Channel(str(message.reply_channel)).send({'a':'b'})
>   File "/usr/local/lib/python3.5/dist-packages/channels/channel.py", line
> 38, in send
> self

SMTPRecipientsRefused: Sender address rejected: not owned by user

2018-05-15 Thread Tom Tanner
I have a Django app running on a server with uWSGI and nginx. 

In my `local_settings.py` file I have this:

###
# EMAIL SETUP #
###
EMAIL_HOST = 'smtp.privateemail.com'
EMAIL_HOST_USER = 'supp...@mydomain.com'
EMAIL_HOST_PASSWORD = 'MY EMAIL PASSWORD'
EMAIL_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True



# OTHER EMAIL SETTINGS #

ADMIN_EMAIL = "ad...@mydomain.com"
SUPPORT_EMAIL = "supp...@mydomain.com"
DEFAULT_FROM_EMAIL = ADMIN_EMAIL
SERVER_EMAIL = ADMIN_EMAIL

I run `python manage.py runserver` on my local machine in the Django 
project's virtual environment. I fill out the password reset form at 
`password_rest/` using the email `my.perso...@gmail.com` and submit it. I 
get this error.

SMTPRecipientsRefused: {u'my.perso...@gmail.com': (553, '5.7.1 
: Sender address rejected: not owned by user 
supp...@mydomain.com')}

My website's email provider is Namecheap.

Why do I get this error when testing on my local machine? What must I 
change/add to get rid of it?

-- 
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/c159b190-4604-4b2d-90d6-562f9b4950db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Standard approach

2018-05-15 Thread Gerald Brown
>From what little I have read, it looks like 
https://groups.google.com/forum/#!topic/pinax-users/OvB4sB87Nr4 is trying 
to do what you are suggesting here.

On Wednesday, May 16, 2018 at 7:53:58 AM UTC+8, Mike Dewhirst wrote:
>
> This list gets a lot of new people joining. They come from all cultures 
> and degrees of general competence. And list members have always made 
> them welcome and try to help as much as possible. 
>
> I would say to beginners - without thinking too hard - that the best 
> place to begin is the excellent Django documentation.  Read "Getting 
> started" https://docs.djangoproject.com/en/1.11/intro/ followed by "What 
> to read next" https://docs.djangoproject.com/en/1.11/intro/whatsnext/ 
>
> However, there are many non-native-english speakers who find reading any 
> documentation just one extra hurdle instead of an open gate. When I see 
> such a request for help in getting started I admire the courage displayed. 
>
> Maybe we need more than a standardised docs approach. Perhaps a wiki 
> would help to display stable advice for different groups of beginners. 
> There have been some particularly illuminating threads in this list 
> revealing the merits of different beginner approaches. The Django blog 
> might be a permanent location for such threads. Maybe there already is a 
> spot for accumulated beginner wisdom? 
>
> There are lots of other resources and recent beginners are probably the 
> most competent to advise. 
>
> I really don't know because I don't have much of a problem reading docs. 
> And it is a while since I was a beginner. 
>
> Just thinking about this, the tutorial project might be valuable as a 
> real project frozen at a seriously simple level so that beginners can 
> browse the source and read the docstrings and comments. A  comment in 
> code might also carry a link to the documentation. Beginners who have 
> trouble with documentation should still be able to figure out the actual 
> code. 
>
> Mike 
>
>

-- 
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/40302159-c407-4496-af36-41d86dcd2fb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Message from a django beginner user

2018-05-15 Thread James Farris
In addition to the Django docs, I recommend https://djangobook.com/ although 
it’s written for Django 1.11, a lot of concepts still apply. 

Another good website is https://tutorial.djangogirls.org/en/

Sent from my mobile device

> On May 15, 2018, at 5:16 PM, Gerald Brown  wrote:
> 
> The best way to learn it is o jump in and start using it.  Django has a good 
> tutorial on-line @ https://docs.djangoproject.com/en/2.0/intro/tutorial01/.  
> When you have problems Google and this Group are your friends.
> 
> Goo luck.
> 
>> On 05/16/2018 01:39 AM, Francis F. Massaquoi, Jr. wrote:
>> Hi, I'm Francis F. Massaquoi, Jr. with great interest in learning django 
>> 2.0, which is the latest version, I have been searching on youtube for a 
>> channel that have the latest version tutorial, I have not really find one, 
>> can someone please help me with a pdf or website, where I can learn django 
>> to the best, I have been reading some pdf, I have the basic knowledge, but I 
>> need to advance my knowledge. Or if you can connect with me on skype, this 
>> is my skype username: francisfmassaquoijr, or if you have a skype group, you 
>> can please add me, or give me your skype username...
>> 
>> Your urgent response will highly be appreciated. 
>> 
>> Thanks to the admin for accepting me..
>> 
>> We do it the django way, because it's the best way to web app 
>> development.
>> -- 
>> 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/e22ff629-023d-41dc-bb08-7d0d0f87fd42%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/24c2685c-376f-d895-b51b-2447bbf77903%40gmail.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/39F98B08-C2C2-46AE-A8E3-8BF7A5674DCC%40gmail.com.
For more options, visit https://groups.google.com/d/optout.