Re: Transaction failure for nested atomic blocks and concurrent processes on MySQL

2014-06-05 Thread Bluemaro
Fixed url 
http://stackoverflow.com/questions/24039678/django-transaction-failure-for-nested-atomic-blocks-and-concurrent-processes-on

-- 
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/8379ca24-2707-4aa4-b4fc-857542f989a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login/Session Not Sticking

2014-06-05 Thread Juergen Schackmann
*PLEASE HELP: I am not sure if this is a bug or caused by my code. But this 
is a serious issue for my production site.*


To get some more debug information, I have created this Middleware:


from django.conf import settings

class SessionDebugMiddleware(object):
def process_response(self, request, response):
session = request.session
user = request.user
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, 
None)
x_meta_requ = '{0},{1},{2},{3}'.format(session_key, 
session.get('_auth_user_id'), session.get('_auth_user_backend','---'), 
user.id)
response['X-Meta-Requ'] = '{0},{1},{2},{3}'.format(session_key, 
session.get('_auth_user_id'), session.get('_auth_user_backend','---'), 
user.id)
return response

If I hit the refresh button 10 times, 
8 times I will get this 
header: igv0xshezhdxh50kks9x00r0l67mx0sk,None,---,None
2 times I will get this header: 
X-Meta-Requ:igv0xshezhdxh50kks9x00r0l67mx0sk,330619,django.contrib.auth.backends.ModelBackend,330619

It seems be be random and does not follow any logic.


Am Mittwoch, 4. Juni 2014 13:55:38 UTC+2 schrieb Juergen Schackmann:
>
> Hi all, 
> this question refers to this previous question: 
> https://groups.google.com/forum/#!topic/django-users/8IXEvfU72S4. 
> However, it seems like the problem is slightly different, I decided to open 
> a new question:
>
> After my site has been up and running for a while in production, I 
> suddenly have a problem with my users loging into it.
>
>1. I have protected certain views/pages with the login_required 
>decorator and I am also using the django admin.
>2. When an anonymous user hits any of these pages, he is redirected to 
>the login page.
>3. When this anonymous user adds its credentials, the POST request is 
>successful and he is redirected to the inital page. At the same time, the 
>user gets a new sessionid (as expected)
>4. However, now the results get very unreliable. When pressing reload 
>or when navigating to other pages (that require a login), either of the 2 
>outcomes might happen:
>
>
>- a) The user is identified and the page is displayed correctly
>- b) The user is redirect to the login page.
>
> I have checked the content of the session via the shell, and nothing is 
> changing there.
>
> The production site is served via a load balancer and 8 application 
> servers. Even stranger: if I test the same code (with the same settings) on 
> a test server, that is not load balanced and basically has not traffic, 
> everything is working fine.
>
> I am running Django 1.6 on Ubuntu with Apache and mod_wsgi in daemon mode 
> behind SSL and I am using the Session database backend. I am using 
> django-allauth.account for account management/login. My Session settings 
> are like this:
>
> SESSION_COOKIE_HTTPONLY = True
> SESSION_COOKIE_AGE = 60*60*24
> SESSION_COOKIE_SECURE = True
>
> So I have the following questions/ideas?
>
> 1. Can this be related to loadbalancing in anyway? My understanding was 
> that Django does not need sticky sessions, when the DB session backend is 
> used.
>
> 2. Can this be related to a threading issue?
>
> 3. Can this be related to high load?
>
> 4. Can this be related to a decoding issue: 
> https://github.com/django/django/blob/master/django/contrib/sessions/backends/base.py#L83.
>  
> However, I have not found any log entries that refer to "Session data 
> corrupted".
>
> Any other hints are welcome.
>
>
>

-- 
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/1fcd32ac-8252-4370-ab13-118924d845f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login/Session Not Sticking

2014-06-05 Thread Juergen Schackmann
*PLEASE HELP: I am not sure if this is a bug or caused by my code. But this 
is a serious issue for my production site.*


To get some more debug information, I have created this Middleware:


from django.conf import settings

