Re: Unable to change db sqllite to mysql

2019-07-11 Thread Jorge Gimeno
On Thu, Jul 11, 2019 at 6:55 PM john samuel 
wrote:

> Hi shreeram,
>
> But the fact is that i  have changed the port number in xampp server for
> mySQL as 3307.
>
> On Thu, Jul 11, 2019 at 9:19 PM SHREERAM KULKARNI <
> shreeramvkulka...@gmail.com> wrote:
>
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.mysql',
>> 'NAME': 'DB_NAME',
>> 'USER': 'DB_USER',
>> 'PASSWORD': 'DB_PASSWORD',
>> 'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
>> 'PORT': '3306',
>> }}
>>
>>
>> On Fri, 12 Jul 2019, 1:45 am john samuel, 
>> wrote:
>>
>>> Hi Guys,
>>> I've done everything from installing sql,setting up of root and password
>>> till xampp server installation and setting the port number correctly with
>>> right installation of sqlclient and editing Database in setting as
>>>
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.mysql',
>>> 'NAME': 'Listo',
>>> 'USER':'root',
>>> 'PASSWORD':'',
>>> 'HOST':'localhost',
>>> 'PORT':'3307',
>>> 'OPTIONS':{
>>> 'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
>>> 'charset':'utf8mb4',
>>> },
>>> 'TEST': {
>>> 'CHARSET':'utf8mb4',
>>> 'COLLATION':'utf8mb4_unicode_ci',
>>> }
>>> }
>>> }
>>>
>>>
>>> But i am still getting an error...kindly help me...
>>> Traceback (most recent call last):
>>>   File "manage.py", line 21, in 
>>> main()
>>>   File "manage.py", line 17, in main
>>> execute_from_command_line(sys.argv)
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
>>> line 381, in execute_from_command_line
>>> utility.execute()
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
>>> line 357, in execute
>>> django.setup()
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py",
>>> line 16, in setup
>>> from django.urls import set_script_prefix
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\__init__.py",
>>> line 1, in 
>>> from .base import (
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\base.py",
>>> line 8, in 
>>> from .exceptions import NoReverseMatch, Resolver404
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\exceptions.py",
>>> line 1, in 
>>> from django.http import Http404
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\__init__.py",
>>> line 5, in 
>>> from django.http.response import (
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\response.py",
>>> line 15, in 
>>> from django.core.serializers.json import DjangoJSONEncoder
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\__init__.py",
>>> line 23, in 
>>> from django.core.serializers.base import SerializerDoesNotExist
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\base.py",
>>> line 7, in 
>>> from django.db import models
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\__init__.py",
>>> line 3, in 
>>> from django.db.models.aggregates import *  # NOQA
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\aggregates.py",
>>> line 5, in 
>>> from django.db.models.expressions import Case, Func, Star, When
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\expressions.py",
>>> line 8, in 
>>> from django.db.models import fields
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py",
>>> line 11, in 
>>> from django import forms
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\__init__.py",
>>> line 6, in 
>>> from django.forms.boundfield import *  # NOQA
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\boundfield.py",
>>> line 3, in 
>>> from django.forms.utils import flatatt, pretty_name
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\utils.py",
>>> line 6, in 
>>> from django.utils import timezone
>>>   File
>>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\timezone.py",
>>> line 11, in 
>>> import pytz
>>> ValueError: source code string cannot contain null bytes
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop 

Re: Unable to change db sqllite to mysql

2019-07-11 Thread john samuel
Hi shreeram,

But the fact is that i  have changed the port number in xampp server for
mySQL as 3307.

On Thu, Jul 11, 2019 at 9:19 PM SHREERAM KULKARNI <
shreeramvkulka...@gmail.com> wrote:

> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'NAME': 'DB_NAME',
> 'USER': 'DB_USER',
> 'PASSWORD': 'DB_PASSWORD',
> 'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
> 'PORT': '3306',
> }}
>
>
> On Fri, 12 Jul 2019, 1:45 am john samuel, 
> wrote:
>
>> Hi Guys,
>> I've done everything from installing sql,setting up of root and password
>> till xampp server installation and setting the port number correctly with
>> right installation of sqlclient and editing Database in setting as
>>
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.mysql',
>> 'NAME': 'Listo',
>> 'USER':'root',
>> 'PASSWORD':'',
>> 'HOST':'localhost',
>> 'PORT':'3307',
>> 'OPTIONS':{
>> 'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
>> 'charset':'utf8mb4',
>> },
>> 'TEST': {
>> 'CHARSET':'utf8mb4',
>> 'COLLATION':'utf8mb4_unicode_ci',
>> }
>> }
>> }
>>
>>
>> But i am still getting an error...kindly help me...
>> Traceback (most recent call last):
>>   File "manage.py", line 21, in 
>> main()
>>   File "manage.py", line 17, in main
>> execute_from_command_line(sys.argv)
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
>> line 381, in execute_from_command_line
>> utility.execute()
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
>> line 357, in execute
>> django.setup()
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py",
>> line 16, in setup
>> from django.urls import set_script_prefix
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\__init__.py",
>> line 1, in 
>> from .base import (
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\base.py",
>> line 8, in 
>> from .exceptions import NoReverseMatch, Resolver404
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\exceptions.py",
>> line 1, in 
>> from django.http import Http404
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\__init__.py",
>> line 5, in 
>> from django.http.response import (
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\response.py",
>> line 15, in 
>> from django.core.serializers.json import DjangoJSONEncoder
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\__init__.py",
>> line 23, in 
>> from django.core.serializers.base import SerializerDoesNotExist
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\base.py",
>> line 7, in 
>> from django.db import models
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\__init__.py",
>> line 3, in 
>> from django.db.models.aggregates import *  # NOQA
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\aggregates.py",
>> line 5, in 
>> from django.db.models.expressions import Case, Func, Star, When
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\expressions.py",
>> line 8, in 
>> from django.db.models import fields
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py",
>> line 11, in 
>> from django import forms
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\__init__.py",
>> line 6, in 
>> from django.forms.boundfield import *  # NOQA
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\boundfield.py",
>> line 3, in 
>> from django.forms.utils import flatatt, pretty_name
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\utils.py",
>> line 6, in 
>> from django.utils import timezone
>>   File
>> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\timezone.py",
>> line 11, in 
>> import pytz
>> ValueError: source code string cannot contain null bytes
>>
>> --
>> 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 

Re: Unable to change db sqllite to mysql

2019-07-11 Thread SHREERAM KULKARNI
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB_NAME',
'USER': 'DB_USER',
'PASSWORD': 'DB_PASSWORD',
'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
'PORT': '3306',
}}


