Re: Script for running Daphne and runworker in the background . runworker ends after session expires.

2019-03-23 Thread Aldian Fazrihady
On Sun, Mar 24, 2019 at 11:41 AM Adam Zedan  wrote:

> Thanks Aldian , what about runworker ?
>

I don't use Daphne worker. However, I am using celery

-- 
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/CAN7EoAb-VPM8btZgVBn5_7hPQhxdwB%2B-HG%3DOb1qAX9nsm%3DooLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Script for running Daphne and runworker in the background . runworker ends after session expires.

2019-03-23 Thread Adam Zedan
Thanks Aldian , what about runworker ?

On Sat, Mar 23, 2019 at 8:36 PM Aldian Fazrihady  wrote:

> Hi,
> Mine is like this. It is still running after exiting ssh:
>
> nohup daphne -v 2 -b $AFCOM_DAPHNE_HOST -p $AFCOM_DAPHNE_PORT 
> afcom.asgi:application > $AFCOM_PROJECT_PATH/daphne/afcom.log 2>&1 &
>
>
> On Sun, Mar 24, 2019 at 10:52 AM Adam Zedan  wrote:
>
>> I am trying to create a bash script that would run Daphne and runworker
>> in the background.
>> This is what I came up with so far
>>
>>
>> echo "Killing Redis."
>> killall redis-server
>>
>>
>> #echo "Starting redis Server."
>> redis-server --daemonize yes
>>
>>
>> echo "Stopping NGINX.."
>> sudo /etc/init.d/nginx stop
>>
>>
>> echo "Starting NGINX.."
>> sudo /etc/init.d/nginx start
>>
>>
>> echo "Killing Daphne.."
>> sudo kill -9 $(ps aux | grep 'daphne' | awk '{print $2}')
>>
>>
>> echo "Starting Daphne."
>> /home/ec2-user/MyDomainVenv/bin/daphne -b 0.0.0.0 -p 8001 
>> main.asgi:channel_layer
>> 2>> ./daphne.log &
>>
>>
>> echo "Starting Django worker thread"
>> #nohup python ./manage.py runworker 2>>./daphneWorker.log >&2 &
>> python ./manage.py runworker
>>
>>
>> However it seems like run worker simply terminates when my ssh session
>> expires. I tried nohup statement as well.
>> How did you fix this problem ?
>>
>> --
>> 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/b2a43f85-9b9a-48bf-918d-c70a70b1b80b%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/chqoK7I_v4A/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAN7EoAaXtyij5N1TgL7xL6-sghwvMXUDn7ab12%2Bc4rPxTP6rHA%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/CACbvB%2B%2BepGFhiCRTGenLjhXKD9toFNpUur3qyqcRDv_p%3DNPwuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Spanning multi-valued relationships with 'filter' and 'values'

2019-03-23 Thread Christhian Jesus
When i try to follow the relationship with 'filter', the lookup is ignored:

Evaluacion.objects.values('id', 'periodo__indicador').filter(
periodo__indicador=1)



My Django version is 2.1.7 and Python 3.7.2
My model is:

Class Periodo(models.Model):
pass

Class Indicador(models.Model):
periodo = models.ForeignKey(Periodo, on_delete=models.CASCADE)

class Evaluacion(models.Model):
periodo = models.ForeignKey(Periodo, on_delete=models.CASCADE)



I think this is a bug, because documentation says:

Finally, note that you can call filter(), order_by(), etc. after the values
() call, that means that these two calls are identical:

Blog.objects.values().order_by('id')
Blog.objects.order_by('id').values()


I tried to change the order between 'values' and 'filter', and it worked:


Evaluacion.objects.filter(periodo__indicador=1).values('id', 
'periodo__indicador')
 





-- 
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/7a05d3e6-addb-4dde-ae1e-36968aa822f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Script for running Daphne and runworker in the background . runworker ends after session expires.

2019-03-23 Thread Aldian Fazrihady
Hi,
Mine is like this. It is still running after exiting ssh:

nohup daphne -v 2 -b $AFCOM_DAPHNE_HOST -p $AFCOM_DAPHNE_PORT
afcom.asgi:application > $AFCOM_PROJECT_PATH/daphne/afcom.log 2>&1 &


On Sun, Mar 24, 2019 at 10:52 AM Adam Zedan  wrote:

> I am trying to create a bash script that would run Daphne and runworker in
> the background.
> This is what I came up with so far
>
>
> echo "Killing Redis."
> killall redis-server
>
>
> #echo "Starting redis Server."
> redis-server --daemonize yes
>
>
> echo "Stopping NGINX.."
> sudo /etc/init.d/nginx stop
>
>
> echo "Starting NGINX.."
> sudo /etc/init.d/nginx start
>
>
> echo "Killing Daphne.."
> sudo kill -9 $(ps aux | grep 'daphne' | awk '{print $2}')
>
>
> echo "Starting Daphne."
> /home/ec2-user/MyDomainVenv/bin/daphne -b 0.0.0.0 -p 8001 
> main.asgi:channel_layer
> 2>> ./daphne.log &
>
>
> echo "Starting Django worker thread"
> #nohup python ./manage.py runworker 2>>./daphneWorker.log >&2 &
> python ./manage.py runworker
>
>
> However it seems like run worker simply terminates when my ssh session
> expires. I tried nohup statement as well.
> How did you fix this problem ?
>
> --
> 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/b2a43f85-9b9a-48bf-918d-c70a70b1b80b%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/CAN7EoAaXtyij5N1TgL7xL6-sghwvMXUDn7ab12%2Bc4rPxTP6rHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Script for running Daphne and runworker in the background . runworker ends after session expires.

2019-03-23 Thread Adam Zedan
Seems like Daphne and runworker both terminate after session expires