class SessionDebugMiddleware(object):
def process_response(self, request, response):
session = request.session
user = request.user
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, 
None)
x_meta_requ = '{0},{1},{2},{3}'.format(session_key, 
session.get('_auth_user_id'), session.get('_auth_user_backend','---'), 
user.id)
response['X-Meta-Requ'] = '{0},{1},{2},{3}'.format(session_key, 
session.get('_auth_user_id'), session.get('_auth_user_backend','---'), 
user.id)
return response

If I hit the refresh button 10 times, 
8 times I will get this 
header:  X-Meta-Requ:igv0xshezhdxh50kks9x00r0l67mx0sk,None,---,None
2 times I will get this header: 
X-Meta-Requ:igv0xshezhdxh50kks9x00r0l67mx0sk,330619,django.contrib.auth.backends.ModelBackend,330619

It seems be be random and does not follow any logic.

-- 
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/bafd1074-ebab-4f3f-bf7d-5c8c7dd8a4eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login/Session Not Sticking

2014-06-05 Thread Juergen Schackmann
*PLEASE HELP: I am not sure if this is a bug or caused by my code. But this 
is a serious issue for my production site.*


To get some more debug information, I have created this Middleware:


from django.conf import settings

class SessionDebugMiddleware(object):
def process_response(self, request, response):
session = request.session
user = getattr(request, 'user', None)
if user:
user=user.id
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, 
None)
response['X-Meta-Requ'] = '{0},{1},{2},{3}'.format(session_key, 
session.get('_auth_user_id'), session.get('_auth_user_backend','---'), user)
return response


If I hit the refresh button 10 times, 
8 times I will get this 
header:  X-Meta-Requ:igv0xshezhdxh50kks9x00r0l67mx0sk,None,---,None
2 times I will get this header: 
X-Meta-Requ:igv0xshezhdxh50kks9x00r0l67mx0sk,330619,django.contrib.auth.backends.ModelBackend,330619

It seems be be random and does not follow any logic.

-- 
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/13b90bb8-7497-4a49-82e5-0a478ca1d1de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login/Session Not Sticking

2014-06-05 Thread Erik Cederstrand
Den 04/06/2014 kl. 13.55 skrev Juergen Schackmann 
:

> The production site is served via a load balancer and 8 application servers. 
> Even stranger: if I test the same code (with the same settings) on a test 
> server, that is not load balanced and basically has not traffic, everything 
> is working fine.

Are you sure all app servers are running the same code? Same settings.py? DNS 
load balancing you forgot about? Maybe you have some lingering app server 
processes that were never shut down? Check the start date of all WSGI processes 
to be sure.

Erik


PS: You may have sweaty palms, but please don't triple post the same question 
to the list.

-- 
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/E68F66BE-BB2E-4387-B1E7-01FA6F8F03EC%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: URLs: mymodel_id vs object_id vs pk ....

2014-06-05 Thread Thomas Güttler

Thank you for answering my question.

Unfortunately "slug" does not work in my context.

My model does not have a "slug". It is like a ticket/issue system. There
are several hundred of tickets each day.

  Thomas Güttler

Am 04.06.2014 15:07, schrieb Thomas Güttler:

What is the best practice for named URL parameter which refer to a primary key 
of a model?

I have seen many ways:

  - object_id
  - mymodel_id
  - pk
  - id
  - .

example:

urlpatterns = [
 url(r'^article/(?P\d+)/$', 'article.view'),
 ...
 ]

Up to now we used "mymodel_id" but it gets boring to type in "mymodel".

This is a question about best practice:

Which do you use (and why)?


Related: https://docs.djangoproject.com/en/dev/topics/http/urls/#named-groups

   Thomas



--
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/53903B4C.7070409%40tbz-pariv.de.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login/Session Not Sticking

2014-06-05 Thread Juergen Schackmann
- all app servers are running the same code with same settings.
- DNS load balancing was never used
- just did a htop, no unexpected or old processes