On Fri, 12 Jul 2019, 1:45 am john samuel,  wrote:

> Hi Guys,
> I've done everything from installing sql,setting up of root and password
> till xampp server installation and setting the port number correctly with
> right installation of sqlclient and editing Database in setting as
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'NAME': 'Listo',
> 'USER':'root',
> 'PASSWORD':'',
> 'HOST':'localhost',
> 'PORT':'3307',
> 'OPTIONS':{
> 'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
> 'charset':'utf8mb4',
> },
> 'TEST': {
> 'CHARSET':'utf8mb4',
> 'COLLATION':'utf8mb4_unicode_ci',
> }
> }
> }
>
>
> But i am still getting an error...kindly help me...
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
> line 381, in execute_from_command_line
> utility.execute()
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
> line 357, in execute
> django.setup()
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py",
> line 16, in setup
> from django.urls import set_script_prefix
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\__init__.py",
> line 1, in 
> from .base import (
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\base.py",
> line 8, in 
> from .exceptions import NoReverseMatch, Resolver404
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\exceptions.py",
> line 1, in 
> from django.http import Http404
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\__init__.py",
> line 5, in 
> from django.http.response import (
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\response.py",
> line 15, in 
> from django.core.serializers.json import DjangoJSONEncoder
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\__init__.py",
> line 23, in 
> from django.core.serializers.base import SerializerDoesNotExist
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\base.py",
> line 7, in 
> from django.db import models
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\__init__.py",
> line 3, in 
> from django.db.models.aggregates import *  # NOQA
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\aggregates.py",
> line 5, in 
> from django.db.models.expressions import Case, Func, Star, When
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\expressions.py",
> line 8, in 
> from django.db.models import fields
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py",
> line 11, in 
> from django import forms
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\__init__.py",
> line 6, in 
> from django.forms.boundfield import *  # NOQA
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\boundfield.py",
> line 3, in 
> from django.forms.utils import flatatt, pretty_name
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\utils.py",
> line 6, in 
> from django.utils import timezone
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\timezone.py",
> line 11, in 
> import pytz
> ValueError: source code string cannot contain null bytes
>
> --
> 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/68059107-83c1-4dc8-accd-68ff69145312%40googlegroups.com
> 
> .
> For 

WebSocket handshak Error

2019-07-11 Thread Fatemeh Ahmadzadeh


Hi my friends
I create daphne.sock for websocket and gunicorn.sock for http request and 
and in nginx.conf proxy_pass equals to unixes.

 but have this errors 

1.   failed: Error during WebSocket handshake: Unexpected response 
code: 404

2.   failed: Error during WebSocket handshake: Unexpected response 
code: 500

according to this  webpage 

https://avilpage.com/2018/05/deploying-scaling-django-channels.html
but I have failed: Error during WebSocket handshake: Unexpected response 
code: 404
Please help me

-- 
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/72a830e2-528a-4efd-9144-ecd602f8b9dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Followed 'Writing custom django-admin commands' - 'Apps aren't loaded yet.'!

2019-07-11 Thread paul_d_sm...@hotmail.com
I've got a basic Django site up and running and am now trying to write a 
custom command by following the "Writing custom django-admin commands" 
documentation.  However having followed it carefully I get this exception:

(myfrontier) C:\Users\PDS\git\myfrontier>set 
DJANGO_SETTINGS_MODULE=myfrontier.settings

(myfrontier) C:\Users\PDS\git\myfrontier>django-admin podcasts
Traceback (most recent call last):
  File "C:\virtualenv\myfrontier\Scripts\django-admin-script.py", line 11, 
in 
load_entry_point('Django', 'console_scripts', 'django-admin')()
  File 
"C:\virtualenv\myfrontier\lib\site-packages\django\core\management\__init__.py",
 
line 381, in execute_from_command_line
utility.execute()
  File 
"C:\virtualenv\myfrontier\lib\site-packages\django\core\management\__init__.py",
 
line 357, in execute
django.setup()
  File "C:\virtualenv\myfrontier\lib\site-packages\django\__init__.py", 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\virtualenv\myfrontier\lib\site-packages\django\apps\registry.py", line 
91, in populate
app_config = AppConfig.create(entry)
  File "C:\virtualenv\myfrontier\lib\site-packages\django\apps\config.py", 
line 90, in create
module = import_module(entry)
  File "C:\virtualenv\myfrontier\lib\importlib\__init__.py", line 126, in 
import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File "c:\users\pds\git\myfrontier\portal\management\podcasts.py", line 2, 
in 
from portal.models import ShowEpisode
  File "c:\users\pds\git\myfrontier\portal\models.py", line 4, in 
class Dir(models.Model):
  File 
"C:\virtualenv\myfrontier\lib\site-packages\django\db\models\base.py", line 
103, in __new__
app_config = apps.get_containing_app_config(module)
  File 
"C:\virtualenv\myfrontier\lib\site-packages\django\apps\registry.py", line 
252, in get_containing_app_config
self.check_apps_ready()
  File 
"C:\virtualenv\myfrontier\lib\site-packages\django\apps\registry.py", line 
135, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

The first two lines of my custom command are just like the example in the 
doc...
from django.core.management.base import BaseCommand, CommandError
from portal.models import ShowEpisode

So what am I doing wrong?  Is the documentation just wrong?  A quick Google 
throws up lots of suggestions and a number of people hitting this so can 
someone from Django dev. give some proper chapter and verse on how to solve 
this please?

thanks,
Paul DS

-- 
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/f10ff11c-e954-449b-a156-59953fc836da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unable to change db sqllite to mysql

2019-07-11 Thread john samuel
Hi Guys,
I've done everything from installing sql,setting up of root and password 
till xampp server installation and setting the port number correctly with 
right installation of sqlclient and editing Database in setting as 

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Listo',
'USER':'root',
'PASSWORD':'',
'HOST':'localhost',
'PORT':'3307',
'OPTIONS':{
'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
'charset':'utf8mb4',
},
'TEST': {
'CHARSET':'utf8mb4',
'COLLATION':'utf8mb4_unicode_ci',
}
}
}


