Re: Daphne and Intermediate certificate

2017-05-04 Thread Алексей Кузуб
Thank you very much, Andrew! It works!

четверг, 4 мая 2017 г., 19:39:49 UTC+3 пользователь Andrew Godwin написал:
>
> You can - if you use the `-e` method of passing arguments to Daphne, as a 
> couple of the examples in the README show, you can use the full Twisted 
> endpoint syntax, which allows a extraCertChain parameter.
>
> You can see their documentation here, including example syntax for how 
> that would look: 
> https://twistedmatrix.com/documents/current/core/howto/endpoints.html#servers
>
> Andrew
>
> On Thu, May 4, 2017 at 7:25 AM, Алексей Кузуб  > wrote:
>
>> Hi! I cam using Django channels and Daphne web server. And I want to use 
>> web sockets with it over https i.e using SSL. Can Daphne use intermediate 
>> certificates and how i can to run this stack?
>>
>> -- 
>> 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/00b0e2b3-801b-4f89-abaa-8d0b47a0a7f0%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/68a7f50c-11e2-4f79-8fe8-e6954b2db7c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unit testing Multiselect fields not loading as expected

2017-05-04 Thread Trevor Woolley
Hi, when I run a unittest on a form containing a MultipleChoiceField, and 
in the unittest I test setting what I think should be a valid field, it 
does not pass. It appears that field in question extracts the data is uses 
for the test before the test database is created, and actually uses the 
production database for the values.

The result of the test and the (altered snippets) are below, if anyone can 
help I'd be grateful.

The below example includes a mock of the data fill function, but there is 
no difference in the ultimate response, if the mock setup is not used. If 
the production database contains the correct IDs the test passes.

Rgds
Trevor

#
# forms.py snippet
#
# appropriate imports

def get_my_list():
""" Function to get the complete stuff list for multiselect """
result = []
my_stuff = Stuff.objects.all()
for stuff in my_stuff:
displayname = "%s (%s)" % (stuff.name1, stuff.name2)
result.append({"id": str(stuff.id), "displayname": displayname})
print("REAL --> %s" % result)
return sorted(result, key=itemgetter("displayname"))


class DispLayIssueForm(forms.Form):
""" Class to manage the changes / adds for the extra Stuff model """
description = forms.CharField(
label='Short Description',
max_length=199,
strip=True
)
my_choices = [(m['id'], m['displayname']) for m in get_my_list()]
print("In Form --> %s" % my_choices)

stuff = forms.MultipleChoiceField(
widget=forms.SelectMultiple(attrs={'size': '10'}),
choices=my_choices,
label="My Stuff",
required=False,
)
db_id = forms.CharField(widget=forms.HiddenInput)

def clean(self):
""" Form Clean function """
# 

def save(self):
""" Form Save function """
# 

def update(self):
""" Form Update function """
# 


#
# test_forms
#
# appropriate imports
# django.test import TestCase


def mocked_get_my_list():
""" Mocking the function so that it grabs the test data """
result = []
my_stuff = Stuff.objects.all()
for stuff in my_stuff:
displayname = "%s (%s)" % (stuff.name1, stuff.name2)
result.append({"id": str(stuff.id), "displayname": displayname})
print("MOCKED --> %s" % result)
return result

class DispLayIssueFormTests(TestCase):
""" Class to test the display issue form """

def setUp(self):
""" Initial setup just creates two stuff entries """
self.name1 = create_stuff("foo1", "bar1")
self.name2 = create_stuff("foo2", "bar2")

def tearDown(self):
""" Final tear downs """
self.name1.delete()
self.name2.delete()

# Other tests that leave the stuff fields empty pass

@mock.patch('form.get_my_list')
def test_valid_save2(self, mock_list):
""" Test to ensure a valid save succeeds - with stuff """
print("START")
mock_list.side_effect = mocked_get_my_list()
testform = DispLayIssueForm({
'description': 'test3',
'stuff': [str(self.name1.id), ],
'db_id': 0,
})
print("ERRORS --> %s" % testform.errors)
print("FORMS --> %s" % testform)
self.assertTrue(testform.is_valid())
testform.save()
dummy = ExtraStuff.objects.get(description='test3')