Am Donnerstag, 5. Juni 2014 11:37:30 UTC+2 schrieb Erik Cederstrand:
>
> Den 04/06/2014 kl. 13.55 skrev Juergen Schackmann  >: 
>
> > The production site is served via a load balancer and 8 application 
> servers. Even stranger: if I test the same code (with the same settings) on 
> a test server, that is not load balanced and basically has not traffic, 
> everything is working fine. 
>
> Are you sure all app servers are running the same code? Same settings.py? 
> DNS load balancing you forgot about? Maybe you have some lingering app 
> server processes that were never shut down? Check the start date of all 
> WSGI processes to be sure. 
>
> Erik 
>
>
> PS: You may have sweaty palms, but please don't triple post the same 
> question to the list.

-- 
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/593d1369-a6a2-4457-b911-952bb0576877%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django app and a submodule name conflict

2014-06-05 Thread Tom Evans
On Wed, Jun 4, 2014 at 8:51 AM, Vahe Evoyan  wrote:
> I have modules in the project with the same names, all placed in different
> applications.
>
> Particularly there are two apps that conflict and result an ImportError. The
> project structure approximately is as follows.
>
> project
>  |_ project
>|_ settings.py
>|_ ...
>  |_ apps
>|_ A
>  |_ handlers
>|_ B.py
>|_ C.py
>|_ B
>  |_ models.py
>
> The settings file adds apps directory to the system path.
>
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
> sys.path.insert(0, os.path.join(BASE_DIR, "apps"))
>
> This configuration assumes that when I import the B.models it will use
> apps/B/models.py. Although the following line in the C.py file raise an
> import error as it imports the A/handlers/B.pywhich does not have models
> module.
>
> A/handlers/C.py:
> from B.models import BModel
>
> The sys.path variable has a correct items, i.e. the first one in the list is
> /path/to/project/appsand sys.modules['B.models'] is referenced to the
> correct file.
>
> BTW, when I use Django's import_by_path function, everything works fine.
>
> Any ideas how I can solve the problem without renaming the modules?
>
> Posted sample sources on GitHub.
>
> Thanks in advance!
>

The simplest solution is to simply rename either app or component that
conflicts.

Cheers

Tom

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


RE: safari ios 7 and django app - function not being called to serve video

2014-06-05 Thread Ilya Kazakevich
Hello,