But i am still getting an error...kindly help me...
Traceback (most recent call last):
  File "manage.py", line 21, in 
main()
  File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
 
line 381, in execute_from_command_line
utility.execute()
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py",
 
line 357, in execute
django.setup()
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py",
 
line 16, in setup
from django.urls import set_script_prefix
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\__init__.py",
 
line 1, in 
from .base import (
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\base.py",
 
line 8, in 
from .exceptions import NoReverseMatch, Resolver404
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\exceptions.py",
 
line 1, in 
from django.http import Http404
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\__init__.py",
 
line 5, in 
from django.http.response import (
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\http\response.py",
 
line 15, in 
from django.core.serializers.json import DjangoJSONEncoder
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\__init__.py",
 
line 23, in 
from django.core.serializers.base import SerializerDoesNotExist
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\serializers\base.py",
 
line 7, in 
from django.db import models
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\__init__.py",
 
line 3, in 
from django.db.models.aggregates import *  # NOQA
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\aggregates.py",
 
line 5, in 
from django.db.models.expressions import Case, Func, Star, When
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\expressions.py",
 
line 8, in 
from django.db.models import fields
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py",
 
line 11, in 
from django import forms
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\__init__.py",
 
line 6, in 
from django.forms.boundfield import *  # NOQA
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\boundfield.py",
 
line 3, in 
from django.forms.utils import flatatt, pretty_name
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\forms\utils.py",
 
line 6, in 
from django.utils import timezone
  File 
"C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\timezone.py",
 
line 11, in 
import pytz
ValueError: source code string cannot contain null bytes

-- 
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/68059107-83c1-4dc8-accd-68ff69145312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


WEb socket Error 404

2019-07-11 Thread Fatemeh Ahmadzadeh


Hi our friend
I create daphne.sock for websocket and gunicorn.sock for http request and 
and in nginx.conf proxy_pass equals to unixes. 

python manage.py runworker is ok without any Errors

but have this errors in nginx

  

1.   failed: Error during WebSocket handshake: Unexpected response 
code: 404

2.   failed: Error during WebSocket handshake: Unexpected response 
code: 500

according to this 

   1.  
   https://avilpage.com/2018/05/deploying-scaling-django-channels.html
   2.  
   http://masnun.rocks/2016/11/02/deploying-django-channels-using-daphne/

this is nginx.config :

server{

listen 80;

server_name 185.252.11.11 domain.com;

 

 

location / {

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_redirect off;

proxy_pass http://../gunicorn.sock;

}

location /static/ {

root 
/home/Farzand-user/Farazan_Parvari_Project/Farzand_Parvar/Farazan_Parvari_Project;

}

 

location /ws/ {

   

proxy_buffers 8 32k;

proxy_buffer_size 64k;

proxy_redirect off;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_read_timeout 86400;

proxy_pass http://unix:/.../daphne.sock;

proxy_set_header   Host $host;

proxy_set_header   X-Real-IP $remote_addr;

proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Host $server_name;

  

  

 

}


}



server is centos with directadmin , nginx 1.15  

-- 
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/0effb95c-9a89-4f86-9790-f9709d349516%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form validations

2019-07-11 Thread Charles Wright
It sounds to me like you may want to use validators for your form.  Here
are two links that might help you out:

https://stackoverflow.com/questions/17165147/how-can-i-make-a-django-form-field-contain-only-alphanumeric-characters


https://docs.djangoproject.com/en/2.2/ref/validators/

On Thu, Jul 11, 2019 at 8:06 AM Jani Tiainen  wrote:

> Hi.
>
> Usually you validate user input and by using Forms or ModelForms.
>
>
> to 11. heinäk. 2019 klo 12.50 Irfan Khan  kirjoitti:
>
>> Dear members,
>> I wanted to validate the form which contains the name, phone number,
>> address,email, etc..,
>> I have developed and tested it if we give any character it’s saving to
>> database table.so I wanted to validate the every field for example
>> In name field it should take only alphabets,
>> And in phone number field it should take only numbers like
>> Can any one please guide me which is best practice to perform
>> 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/CALKGViqQgLhqAzPgG5S-sz4ZdwA2z_q6KeTUQoxtNrzrrA21sQ%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/CAHn91oephj3rT2JoJZaGk5MtSfdJV0Bcb1j9jngE99YW5VyFng%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/CAF35uzdu9X34kOwo3YtNF_mnv%3Dib%3DTPCMpZzCSwH%3DXUHgEWCAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Querying works on shell but not on the Django program code

2019-07-11 Thread Daniel Roseman
I'm not sure why you think that a linting error would stop your code from 
running. Does it actually work when you run the server? If not, what error do 
you get then?
-- 
DR.

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


Re: Form validations

2019-07-11 Thread Khaleel Ahmed H. M. Shariff
Yes you could validate user input using regular expression. Explore the re
module.
Best of luck
God Bless

On Thu, 11 Jul 2019, 11:22 p.m. Irfan Khan,  wrote:

> Yeah currently I do have modelforms but I need to know using regular
> expression can we done
>
> On Thu, 11 Jul 2019 at 6:36 PM, Jani Tiainen  wrote:
>
>> Hi.
>>
>> Usually you validate user input and by using Forms or ModelForms.
>>
>>
>> to 11. heinäk. 2019 klo 12.50 Irfan Khan  kirjoitti:
>>
>>> Dear members,
>>> I wanted to validate the form which contains the name, phone number,
>>> address,email, etc..,
>>> I have developed and tested it if we give any character it’s saving to
>>> database table.so I wanted to validate the every field for example
>>> In name field it should take only alphabets,
>>> And in phone number field it should take only numbers like
>>> Can any one please guide me which is best practice to perform
>>> 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/CALKGViqQgLhqAzPgG5S-sz4ZdwA2z_q6KeTUQoxtNrzrrA21sQ%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/CAHn91oephj3rT2JoJZaGk5MtSfdJV0Bcb1j9jngE99YW5VyFng%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/CALKGViqbjbsdg0tFjZLAkrLazd2YMVQohj66eMMDSwjA-d0chg%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/CAMjBbiDq7_559Kbf-6_t%3DeFzWcyODGHhpGnkv5mf8CZRcVbXfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form validations

2019-07-11 Thread Irfan Khan
Yeah currently I do have modelforms but I need to know using regular
expression can we done

On Thu, 11 Jul 2019 at 6:36 PM, Jani Tiainen  wrote:

> Hi.
>
> Usually you validate user input and by using Forms or ModelForms.
>
>
> to 11. heinäk. 2019 klo 12.50 Irfan Khan  kirjoitti:
>
>> Dear members,
>> I wanted to validate the form which contains the name, phone number,
>> address,email, etc..,
>> I have developed and tested it if we give any character it’s saving to
>> database table.so I wanted to validate the every field for example
>> In name field it should take only alphabets,
>> And in phone number field it should take only numbers like
>> Can any one please guide me which is best practice to perform
>> 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/CALKGViqQgLhqAzPgG5S-sz4ZdwA2z_q6KeTUQoxtNrzrrA21sQ%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/CAHn91oephj3rT2JoJZaGk5MtSfdJV0Bcb1j9jngE99YW5VyFng%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/CALKGViqbjbsdg0tFjZLAkrLazd2YMVQohj66eMMDSwjA-d0chg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: saving inherited model overwrites base model

2019-07-11 Thread Kalev Takkis
If it receives fields from parent model, I would assume it actually has 
access to them. In my case, 'comment' field queried from child model 
returns empty while the field in parent has value.
Something's definitely wrong here, I removed inheritance and created 
explicit OneToOne to Contact and no more monkey-business, fields are saved 
as expected.


On Friday, July 5, 2019 at 9:29:32 PM UTC+1, Jani Tiainen wrote:
>
> Hi.
>
> I think you have a bit confused terms model inheritance and abstract 
> models.
>
> Normal model inheritance in Django means that there will be implicit one 
> to one relation to base model. Inherited model still receives all fields 
> from parent model. On save data is just saved to correct models. To both 
> parent and child. And both models do have separate tables.
>
> If inherited model is abstract all fields are copied to inherited model 
> and django treats model as one. There is no parent table created but 
> columns are added to inheriting model table.
>
> pe 5. heinäk. 2019 klo 20.42 Kalev Takkis  > kirjoitti:
>
>> Hi all,
>>
>> tl;dr: saving inherited model overwrites fields in parent models with 
>> empty strings
>>
>> I have the following models:
>>
>> class Contact(models.Model):
>> comment = models.CharField(max_length=255, blank=True)
>> emails = models.ManyToManyField(
>> Email,
>> blank=True,
>> through='ContactEmail',
>> through_fields=('contact', 'email'),
>> )
>>
>> # couple of more manytomanys, to addresses, phones, etc
>>
>> 
>> class ContactEmail(BaseContactJunctionModel):
>> email = models.ForeignKey(Email, null=True, on_delete=models.SET_NULL)
>> contact = models.ForeignKey(Contact, on_delete=models.CASCADE)
>> event = models.ForeignKey(ContactEvent, on_delete=models.PROTECT)
>> event_date = models.DateTimeField(default=timezone.now)
>>
>>
>> # other similar through tables for the rest of the manytomanys and their 
>> target models
>>
>>
>> class Organisation(Contact):
>>
>> name = models.CharField(max_length=255, blank=True)
>> hierarchy = models.ManyToManyField(
>> 'self',
>> blank=True,
>> symmetrical=False,
>> through='OrganisationHierarchy',
>> through_fields=('sender', 'target'),
>> )
>>
>> # again, more manytomanys, not to self though
>>
>> # not sure this is relevant but as it's to self, then just in case
>> class OrganisationHierarchy(BaseContactJunctionModel):
>> # this, instance that specifies relationship
>> sender = models.ForeignKey(
>> Organisation,
>> null=True, 
>> related_name='senders',
>> on_delete=models.SET_NULL,
>> )
>> 
>> # instance that 'this' or 'sender' is related to
>> target = models.ForeignKey(
>> Organisation,
>> null=True, 
>> related_name='targets',
>> on_delete=models.SET_NULL,
>> )
>>
>> connection_type = models.ForeignKey(
>> ConnectionType,
>> null=True,
>> on_delete=models.PROTECT,
>> )
>>
>> I have a view based on CreateView and a template to capture user
>> input. The post request coming from browser is a-ok, saving
>> emails, contact, contactemails and other manytomany targets and
>> junction tables works without a problem but when getting to
>> saving Organisation, this happens (pseudocode):
>>
>> save() is called from django/db/models/base.py
>> save_base() is called with self=Organisation
>> save_base calls _save_parents(self=Organisation, cls=Organisation)
>> save_parents loops through cls._meta.parents and comes across 
>> relation
>> parent=Contact, field=Organisation.contact_ptr
>> calls _save_table with self=Organisation and cls=Contact
>> _save_table finds from cls._meta that it has
>> local concrete field "comment" and stores it in list 
>> non_pks
>> it then finds the values for those fields like 
>> this: 
>> f.pre_save(self, false) for f in non_pks 
>>
>> I then see a call to _update in queries.py and Contact instance
>> is updated with new values.
>>
>> I don't really understand what's happening here, the code finds
>> local concrete fields from "cls" which at this point is Contact
>> and comes up, correctly, with "comment" but then it tries to
>> query the field value form "self" which at this point is
>> Organisation object. I'm not sure why Organisation has "comment"
>> attribute at all, because the way I read the docs it should only
>> happen when the base model is abstract or when the inherited
>> model is proxy model, neither of which is the case. Anyway, the
>> value returned by save_base for the "comment" from "self" is not 
>> the value I inserted into the form field (and what has previously 
>> been saved to Contact object) but is instead an empty string.
>>
>> The end result is, after 

Re: Form validations

2019-07-11 Thread Jani Tiainen
Hi.

Usually you validate user input and by using Forms or ModelForms.


to 11. heinäk. 2019 klo 12.50 Irfan Khan  kirjoitti:

> Dear members,
> I wanted to validate the form which contains the name, phone number,
> address,email, etc..,
> I have developed and tested it if we give any character it’s saving to
> database table.so I wanted to validate the every field for example
> In name field it should take only alphabets,
> And in phone number field it should take only numbers like
> Can any one please guide me which is best practice to perform
> 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/CALKGViqQgLhqAzPgG5S-sz4ZdwA2z_q6KeTUQoxtNrzrrA21sQ%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/CAHn91oephj3rT2JoJZaGk5MtSfdJV0Bcb1j9jngE99YW5VyFng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Add a custom method to default django packages

2019-07-11 Thread Gaziza Yestemirova
Inside of the django project, there is a folder /lib/site-packages/reversion
And here in models.py I want to add one method, which will convert unicode 
to python list
How I can make extend and add this in my custom class?

-- 
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/0933396d-9948-4412-865d-75e0b27496dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Attribute Error 'NoneType' object has no attribute '_prefetch_related_lookups'

2019-07-11 Thread Warwick Lewarne
Hi all,

I keep getting the above error and I am not sure what I need to do to 
correct it. An example will assist.

my model:
class Product_Group(models.Model):
customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE)
prod_group = models.CharField(max_length=30, unique = True, 
verbose_name = "product group")


def __str__(self):
return self.prod_group

class Part_Number(models.Model):
customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE, 
related_name = 'customer')
prod_group = models.ForeignKey(Product_Group, 
on_delete=models.DO_NOTHING, related_name='product')
part_number = models.CharField(max_length=40, unique = True)
part_description = models.CharField(max_length=60)
   

