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 Django and where should I

Re: Retrieving objects created in trasaction

2017-09-11 Thread Александр Христюхин (roboslone)
Thanks to everyone and sorry for the delay, I've missed your responses. I've tried to use transaction.on_commit, it didn't work for me. For some strange reason Django thought the code wasn't running in a transaction. I'm using Django 1.10 and PostgreSQL 9.6. Bar uses standard manager and yes, I

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

Retrieving objects created in trasaction

2017-08-16 Thread roboslone -
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 database after transaction is commited. Those objects are added to a many-to-many relation. And on that relation change a signal is fired and handled by my signal ha

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 wrote: > > I am currently doi

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

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

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) > wrote: > > Hi, > > First of all, you can use `related_name` in your model fields to get pretty > backref nam

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)
es no RH > <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 wrote: > > Hi everyone,

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 > http://djangodeployment.com

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 for departure > and a

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

2017-06-15 Thread Александр Христюхин (roboslone)
https://docs.djangoproject.com/en/1.11/ref/csrf/#ajax > On 15 Jun 2017, at 17:20, 李余通 wrote: > > Sorry,the message of Django CSRF and X-CSRFToken i can find is less. > Can you give me an example to use requests or urllib2 and set "X-CSRFTo

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, 李余通 wrote: > > Ture,my way is wrong,should i send cookies? > > 在 2017年6月15日星期四 UTC+8下午9:29:17,Александр Христюхин写道: > CSRF token value is passed in Django's response hea

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 = 'http://127.0.0.1:8000

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 wrote: > > >

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 = {'username': 'akash.tomar

Redirect from auth backend

2017-05-05 Thread roboslone -
Hello, I have an authentication backend, that authenticates users against a remote service using session cookie. Mentioned cookie can expire and remote service requires users to refresh it by visiting that service's URL (https://auth-service.com/renew?...). Cookie expiration is managed by that

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 Feb

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 makemigration > Here is my code >

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 detail{%endblock%} > {% block bo

Re: Writing a custome Django Log Formatter.

2017-01-23 Thread Александр Христюхин (roboslone)
Filter applies to handlers, as you can see from my example. So what you need is a custom handler for loggers that require that some_id of yours. > On 23 Jan 2017, at 13:04, Arun S wrote: > > Hi, > > Thanks, I did this. But this applies to all the Modules in the Project. > > Basically my issue

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

Re: Decrease amount of identical "Email reports"

2017-01-09 Thread roboslone
Hi! I don't know how to help you with ADMINS notifications, but you can use Sentry to collect logs and errors. I believe you could set up notifications there as you like. > On 9 Jan 2017, at 11:53, Nacharov Mikhail wrote: > > Hi folks and Happy New Year! > > I have a high load production site

Re: iterate a save in a form view based on a field value

2017-01-06 Thread roboslone
Hi! You probably want to use range() function for that. > On 6 Jan 2017, at 18:21, MikeKJ wrote: > > So I have a form of post values and one of the values is the number of > resources to be used, what I want to do is save multiple instances of the > form data based on the resource quantity to

Re: finding get_user_model

2017-01-06 Thread roboslone
Hi! Did you run migrations after adding 'django.contrib.auth' to your INSTALLED_APPS? > On 6 Jan 2017, at 07:30, Rasika wrote: > > from django.contrib.auth import get_user_model > why I am not able to find the code forget_user_model in auth app. > > While when I searched > https://docs.djangop

Re: Custom Widget for CharField Multiple

2016-12-28 Thread roboslone
Hi! If I understand this correctly, subclassing `forms.widgets.Input` was a wrong idea. As you can see in Input's source (https://docs.djangoproject.com/en/1.10/_modules/django/forms/widgets/#Input ), it always renders

Re: using django app functionality offline in browser when internet is inactive and synchronize with the remote server when internet is available.

2016-12-28 Thread roboslone
Hi! Seems like this is a task for your frontend, not Django. You'd probably want to store orders data in client's browser and then call some handler on your backend (Django), that would correctly process this data. You should be careful, though, because clients could send malformed data to that

Re: What is the best combination of components when installing Django on Windows 10?

2016-12-27 Thread roboslone
Both nginx and Apache are cross-platform, so you could run them on Windows as your front-end servers. You can't use gunicorn and it's not recommended to use uWSGI on Windows (http://stackoverflow.com/questions/21071494/how-to-run-django-with-nginx-on-a-windows-machine

Re: starting django

2016-12-27 Thread roboslone
Server is obviously running, you wouldn't get Django-styled 404 page with your URLconf otherwise. The problem is you're trying to access /pOOls instead of /poLLs. > On 27 Dec 2016, at 17:18, kabangufut...@gmail.com wrote: > > Hello, > 1. check you server to see if is running by typing this in s