On Saturday, March 23, 2019 at 7:51:26 PM UTC-7, Adam Zedan wrote:
>
> I am trying to create a bash script that would run Daphne and runworker in 
> the background.
> This is what I came up with so far
>
>
> echo "Killing Redis."
> killall redis-server
>
>
> #echo "Starting redis Server."
> redis-server --daemonize yes
>
>
> echo "Stopping NGINX.."
> sudo /etc/init.d/nginx stop
>
>
> echo "Starting NGINX.."
> sudo /etc/init.d/nginx start
>
>
> echo "Killing Daphne.."
> sudo kill -9 $(ps aux | grep 'daphne' | awk '{print $2}')
>
>
> echo "Starting Daphne."
> /home/ec2-user/MyDomainVenv/bin/daphne -b 0.0.0.0 -p 8001 
> main.asgi:channel_layer 
> 2>> ./daphne.log &
>
>
> echo "Starting Django worker thread"
> #nohup python ./manage.py runworker 2>>./daphneWorker.log >&2 &
> python ./manage.py runworker
>
>
> However it seems like run worker simply terminates when my ssh session 
> expires. I tried nohup statement as well.
> How did you fix this problem ?
>
>

-- 
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/c45cc88e-cbbf-4474-87d4-37910719e366%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Script for running Daphne and runworker in the background . runworker ends after session expires.

2019-03-23 Thread Adam Zedan
I am trying to create a bash script that would run Daphne and runworker in 
the background.
This is what I came up with so far


echo "Killing Redis."
killall redis-server


#echo "Starting redis Server."
redis-server --daemonize yes


echo "Stopping NGINX.."
sudo /etc/init.d/nginx stop


echo "Starting NGINX.."
sudo /etc/init.d/nginx start


echo "Killing Daphne.."
sudo kill -9 $(ps aux | grep 'daphne' | awk '{print $2}')


echo "Starting Daphne."
/home/ec2-user/MyDomainVenv/bin/daphne -b 0.0.0.0 -p 8001 
main.asgi:channel_layer 
2>> ./daphne.log &


echo "Starting Django worker thread"
#nohup python ./manage.py runworker 2>>./daphneWorker.log >&2 &
python ./manage.py runworker


However it seems like run worker simply terminates when my ssh session 
expires. I tried nohup statement as well.
How did you fix this problem ?

-- 
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/b2a43f85-9b9a-48bf-918d-c70a70b1b80b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to filter 'Invalid HTTP_HOST header ...' errors

2019-03-23 Thread Mike Dewhirst
I'm getting hundreds of Invalid HTTP_HOST header errors and need to 
avoid having them emailed to ADMINS. My ISP has a limit on the number of 
messages which can be sent per hour and occasionally that gets exceeded 
and he complains the site is jamming his queues. While that is a more or 
less jocular response I still need to invest my time looking at these 
stupid emails.


My ALLOWED_HOSTS setting is locked down to only the correct hostname and 
no IP addresses. All the errors are attempts to access well known 
scripts which don't exist on the server or '/'


I am reasonably certain the answer to the problem sits somewhere in the 
logging configuration but that's not trivial - for me anyway.


I'm having trouble deciphering 
https://docs.djangoproject.com/en/1.11/topics/logging/#examples


Can anyone please point me to a worked example which addresses this?

Thanks

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/3a45a72c-714d-c003-e237-417c899c430e%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Having problem with first page of first tutorial

2019-03-23 Thread Thomas POKAM
You should make sure you import the module polls in the site01/urls.py 
file by adding this line:


from polls import views


Le 23/03/2019 à 19:47, Ben Edwards a écrit :
Ive not done https://docs.djangoproject.com/en/2.1/intro/tutorial01/ 3 
times and cant get past the first page.  Its kind of dryving me nuts.


Where I am at is in github https://github.com/ben-tvpp/site01

Ive added the view 
https://github.com/ben-tvpp/site01/blob/master/polls/views.py



# Create your views here.


from django.http import HttpResponse



def index(request):

return HttpResponse("Hello, world. You're at the polls index.")

from django.shortcuts import render


And the urls https://github.com/ben-tvpp/site01/blob/master/site01/urls.py

from django.urls import include, path


urlpatterns = [

path('polls/', include('polls.urls')),

path('admin/', admin.site.urls),

]


And even tried adding polls to 
https://github.com/ben-tvpp/site01/blob/master/site01/settings.py


but when I run the server

site01$ python manage.py runserverIget the below error.

Traceback (most recent call last):

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/autoreload.py",
line 225, in wrapper

fn(*args, **kwargs)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
line 117, in inner_run

self.check(display_num_errors=True)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
line 379, in check

include_deployment_checks=include_deployment_checks,

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
line 366, in _run_checks

return checks.run_checks(**kwargs)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/registry.py",
line 71, in run_checks

new_errors = check(app_configs=app_configs)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
line 40, in check_url_namespaces_unique

all_namespaces = _load_all_namespaces(resolver)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
line 57, in _load_all_namespaces

url_patterns = getattr(resolver, 'url_patterns', [])

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
line 37, in __get__

res = instance.__dict__[self.name] = self.func(instance)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
line 533, in url_patterns

patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
line 37, in __get__

res = instance.__dict__[self.name] = self.func(instance)

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
line 526, in urlconf_module

return import_module(self.urlconf_name)

File
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py",
line 127, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 1006, in _gcd_import

File "", line 983, in _find_and_load

File "", line 967, in
_find_and_load_unlocked

File "", line 677, in _load_unlocked

File "", line 728, in
exec_module

File "", line 219, in
_call_with_frames_removed

File "/mnt/d/django/site01/site01/urls.py", line 20, in 

path('polls/', include('polls.urls')),

File

"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/conf.py",
line 34, in include

urlconf_module = import_module(urlconf_module)

File
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py",
line 127, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 1006, in _gcd_import

File "", line 983, in _find_and_load

File "", line 965, in
_find_and_load_unlocked

ModuleNotFoundError: No module named 'polls.urls'
Unhandled exception in thread started by .wrapper at 0x7f1477b8eea0>







--
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/44655cc2-6e6d-4a31-8249-3a1f84e5f2d4%40googlegroups.c

