Re: Django 1.11 and PostgreSQL 10 compatibility

2017-10-26 Thread Fabio C. Barrionuevo da Luz
Psycopg 2.7.3.2 was released with Postgresql 10 support

http://initd.org/psycopg/articles/2017/10/24/psycopg-2732-released/



2017-10-22 3:54 GMT-03:00 Edandweb :

> Thanks
>
> On Thursday, 19 October 2017 12:27:50 UTC+3, Edandweb wrote:
>>
>> Hi,
>>
>> I am developing a new application in Python and Django, for the database
>> we want to use the last version of PostgreSQL v10.
>> The django Documentation says in https://docs.djangoproject.com
>> /en/1.11/ref/databases/#postgresql-notes:
>>
>>
>>
>> *Django supports PostgreSQL 9.3 and higher. psycopg2
>>  2.5.4 or higher is required, though the latest
>> release is recommended.*I am not sure to understand, it's just 9.3 and
>> higher like 9.3.1 or 9.3.2 or 9.3.4 ... or can we use 9.4 and 9.5 ... ?
>>
>> Thanks
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/7b9054e5-bd0e-4eff-a8e9-9d98fab5bd38%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul

http://pythonclub.com.br/

Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e
mandar o pull-request. Leia mais sobre como publicar em README.md e
contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python
ou é útil para quem usa Python? Está esperando o que? Publica logo, que
estou louco para ler...

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


Re: Django Simple Request

2017-10-26 Thread Ruifeng Hu
Many thanks! 

On Thursday, October 26, 2017 at 4:01:47 AM UTC-5, Mike Dewhirst wrote:
>
> On 26/10/2017 3:08 AM, Ruifeng Hu wrote: 
> > Hi All, 
> > 
> > Is there anyone who can share with me some simples of Django, I just 
> > start learning Django! 
>
> STart here ... 
>
> https://docs.djangoproject.com/en/1.11/ 
>
> Then here to see there are seven parts to the tutorial 
>
> https://docs.djangoproject.com/en/1.11/intro/ 
>
> And start following the first part of the tutorial here ... 
>
> https://docs.djangoproject.com/en/1.11/intro/tutorial01/ 
>
> I haven't looked at the following link but I note that a lot of people 
> on this list recommend it ... 
>
> https://tutorial.djangogirls.org/en/ 
>
> Although a quick glance tells me I should study parts of it. 
>
> Welcome to Django and good luck in your journey 
>
>
>
> > 
> > Thank you! 
> > 
> > Best Regards, 
> > 
> > Ruifeng Hu 
> > 
> > -- 
> > 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/7ddf0376-71a8-4597-b9e8-d6de1301a339%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/7ddf0376-71a8-4597-b9e8-d6de1301a339%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  
>
> > 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/394b054d-8e67-42de-803c-50f456d9b2c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Consulta de campo duplicado en la base

2017-10-26 Thread andres
Hola una consulta, como hago un metodo para que se conecte y consulte a la 
db si el nro de doc ya esta registrado..

-- 
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/bbed4871-f1b2-476a-bcd4-4926efa5464c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing 3 user inputs as argument in url, for a search form

2017-10-26 Thread Jack
I managed to get the code functional.  I haven't done extensive testing but 
it's certainly working right now with your code plus some of my own fixes.  
I should read the documentation more carefully in the future.

Thanks again for the super detailed response James.