=
$ ./manage.py test 
issue.tests.test_forms.DispLayIssueFormTests.test_valid_save2
REAL --> []
In Form --> []
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
START
MOCKED --> [{'id': '1', 'displayname': 'foo1 (bar1)'}, {'id': '2', 
'displayname': 'foo2 (bar2)'}]
ERRORS --> stuffSelect 
a valid choice. 1 is not one of the available choices.
FORMS --> Description:
Stuff:Select a valid choice. 1 is not one of the available 
choices.
F
==
FAIL: test_valid_save2 (issue.tests.test_forms.DispLayIssueFormTests)
Test to ensure a valid save succeeds - with stuff
--
Traceback (most recent call last):
  File "c:\projects\issue\lib\site-packages\mock\mock.py", line 1305, in 
patched
return func(*args, **keywargs)
  File "c:\projects\issue\issue\tests\test_forms.py", line 288, in 
test_valid_save2
self.assertTrue(testform.is_valid())
AssertionError: False is not true

--
Ran 1 test in 0.538s

FAILED (failures=1)
Destroying test database for alias 'default'...
$ ./manage.py shell
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import django
>>> django.get_version()
'1.11'
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop 

Re: Occasional FieldError for a field that really does exist

2017-05-04 Thread Tim Graham
Could it be related to a third-party app similar to 
https://code.djangoproject.com/ticket/27365#comment:12 ?

On Thursday, May 4, 2017 at 5:12:47 PM UTC-4, Evan Heidtmann wrote:
>
> Hello Django friends,
>
>
> My app, running in production with uwsgi, very occasionally will crash 
> because of a FieldError on a (valid) reverse ForeignKey relationship field. 
> Without any code changes, other requests will succeed. Tests that cover 
> this code path always pass. 
>
>
> The two models are in different apps. Both apps are listed in 
> INSTALLED_APPS and the calling module imports both models modules at top 
> level. One of the models is "replaceable" but I'm using the original model 
> (it's oauth2_provider.Application)
>
>
> # app1/models.pyclass A(models.Model):
> name = models.CharField(max_length=20)
> def get_A_model():
> # ... some thirdparty code for replaceable models ...
> # app2/models.pyclass B(models.Model):
> myname = models.CharField(max_length=20)
> a = models.ForeignKey('app1.A')
> # app2/views.pyimport app1.models as app1_modelsfrom . import models
> def view(request):
># This line crashes with "FieldError: Cannot resolve keyword 'b' into 
> field. Choices are: ..."
> qs = app1_models.get_A_model().objects.filter(b__myname='larry')
>
>
> This smells like some kind of deployment issue (code loading too late or 
> not at all?) but if so, I don't know how to debug. Thanks for taking a look 
> and let me know what I can do to gather more helpful information.
>

-- 
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/6769b832-e478-4890-9036-49094e12a644%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django 1.11 login user

2017-05-04 Thread sum abiut
Hi,
 i have try to login user using the guide from
https://docs.djangoproject.com/en/1.11/topics/auth/default/

but get an error. Can someone advise what i am doin wrong here



he is my view.py

#Authentication user
def login(request):
username=request.POST['username']
password=request.POST['password']
user=authenticate(request,username=username,password=password)
if user is not None:
login(request,user)
#Redirect to dashboard page
return render(request,'dashboard.html')
else:
# return invalid login message
return HttpResponse( 'You have enter a wrong password or username
please again')



Error message:


Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/login/

Django Version: 1.11
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'fundmanager']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/core/handlers/exception.py"
in inner
  41. response = get_response(request)

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in _get_response
  187. response = self.process_exception_by_middleware(e,
request)

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in _get_response
  185. response = wrapped_callback(request, *callback_args,
**callback_kwargs)

File "/var/www/projects/benchmark/fundmanager/views.py" in login
  22. username=request.POST['username']

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/utils/datastructures.py"
in __getitem__
  85. raise MultiValueDictKeyError(repr(key))

Exception Type: MultiValueDictKeyError at /login/
Exception Value: "u'username'"

-- 
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/CAPCf-y4Lg1ZkqDA4TR7RuV6z-gutuKmzFZ%2BvpQsr%3DUnqXV2OkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Occasional FieldError for a field that really does exist

2017-05-04 Thread Evan Heidtmann


Hello Django friends,


My app, running in production with uwsgi, very occasionally will crash 
because of a FieldError on a (valid) reverse ForeignKey relationship field. 
Without any code changes, other requests will succeed. Tests that cover 
this code path always pass. 


The two models are in different apps. Both apps are listed in INSTALLED_APPS 
and 
the calling module imports both models modules at top level. One of the 
models is "replaceable" but I'm using the original model (it's 
oauth2_provider.Application)