def __str__(self):
return self.part_description

My form:
from django import forms
from django.contrib.auth.models import User
from .models import Department, Product_Group, Part_Number, Reject_Reason, 
Return_Reason, Supplier, Consumer
from accounts.models import Customer_User




class Report_GenerateForm(forms.Form):
part_number = forms.ModelChoiceField(queryset=None, label='Part Number')
reject_data = forms.ModelChoiceField(queryset=None)
select_data = forms.ModelChoiceField(queryset=None)

def __init__(self, *args, **kwargs):

customer_id = kwargs.pop('customer_id')
table_select = kwargs.pop('table_select')
product = kwargs.pop('product')
super(Report_GenerateForm, self).__init__(*args, **kwargs)
self.fields['part_number'].queryset = 
Part_Number.objects.filter(customer_id= customer_id, prod_group = 
product).select_related('prod_group')
if table_select == 1:
self.fields['select_data'].queryset = 
Department.objects.filter(customer_id=customer_id)
self.fields['select_data'].label = 'Department'
self.fields['reject_data'].queryset = 
Reject_Reason.objects.all()
self.fields['reject_data'].label = 'Reject Reason'
if table_select == 2:
self.fields['select_data'].queryset = 
Supplier.objects.filter(customer_id=customer_id)
self.fields['select_data'].label = 'Supplier'
self.fields['reject_data'].queryset = 
Return_Reason.objects.all()
self.fields['reject_data'].label = 'Reason for Return'
if table_select == 3:
self.fields['select_data'].queryset = 
Consumer.objects.filter(customer_id=customer_id)
self.fields['select_data'].label = 'Customer'
self.fields['reject_data'].queryset = 
Return_Reason.objects.all()
self.fields['reject_data'].label = 'Reason for Return'

-- 
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/a9fee22e-4e00-4db3-a6ac-9de8312fdcdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Form validations

2019-07-11 Thread Irfan Khan
Dear members,
I wanted to validate the form which contains the name, phone number,
address,email, etc..,
I have developed and tested it if we give any character it’s saving to
database table.so I wanted to validate the every field for example
In name field it should take only alphabets,
And in phone number field it should take only numbers like
Can any one please guide me which is best practice to perform
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/CALKGViqQgLhqAzPgG5S-sz4ZdwA2z_q6KeTUQoxtNrzrrA21sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.