Re: Django storing byte string for image

2018-01-03 Thread James Schneider
On Jan 3, 2018 6:16 PM, wrote: As i am doing a django rest framework API for IOS mobile app currently, my >> partner told me that he will sent me a byte string for image. Then i have >> to convert the byte into image when a user request it. > > Storing the file in the DB (be it an image or ot

Django rest framework filtering foreign key value and setting userId = current user

2018-01-03 Thread cherngyorng
So i have a family and schedule model. Family is to add family member and schedule is to create schedule with family as a foreign key in it. But in both api, userId field is a drop down field to select which a user instead of using fix at the current userId. The code and more specific about my

Re: Django storing byte string for image

2018-01-03 Thread cherngyorng
As i am doing a django rest framework API for IOS mobile app currently, my >> partner told me that he will sent me a byte string for image. Then i have >> to convert the byte into image when a user request it. > > > I don't mean to store it into database. Its just i do not know how to do >>

Re: Update View not updating table when Rendering fields manually

2018-01-03 Thread Matemática A3K
On Wed, Jan 3, 2018 at 1:53 AM, Sumit Kumar wrote: > When I am using simply this > > > {% block content %} >{% csrf_token %} >{{ form }} > > {% endblock content %} >

Re: Handling Celery Connection Lost Problem

2018-01-03 Thread Matemática A3K
On Wed, Jan 3, 2018 at 6:25 AM, Mukul Mantosh wrote: > *I'm not sure about understanding you, where are you trying to call it > again? from ipython?* > > I am calling from Django, the code is inside the view. > > *def test(request):* > * try:* > *add.delay(2, 2)* > * except add.OperationalE

Re: 'str' object has no attribute 'tzinfo'

2018-01-03 Thread Inter Nemo
Field in models.py edit_date = models.DateTimeField('Edit the date', auto_now=True) -- 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..

Re: 'str' object has no attribute 'tzinfo'

2018-01-03 Thread Inter Nemo
(sorry for my bad english) i upgrade Django with 1.10 to 2.0 and and this error appeared. if i change my db field: UPDATE `articles` SET

Re: 'str' object has no attribute 'tzinfo'

2018-01-03 Thread Julio Biason
It looks like you're trying to localize a string, which is not a datetime object and, thus, doesn't have a tzinfo property. You'll have to convert your string to a datetime before trying to localize it. On Wed, Jan 3, 2018 at 3:42 PM, Inter Nemo wrote: > *Django:* 2.0.1 > *Error: * > >> 'str' o

'str' object has no attribute 'tzinfo'

2018-01-03 Thread Inter Nemo
*Django:* 2.0.1 *Error: * > 'str' object has no attribute 'tzinfo' > > *File:* ... \AppData\Local\Programs\Python\Python36\lib\site-packages\pytz\__init__.py in localize *Code:* if dt.tzinfo is not None: *Local vars:* Variable Value dt '-00-00 00:00:00.00' is_dst None se

Iterable object and Django StreamingHttpResponse

2018-01-03 Thread Felipe Buccioni
Hi I want to connect to internal http services with django and I need to buffer the output the http response of those services because some contents are very large. I am using python 3.6, django 2.0, `http.client` and the following code: class HTTPStreamIterAndClose(): def __init_

Re: Split API URLs to second project/settings/wsgi ?

2018-01-03 Thread Jason
Sounds like this is a good use case to integrate DRF to solve multiple problems. On Wednesday, January 3, 2018 at 7:57:46 AM UTC-5, guettli wrote: > > > > Am Dienstag, 2. Januar 2018 13:47:40 UTC+1 schrieb Jason: >> >> What you can do is split the backend into a REST API using >> http://www.dj

Re: Django storing byte string for image

2018-01-03 Thread Jason
For some additional reading on pros and cons of storing images in a database: https://www.quora.com/Is-it-a-bad-design-to-store-images-as-blobs-in-a-database https://dzone.com/articles/which-is-better-saving-files-in-database-or-in-fil https://dba.stackexchange.com/questions/736/is-it-better-to-s

Re: Wich OS for develop?

2018-01-03 Thread Jani Tiainen
Hi, There are also alternative ways to do development. Personally I use PyCharm Pro on a windows and osx with docker. That way my whole chain of development happens with consistent environments (within containers) and pretty much eliminates "works for me" issues. PyCharm also does have excellen

Re: Django storing byte string for image

2018-01-03 Thread Avraham Serour
I used this project once: http://django-db-file-storage.readthedocs.io/en/latest/ It seems it uses a TextField for the file bytes. I would expect django.contrib.postgres to implement a binary field, but it don't. I guess you can implement your own field type for bytea, psycopg maps bytes to byte

Re: Split API URLs to second project/settings/wsgi ?

2018-01-03 Thread guettli
Am Dienstag, 2. Januar 2018 13:47:40 UTC+1 schrieb Jason: > > What you can do is split the backend into a REST API using > http://www.django-rest-framework.org/ > > Refactor the views to share common logic, and you can have your template > renders bound to one view handler and an api call to an

Re: How to delete all the objects which are referring the current object without DELETE_CASCADE

2018-01-03 Thread Jani Tiainen
Hi, As I posted on other thread you can do that using meta api. But why you want to do that manually. DELETE_CASCADE does the same thing exactly. 3.1.2018 14.03 kirjoitti: > How to delete all the objects which are referring the current object > without DELETE_CASCADE > > -- > You received this

Re: Django storing byte string for image

2018-01-03 Thread Jani Tiainen
Hi, In general it is considered very bad practice to store files in database. Could you please tell why you need to store files to database instead of normal filesystem? 3.1.2018 14.03 kirjoitti: > What field should i use to store byte string so that i can later use it > for ByteIO to convert

Re: Write custom on delete Cascade

2018-01-03 Thread Jani Tiainen
Hi You need to get all reverse related fields using model meta API. If you want to make custom on_delete action see how CASCADE is made at https://github.com/django/django/blob/2cb6b7732dc7b172797cebb1e8f19be2de89e264/django/db/models/deletion.py#L14 3.1.2018 14.03 kirjoitti: Hi, How to get a

How to delete all the objects which are referring the current object without DELETE_CASCADE

2018-01-03 Thread mohitdubey2695
How to delete all the objects which are referring the current object without DELETE_CASCADE -- 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+unsubsc

Django storing byte string for image

2018-01-03 Thread cherngyorng
What field should i use to store byte string so that i can later use it for ByteIO to convert it into image ? As this is my first time doing on byte string to image, i am pretty lost on what i need to do. I tried using BinaryField for the image model but when checking the field out on Django a

Re: Django and Services

2018-01-03 Thread Kartik Arora
> > The difficulty you're having here is that you're trying to write Java > code in Python. :-) > > Unless there's something stateful about the UserService, there's no > reason for it to be in a class at all - create_user, create_friendship > etc can just be methods sitting in a module. > > A lit