# app1/models.pyclass A(models.Model):
name = models.CharField(max_length=20)
def get_A_model():
# ... some thirdparty code for replaceable models ...
# app2/models.pyclass B(models.Model):
myname = models.CharField(max_length=20)
a = models.ForeignKey('app1.A')
# app2/views.pyimport app1.models as app1_modelsfrom . import models
def view(request):
   # This line crashes with "FieldError: Cannot resolve keyword 'b' into field. 
Choices are: ..."
qs = app1_models.get_A_model().objects.filter(b__myname='larry')


This smells like some kind of deployment issue (code loading too late or 
not at all?) but if so, I don't know how to debug. Thanks for taking a look 
and let me know what I can do to gather more helpful information.

-- 
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/21013282-b301-4963-8d1c-4805db1abacd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial Issues

2017-05-04 Thread René Fleschenberg
Hi Ivan,

It is very likely that your problem is caused by one of these:

- `question` is not assigned to the template context
- `question` is assigned to the template context, but it has a wrong
   value (e.g. `None`)
- the question has no `id` (it is not saved to the database yet).


This then results in this line:

`{% url 'polls:vote' question.id %}`

being something like

{% url 'polls:vote' "" %}

which does not match your URL pattern, because the pattern wants an
integer for the id.

I hope this helps!

René


On 04.05.2017 08:32, Ivan Cox wrote:
> Hi i am new to Django and in the process of going through the django
> tutorial at https://www.djangoproject.com/ 
> I have however run into problems on Part 4. I have added the following
> code to the detail.html page 
> 
> |
> {{ question.question_text }}
> 
> {% if error_message %}{{ error_message }}{% endif %}
> 
> 
> 
> {% csrf_token %}
> {% for choice in question.choice_set.all %}
>  value="{{ choice.id }}" />
> {{ choice.choice_text
> }}
> {% endfor %}
> 
> 
> 
> |
> 
> But when i click on the links on the polls home page i get the following
> error
> 
> 
>   NoReverseMatch at /polls/3/


-- 
René Fleschenberg

Am Stadtgarten 28, 45276 Essen, Germany
Phone: +49 1577 170 7363
E-Mail: r...@fleschenberg.net

-- 
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/70d0da5f-afd3-1d4c-5426-f93d8d6851cd%40fleschenberg.net.
For more options, visit https://groups.google.com/d/optout.


Re: Error was: cannot import name 'GDALRaster in Window 8.1

2017-05-04 Thread Daniel Wiesmann


