datetime.date is not json serializable

2016-02-19 Thread elcaiaimar
Hello, 

I'm having a problem when I try to convert a python dictionary into a json 
dictionary (*json.dumps(results, ensure_ascii=False)*).
Everything is ok, but when there is a date as a valure of the dictionary I 
get this error: datetime.date is not json serializable. I don't know how to 
solve this.

Here my code:

mysqldb = get_mysql_db() cursor = mysqldb.cursor()# SQL query
cursor.execute("SELECT titulo, url from content_medios")
# getting the name of columns
columns = [column[0] for column in cursor.description]
 
# creating the dictionary
results = []
for row in cursor.fetchall():
 results.append(dict(zip(columns, row)))

# converting from py to json
jsonarray = json.dumps(results, ensure_ascii=False)
return jsonarray

mysqldb.close()





Thank you in advance

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


Why does Django allow Circular Model Relation

2016-02-19 Thread Eddilbert Macharia
Hello All,

I was working on a project, and realized that Django does not complain when 
you create Circular Model relationship even when creating migrations where 
i expected to have this complain

e.g.  the example does not make any sense as far as relationships go but it 
makes my point.


class User(models.Model):  
# ... 
product = models.ForeignKey("Product", on_delete=models.CASCADE)

class Products(models.Model): 
bought_buy = models.ForeignKey(User, on_delete=models.CASCADE)


why is this or whats the reasoning behind Django team allowing 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/306a328a-173b-47dc-8e58-12aab538d14b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django allow Circular Model Relation

2016-02-19 Thread Javier Guerra Giraldez
On 19 February 2016 at 13:00, Eddilbert Macharia  wrote:
> Hello All,
>
> I was working on a project, and realized that Django does not complain when
> you create Circular Model relationship even when creating migrations where i
> expected to have this complain

why would it complain?  it might be (sometimes) less than optimal, but
it's valid to have circular relationships.



-- 
Javier

-- 
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/CAFkDaoQJdgY8W%3DT7npsTmiyAipq4cP4oGqv6Q6mDW%3D%2B-PNp1qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django allow Circular Model Relation

2016-02-19 Thread Vadim Serdiuk
Why should it be complained? I know a lot of the same cases that may be 
applied.

пятница, 19 февраля 2016 г., 15:00:12 UTC+2 пользователь Eddilbert Macharia 
написал:
>
> Hello All,
>
> I was working on a project, and realized that Django does not complain 
> when you create Circular Model relationship even when creating migrations 
> where i expected to have this complain
>
> e.g.  the example does not make any sense as far as relationships go but 
> it makes my point.
>
>
> class User(models.Model):  
> # ... 
> product = models.ForeignKey("Product", on_delete=models.CASCADE)
> 
> class Products(models.Model): 
> bought_buy = models.ForeignKey(User, on_delete=models.CASCADE)
>
>
> why is this or whats the reasoning behind Django team allowing 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/7e4469b9-2b6a-43a1-801e-d6db2cd56628%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.9 + DRF causing strange issues

2016-02-19 Thread joe . simpson
Hi,

I'm having a strange issue with Django 1.9 and Django Rest Framework 3.3. 
Most of the upgrade went well apart from one endpoint failing for a reason 
I can't figure out myself.

Here's the traceback:

Traceback (most recent call last):
  File "/home/ubuntu/something/sfm/somethingelse/tests/test_account.py", 
line 54, in test_get_banks
response = self.client.get(reverse('somethingelse-settlement-list'))
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/test/client.py",
 
line 503, in get
**extra)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/test/client.py",
 
line 304, in get
return self.generic('GET', path, secure=secure, **r)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/test/client.py",
 
line 380, in generic
return self.request(**r)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/test/client.py",
 
line 467, in request
six.reraise(*exc_info)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/core/handlers/base.py",
 
line 174, in get_response
response = self.process_exception_by_middleware(e, request)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/core/handlers/base.py",
 
line 172, in get_response
response = response.render()
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/template/response.py",
 
line 160, in render
self.content = self.rendered_content
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/rest_framework/response.py",
 
line 71, in rendered_content
ret = renderer.render(self.data, media_type, context)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/rest_framework/renderers.py",
 
line 172, in render
return template_render(template, context, request=request)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/rest_framework/compat.py",
 
line 232, in template_render
return template.render(context, request=request)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/template/backends/django.py",
 
line 92, in render
context = make_context(context, request)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/template/context.py",
 
line 291, in make_context
context.push(original_context)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/template/context.py",
 
line 61, in push
return ContextDict(self, *dicts, **kwargs)
  File 
"/home/ubuntu/virtualenvs/venv-system/local/lib/python2.7/site-packages/django/template/context.py",
 
line 20, in __init__
super(ContextDict, self).__init__(*args, **kwargs)
ValueError: dictionary update sequence element #0 has length 5; 2 is 
required

Thanks in advance if anyone knows what's going on.

-- 
Legal status: Any views or opinions are solely those of the sender and do 
not necessarily represent those of SF Software Ltd unless expressly stated 
in the body of the text of the email, this email is not intended to form a 
binding contract.

Confidentiality: this communication may contain information that is 
confidential and/or privileged and is for the exclusive use of the intended 
recipient(s). Any form of distribution, copying or use of this 
communication by anyone else is strictly prohibited. If you have received 
this communication in error, please reply to this message or telephone +44 
(0)845 310 1788 and delete this communication and destroy any copies. 