Performing SQL queries on SQLite database

2019-03-23 Thread carl collins
Hello guys,
I'm Carl Collins from Cameroon. I'm working on this Django Project and I
got stuck . Need help.The first thing I   would love to ask is about
performing SQL queries in Django use Django ORM. Presume I have something
like this:

connection = sqlite.connect('data.db')
cursor = connection.cursor()

query = "SELECT * FROM items"
result = cursor.execute(query)

properties = []
for row in result:
items.append({})

connection.close()
print(json.dumps({'properties': properties})



I would love Django to run this automatically i.e fetch some field from the
database each time a button is clicked  and do a post request to an API
using the json returned as the body of the request

NB: The data in the database is populated using a django form and I would
love to use the same data to do a post request to an api. The API requires
that the post body be in json format like

{
"currency": "",
"customerName": "",
"description": "",
"email": "",
"expiryDate": "",
"id": {
"uuid": "",
"version": ""
},
"items": [
{
"itemId": "",
"particulars": "",
"quantity": x,
"subTotal": y,
"unitCost": z
},
{
"itemId": " ",
"particulars": " ",
"quantity": j,
"subTotal": k,
"unitCost": l
}
],
"langKey": "en",
"merchantReference": " ",
"orderDate": " ",
"phoneNumber": " ",
"receiptUrl": " ",
"totalAmount": n
}


Thanks in advance
Cheers
Carl

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


Re: Having problem with first page of first tutorial

2019-03-23 Thread Dylan Young
There is no polls/urls.py file in your repository.

Best,

Casey

On Sat, 23 Mar 2019 at 16:23, Ben Edwards  wrote:

> Ive not done https://docs.djangoproject.com/en/2.1/intro/tutorial01/ 3
> times and cant get past the first page.  Its kind of dryving me nuts.
>
> Where I am at is in github https://github.com/ben-tvpp/site01
>
> Ive added the view
> https://github.com/ben-tvpp/site01/blob/master/polls/views.py
>
> # Create your views here.
>>
>> from django.http import HttpResponse
>>
>>
>> def index(request):
>> return HttpResponse("Hello, world. You're at the polls index.")
>>
> from django.shortcuts import render
>>
>
> And the urls https://github.com/ben-tvpp/site01/blob/master/site01/urls.py
>
> from django.urls import include, path
>>
>> urlpatterns = [
>> path('polls/', include('polls.urls')),
>> path('admin/', admin.site.urls),
>> ]
>>
>
> And even tried adding polls to
> https://github.com/ben-tvpp/site01/blob/master/site01/settings.py
>
> but when I run the server
>
> site01$ python manage.py runserverIget the below error.
>
> Traceback (most recent call last):
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/autoreload.py",
>> line 225, in wrapper
>> fn(*args, **kwargs)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
>> line 117, in inner_run
>> self.check(display_num_errors=True)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
>> line 379, in check
>> include_deployment_checks=include_deployment_checks,
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
>> line 366, in _run_checks
>> return checks.run_checks(**kwargs)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/registry.py",
>> line 71, in run_checks
>> new_errors = check(app_configs=app_configs)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
>> line 40, in check_url_namespaces_unique
>> all_namespaces = _load_all_namespaces(resolver)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
>> line 57, in _load_all_namespaces
>> url_patterns = getattr(resolver, 'url_patterns', [])
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
>> line 37, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
>> line 533, in url_patterns
>> patterns = getattr(self.urlconf_module, "urlpatterns",
>> self.urlconf_module)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
>> line 37, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
>> line 526, in urlconf_module
>> return import_module(self.urlconf_name)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py", line
>> 127, in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)
>> File "", line 1006, in _gcd_import
>> File "", line 983, in _find_and_load
>> File "", line 967, in _find_and_load_unlocked
>> File "", line 677, in _load_unlocked
>> File "", line 728, in exec_module
>> File "", line 219, in
>> _call_with_frames_removed
>> File "/mnt/d/django/site01/site01/urls.py", line 20, in 
>> path('polls/', include('polls.urls')),
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/conf.py",
>> line 34, in include
>> urlconf_module = import_module(urlconf_module)
>> File
>> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py", line
>> 127, in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)
>> File "", line 1006, in _gcd_import
>> File "", line 983, in _find_and_load
>> File "", line 965, in _find_and_load_unlocked
>> ModuleNotFoundError: No module named 'polls.urls'
>> Unhandled exception in thread started by > check_errors..wrapper at 0x7f1477b8eea0>
>>
>
>
>
>>>
>
>
>
> --
> 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/44655cc2-6e6d-4a31-8249-3a1f84e5f2d4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You rece

Having problem with first page of first tutorial

2019-03-23 Thread Ben Edwards
Ive not done https://docs.djangoproject.com/en/2.1/intro/tutorial01/ 3 
times and cant get past the first page.  Its kind of dryving me nuts. 

Where I am at is in github https://github.com/ben-tvpp/site01

Ive added the view 
https://github.com/ben-tvpp/site01/blob/master/polls/views.py

# Create your views here. 
>
> from django.http import HttpResponse 
>
>
> def index(request): 
> return HttpResponse("Hello, world. You're at the polls index.") 
>
from django.shortcuts import render
>

And the urls https://github.com/ben-tvpp/site01/blob/master/site01/urls.py

from django.urls import include, path 
>
> urlpatterns = [ 
> path('polls/', include('polls.urls')), 
> path('admin/', admin.site.urls), 
> ]
>

And even tried adding polls to 
https://github.com/ben-tvpp/site01/blob/master/site01/settings.py

but when I run the server

site01$ python manage.py runserverIget the below error.  