Your question regarding raster2pgsql has nothing to do with Django, so please 
ask questions related to that somewhere else (for instance 
onhttps://gis.stackexchange.com/ )

Regarding your first error, could you share the output of the following command 
on your command line:

gdalinfo --version

(just to check if you have gdal installed)

I agree that the above error message is not useful for users that want to use 
postgis but dont have gdal installed. Maybe its related to the gdal path or 
something else. GDAL should be installed as postgis itself already requires 
gdal.
http://postgis.net/docs/manual-2.3/postgis_installation.html#install_requirements



On Sunday, April 30, 2017 at 3:20:01 PM UTC+1, Prashant Verma wrote:
>
> C:\User\.\Desktop\Geolocation>*python manage.py makemigrations*
> Traceback (most recent call last):
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\utils.py",
>  
> line 115, in load_backend
> return import_module('%s.base' % backend_name)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\importlib\__init__.py",
>  
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 978, in _gcd_import
>   File "", line 961, in _find_and_load
>   File "", line 950, in 
> _find_and_load_unlocked
>   File "", line 655, in _load_unlocked
>   File "", line 677, in exec_module
>   File "", line 205, in 
> _call_with_frames_removed
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py",
>  
> line 7, in 
> from .operations import PostGISOperations
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\gis\db\backends\postgis\operations.py",
>  
> line 7, in 
> from django.contrib.gis.gdal import GDALRaster
> ImportError: cannot import name 'GDALRaster'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "manage.py", line 22, in 
> execute_from_command_line(sys.argv)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\core\management\__init__.py",
>  
> line 363, in execute_from_command_line
> utility.execute()
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\core\management\__init__.py",
>  
> line 337, in execute
> django.setup()
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\__init__.py",
>  
> line 27, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\apps\registry.py",
>  
> line 108, in populate
> app_config.import_models()
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\apps\config.py",
>  
> line 202, in import_models
> self.models_module = import_module(models_module_name)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\importlib\__init__.py",
>  
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 978, in _gcd_import
>   File "", line 961, in _find_and_load
>   File "", line 950, in 
> _find_and_load_unlocked
>   File "", line 655, in _load_unlocked
>   File "", line 677, in exec_module
>   File "", line 205, in 
> _call_with_frames_removed
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\auth\models.py",
>  
> line 4, in 
> from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\auth\base_user.py",
>  
> line 52, in 
> class AbstractBaseUser(models.Model):
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\base.py",
>  
> line 124, in __new__
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\base.py",
>  
> line 330, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\options.py",
>  
> line 214, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\__init__.py",
>  
> line 33, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\utils.py",
>  
> line 211, in __getitem__
> backend = load_backend(db['ENGINE'])
>   File 
> 

Django Tutorial Issues

2017-05-04 Thread Ivan Cox
Hi i am new to Django and in the process of going through the django 
tutorial at https://www.djangoproject.com/ 
I have however run into problems on Part 4. I have added the following code 
to the detail.html page 

{{ question.question_text }}

{% if error_message %}{{ error_message }}{% endif %}



{% csrf_token %}
{% for choice in question.choice_set.all %}

{{ choice.choice_text 
}}
{% endfor %}




But when i click on the links on the polls home page i get the following 
error

NoReverseMatch at /polls/3/

Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
['polls/(?P[0-9]+)/vote/$']

Request Method: GET
Request URL: http://127.0.0.1:8000/polls/3/
Django Version: 1.11
Exception Type: NoReverseMatch
Exception Value: 

Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
['polls/(?P[0-9]+)/vote/$']

Exception Location: 
C:\Users\Echalon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py
 
in _reverse_with_prefix, line 497
Python Executable: 
C:\Users\Echalon\AppData\Local\Programs\Python\Python36-32\python.exe
Python Version: 3.6.0
Python Path: 

['C:\\Web Development\\mysite',
 
'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\python36.zip',
 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs',
 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\lib',
 'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32',
 
'C:\\Users\\Echalon\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages']

Server time: Thu, 4 May 2017 06:31:28 +
Error during template rendering

In template C:\Web Development\mysite\polls\templates\polls\detail.html, 
error at line *5*
Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
['polls/(?P[0-9]+)/vote/$']
1 {{ question.question_text }} 
2 
3 {% if error_message %}{{ error_message }}{% endif 
%} 
4 
5  
6 
7 {% csrf_token %} 
8 {% for choice in question.choice_set.all %} 
9  
10 {{ choice.choice_text 
}} 
11 {% endfor %} 
12  
13  
14

Any help would be greatly appreciated.
















































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


Need help with deployment

2017-05-04 Thread sarfaraz ahmed
Hello Friends,

I have an Windows 2016 Server edition on EC2.
I install Apache 2.4 VC10 on my server and installed 2.7.13

I am not able to find MOD_WSGI.SO for this combination.

Can someone provide me steps to compile or link to download

-- 
Thanks with regards,
Sarfaraz Ahmed

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


Re: Daphne and Intermediate certificate

2017-05-04 Thread Andrew Godwin
You can - if you use the `-e` method of passing arguments to Daphne, as a
couple of the examples in the README show, you can use the full Twisted
endpoint syntax, which allows a extraCertChain parameter.

You can see their documentation here, including example syntax for how that
would look:
https://twistedmatrix.com/documents/current/core/howto/endpoints.html#servers

Andrew

On Thu, May 4, 2017 at 7:25 AM, Алексей Кузуб  wrote:

> Hi! I cam using Django channels and Daphne web server. And I want to use
> web sockets with it over https i.e using SSL. Can Daphne use intermediate
> certificates and how i can to run this stack?
>
> --
> 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/00b0e2b3-801b-4f89-abaa-8d0b47a0a7f0%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/CAFwN1uoyy-fv3%3D7xz595m4J_9FHZVMrdCbjt2y-AwcOv%3DRaO%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Daphne and Intermediate certificate

2017-05-04 Thread Алексей Кузуб
Hi! I cam using Django channels and Daphne web server. And I want to use 
web sockets with it over https i.e using SSL. Can Daphne use intermediate 
certificates and how i can to run this stack?

-- 
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/00b0e2b3-801b-4f89-abaa-8d0b47a0a7f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {{ form }} vs {{ form }}

2017-05-04 Thread Todor Velichkov
Take a look at:
1) Form rendering options 