On Wednesday, October 25, 2017 at 7:50:58 PM UTC-4, James Schneider wrote:
>
>
>
> On Wed, Oct 25, 2017 at 11:29 AM, Jack > 
> wrote:
>
>> I am building a search form where the user inputs 3 values on a form, and 
>> I search the database for all records that match the 3 inputs.  Right now I 
>> am stuck on the user input part.
>>
>> If you look at my *urls.py*, you will see that I tried to put 3 keywords 
>> arguments in there.  Then I tried to pass the 3 keyword arguments in the 
>> url tag with variables from my *forms.py*.  I think this is where things 
>> went wrong but I'm not sure.  I don't know if the .html file can use 
>> variables from *forms.py*
>>
>> Basically what I'm trying to do is to take the 3 user inputs, and pass 
>> them as arguments in the URL.  Right now I'm getting:
>>
>> NoReverseMatch at /
>>
>> Reverse for 'search-results' with keyword arguments '{'pt': '', 'nb': '', 
>> 'nw': ''}' not found. 1 pattern(s) tried: 
>> ['search?(?P\\w+)&(?P\\w+)&(?P\\w+)']
>>
>>
>>
>> *urls.py*
>> url(r'^search?(?P\w+)&(?P\w+)&(?P\w+)', 
>> views.IndexSearchResults.as_view(), name='search-results')
>>
>>
> This is not the correct usage of the URL dispatcher. It should look 
> something like this:
>
> url(r'^search$', views.IndexSearchResults.as_view(), name='search-results')
>
> The URL dispatcher does not match on GET arguments within the URL, that's 
> left for the request object to parse.
>
>
> https://docs.djangoproject.com/en/1.11/topics/http/urls/#what-the-urlconf-searches-against
>
>  
>
> *views.py*
>> class IndexSearchResults(generic.ListView):
>> template_name = 'search-results.html'
>>
>>
> The view is where your GET arguments will be processed. Note that if you 
> are submitting the form directly to the URL above, then no validation of 
> the form values will be performed. If you want those values to be 
> validated, you should submit to a FormView to validate the results and 
> redirect to this search page with the GET arguments in tow. I'd imagine 
> that both strategies are common, since sending bad values to search against 
> usually just results in bad searches. The ORM takes care of most of the 
> security concerns in this case.
>
> You will want to override get_queryset() to add in your GET arguments for 
> filtering after retrieving them from the request object. The GET arguments 
> are automatically captured in to a QueryDict attached to the request:
>
>
> https://docs.djangoproject.com/en/1.11/ref/request-response/#querydict-objects
>
> So, in your IndexSearchResults view:
>
> def get_queryset(self):
> queryset = super().get_queryset()
>
> # I can do something fancy with lists of tuples to cut down on the 
> code, but this is more readable
> pt = self.request.GET.get('pt')
> nb = self.request.GET.get('nb')
> nw = self.request.GET.get('nw')
> 
> if pt:
> queryset = queryset.filter(property_type=pt)
> if nb:
> queryset = queryset.filter(number_of_bedrooms=nb)
> if nw:
> queryset = queryset.filter(number_of_washrooms=nw)
>
> return queryset
>
>
> This should return a queryset to the view that will filter down the list 
> of objects matching the GET arguments.
>
>  
>
>>
>> *models.py*
>> Class BuyerListing(models.Model):
>>  BEDS_OPTION = (
>> (BEDS_0, '0 [Studio/Bachelor]'),
>> (BEDS_1, '1'),
>> (BEDS_1_1, '1+1'),
>> (BEDS_2, '2'),
>> (BEDS_2_1, '2+1'),
>> (BEDS_3, '3'),
>> (BEDS_3_1, '3+1'),
>> (BEDS_4, '4'),
>> (BEDS_5, '5'),
>> (BEDS_5_1, '5+'),
>> )
>>
>>  WASH_OPTION = (
>> (WASH_1, '1'),  
>> (WASH_2, '2'),  
>> (WASH_3, '3'),  
>> (WASH_4, '4'),  
>> (WASH_5, '5'),  
>> (WASH_5_1, '5+'),  
>> )
>>
>> PROPERTY_TYPE = (
>> (CONDO_APARTMENT, 'Condo Apartment'),
>> (DETACHED_HOUSE, 'Detached House'),
>> (SEMI_DETACHED, 'Semi-detached'),
>> (TOWNHOUSE, 'Townhouse'),
>> )
>>
>> property_type = models.CharField(max_length=50)
>> number_of_bedrooms = models.CharField(max_length=50, default=BEDS_0)
>> number_of_washrooms = models.CharField(max_length=50, default=WASH_1)
>>
>
> This might be correct, but generally you would use an IntegerField or 
> FloatField here rather than CharFields for the number of beds/baths. I'm 
> not aware of any exceptions where a number would not be used, but you may 
> know of some. Searching will be slightly faster using real number fields, 
> and you'll be able to filter using queries for 'more than 2 bedrooms' etc., 
> which you can't do with CharFields. I'd imagine that is a desired feature. 
>
>  -James
>

-- 
You recei

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

2017-10-26 Thread Jack
I have a model field for choosing multiple options.  Here is the code for 
models and forms:

*models.py:*
CONDO_APARTMENT = 'Condo Apartment'
DETACHED_HOUSE = 'Detached House'
SEMI_DETACHED = 'Semi-detached'
TOWNHOUSE = 'Townhouse'

PROPERTY_TYPE = (
(CONDO_APARTMENT, 'Condo Apartment'),
(DETACHED_HOUSE, 'Detached House'),
(SEMI_DETACHED, 'Semi-detached'),
(TOWNHOUSE, 'Townhouse'),
)

