Re: Migrating from sqllite3 to postgres

2015-05-25 Thread Luis Zárate
Mmm probably you are looking for export /import data in django.

For export :
python manage.py dumpdata --format=json myapp > data.json

For import:
python manage.py loaddata data.json

See

https://docs.djangoproject.com/en/1.8/ref/django-admin/#loaddata-fixture-fixture

El lunes, 25 de mayo de 2015, Peter of the Norse 
escribió:
>
>> On May 21, 2015, at 11:24 PM, jaspinder singh 
wrote:
>>
>> I have developed an app using sqllite. But my Heroku doesn't support
sqllite and the data keeps leaking every 24 hours. Can someone list the
steps how to change from sqllite3 to postgres
>>
>
>
> From sqlite:
> sqlite> .output backup.sql
> sqlite> .dump
>
> From the command line:
> $ psql django_db -1f backup.sql
>
> You may have to edit the .sql file to make it work. Good luck.
>
> Peter of the Norse
> rahmc...@radio1190.org
>
>
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/53FD5433-F4CA-4684-9BF5-E9FA4EA786C4%40Radio1190.org
.
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyONP3Cw%2BKrGYd%2BzLVcNrCBEr1YH3eW6PhOY7UMsYZN1wQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Software Version for MySql that works with django 1.8

2015-05-25 Thread Robert librado
are either of you using pythonanywhere.com for django
I am having an issue with the wsgi file for my virtualenv

I keep getting this error:
for this code:
import os
import sys

# assuming your django settings file is at
'/home/MYUSERNAME/MYSITE/settings.py'
path = '/home/pycharm/work'
if path not in sys.path:
sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'work.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()




heres the error:

939 :Traceback (most recent call last):
2015-05-25 18:45:19,939 :  File "/bin/user_wsgi_wrapper.py", line 130,
in __call__
2015-05-25 18:45:19,939 :
self.error_log_file.logger.exception("Error running WSGI application")
2015-05-25 18:45:19,939 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2015-05-25 18:45:19,940 :self.error(msg, *args, **kwargs)
2015-05-25 18:45:19,940 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2015-05-25 18:45:19,940 :self._log(ERROR, msg, args, **kwargs)
2015-05-25 18:45:19,940 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2015-05-25 18:45:19,940 :record = self.makeRecord(self.name,
level, fn, lno, msg, args, exc_info, func, extra)
2015-05-25 18:45:19,940 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2015-05-25 18:45:19,941 :rv = LogRecord(name, level, fn, lno, msg,
args, exc_info, func)
2015-05-25 18:45:19,941 :  File
"/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2015-05-25 18:45:19,941 :self.threadName = threading.current_thread().name
2015-05-25 18:45:19,941 :  File "/usr/lib/python2.7/threading.py",
line 1160, in currentThread
2015-05-25 18:45:19,941 :return _active[_get_ident()]
2015-05-25 18:45:19,941 :  File "/bin/user_wsgi_wrapper.py", line 122,
in __call__
2015-05-25 18:45:19,941 :app_iterator = self.app(environ, start_response)
2015-05-25 18:45:19,941 :  File
"/home/pycharm/.virtualenvs/django17/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
line 168, in __call__
2015-05-25 18:45:19,942 :self.load_middleware()
2015-05-25 18:45:19,942 :  File
"/home/pycharm/.virtualenvs/django17/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 44, in load_middleware
2015-05-25 18:45:19,942 :mw_class = import_string(middleware_path)
2015-05-25 18:45:19,942 :  File
"/home/pycharm/.virtualenvs/django17/local/lib/python2.7/site-packages/django/utils/module_loading.py",
line 26, in import_string
2015-05-25 18:45:19,943 :module = import_module(module_path)
2015-05-25 18:45:19,943 :  File
"/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
2015-05-25 18:45:19,943 :__import__(name)
2015-05-25 18:45:19,943 :ImportError: No module named security