2) Outputting forms as HTML 


{{ form }} and {{ form.as_table }} are basically the same.
So in terms of valid markup {{ form }} would be more correct.

On Thursday, May 4, 2017 at 4:46:13 PM UTC+3, guettli wrote:
>
> I am unsure how to render a form.
>
> I see these ways
>
>
>- {{ form }}  
>- {{ form }}
>
>
> If I use a model form, then the first way is the correct one.
>
>
> How to you solve this?
>

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


{{ form }} vs {{ form }}

2017-05-04 Thread guettli
I am unsure how to render a form.

I see these ways


   - {{ form }}  
   - {{ form }}


If I use a model form, then the first way is the correct one.


How to you solve this?

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


Re: Error was: cannot import name 'GDALRaster in Window 8.1

2017-05-04 Thread Prashant Verma
I have installed it now. But It's showing some error: Can you tell me what 
is this? How can I able to fix this? 

C:\Users\Prashant>*gdalinfo --version*
ERROR 1: Can't load requested DLL: C:\Program 
Files\GDAL\gdalplugins\ogr_MSSQLSp
atial.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program 
Files\GDAL\gdalplugins\ogr_MSSQLSp
atial.dll
126: The specified module could not be found.

*GDAL 2.1.3, released 2017/20/01*

On Sunday, 30 April 2017 19:50:01 UTC+5:30, Prashant Verma wrote:
>
> C:\User\.\Desktop\Geolocation>*python manage.py makemigrations*
> Traceback (most recent call last):
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\utils.py",
>  
> line 115, in load_backend
> return import_module('%s.base' % backend_name)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\importlib\__init__.py",
>  
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 978, in _gcd_import
>   File "", line 961, in _find_and_load
>   File "", line 950, in 
> _find_and_load_unlocked
>   File "", line 655, in _load_unlocked
>   File "", line 677, in exec_module
>   File "", line 205, in 
> _call_with_frames_removed
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py",
>  
> line 7, in 
> from .operations import PostGISOperations
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\gis\db\backends\postgis\operations.py",
>  
> line 7, in 
> from django.contrib.gis.gdal import GDALRaster
> ImportError: cannot import name 'GDALRaster'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "manage.py", line 22, in 
> execute_from_command_line(sys.argv)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\core\management\__init__.py",
>  
> line 363, in execute_from_command_line
> utility.execute()
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\core\management\__init__.py",
>  
> line 337, in execute
> django.setup()
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\__init__.py",
>  
> line 27, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\apps\registry.py",
>  
> line 108, in populate
> app_config.import_models()
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\apps\config.py",
>  
> line 202, in import_models
> self.models_module = import_module(models_module_name)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\importlib\__init__.py",
>  
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 978, in _gcd_import
>   File "", line 961, in _find_and_load
>   File "", line 950, in 
> _find_and_load_unlocked
>   File "", line 655, in _load_unlocked
>   File "", line 677, in exec_module
>   File "", line 205, in 
> _call_with_frames_removed
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\auth\models.py",
>  
> line 4, in 
> from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\auth\base_user.py",
>  
> line 52, in 
> class AbstractBaseUser(models.Model):
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\base.py",
>  
> line 124, in __new__
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\base.py",
>  
> line 330, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\options.py",
>  
> line 214, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\__init__.py",
>  
> line 33, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\utils.py",
>  
> line 211, in __getitem__
> backend = load_backend(db['ENGINE'])
>   File 
> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\utils.py",
>  
> line 134, in load_backend
> raise ImproperlyConfigured(error_msg)
> django.core.exceptions.ImproperlyConfigured: 
> 'django.contrib.gis.db.backends.postgis' isn't an 