Traceback (most recent call last): 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/autoreload.py",
>  
> line 225, in wrapper 
> fn(*args, **kwargs) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
>  
> line 117, in inner_run 
> self.check(display_num_errors=True) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
>  
> line 379, in check 
> include_deployment_checks=include_deployment_checks, 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
>  
> line 366, in _run_checks 
> return checks.run_checks(**kwargs) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/registry.py",
>  
> line 71, in run_checks 
> new_errors = check(app_configs=app_configs) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
>  
> line 40, in check_url_namespaces_unique 
> all_namespaces = _load_all_namespaces(resolver) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
>  
> line 57, in _load_all_namespaces 
> url_patterns = getattr(resolver, 'url_patterns', []) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
>  
> line 37, in __get__ 
> res = instance.__dict__[self.name] = self.func(instance) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
>  
> line 533, in url_patterns 
> patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
>  
> line 37, in __get__ 
> res = instance.__dict__[self.name] = self.func(instance) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
>  
> line 526, in urlconf_module 
> return import_module(self.urlconf_name) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py", line 
> 127, in import_module 
> return _bootstrap._gcd_import(name[level:], package, level) 
> File "", line 1006, in _gcd_import 
> File "", line 983, in _find_and_load 
> File "", line 967, in _find_and_load_unlocked 
> File "", line 677, in _load_unlocked 
> File "", line 728, in exec_module 
> File "", line 219, in 
> _call_with_frames_removed 
> File "/mnt/d/django/site01/site01/urls.py", line 20, in  
> path('polls/', include('polls.urls')), 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/conf.py",
>  
> line 34, in include 
> urlconf_module = import_module(urlconf_module) 
> File 
> "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py", line 
> 127, in import_module 
> return _bootstrap._gcd_import(name[level:], package, level) 
> File "", line 1006, in _gcd_import 
> File "", line 983, in _find_and_load 
> File "", line 965, in _find_and_load_unlocked 
> ModuleNotFoundError: No module named 'polls.urls'
> Unhandled exception in thread started by  check_errors..wrapper at 0x7f1477b8eea0> 
>



>>

 

-- 
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/44655cc2-6e6d-4a31-8249-3a1f84e5f2d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Doubt in the creation of fields in the FrontEnd

2019-03-23 Thread Barkalez XX
Then it occurs to me to create a table called List Ingredients and relate 
it to the recipe.

El sábado, 23 de marzo de 2019, 19:16:47 (UTC+1), Aldian Fazrihady escribió:
>
>
> Hi,
>
> Generating fields is possible,
>
> but for your recipe app, that's absolutely not a good thing to do.
>
> Regards,
>
> Aldian Fazrihady
>
> On Sun, Mar 24, 2019 at 1:54 AM Barkalez XX  > wrote:
>
>> Thank for you answer.
>>
>>
>> I did not know that fields could be generated in the database from 
>> FrontEnd.
>>
>> It occurs to me to put a "Add ingredient" button and produce a new field 
>> in the recipe table, but I do not know how to do that.
>>
>> El sábado, 23 de marzo de 2019, 17:54:24 (UTC+1), Aldian Fazrihady 
>> escribió:
>>>
>>> Hi,
>>>
>>> I don't think that's a good idea to frequently add new field to a 
>>> database table.
>>>
>>> A field in form doesn't mean that it will also be a field of a table 
>>> database.
>>> You can make a new ingredient field in a form to become a new row of a 
>>> database table.
>>> You just need to properly design your database schema.
>>>
>>> Regards,
>>>
>>> Aldian Fazrihady
>>>
>>> On Sun, Mar 24, 2019 at 12:46 AM Barkalez XX  wrote:
>>>

 I would like to know if it is possible to create a new field in a table 
 from the FrontEnd. For example, in a form to create recipes, not all 
 recipes contain the same number of ingredients. At first I thought about 
 putting a high number of ingredients to enter in the form to create a 
 recipe, but that's not pretty. I think it would be better for the user to 
 add fields in the form as needed. Although thinking well, if that were 
 done, who would execute the command makemigrations and migrate ?, it 
 occurred to me to create a high number of fields for the ingredients but 
 that did not appear in the FrontEnd form and that they were appearing as 
 needed by the user.

 -- 
 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/c416f450-0172-45e2-9242-4704c4aca421%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...@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/0c94870c-b8df-40eb-89ff-b54565fe4070%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/057a0841-c9a4-44fb-8341-1592863bffd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Doubt in the creation of fields in the FrontEnd

2019-03-23 Thread Aldian Fazrihady
Hi,

Generating fields is possible,

but for your recipe app, that's absolutely not a good thing to do.

Regards,

Aldian Fazrihady

On Sun, Mar 24, 2019 at 1:54 AM Barkalez XX  wrote:

> Thank for you answer.
>
>
> I did not know that fields could be generated in the database from
> FrontEnd.
>
> It occurs to me to put a "Add ingredient" button and produce a new field
> in the recipe table, but I do not know how to do that.
>
> El sábado, 23 de marzo de 2019, 17:54:24 (UTC+1), Aldian Fazrihady
> escribió:
>>
>> Hi,
>>
>> I don't think that's a good idea to frequently add new field to a
>> database table.
>>
>> A field in form doesn't mean that it will also be a field of a table
>> database.
>> You can make a new ingredient field in a form to become a new row of a
>> database table.
>> You just need to properly design your database schema.
>>
>> Regards,
>>
>> Aldian Fazrihady
>>
>> On Sun, Mar 24, 2019 at 12:46 AM Barkalez XX  wrote:
>>
>>>
>>> I would like to know if it is possible to create a new field in a table
>>> from the FrontEnd. For example, in a form to create recipes, not all
>>> recipes contain the same number of ingredients. At first I thought about
>>> putting a high number of ingredients to enter in the form to create a
>>> recipe, but that's not pretty. I think it would be better for the user to
>>> add fields in the form as needed. Although thinking well, if that were
>>> done, who would execute the command makemigrations and migrate ?, it
>>> occurred to me to create a high number of fields for the ingredients but
>>> that did not appear in the FrontEnd form and that they were appearing as
>>> needed by the user.
>>>
>>> --
>>> 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/c416f450-0172-45e2-9242-4704c4aca421%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/0c94870c-b8df-40eb-89ff-b54565fe4070%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/CAN7EoAakLOq4hNFBOe1vsuhDf0mY3BxWkHtny8jWeTGxd6c5dA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Doubt in the creation of fields in the FrontEnd

