Re: cors headers in django

2017-09-20 Thread Александр Христюхин (roboslone)
Hi, take a look at this package: https://github.com/ottoyiu/django-cors-headers README is pretty thorough. > On 20 Sep 2017, at 12:51, Rakhee Menon wrote: > > Hello, > Please can anyone tell how to add CORS headers in

Re: Retrieving objects created in trasaction

2017-09-11 Thread Александр Христюхин (roboslone)
etch to > objects after the transaction has finished? > > > On Wednesday, August 16, 2017 at 8:29:09 PM UTC+2, Александр Христюхин wrote: > Hi, > > I have some function (fetcher) that runs in transaction (it has to) and it > creates a bunch if new objects that are written to

Re: setup.py for Django project?

2017-09-08 Thread Александр Христюхин (roboslone)
`manage.py` is ABSOLUTELY NOT a `setup.py`. It doesn't really matter how you think. `setup.py` is used for package managing while `manage.py` manages Django. > On 8 Sep 2017, at 09:17, callsamle...@gmail.com wrote: > > hi, > yes, django has `setup.py`, that's `manage.py`,LOL > > depend on how

Re: Tutorial help Blank Front page

2017-08-11 Thread Александр Христюхин (roboslone)
Hi, You should open "http://127.0.0.1:8000/polls/ " instead of "http://127.0.0.1:8000/ ". Take a look at the error Django gives you, all registered URLs are listed there. > On 11 Aug 2017, at 20:56, Kareem Hart

Re: How to handle nested backward lookups in a template for a generic detail view?

2017-08-09 Thread Александр Христюхин (roboslone)
se image_set everywhere)", how do I do > that and maintain the ability to reference the data via the two-fold nested > loop I need in my HTML template? > > Thanks, > > Tom > > On Wednesday, August 9, 2017 at 9:10:33 AM UTC-4, Александр Христюхин wrote: > Whoop

Re: How to handle nested backward lookups in a template for a generic detail view?

2017-08-09 Thread Александр Христюхин (roboslone)
Whoops, looks like all dots are in place, my mistake. First and last points are still valid, though. > On 9 Aug 2017, at 16:08, Александр Христюхин (roboslone) > <robosl...@gmail.com> wrote: > > Hi, > > First of all, you can use `related_name` in your model fields

Re: How to handle nested backward lookups in a template for a generic detail view?