On Mon, May 25, 2015 at 5:27 AM, James Bennett 
wrote:

> Have you read Django's documentation?
>
> https://docs.djangoproject.com/en/1.8/ref/databases/#mysql-notes
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAL13Cg89HJfPmyEVpMzQLGY0Oodnzb0C2pOXSJAJdhKa-i%2Bs%3DQ%40mail.gmail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAmfpZ3ih%2BFvqV-yJo14oKeeMr87ot1cwPYx%2BXEPYfgzvJ6YZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Im stuck with my WSGI FIle on pythonanywhere.com

2015-05-25 Thread Robert librado
939 :Traceback (most recent call last):
2015-05-25 18:45:19,939 :  File "/bin/user_wsgi_wrapper.py", line 130,
in __call__
2015-05-25 18:45:19,939 :
self.error_log_file.logger.exception("Error running WSGI application")
2015-05-25 18:45:19,939 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2015-05-25 18:45:19,940 :self.error(msg, *args, **kwargs)
2015-05-25 18:45:19,940 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2015-05-25 18:45:19,940 :self._log(ERROR, msg, args, **kwargs)
2015-05-25 18:45:19,940 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2015-05-25 18:45:19,940 :record = self.makeRecord(self.name,
level, fn, lno, msg, args, exc_info, func, extra)
2015-05-25 18:45:19,940 :  File
"/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2015-05-25 18:45:19,941 :rv = LogRecord(name, level, fn, lno, msg,
args, exc_info, func)
2015-05-25 18:45:19,941 :  File
"/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2015-05-25 18:45:19,941 :self.threadName = threading.current_thread().name
2015-05-25 18:45:19,941 :  File "/usr/lib/python2.7/threading.py",
line 1160, in currentThread
2015-05-25 18:45:19,941 :return _active[_get_ident()]
2015-05-25 18:45:19,941 :  File "/bin/user_wsgi_wrapper.py", line 122,
in __call__
2015-05-25 18:45:19,941 :app_iterator = self.app(environ, start_response)
2015-05-25 18:45:19,941 :  File
"/home/pycharm/.virtualenvs/django17/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
line 168, in __call__
2015-05-25 18:45:19,942 :self.load_middleware()
2015-05-25 18:45:19,942 :  File
"/home/pycharm/.virtualenvs/django17/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 44, in load_middleware
2015-05-25 18:45:19,942 :mw_class = import_string(middleware_path)
2015-05-25 18:45:19,942 :  File
"/home/pycharm/.virtualenvs/django17/local/lib/python2.7/site-packages/django/utils/module_loading.py",
line 26, in import_string
2015-05-25 18:45:19,943 :module = import_module(module_path)
2015-05-25 18:45:19,943 :  File
"/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
2015-05-25 18:45:19,943 :__import__(name)
2015-05-25 18:45:19,943 :ImportError: No module named security




heres the code:



import os
import sys

# assuming your django settings file is at '/home/MYUSERNAME/MYSITE/settings.py'
path = '/home/pycharm/work'
if path not in sys.path:
sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'work.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAmfpZ18K2K%2BzDPAFEu38ZRXweheJr8Z5YWmcc4ctLpgHx1O%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use unlocalize in views

2015-05-25 Thread julio . lacerda
Thank You Luis, but it will be for the entire project, right? I just want 
to apply this to a single variable.

For example,

(float)
variable_x = 15.123  # Thousand separator from my L10N

variable_y = unlocalize(variable_x) 
print variable_y  # 15123

Do you know how can I do that without using a global directive?