2019-03-23 Thread Barkalez XX
Thank for you answer.


I did not know that fields could be generated in the database from FrontEnd.


It occurs to me to put a "Add ingredient" button and produce a new field in 
the recipe table, but I do not know how to do that.

El sábado, 23 de marzo de 2019, 17:54:24 (UTC+1), Aldian Fazrihady escribió:
>
> Hi,
>
> I don't think that's a good idea to frequently add new field to a database 
> table.
>
> A field in form doesn't mean that it will also be a field of a table 
> database.
> You can make a new ingredient field in a form to become a new row of a 
> database table.
> You just need to properly design your database schema.
>
> Regards,
>
> Aldian Fazrihady
>
> On Sun, Mar 24, 2019 at 12:46 AM Barkalez XX  > wrote:
>
>>
>> I would like to know if it is possible to create a new field in a table 
>> from the FrontEnd. For example, in a form to create recipes, not all 
>> recipes contain the same number of ingredients. At first I thought about 
>> putting a high number of ingredients to enter in the form to create a 
>> recipe, but that's not pretty. I think it would be better for the user to 
>> add fields in the form as needed. Although thinking well, if that were 
>> done, who would execute the command makemigrations and migrate ?, it 
>> occurred to me to create a high number of fields for the ingredients but 
>> that did not appear in the FrontEnd form and that they were appearing as 
>> needed by the user.
>>
>> -- 
>> 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/c416f450-0172-45e2-9242-4704c4aca421%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/0c94870c-b8df-40eb-89ff-b54565fe4070%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


social share

2019-03-23 Thread omar ahmed
hello ...
how can i add social share in django  like FB ,twitter and G+ ?

-- 
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/e326da21-a363-4795-942d-c2c5d4240c08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Doubt in the creation of fields in the FrontEnd

2019-03-23 Thread Aldian Fazrihady
Hi,

I don't think that's a good idea to frequently add new field to a database
table.

A field in form doesn't mean that it will also be a field of a table
database.
You can make a new ingredient field in a form to become a new row of a
database table.
You just need to properly design your database schema.

Regards,

Aldian Fazrihady

On Sun, Mar 24, 2019 at 12:46 AM Barkalez XX  wrote:

>
> I would like to know if it is possible to create a new field in a table
> from the FrontEnd. For example, in a form to create recipes, not all
> recipes contain the same number of ingredients. At first I thought about
> putting a high number of ingredients to enter in the form to create a
> recipe, but that's not pretty. I think it would be better for the user to
> add fields in the form as needed. Although thinking well, if that were
> done, who would execute the command makemigrations and migrate ?, it
> occurred to me to create a high number of fields for the ingredients but
> that did not appear in the FrontEnd form and that they were appearing as
> needed by the user.
>
> --
> 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/c416f450-0172-45e2-9242-4704c4aca421%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/CAN7EoAZOOXcWyPjv126sEtXTXgPibMB9rgqqNAHtVhguEi0F%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Doubt in the creation of fields in the FrontEnd

2019-03-23 Thread Barkalez XX

I would like to know if it is possible to create a new field in a table 
from the FrontEnd. For example, in a form to create recipes, not all 
recipes contain the same number of ingredients. At first I thought about 
putting a high number of ingredients to enter in the form to create a 
recipe, but that's not pretty. I think it would be better for the user to 
add fields in the form as needed. Although thinking well, if that were 
done, who would execute the command makemigrations and migrate ?, it 
occurred to me to create a high number of fields for the ingredients but 
that did not appear in the FrontEnd form and that they were appearing as 
needed by the user.

-- 
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/c416f450-0172-45e2-9242-4704c4aca421%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error in Django url mapping

2019-03-23 Thread egbosi Kelechi
Great. You are on the right track, only that the Url path you typed in the
address bar triggered the error.

You should use /first_app/index/
Reason:the index url path is located in the first_app. Urls file.

On Sat, Mar 23, 2019, 5:07 PM The Aryas  Hey Guys, I am facing problem on django url mapping, I did exactly what my
> couse said and copied the code text exactly,but it throws the error:-
>
>
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/index
>
> Using the URLconf defined in protwo.urls, Django tried these URL
> patterns, in this order:
>
>1. admin/
>2. [name='index']
>
> The current path, index, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
>
>
>
> ##The code I written in my project are;:-
>
> 
>
> 
>
>
> from django.contrib import admin
>
> from django.urls import path, include
>
>
> urlpatterns = [
>
> path('admin/', admin.site.urls),
>
> path('first_app/', include('first_app.urls'))
>
>
> ]
>
> --
>
> ---
>
>
> 
>
>
> from django.contrib import admin
>
> from django.urls import path
>
> from . import views
>
> urlpatterns = [
>
> path('index/', views.index, name="index"),
>
> ]
>
> -
> --
> 
>
> from django.shortcuts import render
> from django.http import HttpResponse
>
> # Create your views here.
> def index(request):
> return HttpResponse("Hello World")
>
> 
>
> 
>
> 
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'first_app'
> ]
>
>
> ---
>
> I dont know what to do , I could not find the error plz assist me, I am a
> begginer to this cousre,
> 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+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/4af88190-6f81-409a-aafa-0b6cfda63d70%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Error in Django url mapping

2019-03-23 Thread The Aryas
Hey Guys, I am facing problem on django url mapping, I did exactly what my 
couse said and copied the code text exactly,but it throws the error:-


Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/index

Using the URLconf defined in protwo.urls, Django tried these URL patterns, 
in this order:

   1. admin/
   2. [name='index']

The current path, index, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.




##The code I written in my project are;:-






from django.contrib import admin

from django.urls import path, include


urlpatterns = [

path('admin/', admin.site.urls),

path('first_app/', include('first_app.urls'))


]

--

---