Re: Error was: cannot import name 'GDALRaster in Window 8.1

2017-05-04 Thread Prashant Verma
I have installed it now. But It's showing some error: Can you tell me what
is this? How can I able to fix this?

C:\Users\Prashant>*gdalinfo --version*
ERROR 1: Can't load requested DLL: C:\Program
Files\GDAL\gdalplugins\ogr_MSSQLSp
atial.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program
Files\GDAL\gdalplugins\ogr_MSSQLSp
atial.dll
126: The specified module could not be found.

*GDAL 2.1.3, released 2017/20/01*

On 4 May 2017 at 14:45, Prashant Verma  wrote:

> The error after entered: gdalinfo --version
>
> C:\Users\Prashant>gdalinfo --version
> 'gdalinfo' is not recognized as an internal or external command,
> operable program or batch file.
>
> Though, I have already installed gdal "gdal-201-1800-x64-core" into my
> system.
>
> On 4 May 2017 at 14:43, Prashant Verma  wrote:
>
>> The error after entered: gdalinfo --version
>>
>> C:\Users\Prashant>gdalinfo --version
>> 'gdalinfo' is not recognized as an internal or external command,
>> operable program or batch file.
>>
>> Though, I have already installed gdal "gdal-201-1800-x64-core" into my
>> system.
>>
>>
>> On 4 May 2017 at 12:48, Daniel Wiesmann 
>> wrote:
>>
>>> Your question regarding raster2pgsql has nothing to do with Django, so
>>> please ask questions related to that somewhere else (for instance on
>>> https://gis.stackexchange.com/ )
>>>
>>> Regarding your first error, could you share the output of the following
>>> command on your command line:
>>>
>>> gdalinfo --version
>>>
>>> (just to check if you have gdal installed)
>>>
>>> I agree that the above error message is not useful for users that want
>>> to use postgis but dont have gdal installed. Maybe its related to
>>> something else, Postgis itself already requires gdal
>>>
>>> http://postgis.net/docs/manual-2.3/postgis_installation.html
>>> #install_requirements
>>>
>>> On 03-05-2017 22:22, Prashant Verma wrote:
>>> > Hey Mate,
>>> >
>>> > I am trying to get over by this error. Although, It's little
>>> complicated
>>> > to work in the windows environment.
>>> > By the way, I am trying to follow this process
>>> > https://libregis.org/2011/03/10/how-to-install-and-configure
>>> -postgis-raster-on-windows/,
>>> > however, I am stuck at the raster2pgsql process.
>>> >
>>> > After run this code : "raster2pgsql.py -r image.tif-t tablename -o
>>> > image.sql"
>>> >
>>> > It has thrown an Error: Could not process -t.
>>> >
>>> > After that change code : raster2pgsql -s 4236 -I -C -M *.tif -F -t
>>> > 100x100 public.demelevation > elev.sql
>>> >
>>> > Error : ERROR: Unable to read raster file: *.tif
>>> >
>>> > Can you please me with? Or should I change my windows environment to
>>> ubuntu?
>>> >
>>> > On Monday, 1 May 2017 22:43:23 UTC+5:30, Tim Graham wrote:
>>> >
>>> > It looks like GDAL isn't installed on your system.
>>> >
>>> > Looking at
>>> > https://docs.djangoproject.com/en/stable/ref/contrib/gis/in
>>> stall/#spatial-database
>>> > >> nstall/#spatial-database>,
>>> > I believe it's a required dependency -- perhaps we should try to
>>> > improve the error message.
>>> >
>>> > On Sunday, April 30, 2017 at 10:20:01 AM UTC-4, Prashant Verma
>>> wrote:
>>> >
>>> > C:\User\.\Desktop\Geolocation>*python manage.py
>>> > makemigrations*
>>> > Traceback (most recent call last):
>>> >   File
>>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\s
>>> ite-packages\django\db\utils.py",
>>> > line 115, in load_backend
>>> > return import_module('%s.base' % backend_name)
>>> >   File
>>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\i
>>> mportlib\__init__.py",
>>> > line 126, in import_module
>>> > return _bootstrap._gcd_import(name[level:], package,
>>> level)
>>> >   File "", line 978, in
>>> _gcd_import
>>> >   File "", line 961, in
>>> _find_and_load
>>> >   File "", line 950, in
>>> > _find_and_load_unlocked
>>> >   File "", line 655, in
>>> _load_unlocked
>>> >   File "", line 677, in
>>> > exec_module
>>> >   File "", line 205, in
>>> > _call_with_frames_removed
>>> >   File
>>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\s
>>> ite-packages\django\contrib\gis\db\backends\postgis\base.py",
>>> > line 7, in 
>>> > from .operations import PostGISOperations
>>> >   File
>>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\s
>>> ite-packages\django\contrib\gis\db\backends\postgis\operations.py",
>>> > line 7, in 
>>> > from django.contrib.gis.gdal import GDALRaster
>>> > ImportError: cannot import name 'GDALRaster'
>>> >
>>> > During handling of the above exception, 

Re: Error was: cannot import name 'GDALRaster in Window 8.1

2017-05-04 Thread Prashant Verma
The error after entered: gdalinfo --version

C:\Users\Prashant>gdalinfo --version
'gdalinfo' is not recognized as an internal or external command,
operable program or batch file.

Though, I have already installed gdal "gdal-201-1800-x64-core" into my
system.

On 4 May 2017 at 14:43, Prashant Verma  wrote:

> The error after entered: gdalinfo --version
>
> C:\Users\Prashant>gdalinfo --version
> 'gdalinfo' is not recognized as an internal or external command,
> operable program or batch file.
>
> Though, I have already installed gdal "gdal-201-1800-x64-core" into my
> system.
>
>
> On 4 May 2017 at 12:48, Daniel Wiesmann  wrote:
>
>> Your question regarding raster2pgsql has nothing to do with Django, so
>> please ask questions related to that somewhere else (for instance on
>> https://gis.stackexchange.com/ )
>>
>> Regarding your first error, could you share the output of the following
>> command on your command line:
>>
>> gdalinfo --version
>>
>> (just to check if you have gdal installed)
>>
>> I agree that the above error message is not useful for users that want
>> to use postgis but dont have gdal installed. Maybe its related to
>> something else, Postgis itself already requires gdal
>>
>> http://postgis.net/docs/manual-2.3/postgis_installation.
>> html#install_requirements
>>
>> On 03-05-2017 22:22, Prashant Verma wrote:
>> > Hey Mate,
>> >
>> > I am trying to get over by this error. Although, It's little complicated
>> > to work in the windows environment.
>> > By the way, I am trying to follow this process
>> > https://libregis.org/2011/03/10/how-to-install-and-configure
>> -postgis-raster-on-windows/,
>> > however, I am stuck at the raster2pgsql process.
>> >
>> > After run this code : "raster2pgsql.py -r image.tif-t tablename -o
>> > image.sql"
>> >
>> > It has thrown an Error: Could not process -t.
>> >
>> > After that change code : raster2pgsql -s 4236 -I -C -M *.tif -F -t
>> > 100x100 public.demelevation > elev.sql
>> >
>> > Error : ERROR: Unable to read raster file: *.tif
>> >
>> > Can you please me with? Or should I change my windows environment to
>> ubuntu?
>> >
>> > On Monday, 1 May 2017 22:43:23 UTC+5:30, Tim Graham wrote:
>> >
>> > It looks like GDAL isn't installed on your system.
>> >
>> > Looking at
>> > https://docs.djangoproject.com/en/stable/ref/contrib/gis/in
>> stall/#spatial-database
>> > > nstall/#spatial-database>,
>> > I believe it's a required dependency -- perhaps we should try to
>> > improve the error message.
>> >
>> > On Sunday, April 30, 2017 at 10:20:01 AM UTC-4, Prashant Verma
>> wrote:
>> >
>> > C:\User\.\Desktop\Geolocation>*python manage.py
>> > makemigrations*
>> > Traceback (most recent call last):
>> >   File
>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\
>> site-packages\django\db\utils.py",
>> > line 115, in load_backend
>> > return import_module('%s.base' % backend_name)
>> >   File
>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\
>> importlib\__init__.py",
>> > line 126, in import_module
>> > return _bootstrap._gcd_import(name[level:], package, level)
>> >   File "", line 978, in _gcd_import
>> >   File "", line 961, in
>> _find_and_load
>> >   File "", line 950, in
>> > _find_and_load_unlocked
>> >   File "", line 655, in
>> _load_unlocked
>> >   File "", line 677, in
>> > exec_module
>> >   File "", line 205, in
>> > _call_with_frames_removed
>> >   File
>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\
>> site-packages\django\contrib\gis\db\backends\postgis\base.py",
>> > line 7, in 
>> > from .operations import PostGISOperations
>> >   File
>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\
>> site-packages\django\contrib\gis\db\backends\postgis\operations.py",
>> > line 7, in 
>> > from django.contrib.gis.gdal import GDALRaster
>> > ImportError: cannot import name 'GDALRaster'
>> >
>> > During handling of the above exception, another exception
>> occurred:
>> >
>> > Traceback (most recent call last):
>> >   File "manage.py", line 22, in 
>> > execute_from_command_line(sys.argv)
>> >   File
>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\
>> site-packages\django\core\management\__init__.py",
>> > line 363, in execute_from_command_line
>> > utility.execute()
>> >   File
>> > "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\
>> site-packages\django\core\management\__init__.py",
>> > line 337, in execute
>> > django.setup()
>> >   File
>> > 

Re: pass context to overridden templates

2017-05-04 Thread Florian Schweikert
On 03/05/17 15:53, cjdcordeiro wrote:
> Probably the best would be overriding the app's default class based
> view, but when I look at it
> (https://github.com/django-notifications/django-notifications/blob/master/notifications/views.py#L29)
> it doesn't have a get_context method or anything I can play with to
> change the default context
> 
> ideas? anyone?

As NotificationViewList is a ListView it should have get_context_data
see:
https://docs.djangoproject.com/en/1.11/ref/class-based-views/generic-display/#listview

-- 
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/50149974-8169-8e3a-9b0f-8f0ed25624d7%40ist-total.org.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels, Nginx, Daphne - Not working?

2017-05-04 Thread Alex Elson
I was able to get it working with the development server, python manage.py 
runserver, with an addition to the firewall on Google Cloud.

-- 
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/78173b95-e0a3-4930-8cec-581d36784671%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.