2017-08-09 Thread Александр Христюхин (roboslone)
Hi, First of all, you can use `related_name` in your model fields to get pretty backref names (so you don't have to use image_set everywhere). Second, you're missing dots in your template (`for detail in project.projectdetail_set.all`). And finally, your model is called ProjectDetailImage and

Re: Django Python OSError No such file or directory but file exists

2017-08-07 Thread Александр Христюхин (roboslone)
t; <http://blog.jobconvo.com/post/110644747055/o-impacto-das-entrevistas-virtuais-no-recrutamento?from=email> > - Manual do Recrutador Moderno > <http://blog.jobconvo.com/post/108666785355/manual-do-recrutador-moderno?from=email> > 2017-08-03 1:36 GMT-03:00 "Александр Хри

Re: Django Python OSError No such file or directory but file exists

2017-08-02 Thread Александр Христюхин (roboslone)
Hi, Are you sure s3file contains absolute path? I can't see where s3upload is being called. Also, you might wanna use os.remove instead of calling subprocess. You also might wanna check out PEP-8 and Sphinx for your docstrings. > On 2 Aug 2017, at 02:28, Ronaldo Bahia

Re: Group Permissions programmatically

2017-07-31 Thread Александр Христюхин (roboslone)
Hi, Why don't you use the same approach that is generally used with users? I mean you connect a signal to your User/Group model, that changes permission for created objects, like so: @receiver(post_save, sender=settings.AUTH_USER_MODEL) def create_user_permissions(instance=None, created=None,

Re: Django, permission error saving on disk, why?

2017-07-04 Thread Александр Христюхин (roboslone)
Looks like Linux permission issue. Are you sure user that runs Django is allowed to write anything to given directory? > On 4 Jul 2017, at 14:37, Antonis Christofides > wrote: > > Is it possible to show full traceback and error message? > Antonis Christofides >

Re: Model with mix of timezone aware and naive datetimes?

2017-06-22 Thread Александр Христюхин (roboslone)
Why don't you store all your time as tz-aware and let views decide how to display them? > On 22 Jun 2017, at 05:49, Chris Beck wrote: > > I a model that requires both timezone aware and naive datetimes. To be > specific, I am modelling a travel segment where the standard

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread Александр Христюхин (roboslone)
example to use requests or urllib2 and set "X-CSRFToken" > header to post form? > Thank you very much! > > 在 2017年6月15日星期四 UTC+8下午9:37:25,Александр Христюхин写道: > You could set "X-CSRFToken" header, that would be enough. Why do you post > data manually thou

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread Александр Христюхин (roboslone)
You could set "X-CSRFToken" header, that would be enough. Why do you post data manually though? > On 15 Jun 2017, at 16:33, 李余通 <liyutong19961...@gmail.com> wrote: > > Ture,my way is wrong,should i send cookies? > > 在 2017年6月15日星期四 UTC+8下午9:29:17,Александр

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread Александр Христюхин (roboslone)
CSRF token value is passed in Django's response headers. And anyway, you're no supposed to post data like that. Do you do that in tests? > On 15 Jun 2017, at 16:20, liyutong19961...@gmail.com wrote: > > I uis this code to submit form > ```python > import requests > > url =

Re: Install Django

2017-06-07 Thread Александр Христюхин (roboslone)
It has nothing to do with pytz. The issue is that you're trying to install packages into system's python. You shouldn't do it ever. Use virtualenv instead: https://virtualenv.pypa.io/en/stable/ > On 7 Jun 2017, at 10:34, sadri ashari

Re: testing in django

2017-05-23 Thread Александр Христюхин (roboslone)
Perhaps fixtures is what you want: https://code.djangoproject.com/wiki/Fixtures > On 23 May 2017, at 10:07, Akash Tomar wrote: > > class SignUpTest(TestCase): > def test_createAccount(self): > my_data

Re: Handle uncaught exceptions?

2017-02-28 Thread Александр Христюхин (roboslone)
Hi, what you need is a middleware with process_exception method. Be sure that it's the last one in MIDDLEWARE setting. https://docs.djangoproject.com/en/1.10/topics/http/middleware/#process-exception > On 28

Re: Extract Date-From and Date-To in DateRangeField django

2017-02-17 Thread Александр Христюхин (roboslone)
Hi, do you mean to store some kind of duration? There's DurationField for that. And you could store datetime.timedelta there. To get timedelta between two datetime.datetime objects, you could subtract ine from another: from django.utils import timezone as tz now = tz.now() day_ago = tz.now()

Re: creating models but its not showing in db

2017-01-31 Thread Александр Христюхин (roboslone)
Did you run makemigrations first and then migrate? Also, do you have any instances of your model? > On 31 Jan 2017, at 19:08, Kazi Atik wrote: > > Hi i am creating a table in my model but its not showing in my sqlite.db > files i also run migrate command and

Re: I have problem in when submitting song_form

2017-01-31 Thread Александр Христюхин (roboslone)
Hi, it's your model, you probably have "album" field, that is required and not filled by a view. > On 31 Jan 2017, at 14:35, sridhar chary wrote: > > I don't no where i made mistake > > DETAIL.HTML > > > {% extends 'music/base.html'%} > {% block title %}Album

Re: Writing a custome Django Log Formatter.

2017-01-23 Thread Александр Христюхин (roboslone)
, > > > Can the Filter be applied individally and part of the Code when the Logger is > being setup for a module.??? > > Thanks & Cheers > Arun > > > On Monday, January 23, 2017 at 3:29:25 PM UTC+5:30, Александр Христюхин wrote: > Hi, yes, it's absolutely possib

Re: Writing a custome Django Log Formatter.

2017-01-23 Thread Александр Христюхин (roboslone)
Hi, yes, it's absolutely possible. Refer to Django docs about logging (https://docs.djangoproject.com/en/1.10/topics/logging/ ) and logging docs (https://docs.python.org/3/library/logging.config.html#logging-config-dictschema

Compiling/packing Django to one binary

2016-10-18 Thread Александр Христюхин
Hi! I would like to ask community about methods of shipping Django in production. I do have some limitations, one of which is I don't know what packages are installed on production server (for example, postgres dev libraries or specific version of python). Right now my method is to