from django.contrib import admin

from django.urls import path

from . import views

urlpatterns = [

path('index/', views.index, name="index"),

]

-
--


from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def index(request):
return HttpResponse("Hello World")





INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'first_app'
]

---

I dont know what to do , I could not find the error plz assist me, I am a 
begginer to this cousre,
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+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/4af88190-6f81-409a-aafa-0b6cfda63d70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dispatching requests from one uwsgi to another uwsgi instance running Django Channels

2019-03-23 Thread Ahmed Ishtiaque
Awesome! Sorry I couldn't reply earlier. To explain myself a little better,
I use gunicorn to handle all HTTP requests to my server and daphne to
handle all WebSocket requests. This isn't necessary since daphne can do
both by itself, but the Deploying
 section of
Django Channels docs mentions the following:

"You can choose to either use Daphne for all requests - HTTP and WebSocket
- or if you are conservative about stability, keep running standard HTTP
requests through a WSGI server and use Daphne only for things WSGI cannot
do, like HTTP long-polling and WebSockets. If you do split, you’ll need to
put something in front of Daphne and your WSGI server to work out what
requests to send to each (using HTTP path or domain) - that’s not covered
here, just know you can do it."

As you can guess, I like stability 😅



On Sat, Mar 23, 2019 at 4:44 AM Adam Zedan  wrote:

> YES it worked. I used Daphne with nginx and it worked. Thank you.
>
>
> On Friday, March 22, 2019 at 5:58:20 PM UTC-7, Adam Zedan wrote:
>>
>> I am currently using Django channels for websocket communication. I read
>> this
>> 
>>  article
>> and it states that I should split the project into two uwsgi instances. It
>> states that
>>
>> "The web server undertakes the task of dispatching normal requests to one
>>> uWSGI instance and WebSocket requests to another one"
>>
>>
>> Now I have two uwsgi instances running. This is how I am running both.
>>
>> This uwsgi handles the normal django site requests
>> uwsgi --virtualenv /home/ec2-user/MyProjVenv --socket /home/ec2-user/
>> MyProjVenv/MyProjWeb/site1.socket --chmod-socket=777 --buffer-size=32768
>> --workers=5 --master --module main.wsgi
>>
>>
>> This uwsgi handles the websocket requests
>> uwsgi --virtualenv /home/ec2-user/MyProjVenv --http-socket /home/ec2-user
>> /MyProjVenv/MyProjWeb/web.socket --gevent 1000 --http-websockets --
>> workers=2 --master --chmod-socket=777  --module main.wsgi_websocket
>>
>> Now the websocket uwsgi launches  main.wsgi_websocket
>>
>> The code for main.wsgi_websocket one is this
>> import os
>> import gevent.socket
>> import redis.connection
>> redis.connection.socket = gevent.socket
>> os.environ.update(DJANGO_SETTINGS_MODULE='main.settings')
>> from ws4redis.uwsgi_runserver import uWSGIWebsocketServer
>> application = uWSGIWebsocketServer()
>>
>> Now after spinning up the two uwsgi instances I am able to access the
>> website.The websocket uwsgi instance is also receiving data however I am
>> not sure if its passing that data to the website uwsgi instance. I am using
>> Django Channels here and this is the configuration I have specified in my
>> settings for Django Channels
>>
>> CHANNEL_LAYERS = {
>> "default": {
>> "BACKEND": "asgi_redis.RedisChannelLayer",
>> "CONFIG": {
>> "hosts": [(redis_host, 6379)],
>> },
>>"ROUTING": "main.routing.channel_routing",
>> },
>> }
>>
>> The channel routing is this
>> channel_routing = [
>> include("chat.routing.websocket_routing", path=r"^/chat/stream"),
>> include("chat.routing.custom_routing"),
>> ]
>>
>> and this is the websocket_routing which i have mentioned above
>>
>>
>>
>> websocket_routing = [
>> route("websocket.connect", ws_connect),
>>
>>
>> # Called when WebSockets get sent a data frame
>> route("websocket.receive", ws_receive),
>>
>>
>> # Called when WebSockets disconnect
>> route("websocket.disconnect", ws_disconnect),
>> ]
>>
>> Now the problem is that my ws_receive is never called. If I test on my
>> local dev machine using  "*ipaddress:8000/chat/stream*" this works
>> perfectly fine however I have no clue why my receive is not being called
>> when I use *ipadress:80/ws/ *. I am certain that my other uwsgi instance
>> is getting that data but I dont know how to find out if its passing it to
>> the other uwsgi instance of the djnago side and if it is then why is my
>> receive not being called ?. Any suggestions on this would definitely 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/e4096133-d010-4b96-a403-985fb1b3a104%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Grou

Django channels raises TypeError on close: An asyncio.Future, a coroutine or an awaitable is required

2019-03-23 Thread Rodrigo Bistolfi
Hi there,

I am using Channels 2.1.7 with Python 3.7.2.
My consumer does this on connect:

async def connect(self): 
"""Accept connect if user has been provided by middleware"""  
self.user = self.scope.get('user') 
if self.user: 
await self.accept() 
else: 
await self.close() 

When `self.close()` is called, an exception is raised:

Traceback (most recent call last): 
  File 
"/opt/sps/.venv/lib/python3.7/site-packages/uvicorn/protocols/websockets/websockets_impl.py"
, line 147, in run_asgi 
result = await asgi(self.asgi_receive, self.asgi_send) 
  File "/opt/sps/.venv/lib/python3.7/site-packages/channels/consumer.py", 
line 59, in __call__ 
[receive, self.channel_receive], self.dispatch 
  File "/opt/sps/.venv/lib/python3.7/site-packages/channels/utils.py", line 
59, in await_many_dispatch 
await task 
  File "/opt/sps/.venv/lib/python3.7/site-packages/channels/utils.py", line 
51, in await_many_dispatch 
result = task.result() 
  File 