Em segunda-feira, 25 de maio de 2015 11:53:50 UTC-3, luisza14 escreveu:
>
> Set in yours Settings 
> USE_I18N = FalseUSE_L10N = False
> See:
> https://docs.djangoproject.com/en/1.8/ref/settings/#use-i18n
>
> 2015-05-25 7:01 GMT-06:00 :
>
>> Hello guys!
>>
>> Is there a way to use unlocalize in views? I know that I can use this in 
>> template (
>> https://docs.djangoproject.com/en/1.8/topics/i18n/formatting/#localize)
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/767e0d4e-9671-4363-a09c-1e67839994cc%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc283125-69f7-4124-a96c-69c0c2d48223%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Testing Setup gives 500, but dev server works okay

2015-05-25 Thread Timothy W. Cook
I should add that the actual error is:

selenium.common.exceptions.NoSuchElementException: Message: Unable to
locate element: {"method":"id","selector":"id_login"}

because the main page never loads so it can't find the login button,


On Mon, May 25, 2015 at 12:29 PM, Timothy W. Cook  wrote:

> I have a project that I started, then decided I should apply a TDD
> approach.
>
> Well the user registration and login portion already works but I am
> attempting to add some tests to it.
> The user can register, is redirected back to the main page with a Login
> button.
>
> Here is the test code:
>
> def test_visitor_can_register_and_login_logout(self):
> self.browser.get(self.server_url)
> self.browser.find_element_by_id('id_register').click()
> self.browser.find_element_by_id('id_username').send_keys(TEST_USER)
> self.browser.find_element_by_id('id_email').send_keys(TEST_EMAIL)
>
> self.browser.find_element_by_id('id_password1').send_keys(TEST_PASSWORD)
>
> self.browser.find_element_by_id('id_password2').send_keys(TEST_PASSWORD)
> self.browser.find_element_by_id('submit_registration').click()
> time.sleep(10)
> ## Existing user is invited to login
> self.browser.find_element_by_id('id_login').click()
> self.browser.find_element_by_id('id_login').send_keys(TEST_USER)
>
> self.browser.find_element_by_id('id_password').send_keys(TEST_PASSWORD)
> self.browser.find_element_by_id('log_me_in').click()
>
> ## test user is logged in and can logout
> self.browser.find_element_by_id('id_logout').click()
> self.browser.find_element_by_tag_name('button').click()
> ##redirected back to main page
> self.browser.find_element_by_id('id_login')
>
> I see the main page load, the registration page loads and the inputs are
> filled in.
> When the submit_registion button is clicked I get a 500.  You can see I
> put a sleep in there just so I could see it and verify that the process
> isn't running too fast for the server to respond.
>
> I originally had the registration and login in separate tests but I
> understand that this might require TransactionTestCase ?  I am using
> from django.test import LiveServerTestCase in this class.
>
> I have one other test before that runs fine.
>
> Any ideas?  Tips on troubleshooting this functional test?
>
>
>
>
>
> 
> Timothy Cook
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> MLHIM http://www.mlhim.org
>
>


-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3UetYF2s47x3KiY%3D%3DZ8%3DYpCu%3Dc3L10z-XHOxBfUsHnRDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Testing Setup gives 500, but dev server works okay

2015-05-25 Thread Timothy W. Cook
I have a project that I started, then decided I should apply a TDD
approach.

Well the user registration and login portion already works but I am
attempting to add some tests to it.
The user can register, is redirected back to the main page with a Login
button.

Here is the test code:

def test_visitor_can_register_and_login_logout(self):
self.browser.get(self.server_url)
self.browser.find_element_by_id('id_register').click()
self.browser.find_element_by_id('id_username').send_keys(TEST_USER)
self.browser.find_element_by_id('id_email').send_keys(TEST_EMAIL)

self.browser.find_element_by_id('id_password1').send_keys(TEST_PASSWORD)

self.browser.find_element_by_id('id_password2').send_keys(TEST_PASSWORD)
self.browser.find_element_by_id('submit_registration').click()
time.sleep(10)
## Existing user is invited to login
self.browser.find_element_by_id('id_login').click()
self.browser.find_element_by_id('id_login').send_keys(TEST_USER)

self.browser.find_element_by_id('id_password').send_keys(TEST_PASSWORD)
self.browser.find_element_by_id('log_me_in').click()

## test user is logged in and can logout
self.browser.find_element_by_id('id_logout').click()
self.browser.find_element_by_tag_name('button').click()
##redirected back to main page
self.browser.find_element_by_id('id_login')

I see the main page load, the registration page loads and the inputs are
filled in.
When the submit_registion button is clicked I get a 500.  You can see I put
a sleep in there just so I could see it and verify that the process isn't
running too fast for the server to respond.

I originally had the registration and login in separate tests but I
understand that this might require TransactionTestCase ?  I am using
from django.test import LiveServerTestCase in this class.

I have one other test before that runs fine.

Any ideas?  Tips on troubleshooting this functional test?






Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3Xv1Zz-6uSkUphtNa_kx-YbUbA2MOPn0wOUN-Bpm3sm%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use unlocalize in views

2015-05-25 Thread Luis Zárate
Set in yours Settings
USE_I18N = FalseUSE_L10N = False
See:
https://docs.djangoproject.com/en/1.8/ref/settings/#use-i18n

2015-05-25 7:01 GMT-06:00 :

> Hello guys!
>
> Is there a way to use unlocalize in views? I know that I can use this in
> template (
> https://docs.djangoproject.com/en/1.8/topics/i18n/formatting/#localize)
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/767e0d4e-9671-4363-a09c-1e67839994cc%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyNLG4kN9u44eRnGFdvyAunjUMJiL%2B6ZOjZ-ZJZe_mikiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrating from sqllite3 to postgres

2015-05-25 Thread Peter of the Norse

> On May 21, 2015, at 11:24 PM, jaspinder singh  
> wrote:
> 
> I have developed an app using sqllite. But my Heroku doesn't support sqllite 
> and the data keeps leaking every 24 hours. Can someone list the steps how to 
> change from sqllite3 to postgres
> 


>From sqlite:
sqlite> .output backup.sql
sqlite> .dump

>From the command line:
$ psql django_db -1f backup.sql

You may have to edit the .sql file to make it work. Good luck.

Peter of the Norse
rahmc...@radio1190.org



-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53FD5433-F4CA-4684-9BF5-E9FA4EA786C4%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.


Re: how to mock REST calls during development?

2015-05-25 Thread Jirka Vejrazka
Hi Abraham,

  I needed to solve this a few months ago, decided to use
https://github.com/getsentry/responses

  The way I did this is that I have a function that sets all required
responses (using the endpoint URL and the expected response in a file).
Then I detect in the application setup (apps, models, settings - whatever
you prefer) if I'm on a development machine and call that "mock_setup()" in
that case.

  Relatively simple code and no change required to my production views.

  Small sample at http://dpaste.com/0E1PNVQ

  HTH

   Jirka



On 25 May 2015 at 14:47, Avraham Serour  wrote:

> I used https://pypi.python.org/pypi/requests-mock, but the mocking was
> done on the testCase class, the view was written without if DEBUG or
> anything similar
>
> On Mon, May 25, 2015 at 3:33 PM, Abraham Varricatt <
> abraham.varric...@googlemail.com> wrote:
>
>> Hello everyone,
>>
>> I'm working on a Django application which needs to communicate with a
>> 3rd-party REST API. In production the flow would be like this;
>>
>>1. end-user browser sends a request to my django server
>>2. my server makes a remote REST call to 3rd party server
>>3. 3rd party server responds
>>4. my server sends back response to end-user's browser
>>
>> I'm simulating the above flow during development by using the Httpretty
>> mocking library. Here is how my view looks like;
>>
>> import httpretty
>>
>> THIRD_PARTY_SERVER = http://api.gitlab.com/
>>
>> def my_view(request):
>> if settings.DEBUG:
>> httpretty.enable()
>> httpretty.register_uri(httpretty.GET, THIRD_PARTY_SERVER, 
>> body='{some_mock_response_here}')
>>
>> partner_response = requests.get(THIRD_PARTY_SERVER)
>>
>> if settings.DEBUG:
>> httpretty.disable()
>> httpretty.reset()
>>
>> # Do some stuff here
>> # ...
>>
>> return render(request, 'template.html', context)
>>
>>
>>
>> For the most part, the above works. I can experiment around without
>> hitting the 3rd-party API. But it doesn't feel good. My mocking code is now
>> part of the view function - not what I consider a good design. Problem is,
>> I'm not sure how else this can be done? Does anyone have any better ideas?
>> Note - I'm not doing any testing here. Just need a way to mock 3rd-party
>> REST responses during development when I run "python manage.py runserver"
>> for debugging/experimentation.
>>
>> Ideally, I'd like to move all the mocking code to it's own file and away
>> from my views. This should somehow get activated when I start 'runserver'
>> and work for all my views.
>>
>> Puzzled,
>> Abraham V.
>>
>>
>>
>>
>>
>>
>>  --
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/59821a72-3471-4a9a-affd-3875d28e3a03%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFWa6tJkyPUex%2BzdErn3nnozeYtaM-fbdqoZfEq04b%3D3t2CtsQ%40mail.gmail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFhEBEAjVypPg5c6aEr6ysGjJNwY6rF4e%3DmY18s7Jfuwqv%2BfrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to use unlocalize in views

2015-05-25 Thread julio . lacerda
Hello guys!

Is there a way to use unlocalize in views? I know that I can use this in 
template 
(https://docs.djangoproject.com/en/1.8/topics/i18n/formatting/#localize)

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/767e0d4e-9671-4363-a09c-1e67839994cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


updating members of modelformset with unique fields

2015-05-25 Thread anentropic
http://stackoverflow.com/questions/30425468/django-updating-members-of-modelformset-with-unique-fields

The situation - I have a model and inline formset like:

class ProductImage(models.Model):
product = models.ForeignKey('Product')
display_order = models.PositiveSmallIntegerField(default=0)

class Meta:
unique_together = (('product', 'display_order'),)

inlineformset_factory(
Product, ProductImage, form=ProductImageForm, extra=1)

In the front end I provide a UI to reorder the images for a given product.

The problem:

   - Let's say I already saved two images attached to .
   - These two images have display_order=0 and display_order=1 respectively.
   - now I upload a third image, give it display_order=0 while renumbering 
   the existing images to display_order=2 and display_order=1 respectively.

At this point I get a validation error for the unique check.

Looking through Django source code we find this in BaseModelFormSet.save:

return self.save_existing_objects(commit) + self.save_new_objects(commit)

...ok that looks all good, it will save (update) the existing objects 
first. So from the perspective of the db there is no conflict in the unique 
constraints.

The problem is that saving comes *after* validation, or course, and at the 
point of validation the new objects will conflict with existing ones in the 
db.

It seems like BaseModelFormSet needs some mechanism whereby it could take 
into account the about-to-be-updated values from its form instances.

Does anyone have a workaround that does not involve pushing the problem 
onto the user?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c368d2c7-098e-4e66-94de-0406442ebead%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to mock REST calls during development?

2015-05-25 Thread Avraham Serour
I used https://pypi.python.org/pypi/requests-mock, but the mocking was done
on the testCase class, the view was written without if DEBUG or anything
similar

On Mon, May 25, 2015 at 3:33 PM, Abraham Varricatt <
abraham.varric...@googlemail.com> wrote:

> Hello everyone,
>
> I'm working on a Django application which needs to communicate with a
> 3rd-party REST API. In production the flow would be like this;
>
>1. end-user browser sends a request to my django server
>2. my server makes a remote REST call to 3rd party server
>3. 3rd party server responds
>4. my server sends back response to end-user's browser
>
> I'm simulating the above flow during development by using the Httpretty
> mocking library. Here is how my view looks like;
>
> import httpretty
>
> THIRD_PARTY_SERVER = http://api.gitlab.com/
>
> def my_view(request):
> if settings.DEBUG:
> httpretty.enable()
> httpretty.register_uri(httpretty.GET, THIRD_PARTY_SERVER, 
> body='{some_mock_response_here}')
>
> partner_response = requests.get(THIRD_PARTY_SERVER)
>
> if settings.DEBUG:
> httpretty.disable()
> httpretty.reset()
>
> # Do some stuff here
> # ...
>
> return render(request, 'template.html', context)
>
>
>
> For the most part, the above works. I can experiment around without
> hitting the 3rd-party API. But it doesn't feel good. My mocking code is now
> part of the view function - not what I consider a good design. Problem is,
> I'm not sure how else this can be done? Does anyone have any better ideas?
> Note - I'm not doing any testing here. Just need a way to mock 3rd-party
> REST responses during development when I run "python manage.py runserver"
> for debugging/experimentation.
>
> Ideally, I'd like to move all the mocking code to it's own file and away
> from my views. This should somehow get activated when I start 'runserver'
> and work for all my views.
>
> Puzzled,
> Abraham V.
>
>
>
>
>
>
>  --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/59821a72-3471-4a9a-affd-3875d28e3a03%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tJkyPUex%2BzdErn3nnozeYtaM-fbdqoZfEq04b%3D3t2CtsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how to mock REST calls during development?

2015-05-25 Thread Abraham Varricatt
Hello everyone,

I'm working on a Django application which needs to communicate with a 
3rd-party REST API. In production the flow would be like this;

   1. end-user browser sends a request to my django server
   2. my server makes a remote REST call to 3rd party server
   3. 3rd party server responds
   4. my server sends back response to end-user's browser

I'm simulating the above flow during development by using the Httpretty 
mocking library. Here is how my view looks like;

import httpretty

THIRD_PARTY_SERVER = http://api.gitlab.com/

def my_view(request):
if settings.DEBUG:
httpretty.enable()
httpretty.register_uri(httpretty.GET, THIRD_PARTY_SERVER, 
body='{some_mock_response_here}')

partner_response = requests.get(THIRD_PARTY_SERVER)

if settings.DEBUG:
httpretty.disable()
httpretty.reset()

# Do some stuff here
# ...

return render(request, 'template.html', context)



For the most part, the above works. I can experiment around without hitting 
the 3rd-party API. But it doesn't feel good. My mocking code is now part of 
the view function - not what I consider a good design. Problem is, I'm not 
sure how else this can be done? Does anyone have any better ideas? Note - 
I'm not doing any testing here. Just need a way to mock 3rd-party REST 
responses during development when I run "python manage.py runserver" for 
debugging/experimentation. 

Ideally, I'd like to move all the mocking code to it's own file and away 
from my views. This should somehow get activated when I start 'runserver' 
and work for all my views. 

Puzzled,
Abraham V.






-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/59821a72-3471-4a9a-affd-3875d28e3a03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Software Version for MySql that works with django 1.8

2015-05-25 Thread James Bennett
Have you read Django's documentation?

https://docs.djangoproject.com/en/1.8/ref/databases/#mysql-notes

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL13Cg89HJfPmyEVpMzQLGY0Oodnzb0C2pOXSJAJdhKa-i%2Bs%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


What are the steps to add images to admin/user interface using gravator?

2015-05-25 Thread Preeti
Please tell me the steps to add images to user/admin interface using gravtor

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ba09fc09-dfbf-4141-9551-b01ab4c8df8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Software Version for MySql that works with django 1.8

2015-05-25 Thread Preeti
Tell me software version of MySql that works with django 1.8 & python 2.7

And what are the steps for installation. Do it requires any DB-API 
connector?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/27d5ed47-2b76-458f-8251-00898f873389%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.