1) Use FireBug (http://www.hongkiat.com/blog/installing-firebug-browsers-ios/) 
to check generated HTML for correct link and HTTP request your browser 
sends/receives
2) Check your web server logs to ensure Safari tries to load video (you need 
access log and error log I believe: http://httpd.apache.org/docs/2.2/logs.html )
3) NEVER hardcode urls! Use URL tag 
(https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url)


Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Adam Teale
>Sent: Wednesday, June 04, 2014 1:21 AM
>To: django-users@googlegroups.com
>Subject: safari ios 7 and django app - function not being called to serve video
>
>Hi Guys,
>
>I am in the process of building a web app with django.
>The app is running on apache and files/videos are served with the xsendfile
>apache module.
>The app is working fine on iphones, ipads and macs on the local network - when 
>I
>access the site via a url like https://myapp.local
>
>When I visit the app through it's real world domain (https://myapp.com) via a
>computer everything is ok too.
>But when on the iPhone/ipad the videos do not get loaded. The custom url I have
>made for serving the videos isn't even called.
>
>I am embedding the videos like this:
>preload="metadata" autostart="False" controls>
>
>So the url is called to grab that asset and return the file response with the 
>path.
>This 'serveAsset' doesn't get called from the iPhone/iPad.
>When I hit that url directly the video doesn't load either.
>(But it does from a mac and safari - including using the "Safari iOS7 - 
>iPhone" User
>agent.
>
>Does Safari iOS7 not work with urls that serve material for the page?
>
>Any ideas what might be going on?
>
>Any help would be very much appreciated!
>
>Cheers
>
>Adam
>
>--
>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/62927890-40aa-47d6-84cb-0c
>26bd5285f6%40googlegroups.com
>c26bd5285f6%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/048d01cf80c0%246852d990%2438f88cb0%24%40JetBrains.com.
For more options, visit https://groups.google.com/d/optout.


Re: safari ios 7 and django app - function not being called to serve video

2014-06-05 Thread Adam Teale
Thanks for your suggestions Ilya.

>From the apache side of things my serveAsset function is not called when
the page is viewed from an iPhone/iPad. But it works fine from a browser on
a computer.

I changed to using the URL tag.

I really can't work it out at the moment.
I wonder if it is some configuration on the mac os x server that is running
the django app related to mobile devices?


On Thu, Jun 5, 2014 at 9:16 AM, Ilya Kazakevich <
ilya.kazakev...@jetbrains.com> wrote:

> Hello,
>
> 1) Use FireBug (
> http://www.hongkiat.com/blog/installing-firebug-browsers-ios/) to check
> generated HTML for correct link and HTTP request your browser sends/receives
> 2) Check your web server logs to ensure Safari tries to load video (you
> need access log and error log I believe:
> http://httpd.apache.org/docs/2.2/logs.html )
> 3) NEVER hardcode urls! Use URL tag (
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url)
>
>
> Ilya Kazakevich,
> JetBrains PyCharm (Best Python/Django IDE)
> http://www.jetbrains.com/pycharm/
> "Develop with pleasure!"
>
>
> >-Original Message-
> >From: django-users@googlegroups.com
> >[mailto:django-users@googlegroups.com] On Behalf Of Adam Teale
> >Sent: Wednesday, June 04, 2014 1:21 AM
> >To: django-users@googlegroups.com
> >Subject: safari ios 7 and django app - function not being called to serve
> video
> >
> >Hi Guys,
> >
> >I am in the process of building a web app with django.
> >The app is running on apache and files/videos are served with the
> xsendfile
> >apache module.
> >The app is working fine on iphones, ipads and macs on the local network -
> when I
> >access the site via a url like https://myapp.local
> >
> >When I visit the app through it's real world domain (https://myapp.com)
> via a
> >computer everything is ok too.
> >But when on the iPhone/ipad the videos do not get loaded. The custom url
> I have
> >made for serving the videos isn't even called.
> >
> >I am embedding the videos like this:
> > >preload="metadata" autostart="False" controls>
> >
> >So the url is called to grab that asset and return the file response with
> the path.
> >This 'serveAsset' doesn't get called from the iPhone/iPad.
> >When I hit that url directly the video doesn't load either.
> >(But it does from a mac and safari - including using the "Safari iOS7 -
> iPhone" User
> >agent.
> >
> >Does Safari iOS7 not work with urls that serve material for the page?
> >
> >Any ideas what might be going on?
> >
> >Any help would be very much appreciated!
> >
> >Cheers
> >
> >Adam
> >
> >--
> >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/62927890-40aa-47d6-84cb-0c
> >26bd5285f6%40googlegroups.com
> > >c26bd5285f6%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 a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/u_zJ8Pc4Eyg/unsubscribe.
> To unsubscribe from this group and all its topics, 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/048d01cf80c0%246852d990%2438f88cb0%24%40JetBrains.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/CAMse0ZjOkfqD%2BAp2z_asTFo1ekYbKc_c79B3k0QhN9hCOKMdkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: safari ios 7 and django app - function not being called to serve video

2014-06-05 Thread Adam Teale
Ahh i just worked out the issue.

The server is using SSL certification (https?) and for some reason on the
iphone/ipad the serveAsset was not being called.

So now to work out how to call the URL tag with SSL.

Cheers!


On Thu, Jun 5, 2014 at 10:33 AM, Adam Teale  wrote:

> Thanks for your suggestions Ilya.
>
> From the apache side of things my serveAsset function is not called when
> the page is viewed from an iPhone/iPad. But it works fine from a browser on
> a computer.
>
> I changed to using the URL tag.
>
> I really can't work it out at the moment.
> I wonder if it is some configuration on the mac os x server that is
> running the django app related to mobile devices?
>
>
> On Thu, Jun 5, 2014 at 9:16 AM, Ilya Kazakevich <
> ilya.kazakev...@jetbrains.com> wrote:
>
>> Hello,
>>
>> 1) Use FireBug (
>> http://www.hongkiat.com/blog/installing-firebug-browsers-ios/) to check
>> generated HTML for correct link and HTTP request your browser sends/receives
>> 2) Check your web server logs to ensure Safari tries to load video (you
>> need access log and error log I believe:
>> http://httpd.apache.org/docs/2.2/logs.html )
>> 3) NEVER hardcode urls! Use URL tag (
>> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url)
>>
>>
>> Ilya Kazakevich,
>> JetBrains PyCharm (Best Python/Django IDE)
>> http://www.jetbrains.com/pycharm/
>> "Develop with pleasure!"
>>
>>
>> >-Original Message-
>> >From: django-users@googlegroups.com
>> >[mailto:django-users@googlegroups.com] On Behalf Of Adam Teale
>> >Sent: Wednesday, June 04, 2014 1:21 AM
>> >To: django-users@googlegroups.com
>> >Subject: safari ios 7 and django app - function not being called to
>> serve video
>> >
>> >Hi Guys,
>> >
>> >I am in the process of building a web app with django.
>> >The app is running on apache and files/videos are served with the
>> xsendfile
>> >apache module.
>> >The app is working fine on iphones, ipads and macs on the local network
>> - when I
>> >access the site via a url like https://myapp.local
>> >
>> >When I visit the app through it's real world domain (https://myapp.com)
>> via a
>> >computer everything is ok too.
>> >But when on the iPhone/ipad the videos do not get loaded. The custom url
>> I have
>> >made for serving the videos isn't even called.
>> >
>> >I am embedding the videos like this:
>> >> >preload="metadata" autostart="False" controls>
>> >
>> >So the url is called to grab that asset and return the file response
>> with the path.
>> >This 'serveAsset' doesn't get called from the iPhone/iPad.
>> >When I hit that url directly the video doesn't load either.
>> >(But it does from a mac and safari - including using the "Safari iOS7 -
>> iPhone" User
>> >agent.
>> >
>> >Does Safari iOS7 not work with urls that serve material for the page?
>> >
>> >Any ideas what might be going on?
>> >
>> >Any help would be very much appreciated!
>> >
>> >Cheers
>> >
>> >Adam
>> >
>> >--
>> >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/62927890-40aa-47d6-84cb-0c
>> >26bd5285f6%40googlegroups.com
>> ><
>> https://groups.google.com/d/msgid/django-users/62927890-40aa-47d6-84cb-0
>> >c26bd5285f6%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 a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/u_zJ8Pc4Eyg/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/048d01cf80c0%246852d990%2438f88cb0%24%40JetBrains.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/CAMse0ZiGOCoP5tHJoPQCQ5gDSMMkTknwA8hWnae_VqMqat78Eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: safari ios 7 and django app - function not being called to serve video

2014-06-05 Thread Ilya Kazakevich
What algorithm is used for keys in HTTPS on your installation?
AFAIK, Safari@iOS does NOT support DSA keys (only RSA keys are supported).



Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Adam Teale
>Sent: Thursday, June 05, 2014 6:46 PM
>To: django-users@googlegroups.com
>Subject: Re: safari ios 7 and django app - function not being called to serve 
>video
>
>Ahh i just worked out the issue.
>
>The server is using SSL certification (https?) and for some reason on the
>iphone/ipad the serveAsset was not being called.
>
>So now to work out how to call the URL tag with SSL.
>
>Cheers!
>
>
>On Thu, Jun 5, 2014 at 10:33 AM, Adam Teale  wrote:
>
>
>   Thanks for your suggestions Ilya.
>
>   From the apache side of things my serveAsset function is not called when
>the page is viewed from an iPhone/iPad. But it works fine from a browser on a
>computer.
>
>   I changed to using the URL tag.
>
>   I really can't work it out at the moment.
>   I wonder if it is some configuration on the mac os x server that is 
> running the
>django app related to mobile devices?
>
>
>   On Thu, Jun 5, 2014 at 9:16 AM, Ilya Kazakevich
> wrote:
>
>
>   Hello,
>
>   1) Use FireBug
>(http://www.hongkiat.com/blog/installing-firebug-browsers-ios/) to check
>generated HTML for correct link and HTTP request your browser sends/receives
>   2) Check your web server logs to ensure Safari tries to load 
> video (you
>need access log and error log I believe:
>http://httpd.apache.org/docs/2.2/logs.html )
>   3) NEVER hardcode urls! Use URL tag
>(https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url)
>
>
>   Ilya Kazakevich,
>   JetBrains PyCharm (Best Python/Django IDE)
>   http://www.jetbrains.com/pycharm/
>   "Develop with pleasure!"
>
>
>
>   >-Original Message-
>   >From: django-users@googlegroups.com
>   >[mailto:django-users@googlegroups.com] On Behalf Of Adam Teale
>   >Sent: Wednesday, June 04, 2014 1:21 AM
>   >To: django-users@googlegroups.com
>   >Subject: safari ios 7 and django app - function not being 
> called to serve
>video
>   >
>   >Hi Guys,
>   >
>   >I am in the process of building a web app with django.
>   >The app is running on apache and files/videos are served with 
> the
>xsendfile
>   >apache module.
>   >The app is working fine on iphones, ipads and macs on the local
>network - when I
>   >access the site via a url like https://myapp.local
>   >
>   >When I visit the app through it's real world domain
>(https://myapp.com) via a
>   >computer everything is ok too.
>   >But when on the iPhone/ipad the videos do not get loaded. The
>custom url I have
>   >made for serving the videos isn't even called.
>   >
>   >I am embedding the videos like this:
>   > height:auto
>   >preload="metadata" autostart="False" controls>
>   >
>   >So the url is called to grab that asset and return the file 
> response with
>the path.
>   >This 'serveAsset' doesn't get called from the iPhone/iPad.
>   >When I hit that url directly the video doesn't load either.
>   >(But it does from a mac and safari - including using the 
> "Safari iOS7 -
>iPhone" User
>   >agent.
>   >
>   >Does Safari iOS7 not work with urls that serve material for 
> the page?
>   >
>   >Any ideas what might be going on?
>   >
>   >Any help would be very much appreciated!
>   >
>   >Cheers
>   >
>   >Adam
>   >
>   >--
>
>   >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/62927890-40aa-47d6-84
>cb-0c
>   >26bd5285f6%40googlegroups.com
>
>
>   >4cb-0
>
>   >c26bd5285f6%40googlegroups.co

Using custom user (AbstractUser) and django-registration

2014-06-05 Thread Arnaud Vandecasteele
Hi guys,

I've been trying the whole day to use django-registration with a custom
user model.
Basically this is what I did :

*1/ Create a custom user model (models.py)*

class customUser(AbstractUser):
company_name = models.CharField(max_length=255)

--> My first question is do I need to add "objects = UserManager()" to my
model ?

*2/ Register my new user in the admin interface*

from django.contrib import admin
from django.contrib.auth.models import Group

from .models import customUser
admin.site.register(customUser)


*3/ Add my customUser to my settings.py*AUTH_USER_MODEL = 'myApp.customUser'

*Ok from this point everything works fine ! *

But my next step was to use django-registration [1] to have a full user
creation workflow.
After the installation, when I've tried to register a new user using the
registration forms, Django raised this error:
*django Manager isn't available; User has been swapped *

I've tried different things but none of them have worked.
The only solution I found [2] is by modifying directly django-registration:

Edit registration/forms.py, in the top change
from django.contrib.auth.models import User

to

from django.contrib.auth import get_user_model
User = get_user_model()

While I really don't like to change an existing application, after this
change I was able to use both django-registration and my custom user.

So I'm sure you can guess my question, is there no other way to do this ? I
really would like to keep my code clean without this kind of dirty hack.

Thanks

Arnaud


[1] https://django-registration.readthedocs.org/en/latest/#
[2] https://sulami.github.io/django-tweaking-custom-user-model-fixes.html

-- 

Arnaud Vandecasteele
SIG - WebMapping - Spatial Ontology - GeoCollaboration

Web Site
http://www.marinegis.com/?page_id=131
http://geotribu.net/

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


base.html template conflict

2014-06-05 Thread sergeig . public
I have installed both oscar and mezzanine apps into the same project. I was 
able to see both working when isolated from the other.

oscar requires TEMPLATE_DIRS to have a custom location:

import oscar
TEMPLATE_DIRS = (
oscar.OSCAR_MAIN_TEMPLATE_DIR,
os.path.join(PROJECT_ROOT, "templates"),
)

When oscar.OSCAR_MAIN_TEMPLATE_DIR is defined, it stops mezzanine from 
working, because oscar's base template is used for everything. Commenting 
out oscar line, enables mezzanine to work.

I checked and default loader order is:
TEMPLATE_LOADERS = (
u'django.template.loaders.filesystem.Loader',
)   u'django.template.loaders.app_directories.Loader',
which explains this behavior.

I changed the loader order to:
TEMPLATE_LOADERS = (
u'django.template.loaders.app_directories.Loader',
u'django.template.loaders.filesystem.Loader',
)
and that stopped oscar from working, when TEMPLATE_DIRS is defined with 
both lines.

So, I am kind of confused how to address the issue. I know that in the long 
run I 'd like to use only one base.html for the entire site, but in the 
short run I'd like to see both working using their own default templates.


Thanks

-- 
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/51ff9be9-144e-4fb9-a60c-07c173c74fc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


base.html template conflict

2014-06-05 Thread sergeig . public
I have installed both oscar and mezzanine apps into the same project. I was 
able to see both working when isolated from the other.

oscar requires TEMPLATE_DIRS to have a custom location:

import oscar
TEMPLATE_DIRS = (
oscar.OSCAR_MAIN_TEMPLATE_DIR,
os.path.join(PROJECT_ROOT, "templates"),
)

When oscar.OSCAR_MAIN_TEMPLATE_DIR is defined, it stops mezzanine from 
working, because oscar's base template is used for everything. Commenting 
out oscar line, enables mezzanine to work.

I checked and default loader order is:
TEMPLATE_LOADERS = (
u'django.template.loaders.filesystem.Loader',
)   u'django.template.loaders.app_directories.Loader',
which explains this behavior.

I changed the loader order to:
TEMPLATE_LOADERS = (
u'django.template.loaders.app_directories.Loader',
u'django.template.loaders.filesystem.Loader',
)
and that stopped oscar from working, when TEMPLATE_DIRS is defined with 
both lines.

So, I am kind of confused how to address the issue. I know that in the long 
run I 'd like to use only one base.html for the entire site, but in the 
short run I'd like to see both working using their own default templates.


Thanks

-- 
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/7b2c4a96-c375-41ff-b661-dfd7a80a4ceb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Supervisor alternative on Python 3.3.2?

2014-06-05 Thread Kwest Ambani
Anyone know an alternative for Supervisor? I need something to keep 
Gunicorn running in the background. My server is running Python 3.3.2. with 
Nginx serving only static files.

-- 
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/42356d62-79cd-415f-8890-f9a4a903deeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Displaying an uploaded file in a form

2014-06-05 Thread Shawn H
I've been trying to understand how to handle file uploads, and I've got the 
upload portion down.  I have a FileField in my form, process it in my view, 
and it's saved in the correct location as specified in MEDIA_ROOT and the 
upload_to attribute of the Model.  My problem is, when I try to bind the 
uploaded document in a GET request, nothing is working.  I tried following 
the documentation in the docs 
, 
but when I do that I get a 'FieldFile' does not have the buffer interface 
error.  How do I bind the file to the form so it's available to the user to 
download or open, while preserving the ability for the user to replace the 
uploaded file?  Do I have to extract the file from the model field before 
binding it to the form?  Code below.  Thanks in advance

form_data = {
'sub_id':s.id,
...
'sub_verified_by':s.verified_by
}
form_file = {'sub_pdr': SimpleUploadedFile('SubmissionPDR.docx', 
s.pdr_file)}
form = SubmissionEditForm(form_data, form_file)

-- 
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/3d8413ae-ca26-425a-841a-ebd8006553bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Displaying an uploaded file in a form

2014-06-05 Thread Tom Evans
On Thu, Jun 5, 2014 at 8:12 PM, Shawn H  wrote:
> I've been trying to understand how to handle file uploads, and I've got the
> upload portion down.  I have a FileField in my form, process it in my view,
> and it's saved in the correct location as specified in MEDIA_ROOT and the
> upload_to attribute of the Model.  My problem is, when I try to bind the
> uploaded document in a GET request, nothing is working.  I tried following
> the documentation in the docs, but when I do that I get a 'FieldFile' does
> not have the buffer interface error.  How do I bind the file to the form so
> it's available to the user to download or open, while preserving the ability
> for the user to replace the uploaded file?  Do I have to extract the file
> from the model field before binding it to the form?  Code below.  Thanks in
> advance
>
> form_data = {
> 'sub_id':s.id,
> ...
> 'sub_verified_by':s.verified_by
> }
> form_file = {'sub_pdr': SimpleUploadedFile('SubmissionPDR.docx',
> s.pdr_file)}
> form = SubmissionEditForm(form_data, form_file)

I think you are trying to redisplay a form that has already been
submitted, with the file there? This is not going to work, mainly
because a file field in a form never has an initial value, but also
because it is the wrong approach.

To display all the fields apart from the file field, you should be
passing the form data to the form as initial, not as data - eg
SubmissionEditForm(initial=form_data) - so that you do not create a
bound form - a form that has been submitted already.

To make the file available to download, you simply add the url to the
file to your template context - s.pdr_file.url - and make a link to it
- no forms involved. Or just add 's', and access it in the template:

{% if s.pdr_file %}
Download file
{% endif %}

Cheers

Tom

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


We can do this!

2014-06-05 Thread JJ Zolper

Hey everybody,

I really feel I could learn a lot from the experiences of developers working on 
high profile Django sites as I am working hard to begin that journey as well. 
And that is why I would love to have this project funded to 15k:

https://www.kickstarter.com/projects/1704706557/high-performance-django

"The next goal is at $15k and will help us include exclusive interviews with 
developers of high-profile Django sites as part of the package. We've already 
lined one up with an early Pinterest engineer and have calls out to a few 
others."

I've commited funds to every single Django project I have come across and I 
think we can do this!

Take it easy everyone,

JJ

-- 
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/68bebcab-aea1-43f1-a189-86fc1a4362e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django HTML5 & CSS validation - Best Practice?

2014-06-05 Thread 77cc33
what is the best practice to validate HTML5 and CSS? 

is there some crawler who will visit all pages and tests them for HTML5 and 
CSS valid code? maybe with help of "tidy" or something?

-- 
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/662f77c8-2866-4a0b-afec-e31f32deb8e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Supervisor alternative on Python 3.3.2?

2014-06-05 Thread Mario Gudelj
You can use init instead.
On 06/06/2014 5:09 am, "Kwest Ambani"  wrote:

> Anyone know an alternative for Supervisor? I need something to keep
> Gunicorn running in the background. My server is running Python 3.3.2. with
> Nginx serving only static files.
>
> --
> 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/42356d62-79cd-415f-8890-f9a4a903deeb%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/CAHqTbjng3K812YEBTn_78mi9ZgScjVfYA0PBg73GOcf27mgvXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login/Session Not Sticking

2014-06-05 Thread Mario Gudelj
I know this may sound silly but is there some kind of JavaScript code that
may be messing things up? Had a similar issue before and it was related to
JavaScript stupidity.
On 05/06/2014 10:39 pm, "Juergen Schackmann" 
wrote:

> - all app servers are running the same code with same settings.
> - DNS load balancing was never used
> - just did a htop, no unexpected or old processes
>
> Am Donnerstag, 5. Juni 2014 11:37:30 UTC+2 schrieb Erik Cederstrand:
>>
>> Den 04/06/2014 kl. 13.55 skrev Juergen Schackmann > >:
>>
>> > The production site is served via a load balancer and 8 application
>> servers. Even stranger: if I test the same code (with the same settings) on
>> a test server, that is not load balanced and basically has not traffic,
>> everything is working fine.
>>
>> Are you sure all app servers are running the same code? Same settings.py?
>> DNS load balancing you forgot about? Maybe you have some lingering app
>> server processes that were never shut down? Check the start date of all
>> WSGI processes to be sure.
>>
>> Erik
>>
>>
>> PS: You may have sweaty palms, but please don't triple post the same
>> question to the list.
>
>  --
> 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/593d1369-a6a2-4457-b911-952bb0576877%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/CAHqTbjmozPpYzXij0sf21npjcUNBTm8fmkzm9q842_XFwwKUsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.