property_type = models.CharField(max_length=50, help_text="You can 
select more than 1 option")


*forms.py:*
property_type = forms.MultipleChoiceField(widget=forms.SelectMultiple, 
choices=BuyerListing.PROPERTY_TYPE)


Let's assume the selected choices were 'Condo Apartment' and 
'Semi-detached'.  The value stored on my database is this - ['Condo 
Apartment', 'Semi-detached']

Now this is in a list format, which makes sense, but it seems to have been 
converted to a string.  When I try to call on property_type in a .html 
document...

{% for property in model.property_type %}
{{ property }}
{% endfor %}

The result is displayed in singular characters, like this:

[
'
C
o
n
d
o
 
a
p
.. and so on.  Instead I want the result to be the values in the list, like 
this:

Condo apartment
Semi-detached

How do I do this?  I tried experimenting with different model field types 
but CharField seems like the only appropriate one for MultipleChoiceField.

-- 
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/06ff88b7-4ec4-4ddc-a4da-af8e25e3c516%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Null characters in SQL query after having migrated to python 3.5.3

2017-10-26 Thread Etienne Robillard

Hi,

I successfully ported Django 1.4.22 to Python 3.5.3.

However, I'm getting a unexpected issue when attempting to fetch a new 
session key with the

_get_new_session_key() function.

Environment:


Request Method: GET
Request URL: http://localhost:8133/admin/

Django Version: 1.4.22
Python Version: 3.5.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sitemaps',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'satchmo_admin',
 'sorl.thumbnail',
 'keyedcache',
 'livesettings',
 'l10n',
 'satchmo_utils.thumbnail',
 'satchmo_store.contact',
 'satchmo_store.shop',
 'satchmo_store',
 'tax',
 'tax.modules.no',
 'tax.modules.area',
 'tax.modules.percent',
 'shipping',
 'product',
 'payment',
 'payment.modules.dummy',
 'payment.modules.paypal',
 'shipping',
 'satchmo_utils',
 'app_plugins',
 'billing')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'threaded_multihost.middleware.ThreadLocalMiddleware')


Traceback:
File "/home/erob/src/django-hotsauce-devel/lib/notmm/adapters/base.py" 
in get_response

  190. response = middleware_method(request, response)
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/middleware.py" 
in process_response

  44. request.session.save()
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/db.py" 
in save

  50. return self.create()
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/db.py" 
in create

  31. self._session_key = self._get_new_session_key()
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/base.py" 
in _get_new_session_key

  146. if not self.exists(session_key):
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/db.py" 
in exists
  27. return 
Session.objects.filter(session_key=session_key).exists()
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/models/query.py" 
in exists

  565. return self.query.has_results(using=self.db)
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/models/sql/query.py" 
in has_results

  441. return bool(compiler.execute_sql(SINGLE))
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/models/sql/compiler.py" 
in execute_sql

  818. cursor.execute(sql, params)
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/backends/util.py" 
in execute

  40. return self.cursor.execute(sql, params)
File 
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/backends/sqlite3/base.py" 
in execute

  344. return Database.Cursor.execute(self, query, params)

Exception Type: ValueError at /admin/
Exception Value: the query contains a null character

The sql query is:

('SELECT (\x00) AS "a" FROM "django_session" WHERE '
 '"django_session"."session_key" = ?  LIMIT 1')

And the session_key param is: '22fc98168d24a14fe40a3e8956d818ad'


Any idea how to remove the null character (\x00) from the query?

TIA,

Etienne

--
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/03fadef0-72bf-4d7e-7b9c-45ca9077dd02%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Simple Request

2017-10-26 Thread Mike Dewhirst

On 26/10/2017 3:08 AM, Ruifeng Hu wrote:

Hi All,

Is there anyone who can share with me some simples of Django, I just 
start learning Django!


STart here ...

https://docs.djangoproject.com/en/1.11/

Then here to see there are seven parts to the tutorial

https://docs.djangoproject.com/en/1.11/intro/

And start following the first part of the tutorial here ...

https://docs.djangoproject.com/en/1.11/intro/tutorial01/

I haven't looked at the following link but I note that a lot of people 
on this list recommend it ...


https://tutorial.djangogirls.org/en/

Although a quick glance tells me I should study parts of it.

Welcome to Django and good luck in your journey





Thank you!

Best Regards,

Ruifeng Hu

--
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/7ddf0376-71a8-4597-b9e8-d6de1301a339%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/748426d7-dd4b-0053-d384-83db12132b77%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.