Security: this communication has been created and sent in the knowledge 
that internet e-mail is not secure. We strongly advise you to understand 
and to be aware of the lack of security when e-mailing us. If you 
communicate with us via e-mail, we will assume that you accept the security 
risk and that you authorise us to communicate with you in the same format. 
The sender therefore does not accept liability for any errors or omissions 
in the contents of this message, which arise as a result of e-mail 
transmission. 

Warning: Although we take reasonable precautions to ensure no viruses are 
present in this email, we cannot accept responsibility for any loss or 
damage arising from the use of this email or attachments. 

-
In compliance with Directive on Disclosure, The Companies Regulations 2006, 
effective 01 January 2007 talktopebble.co.uk,schoolfund.co.uk, 
schoolfundfinder.co.uk, easyusbooks.co.uk, clubfund.co.uk are domain names 
registered to SF Software Limited.

SF Software Limited is a company registered in England and Wales with 
company number: 05580540. Our trading name is Pebble our trading address 
and registered office is: Media Exchange Three,

TypeError: view must be a callable or a list/tuple in the case of include()

2016-02-19 Thread ruben . charleville
Hi there. To test out django I created a Work_manager for a site, and 
created this for he urls.py:

from django.conf.urls import include, url
 # from django.contrib import admin

urlpatterns = [
   # url(r'^admin/', admin.site.urls),
url(r'^$', 'TasksManager.views.index.page'),
url(r'^index$', 'TasksManager.views.index.page')
]

In the TasksManager/views/index.py:

# - * - Coding: utf -8 - * -
from django.http import HttpResponse
# View for index page.
def page(request):
return HttpResponse("Testing...")

Yet when I run the program: python manage.py runserver 127.0.0.1:8000 I get 
the response: 

Unhandled exception in thread started by  
Traceback (most recent call last): 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/utils/autoreload.py",
 
line 226, in wrapper 
   fn(*args, **kwargs) 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/management/commands/runserver.py",
 
line 116, in inner_run 
   self.check(display_num_errors=True) 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/management/base.py",
 
line 366, in check 
   include_deployment_checks=include_deployment_checks, 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/checks/registry.py",
 
line 75, in run_checks 
   new_errors = check(app_configs=app_configs) 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/checks/urls.py",
 
line 13, in check_url_config 
   return check_resolver(resolver) 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/checks/urls.py",
 
line 23, in check_resolver 
   for pattern in resolver.url_patterns: 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/utils/functional.py",
 
line 35, in __get__ 
   res = instance.__dict__[self.name] = self.func(instance) 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/urls/resolvers.py",
 
line 297, in url_patterns 
   patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module) 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/utils/functional.py",
 
line 35, in __get__ 
   res = instance.__dict__[self.name] = self.func(instance) 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/urls/resolvers.py",
 
line 290, in urlconf_module 
   return import_module(self.urlconf_name) 
 File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
   __import__(name) 
 File "/home/benedict/Work_manager/Work_manager/urls.py", line 21, in 
 
   url(r'^$', 'TasksManager.views.index.page'), 
 File 
"/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/conf/urls/__init__.py",
 