Update View not updating table when Rendering fields manually

2018-01-03 Thread Sumit Kumar
When I am using simply this {% block content %} {% csrf_token %} {{ form }} {% endblock content %} It is updating my JobFinal Table I can see *POST /JobS

Write custom on delete Cascade

2018-01-03 Thread mohitdubey2695
Hi, How to get all the objects referring to the given object in Django? -- 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.

Re: Handling Celery Connection Lost Problem

2018-01-03 Thread Jani Tiainen
Hi. Trying to add task without running messaging backend (rabbitmq) should be consistently throwing out errors. Since it is not a django problem I suggest that you reach celery support channels for better responses. 3.1.2018 11.26 "Mukul Mantosh" kirjoitti: > *I'm not sure about understanding

Re: I can't print a queryset value.

2018-01-03 Thread 1351552...@qq.com
This will work: >>> for id in Review.objects.values_list('id',flat=True): ... print('ID:%d' % id) ... ID:1 ID:2 ID:3 ID:4 ID:5 ID:6 and i don't know what you say in ur problem2 wblueboat From: karlnaflnest Date: 2018-01-03 15:20 To: Django users Subject: I can't print a queryset value. I am

Re: Installing only social account from allauth

2018-01-03 Thread Andréas Kühne
See my answer on your previous post. Regarding using as little resources as possible - if you don't load / use the templates / views, they won't take any resources. As long as you don't map the urls to views, you won't even expose them - therefore nobody will be able to get to them. Regards, Andr

Re: Re-configuring allauth to fit custom specifications

2018-01-03 Thread Andréas Kühne
Hi, I haven't used allauth specifically, but you can always do things like this: 1. Override the default templates by including your templates first. That way you will only get the functionality that your templates add. See here : https://docs.djangoproject.com/en/2.0/howto/overriding-templates/

Re: Handling Celery Connection Lost Problem

2018-01-03 Thread Mukul Mantosh
On Tuesday, January 2, 2018 at 9:16:33 AM UTC+5:30, Mukul Mantosh wrote: > > How to handle the problem when celery is unable to connect to the broker > (redis or rabbitmq)...while the connection gets lost the entire code gets > stuck because celery is trying to reconnect to the host. > > But wi

Re: Handling Celery Connection Lost Problem

2018-01-03 Thread Mukul Mantosh
*I'm not sure about understanding you, where are you trying to call it again? from ipython?* I am calling from Django, the code is inside the view. *def test(request):* * try:* *add.delay(2, 2)* * except add.OperationalError as exc:* *print('error')* *return HttpResponse('working')* P

Re: Handling Celery Connection Lost Problem

2018-01-03 Thread Matemática A3K
On Tue, Jan 2, 2018 at 11:14 PM, Mukul Mantosh wrote: > I am not using result backend my question is that when the broker > connection is lost it throws a connection refused exception which i could > normally catch through the following given below code. > > *try:* > * add.delay(2, 2)* > *except