"/opt/sps/.venv/lib/python3.7/site-packages/uvicorn/protocols/websockets/websockets_impl.py"
, line 227, in asgi_receive 
data = await self.recv() 
  File "/opt/sps/.venv/lib/python3.7/site-packages/websockets/protocol.py", 
line 420, in recv 
return_when=asyncio.FIRST_COMPLETED, 
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 361, in wait 
fs = {ensure_future(f, loop=loop) for f in set(fs)} 
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 361, in 
fs = {ensure_future(f, loop=loop) for f in set(fs)} 
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 592, in 
ensure_future 
raise TypeError('An asyncio.Future, a coroutine or an awaitable is ' 
TypeError: An asyncio.Future, a coroutine or an awaitable is required 

The relevant code seems to be this:

while len(self.messages) <= 0: 
pop_message_waiter = asyncio.Future(loop=self.loop) 
self._pop_message_waiter = pop_message_waiter 
try: 
# If asyncio.wait() is canceled, it doesn't cancel 
# pop_message_waiter and self.transfer_data_task. 
tasks = [pop_message_waiter, self.transfer_data_task] 
yield from asyncio.wait( 
tasks, 
loop=self.loop,
return_when=asyncio.FIRST_COMPLETED,
)
finally:
self._pop_message_waiter = None 

In websockets/protocol.py line 410 and ss, `self.trasfer_data_task` is 
`None`. If I remove it from the wait list it seems to work.
Any ideas?

Thanks in advance, Rodrigo

-- 
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/d92a08a5-1080-4212-9cea-e46c53c4f3ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Configuration Management

2019-03-23 Thread anand . desai
Hi All,

Can anyone point to a preferred configuration management tool that can be 
used for Django on EC2?

Thanks,
Anand

-- 
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/3555ba6a-a894-4c8e-aa63-c221977a2089%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem in running server

2019-03-23 Thread Maior Marso
do a " pip list " and a python -V to see if Django and python are there.


On Fri, Mar 22, 2019 at 10:20 AM fazal rehman 
wrote:

> Thanks it works 😊
>
> On Fri, Mar 22, 2019, 8:43 PM Scheck David 
>> activate your virtual env or pip install Django
>>
>> Le ven. 22 mars 2019 à 16:04, fazal rehman  a
>> écrit :
>>
>>> (myvenv) C:\cdedjango\src\trydjango>python manage.py runserver
>>> Traceback (most recent call last):
>>>   File "manage.py", line 8, in 
>>> from django.core.management import execute_from_command_line
>>> ModuleNotFoundError: No module named 'django'
>>>
>>> The above exception was the direct cause of the following exception:
>>>
>>> Traceback (most recent call last):
>>>   File "manage.py", line 14, in 
>>> ) from exc
>>> ImportError: Couldn't import Django. Are you sure it's installed and
>>> available on your PYTHONPATH environment variable? Did you forget to
>>> activate a virtual environment?
>>>
>>> --
>>> 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/442fe84e-783b-46bd-82d1-23231766bb25%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>>
>> With kindest regards,
>>
>>
>> *David SCHECK*
>>
>> PRESIDENT/DEVELOPER
>>
>> [image: Signature Logo Sphax Bleu-01.png]
>>
>> Phone: +32 4 87 86 70 12
>> Visit our website ! https://www.sphax.org
>>
>> --
>> 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/CAOPG6seXUnePtwP9JzNEMVoKjJ14OSQcX3Nquwm4dZ-8t3Lrgw%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/CAG9Y3D8NVAY8muwpOCmZvHqVb7z_FjLg%3DG8BqPgjFk7UjjJhdw%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/CAA8xcEt8E4a46e8cvod0KRF3cRBcwBSqKzCYkaO06e2moB8ndw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how to deploy django on cpanel or server

2019-03-23 Thread surojitsahu07
how to deploy django on cpanel or server

-- 
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/7c264e17-0d01-4f35-abaf-7a4aced4f80f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dispatching requests from one uwsgi to another uwsgi instance running Django Channels

2019-03-23 Thread Adam Zedan
YES it worked. I used Daphne with nginx and it worked. Thank you.


On Friday, March 22, 2019 at 5:58:20 PM UTC-7, Adam Zedan wrote:
>
> I am currently using Django channels for websocket communication. I read 
> this 
> 
>  article 
> and it states that I should split the project into two uwsgi instances. It 
> states that
>
> "The web server undertakes the task of dispatching normal requests to one 
>> uWSGI instance and WebSocket requests to another one"
>
>
> Now I have two uwsgi instances running. This is how I am running both.
>
> This uwsgi handles the normal django site requests
> uwsgi --virtualenv /home/ec2-user/MyProjVenv --socket /home/ec2-user/
> MyProjVenv/MyProjWeb/site1.socket --chmod-socket=777 --buffer-size=32768 
> --workers=5 --master --module main.wsgi
>
>
> This uwsgi handles the websocket requests
> uwsgi --virtualenv /home/ec2-user/MyProjVenv --http-socket /home/ec2-user/
> MyProjVenv/MyProjWeb/web.socket --gevent 1000 --http-websockets --workers=
> 2 --master --chmod-socket=777  --module main.wsgi_websocket
>
> Now the websocket uwsgi launches  main.wsgi_websocket
>
> The code for main.wsgi_websocket one is this
> import os
> import gevent.socket
> import redis.connection
> redis.connection.socket = gevent.socket
> os.environ.update(DJANGO_SETTINGS_MODULE='main.settings')
> from ws4redis.uwsgi_runserver import uWSGIWebsocketServer
> application = uWSGIWebsocketServer()
>
> Now after spinning up the two uwsgi instances I am able to access the 
> website.The websocket uwsgi instance is also receiving data however I am 
> not sure if its passing that data to the website uwsgi instance. I am using 
> Django Channels here and this is the configuration I have specified in my 
> settings for Django Channels
>
> CHANNEL_LAYERS = {
> "default": {
> "BACKEND": "asgi_redis.RedisChannelLayer",
> "CONFIG": {
> "hosts": [(redis_host, 6379)],
> },
>"ROUTING": "main.routing.channel_routing", 
> },
> }
>
> The channel routing is this
> channel_routing = [
> include("chat.routing.websocket_routing", path=r"^/chat/stream"),
> include("chat.routing.custom_routing"),
> ]
>
> and this is the websocket_routing which i have mentioned above
>
>
>
> websocket_routing = [
> route("websocket.connect", ws_connect),
>
>
> # Called when WebSockets get sent a data frame
> route("websocket.receive", ws_receive),
>
>
> # Called when WebSockets disconnect
> route("websocket.disconnect", ws_disconnect),
> ]
>
> Now the problem is that my ws_receive is never called. If I test on my 
> local dev machine using  "*ipaddress:8000/chat/stream*" this works 
> perfectly fine however I have no clue why my receive is not being called 
> when I use *ipadress:80/ws/ *. I am certain that my other uwsgi instance 
> is getting that data but I dont know how to find out if its passing it to 
> the other uwsgi instance of the djnago side and if it is then why is my 
> receive not being called ?. Any suggestions on this would definitely 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/e4096133-d010-4b96-a403-985fb1b3a104%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dispatching requests from one uwsgi to another uwsgi instance running Django Channels