line 85, in url 
   raise TypeError('view must be a callable or a list/tuple in the case of 
include().') 
TypeError: view must be a callable or a list/tuple in the case of include().


Some help would be much appreciated.

Ruben

-- 
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/1c6584a6-bc61-4104-be27-6fbeffba9e5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: datetime.date is not json serializable

2016-02-19 Thread Tim Graham
datetime isn't JSON serializable by default. Django includes a custom 
encoder which handles datetime and some other types. You can use it like 
this:

from django.core.serializers.json import DjangoJSONEncoder
data =  json.dumps(data, cls=DjangoJSONEncoder)

On Friday, February 19, 2016 at 3:02:48 AM UTC-5, elcaiaimar wrote:
>
> Hello, 
>
> I'm having a problem when I try to convert a python dictionary into a json 
> dictionary (*json.dumps(results, ensure_ascii=False)*).
> Everything is ok, but when there is a date as a valure of the dictionary I 
> get this error: datetime.date is not json serializable. I don't know how to 
> solve this.
>
> Here my code:
>
> mysqldb = get_mysql_db() cursor = mysqldb.cursor()# SQL query
> cursor.execute("SELECT titulo, url from content_medios")
> # getting the name of columns
> columns = [column[0] for column in cursor.description]
>  
> # creating the dictionary
> results = []
> for row in cursor.fetchall():
>  results.append(dict(zip(columns, row)))
>
> # converting from py to json
> jsonarray = json.dumps(results, ensure_ascii=False)
> return jsonarray
>
> mysqldb.close()
>
>
>
>
>
> Thank you in advance
>
>

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


Re: TypeError: view must be a callable or a list/tuple in the case of include()

2016-02-19 Thread Tim Graham
You need to import your views and reference the callable as described at 
https://docs.djangoproject.com/en/stable/topics/http/urls/#example.

Referencing the view by string using patterns() is deprecated:
https://docs.djangoproject.com/en/stable/releases/1.8/#django-conf-urls-patterns

On Friday, February 19, 2016 at 8:55:44 AM UTC-5, ruben.ch...@gmail.com 
wrote:
>
> Hi there. To test out django I created a Work_manager for a site, and 
> created this for he urls.py:
>
> from django.conf.urls import include, url
>  # from django.contrib import admin
>
> urlpatterns = [
># url(r'^admin/', admin.site.urls),
> url(r'^$', 'TasksManager.views.index.page'),
> url(r'^index$', 'TasksManager.views.index.page')
> ]
>
> In the TasksManager/views/index.py:
>
> # - * - Coding: utf -8 - * -
> from django.http import HttpResponse
> # View for index page.
> def page(request):
> return HttpResponse("Testing...")
>
> Yet when I run the program: python manage.py runserver 127.0.0.1:8000 I 
> get the response: 
>
> Unhandled exception in thread started by  0x7f4cd2aaf410> 
> Traceback (most recent call last): 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/utils/autoreload.py",
>  
> line 226, in wrapper 
>fn(*args, **kwargs) 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/management/commands/runserver.py",
>  
> line 116, in inner_run 
>self.check(display_num_errors=True) 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/management/base.py",
>  
> line 366, in check 
>include_deployment_checks=include_deployment_checks, 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/checks/registry.py",
>  
> line 75, in run_checks 
>new_errors = check(app_configs=app_configs) 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/checks/urls.py",
>  
> line 13, in check_url_config 
>return check_resolver(resolver) 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/core/checks/urls.py",
>  
> line 23, in check_resolver 
>for pattern in resolver.url_patterns: 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/utils/functional.py",
>  
> line 35, in __get__ 
>res = instance.__dict__[self.name] = self.func(instance) 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/urls/resolvers.py",
>  
> line 297, in url_patterns 
>patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module) 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/utils/functional.py",
>  
> line 35, in __get__ 
>res = instance.__dict__[self.name] = self.func(instance) 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/urls/resolvers.py",
>  
> line 290, in urlconf_module 
>return import_module(self.urlconf_name) 
>  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in 
> import_module 
>__import__(name) 
>  File "/home/benedict/Work_manager/Work_manager/urls.py", line 21, in 
>  
>url(r'^$', 'TasksManager.views.index.page'), 
>  File 
> "/usr/local/lib/python2.7/dist-packages/Django-1.10.dev20160212033127-py2.7.egg/django/conf/urls/__init__.py",
>  
> line 85, in url 
>raise TypeError('view must be a callable or a list/tuple in the case of 
> include().') 
> TypeError: view must be a callable or a list/tuple in the case of 
> include().
>
>
> Some help would be much appreciated.
>
> Ruben
>

-- 
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/ad6e60d6-47f4-4ff7-a22e-b50d66bc50fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django allow Circular Model Relation

2016-02-19 Thread Eddilbert Macharia
Hello vadim when would such a relationship be needed I'm curious 

-- 
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/fbf2ef33-9309-44ce-aa73-f0238264589c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django allow Circular Model Relation

2016-02-19 Thread Tim Chase
On 2016-02-19 07:29, Eddilbert Macharia wrote:
> Hello vadim when would such a relationship be needed I'm curious 

Think of a hierarchy at a company.  Most employees have a
supervisor.  So your table would reference the supervisor in the same
table:

  class Employee(models.Model):
name = ...
# ...
supervisor = models.ForeignKey("Employee")

You can then query for a person's manager, as well as use the
reverse relationship to find out the employees that a person manages.

-tkc


-- 
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/20160219100458.73d825f7%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Re: null datetime field and json fixtures

2016-02-19 Thread Malik Rumi
In [1]: import uuid

In [2]: uuid.UUID('61877565-5fe5-4175-9f2b-d24704df0b74')
Out[2]: UUID('61877565-5fe5-4175-9f2b-d24704df0b74')

BUT

In [3]: uuid.UUID4('61877565-5fe5-4175-9f2b-d24704df0b74')
---
AttributeErrorTraceback (most recent call last)
 in ()
> 1 uuid.UUID4('61877565-5fe5-4175-9f2b-d24704df0b74')

AttributeError: 'module' object has no attribute 'UUID4'


So uuid.UUID4() [or 3 or whatever] can only be used a certain way, as in
Michael's example?

The remaining question for me, then, is *what is the proper format *for a
uuid in a json fixture, or any other document I am trying to mass import
into Django?

61877565-5fe5-4175-9f2b-d24704df0b74 - (apparently not)

'61877565-5fe5-4175-9f2b-d24704df0b74'

('61877565-5fe5-4175-9f2b-d24704df0b74')

UUID('61877565-5fe5-4175-9f2b-d24704df0b74')

urn:uuid('61877565-5fe5-4175-9f2b-d24704df0b74')

some other variation I haven't come up with yet?

Here is a portion of my json document:

[{"model": "essell.Code", "fields": { "uuid":
"48189959-be4c-4f10-819a-f1657061b3cd", "arrow": "Amendment II",
"shorttitle": "", "popularname": "Keep & Bear Arms", "acronym": "",
"offcite": "", "brokenarrow": "", "slug": "amendment-ii-keep-bear-arms",
"codetext": "A well regulated Militia, being necessary to the security of a
free State, the right of the people to keep and bear Arms, shall not be
infringed.", "effdate": "1792-03-13", "sunsetdate": "", "sunsetcause":
"''", "postdate": "2016-02-05 13:06:53.20548-06", "crossref": "''",
"codekind": "Article", "codekindsortseq": "1", "codelevel": "Constitution",
"codelevelsortseq": "1", "siblingrank": "11", "childof_id": "",
"jurisdiction_id": "e6e11b06-ea3b-4e98-a31f-9a83447ad884"} }, {"model"


As you can see, the uuid is double quoted, but so are all the keys and
values. This is normal json format as I understand it. So should the uuid
be single quoted inside the double quotes? i.e.

"'61877565-5fe5-4175-9f2b-d24704df0b74'"

How do I get this done? Thanks.




On Thu, Feb 18, 2016 at 4:10 PM, James Schneider 
wrote:

>
>
> On Thu, Feb 18, 2016 at 8:20 AM, Malik Rumi 
> wrote:
>
>> James,
>>
>> I used csvkit csvkit.readthedocs.org/en/latest/index.html to convert the
>> csv to json.
>>
>
> Looks legit. I'll just assume it creates syntactically correct JSON,
> otherwise it probably wouldn't last long as a public package.
>
>
>>
>> On Wednesday, February 17, 2016 at 7:05:59 PM UTC-6, James Schneider
>> wrote:
>>>
>>>
 The uuid.UUID() function is somewhat forgiving when it comes to
>>> providing values. See https://docs.python.org/3.5/library/uuid.html.
>>> Does the UUID in your JSON data match any of those formats? The only common
>>> format for a UUID that I've seen that doesn't match any of those formats
>>> would be '----' which is a string that
>>> contains dashes, but no surrounding braces. I believe that's the format
>>> that is pulled when using UUID's from Django installations by default. I'm
>>> actually surprised the Python UUID library doesn't support it, but maybe
>>> it's one of those RFC things that specifies the formats that must be
>>> accepted.
>>>
>>
>> Okay, THIS really bothers me for a couple of reasons. 1) Yes, my uuids
>> are in the 8-4-4-4-12 format. 2) Yes, this comes from using the uuidfield
>> as recommended in the docs
>> https://docs.djangoproject.com/es/1.9/ref/models/fields/#uuidfield 3)
>> You're right, this 8-4-4-4-12 format IS NOT on the Python docs page you
>> referred me to.
>>
>
> Yes, that is a bit confusing, and admittedly fooled me as well. I only
> glanced at the tables of available formats and didn't look at the examples
> below. I should have known better since I did some other work with UUID's a
> short while ago in the same format and didn't run into an issue.
>
>
>>
>>
> How can Django say this is based on the Python uuid module when it does
>> not comply? What GOOD is it if it does not comply? Now maybe there is some
>> internal workings that hack a valid Python format. My guess
>>
> is UUID('urn:uuid:12345678-1234-5678-1234-567812345678'). It wouldn't be
>> that hard to strip off the urn:uuid, and I know for a fact, because I've
>> seen it with my own eyes, there is code to strip out the dashes. But
>> essentially you are saying that my problems are NOT JSON (which I had
>> started to suspect anyway, see
>> http://stackoverflow.com/questions/35463713/badly-formed-hexadecimal-uuid-string-error-in-django-fixture-json-uuid-conversi
>>  2nd Update. But you also seem to be saying this is not a bug, but a
>> 'feature', because Django knows their uuid format does not comply. But that
>> doesn't make sense to me. How is it to be effectively used without
>> universal Python compliance? Why isn't this lack of compliance documented?
>> What is the workaround, or does it just mean junk the Django uuid
>> altogether as not ready for prime time and save you

Re: Why does Django allow Circular Model Relation

2016-02-19 Thread Alex Heyden
You would use it any time the relationship means something different. It
would generally be inappropriate to use it as a simple backwards
relationship (Django does this for you), but there's no reason not to have
multiple relationships in a number of directions. In an HR system, someone
could be both my beneficiary and my employee.

On Fri, Feb 19, 2016 at 9:29 AM, Eddilbert Macharia 
wrote:

> Hello vadim when would such a relationship be needed I'm curious
>
> --
> 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/fbf2ef33-9309-44ce-aa73-f0238264589c%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%2Bv0ZYWJMybd4EaFhYFA2DgBdrhLeoqR2Ko46%2BcB_3250R-eSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


problem with DJANGO_SETTINGS_MODULE

2016-02-19 Thread bob gailer
After several days of running my server with no problem I am suddenly 
confronted with:


"django.core.exceptions.ImproperlyConfigured: Requested setting 
DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must 
either define the environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings."


Researching the django docs did not help.

 settings.py is in  .../mysite/mysite as per the tutorial. I am using a 
virtualenv


Question:s why the change? It was working!

There is no DJANGO_SETTINGS_MODULE environment variable

I've tried (following the documentation)
set DJANGO_SETTINGS_MODULE=mysite.setting

which results in (very long traceback) ending in
ImportError: No module named 'mysite

I am running version 1.9, python 3,5. windows 10.

Please guide me.

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


Re: null datetime field and json fixtures

2016-02-19 Thread James Schneider
>
> The only uuid currently in this fixture is the one I got from Django when
> I put another model (only one row) in with a fixture (no date field) and it
> worked. I needed the uuid of that object to put into the foreign key of the
> model I am having trouble with now.
>
>
>
So I was sniffing around the Internet for ideas, and I came across this SO:
http://stackoverflow.com/questions/32445546/django-uuidfield-modelfield-causes-error-in-django-admin-badly-formed-hexadecim

You mentioned that this is the only UUID in your fixture (which seems
strange). Do you have a mixture of UUID's and integer PK's? It's possible
that the UUID errors are actually resulting from an integer being passed to
uuid.UUID() rather than one of your real UUID's.

-James

-- 
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%2Be%2BciX%3Dz0KEvJJdMF7%3D3MKrWsuvhO6P%2B6%2BRso_QYM4Y6%3D4gsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.9 + DRF causing strange issues

2016-02-19 Thread James Schneider
On Fri, Feb 19, 2016 at 5:51 AM,  wrote:

> Hi,
>
> I'm having a strange issue with Django 1.9 and Django Rest Framework 3.3.
> Most of the upgrade went well apart from one endpoint failing for a reason
> I can't figure out myself.
>
> Here's the traceback:
>
> Traceback (most recent call last):
>   File "/home/ubuntu/something/sfm/somethingelse/tests/test_account.py",
> line 54, in test_get_banks
> response = self.client.get(reverse('somethingelse-settlement-list'))
>
>
Can you run the shell and see what the result of reverse('
somethingelse-settlement-list')?

Also, this SO post seems to have a resolution for this problem:
https://github.com/tomchristie/django-rest-framework/issues/1295

Looks to be an issue between reverse and the setup in urls.py.

-James

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


Re: Django 1.9 + DRF causing strange issues

2016-02-19 Thread James Schneider
>
>
> Also, this SO post seems to have a resolution for this problem:
> https://github.com/tomchristie/django-rest-framework/issues/1295
>


Whoops...

s/SO post/Github issue/

-James

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


Re: TypeError: view must be a callable or a list/tuple in the case of include()

2016-02-19 Thread ruben . charleville
Many thanks Tim! Problem solved.

Best Regards,
Ruben

-- 
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/35dbb900-eed1-4877-adc8-45a92af3002f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Gmail Django

2016-02-19 Thread setivolkylany
my settings

EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'webmaster@vaility'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_FILE_PATH = None
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'lv210493'
EMAIL_HOST_USER = 'setivolkyl...@gmail.com'
EMAIL_PORT = 587
EMAIL_SUBJECT_PREFIX = '[Django] '
EMAIL_TIMEOUT = None
EMAIL_USE_TLS = True
SERVER_EMAIL = 'root@vaility'  # email for errors

Every time I had next error

SMTPAuthenticationError: (534, b'5.7.14 
 Please log in via your web browser 
and\n5.7.14 then try again.\n5.7.14  Learn more at\n5.7.14 
 https://support.google.com/mail/answer/78754 eb3sm1684842lbc.31 - gsmtp')

I again sigin in my account, but not result


-- 
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/d2feb1b0-56c0-41ee-9a61-75acf91f5b90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


key specification without a key length

2016-02-19 Thread Sammi Singh
Hi,

I'm new to Django and facing this error "*django.db.utils.OperationalError: 
(1170, "BLOB/TEXT column 'id' used in key specification without a key 
length")*"

Here is my code:

class Steps(models.Model):

author = models.ForeignKey(User)

#id = models.TextField(primary_key=True)

id = models.CharField(primary_key=True, max_length = 32)

text = models.TextField()

status = models.TextField()

step_id = models.TextField(null=True)

release_id = models.TextField(null=True)

region = models.TextField(null=True)

# Time is a rhinocerous

updated = models.DateTimeField(auto_now=True)

created = models.DateTimeField(auto_now_add=True)


class UserConfig(models.Model):

author = models.ForeignKey(User)

#id = models.TextField(primary_key=True)

id = models.CharField(primary_key=True, max_length = 32)

co_range = models.TextField()

tu_range = models.TextField()

st_range = models.TextField()

de_host = models.TextField()

in_host1 = models.TextField()

in_host2 = models.TextField()

in_host3 = models.TextField()

co_host = models.TextField()

vp_name = models.TextField()


# Time is a rhinocerous

updated = models.DateTimeField(auto_now=True)

created = models.DateTimeField(auto_now_add=True)


Any help would be appreciated..


Regards

Sammi

-- 
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/5100d863-f887-4b97-9ea4-95227ab99bdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


1170, "BLOB/TEXT column

2016-02-19 Thread Sammi Singh
Hi,

I'm new wot Django and stuck with below error when run migrate. Any 
suggestions??

*django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'id' used in 
key specification without a key length")*

Here is my code:

class Steps(models.Model):

author = models.ForeignKey(User)

#id = models.TextField(primary_key=True)

id = models.CharField(primary_key=True, max_length = 32)

text = models.TextField()

status = models.TextField()

step_id = models.TextField(null=True)

release_id = models.TextField(null=True)

region = models.TextField(null=True)

# Time is a rhinocerous

updated = models.DateTimeField(auto_now=True)

created = models.DateTimeField(auto_now_add=True)


class Meta:

ordering = ['created']


def __unicode__(self):

return self.text+' - '+self.author.username


class UserConfig(models.Model):

author = models.ForeignKey(User)

#id = models.TextField(primary_key=True)

id = models.CharField(primary_key=True, max_length = 32)

co_range = models.TextField()

tu_range = models.TextField()

st_range = models.TextField()

de_host = models.TextField()

in_host1 = models.TextField()

in_host2 = models.TextField()

in_host3 = models.TextField()

co_host = models.TextField()

vp_name = models.TextField()


# Time is a rhinocerous

updated = models.DateTimeField(auto_now=True)

created = models.DateTimeField(auto_now_add=True)


class Meta:

ordering = ['created']


def __unicode__(self):

return self.text+' - '+self.author.username

Regards
Sammi

-- 
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/7f1a4f9c-7a75-4202-ac3b-2e8f369ea2e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Gmail Django

2016-02-19 Thread m1chael
You may have to dig deep in Google's settings and turn off a lot of
security, don't give up, this is an annoying one.

On Fri, Feb 19, 2016 at 3:17 PM,  wrote:

> my settings
>
> EMAIL_USE_TLS = True
> DEFAULT_FROM_EMAIL = 'webmaster@vaility'
> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
> EMAIL_FILE_PATH = None
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_HOST_PASSWORD = 'lv210493'
> EMAIL_HOST_USER = 'setivolkyl...@gmail.com'
> EMAIL_PORT = 587
> EMAIL_SUBJECT_PREFIX = '[Django] '
> EMAIL_TIMEOUT = None
> EMAIL_USE_TLS = True
> SERVER_EMAIL = 'root@vaility'  # email for errors
>
> Every time I had next error
>
> SMTPAuthenticationError: (534, b'5.7.14 <
> https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsy1\n5.7.14
> Hm68kFAtFDZroMBYjdIl_EN2We7HAeUt2puFzfziG5SUr_1ZyN9UgsCfV_M_RKiMRBEYw9\n5.7.14
> F4k9yCuW8gTxTgcL5lV4ofXgDXumhhKkh7yc-BvkyqL1NBPZv_WXNPD7qQQUhUO8-KikpH\n5.7.14
> ct0vd7ZvgpfIF48HMJKlSiICSCHsmwaqU9Atwc5dx4RlcMJ7Bcn63ePgmwruSeBHh4rKOB\n5.7.14
> nGaIDTGZyrou7ao5k4lm5t6wxosA> Please log in via your web browser
> and\n5.7.14 then try again.\n5.7.14  Learn more at\n5.7.14
> https://support.google.com/mail/answer/78754 eb3sm1684842lbc.31 - gsmtp')
>
> I again sigin in my account, but not result
>
>
> --
> 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/d2feb1b0-56c0-41ee-9a61-75acf91f5b90%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/CAAuoY6OQM72VC%3DRYzVXCb583HQLO-MRha0LCquLzyosKTJWxHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Gmail Django

2016-02-19 Thread Daniel Wilcox
You should generate a certificate to use TLS (even something self signed,
or try Let's Encrypt and get a free cert from there).  Other than that we
have the same settings and I've been sending mail successfully with almost
identical settings the past day or so.

I presume you are using an app-specific password.  Another difference I see
is that I removed the default from setting since it doesn't match the host
user (and I don't expect that google would deliver it).

Best of luck!

On Fri, Feb 19, 2016 at 12:17 PM,  wrote:

> my settings
>
> EMAIL_USE_TLS = True
> DEFAULT_FROM_EMAIL = 'webmaster@vaility'
> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
> EMAIL_FILE_PATH = None
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_HOST_PASSWORD = 'lv210493'
> EMAIL_HOST_USER = 'setivolkyl...@gmail.com'
> EMAIL_PORT = 587
> EMAIL_SUBJECT_PREFIX = '[Django] '
> EMAIL_TIMEOUT = None
> EMAIL_USE_TLS = True
> SERVER_EMAIL = 'root@vaility'  # email for errors
>
> Every time I had next error
>
> SMTPAuthenticationError: (534, b'5.7.14 <
> https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsy1\n5.7.14
> Hm68kFAtFDZroMBYjdIl_EN2We7HAeUt2puFzfziG5SUr_1ZyN9UgsCfV_M_RKiMRBEYw9\n5.7.14
> F4k9yCuW8gTxTgcL5lV4ofXgDXumhhKkh7yc-BvkyqL1NBPZv_WXNPD7qQQUhUO8-KikpH\n5.7.14
> ct0vd7ZvgpfIF48HMJKlSiICSCHsmwaqU9Atwc5dx4RlcMJ7Bcn63ePgmwruSeBHh4rKOB\n5.7.14
> nGaIDTGZyrou7ao5k4lm5t6wxosA> Please log in via your web browser
> and\n5.7.14 then try again.\n5.7.14  Learn more at\n5.7.14
> https://support.google.com/mail/answer/78754 eb3sm1684842lbc.31 - gsmtp')
>
> I again sigin in my account, but not result
>
>
> --
> 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/d2feb1b0-56c0-41ee-9a61-75acf91f5b90%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/CAGq7KhqUEhjqqnM5cNj1mCbTGXjLj5exJHNakwVnQdjAgaXrug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Gmail Django

2016-02-19 Thread Luis Zárate
Those are your real credentials, hurry up and change the password, you must
never post your real credentials in public mail list.

M1chael is right you need to change the gmail settings for allow login with
insecure applications.

2016-02-19 16:03 GMT-06:00 Daniel Wilcox :

> You should generate a certificate to use TLS (even something self signed,
> or try Let's Encrypt and get a free cert from there).  Other than that we
> have the same settings and I've been sending mail successfully with almost
> identical settings the past day or so.
>
> I presume you are using an app-specific password.  Another difference I
> see is that I removed the default from setting since it doesn't match the
> host user (and I don't expect that google would deliver it).
>
> Best of luck!
>
> On Fri, Feb 19, 2016 at 12:17 PM,  wrote:
>
>> my settings
>>
>> EMAIL_USE_TLS = True
>> DEFAULT_FROM_EMAIL = 'webmaster@vaility'
>> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
>> EMAIL_FILE_PATH = None
>> EMAIL_HOST = 'smtp.gmail.com'
>> EMAIL_HOST_PASSWORD = 'lv210493'
>> EMAIL_HOST_USER = 'setivolkyl...@gmail.com'
>> EMAIL_PORT = 587
>> EMAIL_SUBJECT_PREFIX = '[Django] '
>> EMAIL_TIMEOUT = None
>> EMAIL_USE_TLS = True
>> SERVER_EMAIL = 'root@vaility'  # email for errors
>>
>> Every time I had next error
>>
>> SMTPAuthenticationError: (534, b'5.7.14 <
>> https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsy1\n5.7.14
>> Hm68kFAtFDZroMBYjdIl_EN2We7HAeUt2puFzfziG5SUr_1ZyN9UgsCfV_M_RKiMRBEYw9\n5.7.14
>> F4k9yCuW8gTxTgcL5lV4ofXgDXumhhKkh7yc-BvkyqL1NBPZv_WXNPD7qQQUhUO8-KikpH\n5.7.14
>> ct0vd7ZvgpfIF48HMJKlSiICSCHsmwaqU9Atwc5dx4RlcMJ7Bcn63ePgmwruSeBHh4rKOB\n5.7.14
>> nGaIDTGZyrou7ao5k4lm5t6wxosA> Please log in via your web browser
>> and\n5.7.14 then try again.\n5.7.14  Learn more at\n5.7.14
>> https://support.google.com/mail/answer/78754 eb3sm1684842lbc.31 - gsmtp')
>>
>> I again sigin in my account, but not result
>>
>>
>> --
>> 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/d2feb1b0-56c0-41ee-9a61-75acf91f5b90%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/CAGq7KhqUEhjqqnM5cNj1mCbTGXjLj5exJHNakwVnQdjAgaXrug%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

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


Re: key specification without a key length

2016-02-19 Thread Mike Dewhirst

On 20/02/2016 6:26 AM, Sammi Singh wrote:

Hi,

I'm new to Django and facing this error
"*/django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'id' used
in key specification without a key length")/*"

Here is my code:

class Steps(models.Model):

    author = models.ForeignKey(User)

#Â  Â  id = models.TextField(primary_key=True)


I don't think it makes sense to use a text field as a primary key. If 
you don't want to use the default primary key (and you need a strong 
case to want something else) and you really want a string as a primary 
key use models.CharField(max_length=99, primary_key=True)





    id = models.CharField(primary_key=True, max_length = 32)

    text = models.TextField()

    status = models.TextField()

    step_id = models.TextField(null=True)

    release_id = models.TextField(null=True)

    region = models.TextField(null=True)

    # Time is a rhinocerous

    updated = models.DateTimeField(auto_now=True)

    created = models.DateTimeField(auto_now_add=True)


class UserConfig(models.Model):

    author = models.ForeignKey(User)

#Â  Â  id = models.TextField(primary_key=True)

    id = models.CharField(primary_key=True, max_length = 32)

    co_range = models.TextField()

    tu_range = models.TextField()

    st_range = models.TextField()

    de_host = models.TextField()

    in_host1 = models.TextField()

    in_host2 = models.TextField()

    in_host3 = models.TextField()

    co_host = models.TextField()

    vp_name = models.TextField()


    # Time is a rhinocerous

    updated = models.DateTimeField(auto_now=True)

    created = models.DateTimeField(auto_now_add=True)


Any help would be appreciated..


Regards

Sammi

--
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/5100d863-f887-4b97-9ea4-95227ab99bdf%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/56C7A494.4060103%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: null datetime field and json fixtures

2016-02-19 Thread Michal Petrucha
On Fri, Feb 19, 2016 at 10:20:42AM -0600, Malik Rumi wrote:
> In [1]: import uuid
> 
> In [2]: uuid.UUID('61877565-5fe5-4175-9f2b-d24704df0b74')
> Out[2]: UUID('61877565-5fe5-4175-9f2b-d24704df0b74')
> 
> BUT
> 
> In [3]: uuid.UUID4('61877565-5fe5-4175-9f2b-d24704df0b74')
> ---
> AttributeErrorTraceback (most recent call last)
>  in ()
> > 1 uuid.UUID4('61877565-5fe5-4175-9f2b-d24704df0b74')
> 
> AttributeError: 'module' object has no attribute 'UUID4'
> 
> 
> So uuid.UUID4() [or 3 or whatever] can only be used a certain way, as in
> Michael's example?

There's no such thing as UUID4 in the Python uuid module -- there's
UUID (which is the class representing UUIDs), and there's the function
uuid4 (note that it's lowercase, it takes no arguments, and it will
return an instance of UUID).

> The remaining question for me, then, is *what is the proper format *for a
> uuid in a json fixture, or any other document I am trying to mass import
> into Django?
> 
> 61877565-5fe5-4175-9f2b-d24704df0b74 - (apparently not)
> 
> '61877565-5fe5-4175-9f2b-d24704df0b74'
> 
> ('61877565-5fe5-4175-9f2b-d24704df0b74')
> 
> UUID('61877565-5fe5-4175-9f2b-d24704df0b74')
> 
> urn:uuid('61877565-5fe5-4175-9f2b-d24704df0b74')
> 
> some other variation I haven't come up with yet?
> 
> Here is a portion of my json document:
> 
> [{"model": "essell.Code", "fields": { "uuid":
> "48189959-be4c-4f10-819a-f1657061b3cd", "arrow": "Amendment II",
> "shorttitle": "", "popularname": "Keep & Bear Arms", "acronym": "",
> "offcite": "", "brokenarrow": "", "slug": "amendment-ii-keep-bear-arms",
> "codetext": "A well regulated Militia, being necessary to the security of a
> free State, the right of the people to keep and bear Arms, shall not be
> infringed.", "effdate": "1792-03-13", "sunsetdate": "", "sunsetcause":
> "''", "postdate": "2016-02-05 13:06:53.20548-06", "crossref": "''",
> "codekind": "Article", "codekindsortseq": "1", "codelevel": "Constitution",
> "codelevelsortseq": "1", "siblingrank": "11", "childof_id": "",
> "jurisdiction_id": "e6e11b06-ea3b-4e98-a31f-9a83447ad884"} }, {"model"
> 
> 
> As you can see, the uuid is double quoted, but so are all the keys and
> values. This is normal json format as I understand it. So should the uuid
> be single quoted inside the double quotes? i.e.
> 
> "'61877565-5fe5-4175-9f2b-d24704df0b74'"
> 
> How do I get this done? Thanks.

The two UUIDs in that JSON snippet look correct at a first (and
second) glance. Have you tried using a debugger, or just a
quick-and-dirty print statement to see what value is being passed into
uuid.UUID that makes it raise an exception?

My guess would be that the JSON file contains a value somewhere that
is not a correct UUID, but I may be wrong, of course.

Regards,

Michal

-- 
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/20160219232920.GF880%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: 1170, "BLOB/TEXT column

2016-02-19 Thread Luis Zárate
Check your migrations, I think you use TextField the first time, run
makemigrations  and create the initial migrations, before you run migrate
django raise a exception so you change it for CharField and run
makemigrations  a second time and create the correction in the 002
migration but the initial migration has the problem so when you run migrate
again the problem persist.



El viernes, 19 de febrero de 2016, Sammi Singh 
escribió:
> Hi,
> I'm new wot Django and stuck with below error when run migrate. Any
suggestions??
>
> django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'id' used in
key specification without a key length")
>
> Here is my code:
>
> class Steps(models.Model):
>
> author = models.ForeignKey(User)
>
> #id = models.TextField(primary_key=True)
>
> id = models.CharField(primary_key=True, max_length = 32)
>
> text = models.TextField()
>
> status = models.TextField()
>
> step_id = models.TextField(null=True)
>
> release_id = models.TextField(null=True)
>
> region = models.TextField(null=True)
>
> # Time is a rhinocerous
>
> updated = models.DateTimeField(auto_now=True)
>
> created = models.DateTimeField(auto_now_add=True)
>
> class Meta:
>
> ordering = ['created']
>
> def __unicode__(self):
>
> return self.text+' - '+self.author.username
>
> class UserConfig(models.Model):
>
> author = models.ForeignKey(User)
>
> #id = models.TextField(primary_key=True)
>
> id = models.CharField(primary_key=True, max_length = 32)
>
> co_range = models.TextField()
>
> tu_range = models.TextField()
>
> st_range = models.TextField()
>
> de_host = models.TextField()
>
> in_host1 = models.TextField()
>
> in_host2 = models.TextField()
>
> in_host3 = models.TextField()
>
> co_host = models.TextField()
>
> vp_name = models.TextField()
>
> # Time is a rhinocerous
>
> updated = models.DateTimeField(auto_now=True)
>
> created = models.DateTimeField(auto_now_add=True)
>
> class Meta:
>
> ordering = ['created']
>
> def __unicode__(self):
>
> return self.text+' - '+self.author.username
>
> Regards
> Sammi
>
> --
> 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/7f1a4f9c-7a75-4202-ac3b-2e8f369ea2e6%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

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


Re: key specification without a key length

2016-02-19 Thread Luis Zárate
I response in the other mail, but I am curious
changing TextField for. CharField with max_length has big impact in the
database performance.

I saw you have a lot of TextFields so are you sure that you need all those
TextFields ? Or y
could you change those TextFields for CharFields with a small max_length ?

#id = models.TextField(primary_key=True)

id = models.CharField(primary_key=True, max_length = 32)




El viernes, 19 de febrero de 2016, Mike Dewhirst 
escribió:
> On 20/02/2016 6:26 AM, Sammi Singh wrote:
>>
>> Hi,
>>
>> I'm new to Django and facing this error
>> "*/django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'id' used
>> in key specification without a key length")/*"
>>
>> Here is my code:
>>
>> class Steps(models.Model):
>>
>> Â  Â  author = models.ForeignKey(User)
>>
>> #Â  Â  id = models.TextField(primary_key=True)
>
> I don't think it makes sense to use a text field as a primary key. If you
don't want to use the default primary key (and you need a strong case to
want something else) and you really want a string as a primary key use
models.CharField(max_length=99, primary_key=True)
>
>
>>
>> Â  Â  id = models.CharField(primary_key=True, max_length = 32)
>>
>> Â  Â  text = models.TextField()
>>
>> Â  Â  status = models.TextField()
>>
>> Â  Â  step_id = models.TextField(null=True)
>>
>> Â  Â  release_id = models.TextField(null=True)
>>
>> Â  Â  region = models.TextField(null=True)
>>
>> Â  Â  # Time is a rhinocerous
>>
>> Â  Â  updated = models.DateTimeField(auto_now=True)
>>
>> Â  Â  created = models.DateTimeField(auto_now_add=True)
>>
>>
>> class UserConfig(models.Model):
>>
>> Â  Â  author = models.ForeignKey(User)
>>
>> #Â  Â  id = models.TextField(primary_key=True)
>>
>> Â  Â  id = models.CharField(primary_key=True, max_length = 32)
>>
>> Â  Â  co_range = models.TextField()
>>
>> Â  Â  tu_range = models.TextField()
>>
>> Â  Â  st_range = models.TextField()
>>
>> Â  Â  de_host = models.TextField()
>>
>> Â  Â  in_host1 = models.TextField()
>>
>> Â  Â  in_host2 = models.TextField()
>>
>> Â  Â  in_host3 = models.TextField()
>>
>> Â  Â  co_host = models.TextField()
>>
>> Â  Â  vp_name = models.TextField()
>>
>>
>> Â  Â  # Time is a rhinocerous
>>
>> Â  Â  updated = models.DateTimeField(auto_now=True)
>>
>> Â  Â Â created = models.DateTimeField(auto_now_add=True)
>>
>>
>> Any help would be appreciated..
>>
>>
>> Regards
>>
>> Sammi
>>
>> --
>> 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/5100d863-f887-4b97-9ea4-95227ab99bdf%40googlegroups.com
>> <
https://groups.google.com/d/msgid/django-users/5100d863-f887-4b97-9ea4-95227ab99bdf%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/56C7A494.4060103%40dewhirst.com.au
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyPLG2Tnyqxz_6yHWDX_qHgjgRL2%2B-5wOHCa3b0GQYeiAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.