2019-03-23 Thread Adam Zedan
Hi Ahmed I am a little confused here. I was using NGINX and uwsgi.  Now 
based on your response i decided to use Daphne.. So Now I have NGINX with 
Daphne. I am not sure where gunicorn fits in here . I am following this 
 tutorial. 
Essentially now I am getting a 502 Bad gateway when accessing my website.

This is the nginx configuration I have

server {
# the port your site will be served on
listen  80;
server_name .MyDomain.com;
charset utf-8;


# max upload size
client_max_body_size 75M;   # adjust to taste


# Django media
location /media  {
# your Django project's media files - amend as required
alias /home/ec2-user/MyDomainVenv/MyDomainWeb/media;
}


location /static {
# your Django project's static files - amend as required
alias /home/ec2-user/MyDomainVenv/MyDomainWeb/static;
}




location / {
proxy_pass http://0.0.0.0:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";


proxy_redirect off;
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-Host $server_name;
}
}

any suggestions on what might be going wrong ? I tried accessing my website 
and this is what i got

==> /var/log/nginx/error.log <==
2019/03/23 07:13:21 [error] 22191#0: *4 connect() failed (111: Connection 
refused) while connecting to upstream, client: 71.231.182.18, server: 
MyDomain.com, request: "GET /admin/ HTTP/1.1", upstream: 
"http://0.0.0.0:8001/admin/";, host: "www.MyDomain.com"


==> /var/log/nginx/access.log <==
71.231.182.18 - - [23/Mar/2019:07:13:21 +] "GET /admin/ HTTP/1.1" 502 
575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 
(KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36" "-"





On Friday, March 22, 2019 at 10:31:08 PM UTC-7, Ahmed Ishtiaque wrote:
>
> Aldian has pointed it out already, but I also use Nginx + gunicorn + 
> daphne for my production server. Nginx decides when to upgrade a request to 
> wss:// and passes it on to my daphne instance to handle automatically. 
> Would be happy to share my config for that if you want.
>
> Best,
> Ahmed
>
> On Fri, Mar 22, 2019 at 10:15 PM Aldian Fazrihady  > wrote:
>
>> Does it really use Django channels?  I am using Django channels and 
>> following its suggested package:  ASGI provided by Daphne
>>
>> Regards, 
>>
>> Aldian Fazrihady
>>
>> On Sat, 23 Mar 2019, 07:58 Adam Zedan, > 
>> wrote:
>>
>>> I am currently using Django channels for websocket communication. I read 
>>> this 
>>> 
>>>  article 
>>> and it states that I should split the project into two uwsgi instances. It 
>>> states that
>>>
>>> "The web server undertakes the task of dispatching normal requests to 
 one uWSGI instance and WebSocket requests to another one"
>>>
>>>
>>> Now I have two uwsgi instances running. This is how I am running both.
>>>
>>> This uwsgi handles the normal django site requests
>>> uwsgi --virtualenv /home/ec2-user/MyProjVenv --socket /home/ec2-user/
>>> MyProjVenv/MyProjWeb/site1.socket --chmod-socket=777 --buffer-size=32768 
>>> --workers=5 --master --module main.wsgi
>>>
>>>
>>> This uwsgi handles the websocket requests
>>> uwsgi --virtualenv /home/ec2-user/MyProjVenv --http-socket /home/ec2-
>>> user/MyProjVenv/MyProjWeb/web.socket --gevent 1000 --http-websockets --
>>> workers=2 --master --chmod-socket=777  --module main.wsgi_websocket
>>>
>>> Now the websocket uwsgi launches  main.wsgi_websocket
>>>
>>> The code for main.wsgi_websocket one is this
>>> import os
>>> import gevent.socket
>>> import redis.connection
>>> redis.connection.socket = gevent.socket
>>> os.environ.update(DJANGO_SETTINGS_MODULE='main.settings')
>>> from ws4redis.uwsgi_runserver import uWSGIWebsocketServer
>>> application = uWSGIWebsocketServer()
>>>
>>> Now after spinning up the two uwsgi instances I am able to access the 
>>> website.The websocket uwsgi instance is also receiving data however I am 
>>> not sure if its passing that data to the website uwsgi instance. I am using 
>>> Django Channels here and this is the configuration I have specified in my 
>>> settings for Django Channels
>>>
>>> CHANNEL_LAYERS = {
>>> "default": {
>>> "BACKEND": "asgi_redis.RedisChannelLayer",
>>> "CONFIG": {
>>> "hosts": [(redis_host, 6379)],
>>> },
>>>"ROUTING": "main.routing.channel_routing", 
>>> },
>>> }
>>>
>>> The channel routing is this
>>> channel_routing = [
>>> include("chat.routing.websocket_routing", path=r"^/chat/stream"),
>>> include(