Re: Edx LDAP Auth setting

2015-02-25 Thread 'Yip Terence' via Django users
Hi M,
 
Actually, I can connect with our AD server, but I need to hardcode the user 
in the connection string so that I would like to ask for the solution about 
how can I get the %user value and create the profile.  
 
Maybe I can paste my connection string here for more easy to understand.  I 
have been pasted the following code in 
/edx/app/edxapp/edx-platform/lms/envs/common.py.  I can successful login to 
edX when I hardcode the user in "AUTH_LDAP_USER_SEARCH".  Is that paste 
the code in the wrong location? 
 
 
---
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType, 
PosixGroupType
#AUTH_LDAP_START_TLS = True
AUTH_LDAP_GLOBAL_OPTIONS = {
 ldap.OPT_X_TLS_REQUIRE_CERT: False,
 ldap.OPT_REFERRALS: False,
}
# Baseline configuration.
AUTH_LDAP_SERVER_URI = "ldap://dc.abc.hk:389";
AUTH_LDAP_BIND_DN = "CN=connection_account,OU=SystemAcct,DC=abc,DC=hk"
AUTH_LDAP_BIND_PASSWORD = "password"
user = request.user
AUTH_LDAP_USER_SEARCH = LDAPSearch('OU=Users,DC=abc,DC=hk', 
ldap.SCOPE_SUBTREE, "(&(
mail=usern...@abc.hk)(objectClass=User)(objectCategory=person))")
 
AUTH_LDAP_ALWAYS_UPDATE_USER = True
# Set up the basic group parameters.
AUTH_LDAP_GROUP_SEARCH = LDAPSearch('OU=Users,DC=vtc,DC=hk', 
ldap.SCOPE_SUBTREE, "(&(objectClass=User)(objectCategory=person))")
 
# set group type
AUTH_LDAP_GROUP_TYPE = PosixGroupType()
AUTH_LDAP_CONNECTION_OPTIONS = {
 ldap.OPT_REFERRALS: 0,
}
 
# Simple group restrictions
#~ AUTH_LDAP_REQUIRE_GROUP = 
"cn=enabled,ou=django,ou=groups,dc=example,dc=com"
#~ AUTH_LDAP_DENY_GROUP = 
"cn=disabled,ou=django,ou=groups,dc=example,dc=com"
# Populate the Django user from the LDAP directory.
AUTH_LDAP_USER_ATTR_MAP = {
 "username": "cn",
 "first_name": "givenName",
 "last_name": "sn",
 "email": "mail"
}
 
AUTH_LDAP_PROFILE_ATTR_MAP = {
 "name": "cn"
}

# important! to use the group's permission
AUTH_LDAP_MIRROR_GROUPS = True
# Use LDAP group membership to calculate group permissions.
AUTH_LDAP_FIND_GROUP_PERMS = True
# Cache group memberships for an hour to minimize LDAP traffic
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
-
 
Looking for your reply.  Thanks!
 
Thanks and Regards,
Terence Yip

somecallitblues於 2015年2月24日星期二 UTC+8下午7時09分22秒寫道:

> To check the version go to shell and run this:
>
> >>> import django_auth_ldap
>
> >>> django_auth_ldap.version
>
> (1, 1, 2)
>
> >>> 
>
> As for virtualenv, it's a good practice but it's not necessary. 
>
> By the way, have you tried performing a simple search on the LDAP server? 
> I think that your best bet is to start with python-ldap (forget about 
> django_auth_ldap), try to connect to the server, perform a bind and get a 
> feel for it. 
>
> I normally open the shell and run something like this in it 
> https://bpaste.net/show/d4348eb1b3dd
>
> You have to know the following:
>
> - protocol (secure or not)
>
> - IP or domain name of the LDAP server
>
> - port
>
> - A full DN of one of the users would be useful but once you establish the 
> connection you can figure this out.
>
> I remember that I was using Django 1.5.x and django_auth_ldap was still 
> using User model by default. Not sure if that's still the case but you may 
> have to patch it.
>
> Good luck!
>
> M
>
>
>
>
>
>
>
>
>
> On 24 February 2015 at 17:37, 'Yip Terence' via Django users <
> django...@googlegroups.com > wrote:
>
>> Hi L,
>>
>>  
>>
>> Thanks for your reply.
>>
>>  
>>
>> I’m through pip to install the django-auth-ldap already.  But there are 
>> two question here. 
>>
>> 1.   How can I check the django-auth-ldap version?
>>
>> 2.   What do you mean of install via virt env? I’m follow the edX 
>> Ubuntu 12.04 +64 bit installation guide to install the edX, is that virt 
>> env? 
>>
>>
>> *https://github.com/edx/configuration/wiki/edX-Ubuntu-12.04-64-bit-Installation*
>>  
>> 
>>
>>  
>>
>>
>> -
>>
>> root@ethiopia:/edx/app/edxapp/edx-platform/lms/envs# pip install 
>> django-auth-ldap
>>
>> Requirement already satisfied (use --upgrade to upgrade): 
>> django-auth-ldap in /usr/local/lib/python2.7/dist-packages
>>
>> Requirement already satisfied (use --upgrade to upgrade): django in 
>> /usr/local/lib/python2.7/dist-packages (from django-auth-ldap)
>>
>> Requirement already satisfied (use --upgrade to upgrade): 
>> python-ldap>=2.0 in /usr/local/lib/python2.7/dist-packages (from 
>> django-auth-ldap)
>>
>> Requirement already satisfied (use --upgrade to upgrade): setuptools in 
>> /usr/local/lib/python2.7/dist-packages (from 
>> python-ldap>=2.0->django-auth-ldap)
>>  
>> Cleaning up...
>>  
>>  
>>
>> Thanks and Regards,
>>
>> Terence Yip
>>
>

Re: Gunicorn sock file is missing?

2015-02-25 Thread Kaloian
Hi Erik,

No it doesn't start at all, running the gunicorn_start script gives: 


*[ERROR] Retrying in 1 second.*
*[ERROR] Retrying in 1 second.*
*[ERROR] Retrying in 1 second.*
*[ERROR] Retrying in 1 second.*
*[ERROR] Retrying in 1 second.**[ERROR] Can't connect to 
/path/to/my/gunicorn.sock *

This is why I thought that the missing sock file is failing it to start. Do 
you think it could be something else? 
I have already tried to add the absolute path in gunicorn_start but nothing 
changed. 

Thanks,
Kaloian


On Wednesday, February 25, 2015 at 11:55:43 AM UTC+2, Erik Cederstrand 
wrote:
>
>
> > Den 25/02/2015 kl. 07.16 skrev Kaloian  >: 
> > 
> > I have an ansible provisioned VM based on this one 
> https://github.com/jcalazan/ansible-django-stack but for some reason 
> trying to start Gunicorn gives the following error: 
> > 
> > Can't connect to /path/to/my/gunicorn.sock 
> > 
> > [...] 
> > 
> > Can anyone point me to any direction what could be causing the missing 
> gunicorn.sock file ? 
>
> Is gunicorn even running? If not, you ned to find out why it failed to 
> start, or why it crashed. As a start, try adding the absolute path to 
> gunicorn in your gunicorn_start script instead of just "exec gunicorn". 
>
> Erik 
>

-- 
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/e326ee4c-1443-4f59-a00a-9249269caad1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to filter results using forms in Django/Python (best approach) ?

2015-02-25 Thread C. Kirby
Great.
It is similar to django-filters. It looks like the maintainer of filters 
and I started our projects at about the same time. I think that my version 
provides more extension hooks out of the box, but also requires more 
development for filtering on string-based fields. I may build out on some 
of the ideas that django-filters uses for string fields.
Compared to django-datafiters, I think mine is more extensible and I have 
more documentation.

Kirby

On Wednesday, February 25, 2015 at 5:15:01 PM UTC-6, Ronaldo Bahia wrote:
>
> Hi Kirby,
>
> It seems very interesting. I'll let you know if I try it.
> Just for curiosity, what differentiates your project from django-filters 
> or django-datafilters ?
>
> Thanks.
>
>
> *Ronaldo Bahia *
>
> 2015-02-24 12:57 GMT-03:00 C. Kirby >:
>
>> I'm sorry I missed this thread at the beginning. I have an app that 
>> basically gives you the ability to build "advanced search" forms in almost 
>> the same way as model forms. You can take a look at it at 
>> https://github.com/ckirby/django-modelqueryform
>>
>> If you try it or at least look at it, please let me know what you think. 
>> I am successfully using it in 3 different projects.
>>
>> Best,
>> Kirby
>>
>> On Monday, February 23, 2015 at 6:33:32 PM UTC-6, Vijay Khemlani wrote:
>>>
>>> You're welcome, glad I could help :D
>>>
>>> On Mon, Feb 23, 2015 at 5:25 PM, Ronaldo Bahia  
>>> wrote:
>>>
 Awesome! Now it works perfectly.

 I'm updating my stackoverflow code for anyone facing the same doubt.

 Thanks a lot man


 Em segunda-feira, 23 de fevereiro de 2015 13:02:06 UTC-3, Vijay 
 Khemlani escreveu:
>
> Change the declaration of the funciotn
>
> def filter_job_candidates(job):
>
> to
>
> def filter_job_candidates(self, job):
>
> And the filtering depends on the particular job being displayed on the 
> view, if you change the line to
>
> Job.objects.applied_to.all()
>
> Then it would filter the candidates for all the jobs, not the 
> particular one the user is seeing on the view (the one that is passed to 
> the form method).
>
>
>
>
> On Mon, Feb 23, 2015 at 12:31 PM, Ronaldo Bahia  
> wrote:
>
>> Oh, I'm feeling stupid right now :D
>>
>> now my new error:
>>
>> filter_job_candidates() takes exactly 1 argument (2 given)
>>
>> in views.py
>>
>> job_candidates = form_cand.filter_job_candidates(self.object)
>>
>> I've tried to remove the arguments but django says "global name 
>> 'self' not defined"
>>
>> I also think that in forms.py the correct way to write is:
>>
>> def filter_job_candidates(job):
>> assert self.is_valid()
>>  job_candidates = Job.objects.applied_to.all()
>>
>> Or am I wrong?
>>
>> Sorry for bothering...
>>
>>
>>
>> Em segunda-feira, 23 de fevereiro de 2015 10:50:49 UTC-3, Vijay 
>> Khemlani escreveu:
>>>
>>> Oh, if it is that line I missed a parenthesis in the my previuos 
>>> snippet in the filter of haircolor
>>>
>>> job_candidates = job_candidates.filter(candidate__candidatelook__
>>> haircolor=self.cleaned_data['haircolor'])
>>>
>>> You also need to change the other filter
>>>
>>> job_candidates = job_candidates.filter(status=s
>>> elf.cleaned_data['status'])
>>>
>>> But you should ble able to detect that kind of errors, those are 
>>> Python things, not something specifically about Django.
>>>
>>>
>>>
>>>
>>> On Mon, Feb 23, 2015 at 7:40 AM, Ronaldo Bahia  
>>> wrote:
>>>
 I have just updated my code in stackoverflow:
 http://stackoverflow.com/questions/28637326/how-to-filter-re
 sults-using-forms-in-django-best-approach

 *Ronaldo Bahia *
 Diretor | JobConvo.com
 Tel: 11 3280 6971

 2015-02-22 23:16 GMT-03:00 Vijay Khemlani :

> Well, I think you can continue posting the updated code here or 
> pastebin or in the stackoverflow question, where other people can 
> suggest 
> solutions.
>
> What is the complete message you are getting in your syntax error? 
> can you upload your whole forms.py into pastebin or something?
>
> Regards
>
> On Sun, Feb 22, 2015 at 10:53 PM, Ronaldo Bahia <
> ron...@jobconvo.com> wrote:
>
>> Vijay,
>>
>> For some reason, I'm getting SyntaxError with self.cleaned_data 
>> in forms.py 
>>
>> I'd like you to teach me how to make this. I have no problem to 
>> share my project code.
>>
>> Do you think we can make it?
>>
>> Please, email me so we can discuss about it or add me in skype: 
>> bahiamartins
>>
>> Thanks very much
>>
>> Em sábad

Re: Can the new `Prefetch` solve my problem?

2015-02-25 Thread James Schneider
Well, the Desk model you provided is blank, but I'll believe you that
there's a favorite_or_nearby_chairs attribute. ;-)

Should be relatively simple. Just add a .select_related('nearby_desks') to
your existing query and that should pull in the associated Desk object in a
single query. You can also substitute in prefetch_related(), although
you'll still have two queries at that point.

If you are trying to profile your site, I would recommend the
Django-debug-toolbar. That should tell you whether or not that query set is
the culprit.

-James
On Feb 25, 2015 1:28 PM, "Ram Rachum"  wrote:

> Hi James,
>
> I've read the docs but I still couldn't figure it out. My queryset works
> great in production, I'm trying to optimize it because our pageloads are
> too slow. I know how to use querysets in Django pretty well, I just don't
> know how to use `Prefetch`.
>
> Can you give me the solution for the simplified example I gave? This might
> help me figure out what I'm not understanding. One thing that might be
> unclear with the example I gave, is that I meant I want to get a queryset
> for `Desk` where every desk has an attribute names `favorite_or_nearby_chairs`
> which contains the queryset of chairs that I desrcibed, prefetched.
>
>
> Thanks,
> Ram.
>
> On Wed, Feb 25, 2015 at 11:18 PM, James Schneider  > wrote:
>
>> I assume that you are talking about the select_related() and
>> prefetch_related() queryset methods?
>>
>> https://docs.djangoproject.com/en/1.7/ref/models/querysets/#select-related
>>
>> https://docs.djangoproject.com/en/1.7/ref/models/querysets/#prefetch-related
>>
>> Both of those sections have excellent examples, and detail what the
>> differences are (primarily joins vs. separate queries, respectively).
>>
>> For better help, you'll need to go into more detail about the queries you
>> are trying to make, what you've tried (with code examples if possible), and
>> the results/errors you are seeing.
>>
>> In general, I would try to get an initial queryset working and gathering
>> the correct results first before looking at optimizations such as
>> select_related(). Any sort of pre-fetching will only confuse the situation
>> if the base queryset is incorrect.
>>
>> -James
>>
>> On Wed, Feb 25, 2015 at 12:05 PM, cool-RR  wrote:
>>
>>> Hi guys,
>>>
>>> I'm trying to solve a problem using the new `Prefetch` but I can't
>>> figure out how to use it.
>>>
>>> I have these models:
>>>
>>> class Desk(django.db.models.Model):
>>> pass
>>>
>>> class Chair(django.db.models.Model):
>>> desk = django.db.models.Foreignkey('Desk', related_name='chair',)
>>> nearby_desks = django.db.models.ManyToManyField(
>>> 'Desk',
>>> blank=True,
>>> )
>>>
>>> I want to get a queryset for `Desk`, but it should also include a
>>> prefetched attribute `favorite_or_nearby_chairs`, whose value should be
>>> equal to:
>>>
>>> Chair.objects.filter(
>>> (django.db.models.Q(nearby_desks=desk) |
>>> django.db.models.Q(desk=desk)),
>>> some_other_lookup=whatever,
>>> )
>>>
>>> Is this possible with `Prefetch`? I couldn't figure out how to use the
>>> arguments.
>>>
>>>
>>> Thanks,
>>> Ram.
>>>
>>> --
>>> 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/46d9fdb7-c008-4496-acda-ac7cb30b4a89%40googlegroups.com
>>> 
>>> .
>>> 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/EuPduHjSNos/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/CA%2Be%2BciVk7_6VBDoBE-qjLBwrBxiNeVdP6-fwwnOXV%3DvSA3HnCw%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 gro

Re: Re: how to put files in different dirs

2015-02-25 Thread 163 email
yes , what i mean is "media files".
there are so many file,may be several thousands ,to be uploaded from client to 
server. 
if all files in one dir , it'll be slow. 
but i don't find any way  put files in different dirs just using django.
now i write a function to put  files in different dirs ,but it complex.
is there any easy way ?
Thanks ! 



163 email

From: Rodrigo Zayit
Date: 2015-02-25 23:36
To: django-users
CC: paiis314
Subject: Re: how to put files in different dirs
Hi!


I didn't understand your question. You don't need to put all your files in the 
same dir... you can create folders like "images", "images/products", "css", 
"js", etc
Or are you asking about "media files"? I mean, files that will be uploaded 
through admin area...?


Best regards,
Rodrigo Zayit

On Wednesday, 4 February 2015 11:50:11 UTC-2, 老张 wrote:
hi . Guys
i'm designing a django web site,which produce many files.
if all these files are in ONE directory。i'm afraid that performance is a 
problem.
even i can put many entries in  stattic-dirs in setting.py.but it seems only 
one entry in stattic-dirs be used
Can anyone tell me how  i  can put files in different dirs , or in different 
dirs with same parent dir ?
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/12150c6c-e90e-414c-be8b-e77d4d220308%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/201502260930373900639%40163.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form Wizard: store the session values

2015-02-25 Thread Karim
Solved with a very easy approach.

I override the WizardView get method and I use a session variable to
understand if the user want to restore the edit or create a new form

   def get(self, request, *args, **kwargs):
"""
This method override the WizardView handling the restore of the
session
if the value request.session['restore-wizard'] is True
"""
try:
if request.session['restore-wizard']:
return self.render(self.get_form())
except KeyError:
# just call the default super get
return super(ServiceCreationWizard, self).get(request, *args,
**kwargs


-- 
Karim N. Gorjux

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


Re: TypeError: __str__ returned non-string (type bytes)

2015-02-25 Thread Mike Dewhirst
Erik and James

I really appreciate your feedback. The problem is resolved. It was related 
to py3 development and py2 in production. Erik had hit the nail on the head 
which I discovered when I went looking at why other tests were passing and 
those two were not. I had been inconsistent in implementing 
@python_2_unicode_compatible

Thank you again

Mike

On Wednesday, February 25, 2015 at 9:08:45 PM UTC+11, Erik Cederstrand 
wrote:
>
>
> > Den 25/02/2015 kl. 05.33 skrev Mike Dewhirst  >: 
> > 
> > == 
> > ERROR: test_checkreference_exp 
> (substance.tests.test_substance.TestSubstance) 
> > -- 
> > Traceback (most recent call last): 
> >  File "C:\Users\mike\env\xxdx3\ssds\substance\tests\test_substance.py", 
> line 57, in test_checkreference_exp 
> >self.assertEqual(subst.checkreference('1'), True) 
> >  File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line 
> 449, in checkreference 
> >if checkit(self, ref): 
> >  File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line 
> 441, in checkit 
> >val = u"{0}".format(obj.__dict__[field]) 
> > TypeError: __str__ returned non-string (type bytes) 
>
> "obj.__dict__[field]" returns an object that has a __str__ method 
> (format() calls the __str__ method of the object to convert it to a 
> string). The __str__ method should only return unicode data but is 
> returning byte strings. What does "obj.__dict__[field]" return, and can you 
> show us the __str__ method of that class? 
>
> Erik

-- 
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/708ead8d-ba38-4676-8f2f-fc10b2ad4aab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to filter results using forms in Django/Python (best approach) ?

2015-02-25 Thread Ronaldo Bahia
Hi Kirby,

It seems very interesting. I'll let you know if I try it.
Just for curiosity, what differentiates your project from django-filters or
django-datafilters ?

Thanks.


*Ronaldo Bahia *

2015-02-24 12:57 GMT-03:00 C. Kirby :

> I'm sorry I missed this thread at the beginning. I have an app that
> basically gives you the ability to build "advanced search" forms in almost
> the same way as model forms. You can take a look at it at
> https://github.com/ckirby/django-modelqueryform
>
> If you try it or at least look at it, please let me know what you think. I
> am successfully using it in 3 different projects.
>
> Best,
> Kirby
>
> On Monday, February 23, 2015 at 6:33:32 PM UTC-6, Vijay Khemlani wrote:
>>
>> You're welcome, glad I could help :D
>>
>> On Mon, Feb 23, 2015 at 5:25 PM, Ronaldo Bahia 
>> wrote:
>>
>>> Awesome! Now it works perfectly.
>>>
>>> I'm updating my stackoverflow code for anyone facing the same doubt.
>>>
>>> Thanks a lot man
>>>
>>>
>>> Em segunda-feira, 23 de fevereiro de 2015 13:02:06 UTC-3, Vijay Khemlani
>>> escreveu:

 Change the declaration of the funciotn

 def filter_job_candidates(job):

 to

 def filter_job_candidates(self, job):

 And the filtering depends on the particular job being displayed on the
 view, if you change the line to

 Job.objects.applied_to.all()

 Then it would filter the candidates for all the jobs, not the
 particular one the user is seeing on the view (the one that is passed to
 the form method).




 On Mon, Feb 23, 2015 at 12:31 PM, Ronaldo Bahia 
 wrote:

> Oh, I'm feeling stupid right now :D
>
> now my new error:
>
> filter_job_candidates() takes exactly 1 argument (2 given)
>
> in views.py
>
> job_candidates = form_cand.filter_job_candidates(self.object)
>
> I've tried to remove the arguments but django says "global name 'self'
> not defined"
>
> I also think that in forms.py the correct way to write is:
>
> def filter_job_candidates(job):
> assert self.is_valid()
>  job_candidates = Job.objects.applied_to.all()
>
> Or am I wrong?
>
> Sorry for bothering...
>
>
>
> Em segunda-feira, 23 de fevereiro de 2015 10:50:49 UTC-3, Vijay
> Khemlani escreveu:
>>
>> Oh, if it is that line I missed a parenthesis in the my previuos
>> snippet in the filter of haircolor
>>
>> job_candidates = job_candidates.filter(candidate__candidatelook__
>> haircolor=self.cleaned_data['haircolor'])
>>
>> You also need to change the other filter
>>
>> job_candidates = job_candidates.filter(status=s
>> elf.cleaned_data['status'])
>>
>> But you should ble able to detect that kind of errors, those are
>> Python things, not something specifically about Django.
>>
>>
>>
>>
>> On Mon, Feb 23, 2015 at 7:40 AM, Ronaldo Bahia 
>> wrote:
>>
>>> I have just updated my code in stackoverflow:
>>> http://stackoverflow.com/questions/28637326/how-to-filter-re
>>> sults-using-forms-in-django-best-approach
>>>
>>> *Ronaldo Bahia *
>>> Diretor | JobConvo.com
>>> Tel: 11 3280 6971
>>>
>>> 2015-02-22 23:16 GMT-03:00 Vijay Khemlani :
>>>
 Well, I think you can continue posting the updated code here or
 pastebin or in the stackoverflow question, where other people can 
 suggest
 solutions.

 What is the complete message you are getting in your syntax error?
 can you upload your whole forms.py into pastebin or something?

 Regards

 On Sun, Feb 22, 2015 at 10:53 PM, Ronaldo Bahia <
 ron...@jobconvo.com> wrote:

> Vijay,
>
> For some reason, I'm getting SyntaxError with self.cleaned_data in
> forms.py
>
> I'd like you to teach me how to make this. I have no problem to
> share my project code.
>
> Do you think we can make it?
>
> Please, email me so we can discuss about it or add me in skype:
> bahiamartins
>
> Thanks very much
>
> Em sábado, 21 de fevereiro de 2015 20:49:21 UTC-2, Vijay Khemlani
> escreveu:
>>
>> If both forms are used in the same view, I see little reason to
>> make them separate and ModelForms, the form class I put above should 
>> be a
>> better choice.
>>
>> In order to do the actual filtering, you can do something like
>> this
>>
>> class ScreeningForm(forms.Form):
>> haircolor = forms.ChoiceField(choices=Cand
>> idateLook.HAIRCOLOR_CHOICES, required=False)
>> status = forms.ChoiceField(choices=CandidateToJob.STATUS_CHOICES,
>> required=False)
>>
>> def filter_job_candidates(job

MySQLdb Missing Module errors

2015-02-25 Thread Rootz
I recently installed the django framework ( v1.7.4 ) and the mysql database 
connector ( pymysql ) for python. It is my understanding that the MySQLdb 
python connector is depreciated and is no longer available for download 
through PIP . However I installed pymysql which is an alternate download 
for MySQLdb connector for python. The connector (pysql) works with the 
MySQL database installed but my current django installation does not work 
because I recieve errors about missing MySQLdb module.

However despite the setback trying to use the MySQLdb package I was able to 
make changes to the installed django package ( 
django/db/backends/mysql/base.py ) that
help to make my django projects functional and error free now. 

I hope this will help those in the Django community, whom are affected by 
the same errors that I was recieving.

Thanks

Below I have outlined some of the changes I made to my django package are 
as follows:

Updates made in base.py (The base.py is locate in the django package)
Path to base.py inside the django package ( django/db/backends/mysql/ )
import pymysql as Database#MySQLdb as Database



from pymysql.converters import conversions, Thing2Literal
from pymysql.constants import FIELD_TYPE, CLIENT


### line 30 - 31 replaced MySQLdb for pymysql
### line 15 replaced MySQLdb for pymysql


#from MySQLdb.converters import conversions, Thing2Literal
#from MySQLdb.constants import FIELD_TYPE, CLIENT




Below is a snippet installing MySQLdb connector using PIP

C:\Users\root\Documents\GitHub\djangoproject-tutorial\tutorial> pip install 
mysqldb
Downloading/unpacking mySQLdb
  Could not find any downloads that satisfy the requirement mySQLdb
Cleaning up...
No distributions at all found for mySQLdb
Storing debug log for failure in C:\Users\root\pip\pip.log
C:\Users\root\Documents\GitHub\djangoproject-tutorial\tutorial>


Below is a snippet of the Django-1.7.4 interacting with the pymysql 
connector

File 
"C:\Users\root\Documents\GitHub\djangoproject-tutorial\tutorial\lib\site-packages\django\db\backends\mysql\base.py"
, line 18, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: 
No module named 'MySQLdb'


-- 
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/aac9808f-ca9f-4b57-96f4-086704267761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Delete the file related on the FileField

2015-02-25 Thread Karim
On Thu, Feb 26, 2015 at 2:13 AM, Rodrigo Zayit  wrote:

> Hi Karim,
> ​[]​
>
>
Thank you!


-- 
Karim N. Gorjux

-- 
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/CACeuRGWiDoo%3DY-GiyL3FCNzg%2BKnAvqDWYSWv%2BaZF8wDQozuXdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: wsgi dont have permission to access /wsgi_app on this server

2015-02-25 Thread dk
found the reason!!!
is not the permission is the group
doing this to the folder put into the user and group that apache can read.

chown -R apache:apache myfolder


from here
http://stackoverflow.com/questions/21498904/forbidden-you-dont-have-permission-to-access-on-this-server-centos-6-laravel
just in case some one might need it later 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/76525212-cbae-47d5-8e4f-c98ffdcae2d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Fwd: Can the new `Prefetch` solve my problem?

2015-02-25 Thread Ram Rachum
Hi James,

I've read the docs but I still couldn't figure it out. My queryset works
great in production, I'm trying to optimize it because our pageloads are
too slow. I know how to use querysets in Django pretty well, I just don't
know how to use `Prefetch`.

Can you give me the solution for the simplified example I gave? This might
help me figure out what I'm not understanding. One thing that might be
unclear with the example I gave, is that I meant I want to get a queryset
for `Desk` where every desk has an attribute names `favorite_or_nearby_chairs`
which contains the queryset of chairs that I desrcibed, prefetched.


Thanks,
Ram.

On Wed, Feb 25, 2015 at 11:18 PM, James Schneider 
wrote:

> I assume that you are talking about the select_related() and
> prefetch_related() queryset methods?
>
> https://docs.djangoproject.com/en/1.7/ref/models/querysets/#select-related
>
> https://docs.djangoproject.com/en/1.7/ref/models/querysets/#prefetch-related
>
> Both of those sections have excellent examples, and detail what the
> differences are (primarily joins vs. separate queries, respectively).
>
> For better help, you'll need to go into more detail about the queries you
> are trying to make, what you've tried (with code examples if possible), and
> the results/errors you are seeing.
>
> In general, I would try to get an initial queryset working and gathering
> the correct results first before looking at optimizations such as
> select_related(). Any sort of pre-fetching will only confuse the situation
> if the base queryset is incorrect.
>
> -James
>
> On Wed, Feb 25, 2015 at 12:05 PM, cool-RR  wrote:
>
>> Hi guys,
>>
>> I'm trying to solve a problem using the new `Prefetch` but I can't figure
>> out how to use it.
>>
>> I have these models:
>>
>> class Desk(django.db.models.Model):
>> pass
>>
>> class Chair(django.db.models.Model):
>> desk = django.db.models.Foreignkey('Desk', related_name='chair',)
>> nearby_desks = django.db.models.ManyToManyField(
>> 'Desk',
>> blank=True,
>> )
>>
>> I want to get a queryset for `Desk`, but it should also include a
>> prefetched attribute `favorite_or_nearby_chairs`, whose value should be
>> equal to:
>>
>> Chair.objects.filter(
>> (django.db.models.Q(nearby_desks=desk) |
>> django.db.models.Q(desk=desk)),
>> some_other_lookup=whatever,
>> )
>>
>> Is this possible with `Prefetch`? I couldn't figure out how to use the
>> arguments.
>>
>>
>> Thanks,
>> Ram.
>>
>> --
>> 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/46d9fdb7-c008-4496-acda-ac7cb30b4a89%40googlegroups.com
>> 
>> .
>> 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/EuPduHjSNos/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/CA%2Be%2BciVk7_6VBDoBE-qjLBwrBxiNeVdP6-fwwnOXV%3DvSA3HnCw%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/CANXboVaoYtOF5XJ2y_LOcokmn%3DfPEkqLBktYMtKVPaxCrFf-cA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can the new `Prefetch` solve my problem?

2015-02-25 Thread Ram Rachum
Hi James,

I've read the docs but I still couldn't figure it out. My queryset works
great in production, I'm trying to optimize it because our pageloads are
too slow. I know how to use querysets in Django pretty well, I just don't
know how to use `Prefetch`.

Can you give me the solution for the simplified example I gave? This might
help me figure out what I'm not understanding. One thing that might be
unclear with the example I gave, is that I meant I want to get a queryset
for `Desk` where every desk has an attribute names `favorite_or_nearby_chairs`
which contains the queryset of chairs that I desrcibed, prefetched.


Thanks,
Ram.

On Wed, Feb 25, 2015 at 11:18 PM, James Schneider 
wrote:

> I assume that you are talking about the select_related() and
> prefetch_related() queryset methods?
>
> https://docs.djangoproject.com/en/1.7/ref/models/querysets/#select-related
>
> https://docs.djangoproject.com/en/1.7/ref/models/querysets/#prefetch-related
>
> Both of those sections have excellent examples, and detail what the
> differences are (primarily joins vs. separate queries, respectively).
>
> For better help, you'll need to go into more detail about the queries you
> are trying to make, what you've tried (with code examples if possible), and
> the results/errors you are seeing.
>
> In general, I would try to get an initial queryset working and gathering
> the correct results first before looking at optimizations such as
> select_related(). Any sort of pre-fetching will only confuse the situation
> if the base queryset is incorrect.
>
> -James
>
> On Wed, Feb 25, 2015 at 12:05 PM, cool-RR  wrote:
>
>> Hi guys,
>>
>> I'm trying to solve a problem using the new `Prefetch` but I can't figure
>> out how to use it.
>>
>> I have these models:
>>
>> class Desk(django.db.models.Model):
>> pass
>>
>> class Chair(django.db.models.Model):
>> desk = django.db.models.Foreignkey('Desk', related_name='chair',)
>> nearby_desks = django.db.models.ManyToManyField(
>> 'Desk',
>> blank=True,
>> )
>>
>> I want to get a queryset for `Desk`, but it should also include a
>> prefetched attribute `favorite_or_nearby_chairs`, whose value should be
>> equal to:
>>
>> Chair.objects.filter(
>> (django.db.models.Q(nearby_desks=desk) |
>> django.db.models.Q(desk=desk)),
>> some_other_lookup=whatever,
>> )
>>
>> Is this possible with `Prefetch`? I couldn't figure out how to use the
>> arguments.
>>
>>
>> Thanks,
>> Ram.
>>
>> --
>> 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/46d9fdb7-c008-4496-acda-ac7cb30b4a89%40googlegroups.com
>> 
>> .
>> 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/EuPduHjSNos/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/CA%2Be%2BciVk7_6VBDoBE-qjLBwrBxiNeVdP6-fwwnOXV%3DvSA3HnCw%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/CANXboVY7ffbsLKi5hCaNkGUNz%2B_A2vO-PueQfCGhB%3DJoKOERnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Signals - request_finished

2015-02-25 Thread Rootz
Still not working

On Wednesday, February 25, 2015 at 12:55:29 PM UTC-5, Rodrigo Zayit wrote:
>
> If it is being loaded and it is not working, try to do by this way:
>
> from django.core.signals import request_finished
> from django.dispatch import receiver
>
> @receiver(request_finished)
> def request_finished_callback(sender, **kwargs):
> # . . .
>
> On Wednesday, 25 February 2015 14:01:24 UTC-3, Rootz wrote:
>>
>> I have tried using the request_finished signal but nothing happens when I 
>> tried testing it.
>> What suggestions or recommendations can I do to help fix the problem?
>>
>> Thank you.
>>
>>
>> Below is a sample of the signals.py file (sample is taken from 
>> djangoproject.com )
>>
>> ###SIGNALS.PY
>>
>>
>> from django.core.signals import request_finished
>>
>>
>> def my_callback(sender, **kwargs):
>> print("request finished")
>> 
>> request_finished.connect(my_callback)
>>
>>
>>
>>

-- 
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/e2287639-0b90-4e27-9766-bf4bd356fadd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can the new `Prefetch` solve my problem?

2015-02-25 Thread James Schneider
I assume that you are talking about the select_related() and
prefetch_related() queryset methods?

https://docs.djangoproject.com/en/1.7/ref/models/querysets/#select-related
https://docs.djangoproject.com/en/1.7/ref/models/querysets/#prefetch-related

Both of those sections have excellent examples, and detail what the
differences are (primarily joins vs. separate queries, respectively).

For better help, you'll need to go into more detail about the queries you
are trying to make, what you've tried (with code examples if possible), and
the results/errors you are seeing.

In general, I would try to get an initial queryset working and gathering
the correct results first before looking at optimizations such as
select_related(). Any sort of pre-fetching will only confuse the situation
if the base queryset is incorrect.

-James

On Wed, Feb 25, 2015 at 12:05 PM, cool-RR  wrote:

> Hi guys,
>
> I'm trying to solve a problem using the new `Prefetch` but I can't figure
> out how to use it.
>
> I have these models:
>
> class Desk(django.db.models.Model):
> pass
>
> class Chair(django.db.models.Model):
> desk = django.db.models.Foreignkey('Desk', related_name='chair',)
> nearby_desks = django.db.models.ManyToManyField(
> 'Desk',
> blank=True,
> )
>
> I want to get a queryset for `Desk`, but it should also include a
> prefetched attribute `favorite_or_nearby_chairs`, whose value should be
> equal to:
>
> Chair.objects.filter(
> (django.db.models.Q(nearby_desks=desk) |
> django.db.models.Q(desk=desk)),
> some_other_lookup=whatever,
> )
>
> Is this possible with `Prefetch`? I couldn't figure out how to use the
> arguments.
>
>
> Thanks,
> Ram.
>
> --
> 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/46d9fdb7-c008-4496-acda-ac7cb30b4a89%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/CA%2Be%2BciVk7_6VBDoBE-qjLBwrBxiNeVdP6-fwwnOXV%3DvSA3HnCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Signals - request_finished

2015-02-25 Thread Rootz
how do I load the signals file at the same point?

On Wednesday, February 25, 2015 at 12:29:57 PM UTC-5, Vijay Khemlani wrote:
>
> is the signals.py module being loaded at some point?
>
> If it isn't, then the connect function is never being called.
>
> On Wed, Feb 25, 2015 at 2:01 PM, Rootz > 
> wrote:
>
>> I have tried using the request_finished signal but nothing happens when I 
>> tried testing it.
>> What suggestions or recommendations can I do to help fix the problem?
>>
>> Thank you.
>>
>>
>> Below is a sample of the signals.py file (sample is taken from 
>> djangoproject.com )
>>
>> ###SIGNALS.PY
>>
>>
>> from django.core.signals import request_finished
>>
>>
>> def my_callback(sender, **kwargs):
>> print("request finished")
>> 
>> request_finished.connect(my_callback)
>>
>>
>>
>>  -- 
>> 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/c25adbf7-4654-440f-bb43-9a234339ad17%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/55f732cb-4f92-4d04-a7d4-0d8609f894d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Migrations force me to have, forever, any name/reference I use in field validators=, choices=, whatever, valid forever (even if the requirements change).

2015-02-25 Thread Luis Masuelli
I have an issue with migrations.

Suppose I declare (in my application, with name myapp) a field with a 
validators= declared. In such value (which is an iterable), I declare a 
function:

class MyModel(models.Model):
"""
This one is identifiable.
"""

identifier = models.CharField(max_length=10, unique=True, validators=[
valid_identifier])

Assume I created the migration with makemigrations:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.conf import settings
import django.core.validators
import micnt.models


class Migration(migrations.Migration):

dependencies = [
...
]

operations = [
migrations.CreateModel(
name='MyModel',
fields=[
('identifier', models.CharField(max_length=10, unique=True, 
validators=[myapp.models.valid_identifier])),
],
options={
},
bases=(models.Model,),
),
]

Assume valid_identifier is any external callable which will take one 
positional argument, and eventually raise ValidationError under certain 
conditions.

Now the requirements vary: The identifier may be national or foreign, so 
the country is required as an additional field, and also a discriminator 
field. Additionally, the validation I must perform is cross-field, so 
instead of using something in validators, I define a clean() method, and 
make the combination of country/identifier unique, instead of just the 
identifier unique:

class MyModel(models.Model):
"""
This one is identifiable.
"""

identifier_type = models.CharField(max_length=10, choices=(('passport', 
_(u'Passport')), ('national', _(u'National'))), null=False)
identifier = models.CharField(max_length=10)
country = models.ForeignKey(Country, null=False)  # assume Country 
model exists

class Meta:
unique_together = (('identifier', 'country'),)

def clean(self):
raise ValidationError('Implement this!')


And then, I don't need anymore the valid_identifier function, since my code 
does not use it anymore. So I delete it.

Now I will create the migration with makemigrations as usual. What will 
happen?

a. The command will succeed.
b. The command will explode (i. e. a normal Python exception).
c. The command will create an inconsistent migration, without exploding.
d. Jesus will come again.
e. The command will get into a kind of endless loop.

If you guesses "b", you were right. Django will report an error, since 
myapp.models.valid_identifier does not exist anymore (AttributeError).

So, once I set a value for validators= parameter and create a migration, I 
am forced to keep such reference valid for the rest of my life (e.g. by 
having valid_identifier=None, if I don't need the function anymore), or 
else the migrations will not work again since they will be traversed, 
imported, and will get such AttributeError.

Is this an expected, normal, behavior?

-- 
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/0f186fe2-e37a-41ef-882f-9d509dd6c5cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread felix

El 25/02/15 12:19, dk escribió:
thanks guys, I installed Apache and I am setting everything,  does my 
project really need to be in /etc/www/



No. It's even not recommended.
or I can put anywhere in the computer? just making sure the 
apache.conf point to that address?





   Basic configuration

Once you’ve got mod_wsgi installed and activated, edit your Apache 
server’s httpd.conf file and add the following. If you are using a 
version of Apache older than 2.4, replace Require all granted with Allow 
from all and also add the line Order deny,allow above it.


WSGIScriptAlias  //path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath  /path/to/mysite.com



Require  all  granted



Cheers,
Felix.

--
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/54EE1700.2060401%40epepm.cupet.cu.
For more options, visit https://groups.google.com/d/optout.


wsgi dont have permission to access /wsgi_app on this server

2015-02-25 Thread dk
since I couldn't get my webpage to display I started from the basic, trying 
to debug and go step by step, so I am trying to see if I can get mod_wsgi 
to work, 

https://wiki.archlinux.org/index.php/Mod_wsgi
and this is the tutorial that I am following, 

but when I go to check the website and see if I display something I get.

Forbidden
You don't have permission to access /wsgi_app on this server.


so I went and chmod 777 that python file to see if that might be the issue, 
but I still get it. have any one gotten into an issue like this?   any 
tricks that I can try?

thanks guys.




-- 
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/fee6d09e-632b-4e59-88d5-bc50bc637ed1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Can the new `Prefetch` solve my problem?

2015-02-25 Thread cool-RR
Hi guys,

I'm trying to solve a problem using the new `Prefetch` but I can't figure 
out how to use it. 

I have these models:

class Desk(django.db.models.Model):
pass

class Chair(django.db.models.Model):
desk = django.db.models.Foreignkey('Desk', related_name='chair',)
nearby_desks = django.db.models.ManyToManyField(
'Desk',
blank=True,
)

I want to get a queryset for `Desk`, but it should also include a 
prefetched attribute `favorite_or_nearby_chairs`, whose value should be 
equal to: 

Chair.objects.filter(
(django.db.models.Q(nearby_desks=desk) | 
django.db.models.Q(desk=desk)),
some_other_lookup=whatever,
)

Is this possible with `Prefetch`? I couldn't figure out how to use the 
arguments.


Thanks,
Ram.

-- 
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/46d9fdb7-c008-4496-acda-ac7cb30b4a89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread James Schneider
I believe a2ensite is a Debian-specific shortcut that allows you to quickly
enable/disable various site configurations through the use of symlinks.

For CentOS you'll need to create a configuration file in your conf.d
directory for your virtual host. I believe it will be included
automatically by httpd when it is restarted, whereas Debian configures
apache to pull configuration files from the sites-enabled directory which
contains symlinks back to the real files in sites-available.

-James
On Feb 25, 2015 11:21 AM, "dk"  wrote:

> looks like centos7 doesn't have or need that,
> it comes with a folder call conf.d
> and if the .conf file I inside this folder,  is like if was activate it.
> =)
>
>
> On Wednesday, February 25, 2015 at 1:01:57 PM UTC-6, Blazor wrote:
>
>> thanks   I am watching
>>> https://www.youtube.com/watch?v=hBMVVruB9Vs
>>> but i am stuck at min 20 since it say that I need to activate the
>>> website, with a2ensite
>>> they gave me a centos7 machine that doesn't have those commands.
>>>
>>
>>
>> a2ensite is basically a shortcut for creating a symbolic link between the
>> sites-available entry you are interested into and the sites-enabled
>> directory. You can do it manually:
>>
>> # as an administrative user
>> cd /etc/apache2/sites-enabled
>> ln -s ../sites-available/
>>
>>
>> B.
>>
>  --
> 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/a7702198-bc1b-4aeb-92a3-0a673979d04f%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/CA%2Be%2BciUc7xNTPVpSrmzku%3DiXU-3DCyO%2BLHz0Z70tnNo2GUPrEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread dk
looks like centos7 doesn't have or need that, 
it comes with a folder call conf.d 
and if the .conf file I inside this folder,  is like if was activate it.  =)


On Wednesday, February 25, 2015 at 1:01:57 PM UTC-6, Blazor wrote:

> thanks   I am watching 
>> https://www.youtube.com/watch?v=hBMVVruB9Vs
>> but i am stuck at min 20 since it say that I need to activate the 
>> website, with a2ensite 
>> they gave me a centos7 machine that doesn't have those commands.
>>
>
>
> a2ensite is basically a shortcut for creating a symbolic link between the 
> sites-available entry you are interested into and the sites-enabled 
> directory. You can do it manually:
>
> # as an administrative user
> cd /etc/apache2/sites-enabled
> ln -s ../sites-available/
>
>
> B.
>

-- 
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/a7702198-bc1b-4aeb-92a3-0a673979d04f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread Blazor

>
> thanks   I am watching 
> https://www.youtube.com/watch?v=hBMVVruB9Vs
> but i am stuck at min 20 since it say that I need to activate the website, 
> with a2ensite 
> they gave me a centos7 machine that doesn't have those commands.
>


a2ensite is basically a shortcut for creating a symbolic link between the 
sites-available entry you are interested into and the sites-enabled 
directory. You can do it manually:

# as an administrative user
cd /etc/apache2/sites-enabled
ln -s ../sites-available/


B.

-- 
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/7c2d6dcb-e542-4f43-8907-94485f4f0f4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread dk
thanks   I am watching 
https://www.youtube.com/watch?v=hBMVVruB9Vs
but i am stuck at min 20 since it say that I need to activate the website, 
with a2ensite 
they gave me a centos7 machine that doesn't have those commands.


On Wednesday, February 25, 2015 at 11:39:01 AM UTC-6, Andrew Farrell wrote:

>  Linode 
> 
>  and Digital Ocean 
> 
>  both 
> have good tutorials on setting up a production deployment of Django on a 
> virtual private server.
>
> On Wed, Feb 25, 2015 at 11:29 AM, Rodrigo Zayit  > wrote:
>
>> anywhere
>>
>>
>> Atenciosamente,
>> Rodrigo de Oliveira
>>
>> On Wed, Feb 25, 2015 at 2:19 PM, dk > 
>> wrote:
>>
>>> thanks guys, I installed Apache and I am setting everything,  does my 
>>> project really need to be in /etc/www/
>>>
>>> or I can put anywhere in the computer? just making sure the apache.conf 
>>> point to that address?
>>>
>>>
>>>
>>> On Wednesday, February 25, 2015 at 6:29:25 AM UTC-6, Fernando Ramos 
>>> wrote:
>>>
 If there's more than one person using it your site will only grow. The 
 Django web server is meant for debugging, not production.
 Go the extra step and setup ngnix or another simple http server. You 
 will thank yourself later.


 El martes, 24 de febrero de 2015, 14:49:16 (UTC-7), dk escribió:
>
> its just a website with one link =)
> basicly shows one graph. and that's it.
>
> On Tuesday, February 24, 2015 at 3:41:14 PM UTC-6, george wrote:
>
>> not production i hope.
>>
>> in prod use nginx. if not on prod use runserver 0.0.0.0:8000
>> Em 24/02/2015 18:37, "dk"  escreveu:
>>
>>> I got a virtual machine with Linux centos that we are going to use 
>>> for our django webpage.  
>>> that machine will have the html service on. so when people go to the 
>>> computer typing the IP, will show them the webpage. is there any 
>>> special 
>>> trick to do? like make a service that lunch manage.py with the 
>>> runserver 
>>> command?
>>> if any one can point me to a webpage I will appreciate.
>>>
>>> thanks guys.
>>>
>>> -- 
>>> 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/e3255fbf-
>>> 27c2-4ac5-bec6-939b9a8744cd%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...@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/5f1533ca-afee-4779-914e-6632931cea10%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...@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/CAL6GM4%2B4dryN7oOtD%2Bmejc0NUrDZrgf6wUEORtq6dGjfMSGosg%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 h

Model field with default value and choices is always reported as changed, even if unchanged

2015-02-25 Thread Carsten Fuchs

Hi all,

please consider this model definition:


def PrevMonth():
h = date.today()
return 12 if h.month == 1 else h.month-1

MONTHS_CHOICES = (
(1, "Januar"), (2, "Februar"), (3, "März"), (4, "April"),
(5, "Mai"), (6, "Juni"), (7, "Juli"), (8, "August"),
(9, "September"), (10, "Oktober"), (11, "November"), (12, "Dezember")
)

class TestModel(models.Model):
key   = models.ForeignKey(ParentModel, db_column='key', to_field='key')
monat = models.SmallIntegerField(default=PrevMonth, 
choices=MONTHS_CHOICES)



I use TestModel in the Django Admin "inline", i.e. as the related model 
of ParentModel.


The problem is that whenever an existing ParentModel instance with 
existing TestModel inlines is saved, the parent model's History view 
claims that field "monat" of TestModel has been changed, even if it 
hasn't. (If many instances of TestModel refer to the same parent model 
instance, the claim is made for each TestModel instance.)


The problem disappears if in the definition of field `monat`, either 
parameter `default` or `choices` is omitted. It also disappears if I 
change the definition to use a constant for the default value, e.g. 
`default=6`.


Does someone know what may be causing this, or how (else) it can be avoided?

Best regards,
Carsten

--
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/54EE1059.4040901%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: Python / Django slow ? Deciding my next technological stack

2015-02-25 Thread Benj
Thanks for quality answers guys, I'll definitely go the Python route and 
follow my initial intuition.

On Wednesday, February 25, 2015 at 5:57:21 PM UTC+1, Nikolas 
Stevenson-Molnar wrote:
>
> On 2/25/2015 6:27 AM, Tom Evans wrote: 
> > On Tue, Feb 24, 2015 at 11:30 PM, Benj > 
> wrote: 
> >> Hi, 
> >> i'm going to invest lots of time and energy in various web projects 
> (mostly 
> >> community web sites), and want to pick up a language / framework and 
> invest 
> >> heavily on it. 
> >> I've spent a lot of time evaluating the various options, and narrowed 
> my 
> >> choice to 2 stacks: C sharp asp.net  MVC or Python / Django. 
> >> 
> >> I'm more attracted to Python / Django combo, because of the Python 
> language, 
> >> and high level framework Django. I really want to use these. 
> >> My only concern is speed. I read that Python can't run concurrent 
> tasks, is 
> >> this true ? So a multi-processor with hyperthreads won't benefit the 
> stack 
> >> and even slow it down ? 
> >> I have no clue how this translates in reality, but should I expect 
> noticable 
> >> performance difference on a same server, shall I use Python / Django 
> than if 
> >> I had C Sharp Asp.net ? 
> >> I don't want to invest lots of time and efforts only to discover in the 
> end 
> >> that the site is slow. 
> >> You that have real world experiences with running sites, what are your 
> >> conclusions ? 
> >> 
> >> 
> >> I expect sites to be medium traffic: could be handled by a good 
> dedicated 
> >> server or average cloud ressources. 
> >> 
> >> Benj 
> > Unless you are producing web-scale sites (gmail, ebay, instagram), the 
> > speed of your website will depend more upon what you do with a 
> > framework than the framework you choose. 
> > 
> > If you are producing web-scale sites, then whatever framework you 
> > choose you will need to make the right design decisions and/or 
> > compromises. 
> > 
> > Even with the best framework in the world, if you design the 
> > architecture of a website poorly, the website will be slow. 
> > 
> > Even less important than the choice of framework is the choice of 
> > hosting container for your framework. If you ever get to the point 
> > where the speed of your wsgi container is the thing that is holding 
> > you back, well done, now you should spend some time looking at it. 
> > Until then, use the way that is easiest for you. 
> > 
> > Cheers 
> > 
> > Tom 
>
> I recently came across a recent article addressing many of common myths 
> about Python. I recommend giving it a read: 
>
> https://www.paypal-engineering.com/2014/12/10/10-myths-of-enterprise-python/ 
>
> As Tom says, it's mostly a matter of how you use the language. You can 
> write slow assembly and you can write fast Python. There are certain 
> areas where writing code in another language will yield significant 
> performance advantages, but for that most part, much of what you'd want 
> to do has already been efficiently implemented in C and made available 
> in Python. E.g., numpy (actually some of this is Fortran, too), scipy, 
> Pillow (for image processing), et. al. 
>
> My general thought is that if it works for Instagram (any many other 
> high-traffic services), it'll probably work for whatever I'm doing. 
>
> _Nik 
>

-- 
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/7856d567-92f4-492d-b36d-ebb39c8d411d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Signals - request_finished

2015-02-25 Thread Rodrigo Zayit
If it is being loaded and it is not working, try to do by this way:

from django.core.signals import request_finished
from django.dispatch import receiver

@receiver(request_finished)
def request_finished_callback(sender, **kwargs):
# . . .

On Wednesday, 25 February 2015 14:01:24 UTC-3, Rootz wrote:
>
> I have tried using the request_finished signal but nothing happens when I 
> tried testing it.
> What suggestions or recommendations can I do to help fix the problem?
>
> Thank you.
>
>
> Below is a sample of the signals.py file (sample is taken from 
> djangoproject.com )
>
> ###SIGNALS.PY
>
>
> from django.core.signals import request_finished
>
>
> def my_callback(sender, **kwargs):
> print("request finished")
> 
> request_finished.connect(my_callback)
>
>
>
>

-- 
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/20145e05-59bf-4f4b-a851-718a496609fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread Andrew Farrell
 Linode

 and Digital Ocean

both
have good tutorials on setting up a production deployment of Django on a
virtual private server.

On Wed, Feb 25, 2015 at 11:29 AM, Rodrigo Zayit 
wrote:

> anywhere
>
>
> Atenciosamente,
> Rodrigo de Oliveira
>
> On Wed, Feb 25, 2015 at 2:19 PM, dk  wrote:
>
>> thanks guys, I installed Apache and I am setting everything,  does my
>> project really need to be in /etc/www/
>>
>> or I can put anywhere in the computer? just making sure the apache.conf
>> point to that address?
>>
>>
>>
>> On Wednesday, February 25, 2015 at 6:29:25 AM UTC-6, Fernando Ramos wrote:
>>
>>> If there's more than one person using it your site will only grow. The
>>> Django web server is meant for debugging, not production.
>>> Go the extra step and setup ngnix or another simple http server. You
>>> will thank yourself later.
>>>
>>>
>>> El martes, 24 de febrero de 2015, 14:49:16 (UTC-7), dk escribió:

 its just a website with one link =)
 basicly shows one graph. and that's it.

 On Tuesday, February 24, 2015 at 3:41:14 PM UTC-6, george wrote:

> not production i hope.
>
> in prod use nginx. if not on prod use runserver 0.0.0.0:8000
> Em 24/02/2015 18:37, "dk"  escreveu:
>
>> I got a virtual machine with Linux centos that we are going to use
>> for our django webpage.
>> that machine will have the html service on. so when people go to the
>> computer typing the IP, will show them the webpage. is there any special
>> trick to do? like make a service that lunch manage.py with the runserver
>> command?
>> if any one can point me to a webpage I will appreciate.
>>
>> thanks guys.
>>
>> --
>> 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/e3255fbf-27c2-4ac5-bec6-939b9a8744cd%
>> 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/5f1533ca-afee-4779-914e-6632931cea10%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/CAL6GM4%2B4dryN7oOtD%2Bmejc0NUrDZrgf6wUEORtq6dGjfMSGosg%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/CA%2By5TLY2Sa2ponpCV1DyxbsoVkd%3DAdVgwmid_VUpDmMkGvX9%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread Rodrigo Zayit
anywhere


Atenciosamente,
Rodrigo de Oliveira

On Wed, Feb 25, 2015 at 2:19 PM, dk  wrote:

> thanks guys, I installed Apache and I am setting everything,  does my
> project really need to be in /etc/www/
>
> or I can put anywhere in the computer? just making sure the apache.conf
> point to that address?
>
>
>
> On Wednesday, February 25, 2015 at 6:29:25 AM UTC-6, Fernando Ramos wrote:
>
>> If there's more than one person using it your site will only grow. The
>> Django web server is meant for debugging, not production.
>> Go the extra step and setup ngnix or another simple http server. You will
>> thank yourself later.
>>
>>
>> El martes, 24 de febrero de 2015, 14:49:16 (UTC-7), dk escribió:
>>>
>>> its just a website with one link =)
>>> basicly shows one graph. and that's it.
>>>
>>> On Tuesday, February 24, 2015 at 3:41:14 PM UTC-6, george wrote:
>>>
 not production i hope.

 in prod use nginx. if not on prod use runserver 0.0.0.0:8000
 Em 24/02/2015 18:37, "dk"  escreveu:

> I got a virtual machine with Linux centos that we are going to use for
> our django webpage.
> that machine will have the html service on. so when people go to the
> computer typing the IP, will show them the webpage. is there any special
> trick to do? like make a service that lunch manage.py with the runserver
> command?
> if any one can point me to a webpage I will appreciate.
>
> thanks guys.
>
> --
> 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/e3255fbf-27c2-4ac5-bec6-939b9a8744cd%
> 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/5f1533ca-afee-4779-914e-6632931cea10%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/CAL6GM4%2B4dryN7oOtD%2Bmejc0NUrDZrgf6wUEORtq6dGjfMSGosg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Signals - request_finished

2015-02-25 Thread Vijay Khemlani
is the signals.py module being loaded at some point?

If it isn't, then the connect function is never being called.

On Wed, Feb 25, 2015 at 2:01 PM, Rootz  wrote:

> I have tried using the request_finished signal but nothing happens when I
> tried testing it.
> What suggestions or recommendations can I do to help fix the problem?
>
> Thank you.
>
>
> Below is a sample of the signals.py file (sample is taken from
> djangoproject.com )
>
> ###SIGNALS.PY
>
>
> from django.core.signals import request_finished
>
>
> def my_callback(sender, **kwargs):
> print("request finished")
>
> request_finished.connect(my_callback)
>
>
>
>  --
> 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/c25adbf7-4654-440f-bb43-9a234339ad17%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/CALn3ei0UXb%2B0rwNL6CYmTQTUAJJctVyoNRa6x5SSRt5h8SCLpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread dk
thanks guys, I installed Apache and I am setting everything,  does my 
project really need to be in /etc/www/

or I can put anywhere in the computer? just making sure the apache.conf 
point to that address?



On Wednesday, February 25, 2015 at 6:29:25 AM UTC-6, Fernando Ramos wrote:

> If there's more than one person using it your site will only grow. The 
> Django web server is meant for debugging, not production.
> Go the extra step and setup ngnix or another simple http server. You will 
> thank yourself later.
>
>
> El martes, 24 de febrero de 2015, 14:49:16 (UTC-7), dk escribió:
>>
>> its just a website with one link =)
>> basicly shows one graph. and that's it.
>>
>> On Tuesday, February 24, 2015 at 3:41:14 PM UTC-6, george wrote:
>>
>>> not production i hope.
>>>
>>> in prod use nginx. if not on prod use runserver 0.0.0.0:8000
>>> Em 24/02/2015 18:37, "dk"  escreveu:
>>>
 I got a virtual machine with Linux centos that we are going to use for 
 our django webpage.  
 that machine will have the html service on. so when people go to the 
 computer typing the IP, will show them the webpage. is there any special 
 trick to do? like make a service that lunch manage.py with the runserver 
 command?
 if any one can point me to a webpage I will appreciate.

 thanks guys.

 -- 
 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/e3255fbf-27c2-4ac5-bec6-939b9a8744cd%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/5f1533ca-afee-4779-914e-6632931cea10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using Signals - request_finished

2015-02-25 Thread Rootz
I have tried using the request_finished signal but nothing happens when I 
tried testing it.
What suggestions or recommendations can I do to help fix the problem?

Thank you.


Below is a sample of the signals.py file (sample is taken from 
djangoproject.com )

###SIGNALS.PY


from django.core.signals import request_finished


def my_callback(sender, **kwargs):
print("request finished")

request_finished.connect(my_callback)



-- 
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/c25adbf7-4654-440f-bb43-9a234339ad17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python / Django slow ? Deciding my next technological stack

2015-02-25 Thread Nikolas Stevenson-Molnar

On 2/25/2015 6:27 AM, Tom Evans wrote:

On Tue, Feb 24, 2015 at 11:30 PM, Benj  wrote:

Hi,
i'm going to invest lots of time and energy in various web projects (mostly
community web sites), and want to pick up a language / framework and invest
heavily on it.
I've spent a lot of time evaluating the various options, and narrowed my
choice to 2 stacks: C sharp asp.net  MVC or Python / Django.

I'm more attracted to Python / Django combo, because of the Python language,
and high level framework Django. I really want to use these.
My only concern is speed. I read that Python can't run concurrent tasks, is
this true ? So a multi-processor with hyperthreads won't benefit the stack
and even slow it down ?
I have no clue how this translates in reality, but should I expect noticable
performance difference on a same server, shall I use Python / Django than if
I had C Sharp Asp.net ?
I don't want to invest lots of time and efforts only to discover in the end
that the site is slow.
You that have real world experiences with running sites, what are your
conclusions ?


I expect sites to be medium traffic: could be handled by a good dedicated
server or average cloud ressources.

Benj

Unless you are producing web-scale sites (gmail, ebay, instagram), the
speed of your website will depend more upon what you do with a
framework than the framework you choose.

If you are producing web-scale sites, then whatever framework you
choose you will need to make the right design decisions and/or
compromises.

Even with the best framework in the world, if you design the
architecture of a website poorly, the website will be slow.

Even less important than the choice of framework is the choice of
hosting container for your framework. If you ever get to the point
where the speed of your wsgi container is the thing that is holding
you back, well done, now you should spend some time looking at it.
Until then, use the way that is easiest for you.

Cheers

Tom


I recently came across a recent article addressing many of common myths 
about Python. I recommend giving it a read: 
https://www.paypal-engineering.com/2014/12/10/10-myths-of-enterprise-python/


As Tom says, it's mostly a matter of how you use the language. You can 
write slow assembly and you can write fast Python. There are certain 
areas where writing code in another language will yield significant 
performance advantages, but for that most part, much of what you'd want 
to do has already been efficiently implemented in C and made available 
in Python. E.g., numpy (actually some of this is Fortran, too), scipy, 
Pillow (for image processing), et. al.


My general thought is that if it works for Instagram (any many other 
high-traffic services), it'll probably work for whatever I'm doing.


_Nik

--
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/54EDFF29.5070908%40consbio.org.
For more options, visit https://groups.google.com/d/optout.


Re: how to put files in different dirs

2015-02-25 Thread Rodrigo Zayit
Hi!

I didn't understand your question. You don't need to put all your files in 
the same dir... you can create folders like "images", "images/products", 
"css", "js", etc
Or are you asking about "media files"? I mean, files that will be uploaded 
through admin area...?

Best regards,
Rodrigo Zayit

On Wednesday, 4 February 2015 11:50:11 UTC-2, 老张 wrote:
>
> hi . Guys
> i'm designing a django web site,which produce many files.
> if all these files are in ONE directory。i'm afraid that performance is a 
> problem.
> even i can put many entries in  stattic-dirs in setting.py.but it seems 
> only one entry in stattic-dirs be used
> Can anyone tell me how  i  can put files in different dirs , or in 
> different dirs with same parent dir ?
> 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/12150c6c-e90e-414c-be8b-e77d4d220308%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Delete the file related on the FileField

2015-02-25 Thread Rodrigo Zayit
Hi Karim,

You can do:

from django.db.models.signals import pre_delete
from django.dispatch.dispatcher import receiver

@receiver(pre_delete, sender=ModelName)
def modelname_delete(sender, instance, **kwargs):
instance.field_name.delete(False)

or on your model you can write your delete method:

def delete(self, *args, **kwargs):
self.field_name.storage.delete(self.field_name.path)
return super(ModelName, self).delete(*args, **kwargs)


Best regards,
Rodrigo Zayit

On Tuesday, 24 February 2015 22:30:53 UTC-3, Karim Gorjux wrote:
>
> I'm using a form that get an image and store it in the database. Doing my 
> (manual) tests I discover that the deleting the FileField doesn't remove 
> the associated file on the hard disk. Is there a design pattern to handle 
> the remaining file?
>
> Thank you.
>
> -- 
> Karim N. Gorjux
>  

-- 
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/bd066bec-20d6-4162-b9bf-a74803f3f407%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: File upload error

2015-02-25 Thread Amirouche Boubekki
Héllo again (at last)

On Mon, Feb 16, 2015 at 11:20 AM Sola Chong  wrote:

> I having a error "*expected string or buffer*" when submit to upload
> avatar when edit profile. Can't figure out what is the problem..
>



I've setup a small project with your code (and small modifications) using
django 1.7 and python 2.7.8 (it's important to provide that infos).

I did not reproduce the error.

I describe below what I changed or can be changed:



>
> *Model:*
> class MyProfile(models.Model):
> user = models.ForeignKey(User)
> dob = models.DateField(null=True, blank=True)
> address = models.CharField(max_length=100, blank=True)
> contact = models.CharField(max_length=50, blank=True)
> bio = models.TextField(blank=True)
> avatar_url = FileField(_("Avatar"), max_length=200, format="Image",
>  upload_to='user/avatar', blank=True)
> banner_url = FileField(_("Cover"), max_length=200, format="Image",
>  upload_to='user/cover', blank=True)
> created = models.DateTimeField(auto_now_add=True)
> last_modified = models.DateTimeField(auto_now=True)
>

- There is no "format" parameter in FileField constructor.
- it's better to stay consistent regarding the model fields and use
models.FileField instead of FileField alone. If FileField is a custom
class, it should have another name.
- User model is referenced directly. You can live with that. It can break
in some situations cf.
https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#referencing-the-user-model


> *Forms:*
> class UserModelForm(forms.ModelForm):
> class Meta:
> model = User
> fields = ('first_name', 'last_name', 'email')
> widgets = {
> 'email': forms.TextInput(attrs={'readonly':'readonly'}),
> }
>
>
> class UserProfileModelForm(forms.ModelForm):
> dob = forms.DateField(widget=forms.DateInput(format = '%d/%m/%Y'),
>input_formats=('%d/%m/%Y',),
>required=True, help_text='dd/mm/')
> avatar_url = forms.FileField()
>
> class Meta:
> model = MyProfile
> fields = ('dob', 'address', 'contact', 'bio', 'avatar_url')
>
>
> *Views:*
> def editProfileView(request, template="controlpanel/cp_edit_profile.html"
> ):
>
> myprofiles = MyProfile.objects.all()
> myprofile = get_object_or_404(myprofiles, user=request.user)
>
> if request.method == "POST":
> form = UserProfileModelForm(request.POST, request.FILES, instance=
> myprofile)
> userForm = UserModelForm(request.POST, request.FILES, instance=
> request.user)
>
> if form.is_valid() and userForm.is_valid():
> user = userForm.save()
> profile = form.save(commit = False)
> profile.user = user
> profile.save()
>
>
> info(request, _("Successfully Edit"))
> else:
> userForm = UserModelForm(instance=request.user)
> form = UserProfileModelForm(instance=myprofile)
>
>
> context = {"cpprofile": myprofile, 'userForm':userForm, 'form':form}
>
> return render(request, template, context)
>
> *Template:*
> 
> 
> {{ title }}
> {% fields_for userForm %}
> {% fields_for form %}
> 
> {% block account_form_actions %}
>  "submit" value="Submit">
> {% endblock %}
> 
> 
> 
>
>
I don't know {% fields_for %} tag. I used {{ userForm.as_ul }} instead.

If you are interested, I can push the code online.


HTH

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


Re: Python / Django slow ? Deciding my next technological stack

2015-02-25 Thread Tom Evans
On Tue, Feb 24, 2015 at 11:30 PM, Benj  wrote:
> Hi,
> i'm going to invest lots of time and energy in various web projects (mostly
> community web sites), and want to pick up a language / framework and invest
> heavily on it.
> I've spent a lot of time evaluating the various options, and narrowed my
> choice to 2 stacks: C sharp asp.net  MVC or Python / Django.
>
> I'm more attracted to Python / Django combo, because of the Python language,
> and high level framework Django. I really want to use these.
> My only concern is speed. I read that Python can't run concurrent tasks, is
> this true ? So a multi-processor with hyperthreads won't benefit the stack
> and even slow it down ?
> I have no clue how this translates in reality, but should I expect noticable
> performance difference on a same server, shall I use Python / Django than if
> I had C Sharp Asp.net ?
> I don't want to invest lots of time and efforts only to discover in the end
> that the site is slow.
> You that have real world experiences with running sites, what are your
> conclusions ?
>
>
> I expect sites to be medium traffic: could be handled by a good dedicated
> server or average cloud ressources.
>
> Benj

Unless you are producing web-scale sites (gmail, ebay, instagram), the
speed of your website will depend more upon what you do with a
framework than the framework you choose.

If you are producing web-scale sites, then whatever framework you
choose you will need to make the right design decisions and/or
compromises.

Even with the best framework in the world, if you design the
architecture of a website poorly, the website will be slow.

Even less important than the choice of framework is the choice of
hosting container for your framework. If you ever get to the point
where the speed of your wsgi container is the thing that is holding
you back, well done, now you should spend some time looking at it.
Until then, use the way that is easiest for you.

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


[ANNOUNCE] Django 1.8 beta 1 and 1.7.5 released

2015-02-25 Thread Tim Graham
In addition to a bug fix release for the 1.7 series, the Django team has 
made the second release on the way to Django 1.8. Check out the blog post:

https://www.djangoproject.com/weblog/2015/feb/25/releases/

-- 
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/8bd0b8c8-20ba-4d5e-9e1d-74b12846751e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template_dir , template_loader missing in settings.py

2015-02-25 Thread 严超
Also this is the info that you may need :
http://stackoverflow.com/questions/3038459/django-template-path

*Best Regards!*


*Chao Yan--About me : http://about.me/chao_yan
*

*My twitter: @yanchao727 *
*My Weibo: http://weibo.com/herewearenow *
*--*

2015-02-25 20:54 GMT+08:00 严超 :

> TEMPLATE_DIRS = (
> join(BASE_DIR, 'templates'),
> )
> As a beginner, I would recommend using cookiecutter-django
>  to initiate a project
> and take look.
>
> *Best Regards!*
>
>
> *Chao Yan--About me : http://about.me/chao_yan
> *
>
> *My twitter: @yanchao727 *
> *My Weibo: http://weibo.com/herewearenow *
> *--*
>
> 2015-02-25 15:23 GMT+08:00 Priya Panthi :
>
>> hello all, I am beginner in django..As template_dir , template_loader are
>> missing in settings.py, I am facing lots of problems..Please kindly suggest
>> how I should include these. It would be a great help. I have spent hours
>> sorting it out but in vain..Thanks in advance..
>>
>> --
>> 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/dbff6410-b0f8-4c49-acac-b73de0ca9475%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/CALAMvO-Ttt13-3Q3-Xzu%2B1BhYnQSu7RhF-_uQUJN0he5RR3asg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: template_dir , template_loader missing in settings.py

2015-02-25 Thread 严超
TEMPLATE_DIRS = (
join(BASE_DIR, 'templates'),
)
As a beginner, I would recommend using cookiecutter-django
 to initiate a project and
take look.

*Best Regards!*


*Chao Yan--About me : http://about.me/chao_yan
*

*My twitter: @yanchao727 *
*My Weibo: http://weibo.com/herewearenow *
*--*

2015-02-25 15:23 GMT+08:00 Priya Panthi :

> hello all, I am beginner in django..As template_dir , template_loader are
> missing in settings.py, I am facing lots of problems..Please kindly suggest
> how I should include these. It would be a great help. I have spent hours
> sorting it out but in vain..Thanks in advance..
>
> --
> 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/dbff6410-b0f8-4c49-acac-b73de0ca9475%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/CALAMvO9WMidTWikdHAgQveKPw_kutFPGT1uYJbmSQMHxnnWRgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how to return a form in ajax call from template?

2015-02-25 Thread SHINTO PETER
how to return a form in ajax call from template?

-- 
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/58c0fa83-b914-4fcf-a02b-feebf47d7b2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


template_dir , template_loader missing in settings.py

2015-02-25 Thread Priya Panthi
hello all, I am beginner in django..As template_dir , template_loader are 
missing in settings.py, I am facing lots of problems..Please kindly suggest 
how I should include these. It would be a great help. I have spent hours 
sorting it out but in vain..Thanks in advance..

-- 
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/dbff6410-b0f8-4c49-acac-b73de0ca9475%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django deployment in a virtual machine.

2015-02-25 Thread Fernando Ramos
If there's more than one person using it your site will only grow. The 
Django web server is meant for debugging, not production.
Go the extra step and setup ngnix or another simple http server. You will 
thank yourself later.


El martes, 24 de febrero de 2015, 14:49:16 (UTC-7), dk escribió:
>
> its just a website with one link =)
> basicly shows one graph. and that's it.
>
> On Tuesday, February 24, 2015 at 3:41:14 PM UTC-6, george wrote:
>
>> not production i hope.
>>
>> in prod use nginx. if not on prod use runserver 0.0.0.0:8000
>> Em 24/02/2015 18:37, "dk"  escreveu:
>>
>>> I got a virtual machine with Linux centos that we are going to use for 
>>> our django webpage.  
>>> that machine will have the html service on. so when people go to the 
>>> computer typing the IP, will show them the webpage. is there any special 
>>> trick to do? like make a service that lunch manage.py with the runserver 
>>> command?
>>> if any one can point me to a webpage I will appreciate.
>>>
>>> thanks guys.
>>>
>>> -- 
>>> 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/e3255fbf-27c2-4ac5-bec6-939b9a8744cd%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/a505ef16-3405-411b-a5d8-b9508b31680b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Notify to other application instance running on different machine

2015-02-25 Thread Raghvendra Parashar
 

I am running Django application on multiple machines say m1, m2, m3.

all of them are using centralized database hosted on my_db_host.com.

I want to notify to m2, m3 instances from m1 on particular action/activity.

I have explored crossbar.io, but could not find proper guideline to 
integrate this.

Please let me know what is the best approach for message passing from one 
app-instance to other.

posted same question on SO: 
http://stackoverflow.com/questions/28580289/notify-to-other-application-instance-running-on-different-machine?noredirect=1#comment45495163_28580289


-- 
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/8de92e8b-8be6-460a-a67c-bfeb2070eb44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: OperationalError: ORA-03114: not connected to ORACLE.

2015-02-25 Thread Andreas Kuhne
Hi Alex,

Correct. There seems to be something wrong with the configuration of
mod_wsgi, because you are able to connect via dbshell (which loads all of
your environment variables and is able to connect). The same thing with
runserver.

Check for a good tutorial on how to configure apache + mod_wsgi. Also check
in the logs for mod_wsgi. There probably are some configuration issues that
are easy to solve.

Regards,

Andréas

2015-02-25 11:51 GMT+01:00 :

> Hi Andreas,
>
> I did the following test... i used "python manage.py runserver" and i was
> able to use the admin page (http://127.0.0.1:8000/admin/) of Django and
> log into the DB.
>
> So that means the apache and the mod_wsgi as you said have a problem,
> correct ???
>
> Regars,
> Alex
>
> On Tuesday, February 24, 2015 at 6:05:14 PM UTC+2, Andréas Kühne wrote:
>>
>> The file you wrote connects to the database itself, it doesn't use
>> djangos connection, so the only thing you are testing is if you can connect
>> to the database. And that we know (because you are able to do it with
>> ./manage.py dbshell). What you need to check is if the settings.py file
>> used by django is correctly interpreted by mod_wsgi.
>>
>> Because you are bepassing all of that, your test file will work and just
>> connects to the database.
>>
>> As I said earlier, make sure that your mod_wsgi is configured correctly
>> and that it can read your settings file.
>>
>> Regards,
>>
>> Andréas
>>
>> 2015-02-24 16:19 GMT+01:00 :
>>
>>> Well i have created the below test script to check if i am able to
>>> connect to the DB using mod_wsgi and i get back the sysdate from the DB.. I
>>> have configured mod_wsgi under the alias /test to execute the below script
>>> and i always get the time..  So it seems that the configuration in mod_wsgi
>>> is correct
>>> 
>>> import os,sys
>>>
>>> import cx_Oracle
>>>
>>>
>>> con = cx_Oracle.connect("username/password@DB")
>>> print('DATABASE VERSION: ' + con.version)
>>> print ''
>>>
>>> time= con.cursor()
>>> time.execute("SELECT TO_CHAR (SYSDATE, 'MM-DD- HH24:MI:SS') FROM
>>> DUAL")
>>>
>>> for t in time:
>>> print t
>>>
>>> con.close()
>>>
>>> def application(environ, start_response):
>>> status = '200 OK'
>>> output = 'Hello World! \r\r'
>>> output += str(t)
>>> #print sys.stderr
>>>
>>> response_headers = [('Content-type', 'text/plain'),
>>> ('Content-Length', str(len(output)))]
>>>
>>> start_response(status, response_headers)
>>>
>>> return [output]
>>>
>>>
>>> -
>>>
>>>
>>> On Tuesday, February 24, 2015 at 4:21:01 PM UTC+2, Andréas Kühne wrote:

 Hmmm

 You can use ./manage.py dbshell, so your configuration is correct in
 THAT case, however, have you set all the variables correctly for django
 when running apache + mod_wsgi? Has the connection ever worked there?

 What do the config files for mod_wsgi look like and are all of the
 paths correctly set in the mod_wsgi script?

 I'm just guessing now, but I think that the problem is your mod_wsgi
 setup.

 Regards,

 Andréas

 2015-02-24 14:17 GMT+01:00 :

> Is there any way to find out where the problem occurs ?? Is there a
> way to enable some debugging or trace in order to see which python scripts
> are called in Django and find out where the whole process is failing ??
>
> In the last lines of the stack trace it tries to close the connection
> and for some reason it fails... is it because the connection was never
> created ?? or it was closed before the application was ready to send 
> data..
> ???
>
> Can anyone help 
>
> On Tuesday, February 24, 2015 at 2:08:53 PM UTC+2, Andréas Kühne wrote:
>>
>> The reason I asked this is because that means that your connection
>> parameters are correct, so it should work?
>>
>> Sorry I don't know what to do to help you more.
>>
>> Regards,
>>
>> Andréas
>>
>> 2015-02-24 12:49 GMT+01:00 :
>>
>>> Hi Andreas,
>>>
>>> I can connect using "python manage.py dbshell" it connects without
>>> any error.
>>>
>>> Is there a difference, if i am not mistaken the dbshell test shows
>>> that the configuration of the DB is correct and that i can connect from 
>>> the
>>> machine, correct ?? From the stack trace it seems that the real issue is
>>> not returned and the only thing i get is the "NOT CONNECTED TO ORACLE" 
>>> error
>>>
>>>
>>> Regards,
>>> Alex
>>>
>>> On Friday, February 20, 2015 at 7:12:05 PM UTC+2, Andréas Kühne
>>> wrote:


 2015-02-20 17:18 GMT+01:00 :

> Hi,
>
> I migrated my project to a new infrastructure but i kept the same
> versions Apache 2.2 + mod_wsgi + python 2.6.1 + Django 1.2.1
>
> I am trying to run my p

Re: OperationalError: ORA-03114: not connected to ORACLE.

2015-02-25 Thread alexandrosstylianou88
Hi Andreas, 

I did the following test... i used "python manage.py runserver" and i was 
able to use the admin page (http://127.0.0.1:8000/admin/) of Django and log 
into the DB.  

So that means the apache and the mod_wsgi as you said have a problem, 
correct ??? 

Regars,
Alex

On Tuesday, February 24, 2015 at 6:05:14 PM UTC+2, Andréas Kühne wrote:
>
> The file you wrote connects to the database itself, it doesn't use djangos 
> connection, so the only thing you are testing is if you can connect to the 
> database. And that we know (because you are able to do it with ./manage.py 
> dbshell). What you need to check is if the settings.py file used by django 
> is correctly interpreted by mod_wsgi. 
>
> Because you are bepassing all of that, your test file will work and just 
> connects to the database.
>
> As I said earlier, make sure that your mod_wsgi is configured correctly 
> and that it can read your settings file.
>
> Regards,
>
> Andréas
>
> 2015-02-24 16:19 GMT+01:00 >:
>
>> Well i have created the below test script to check if i am able to 
>> connect to the DB using mod_wsgi and i get back the sysdate from the DB.. I 
>> have configured mod_wsgi under the alias /test to execute the below script 
>> and i always get the time..  So it seems that the configuration in mod_wsgi 
>> is correct 
>> 
>> import os,sys
>>
>> import cx_Oracle
>>
>>
>> con = cx_Oracle.connect("username/password@DB")
>> print('DATABASE VERSION: ' + con.version)
>> print ''
>>
>> time= con.cursor()
>> time.execute("SELECT TO_CHAR (SYSDATE, 'MM-DD- HH24:MI:SS') FROM 
>> DUAL")
>>
>> for t in time:
>> print t
>>
>> con.close()
>>
>> def application(environ, start_response):
>> status = '200 OK'
>> output = 'Hello World! \r\r'
>> output += str(t)
>> #print sys.stderr
>>
>> response_headers = [('Content-type', 'text/plain'),
>> ('Content-Length', str(len(output)))]
>>
>> start_response(status, response_headers)
>>
>> return [output]
>>
>>
>> -
>>
>>
>> On Tuesday, February 24, 2015 at 4:21:01 PM UTC+2, Andréas Kühne wrote:
>>>
>>> Hmmm
>>>
>>> You can use ./manage.py dbshell, so your configuration is correct in 
>>> THAT case, however, have you set all the variables correctly for django 
>>> when running apache + mod_wsgi? Has the connection ever worked there?
>>>
>>> What do the config files for mod_wsgi look like and are all of the paths 
>>> correctly set in the mod_wsgi script?
>>>
>>> I'm just guessing now, but I think that the problem is your mod_wsgi 
>>> setup.
>>>
>>> Regards,
>>>
>>> Andréas 
>>>
>>> 2015-02-24 14:17 GMT+01:00 :
>>>
 Is there any way to find out where the problem occurs ?? Is there a way 
 to enable some debugging or trace in order to see which python scripts are 
 called in Django and find out where the whole process is failing ?? 

 In the last lines of the stack trace it tries to close the connection 
 and for some reason it fails... is it because the connection was never 
 created ?? or it was closed before the application was ready to send 
 data.. 
 ??? 

 Can anyone help  

 On Tuesday, February 24, 2015 at 2:08:53 PM UTC+2, Andréas Kühne wrote:
>
> The reason I asked this is because that means that your connection 
> parameters are correct, so it should work?
>
> Sorry I don't know what to do to help you more.
>
> Regards,
>
> Andréas
>
> 2015-02-24 12:49 GMT+01:00 :
>
>> Hi Andreas, 
>>
>> I can connect using "python manage.py dbshell" it connects without 
>> any error. 
>>
>> Is there a difference, if i am not mistaken the dbshell test shows 
>> that the configuration of the DB is correct and that i can connect from 
>> the 
>> machine, correct ?? From the stack trace it seems that the real issue is 
>> not returned and the only thing i get is the "NOT CONNECTED TO ORACLE" 
>> error
>>
>>
>> Regards,
>> Alex
>>
>> On Friday, February 20, 2015 at 7:12:05 PM UTC+2, Andréas Kühne wrote:
>>>
>>>
>>> 2015-02-20 17:18 GMT+01:00 :
>>>
 Hi, 

 I migrated my project to a new infrastructure but i kept the same 
 versions Apache 2.2 + mod_wsgi + python 2.6.1 + Django 1.2.1  

 I am trying to run my project and i am getting the below exception 
 that seems to be from Django and i need help pin pointing the exact 
 cause, 
 because i think that the actual exception is never caught and returned 
 to 
 the log and all i am getting is the OperationalError: ORA-03114: not 
 connected to ORACLE. I checked the Oracle DB and i can connect to it. 

 [Fri Feb 20 17:40:51 2015] [error] [client xx.xx.xx.xx] mod_wsgi 
 (pid=27565): Exception occurred processing WSGI script 
 '/opt/wgt_proxy/wgtproxy

How load a form in popup div through ajax and submit the data in django?

2015-02-25 Thread SHINTO PETER
How load a form in popup div through ajax and submit the data in django?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.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/c843d065-8ea2-4400-9abe-07203b559069%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: __str__ returned non-string (type bytes)

2015-02-25 Thread Erik Cederstrand

> Den 25/02/2015 kl. 05.33 skrev Mike Dewhirst :
> 
> ==
> ERROR: test_checkreference_exp (substance.tests.test_substance.TestSubstance)
> --
> Traceback (most recent call last):
>  File "C:\Users\mike\env\xxdx3\ssds\substance\tests\test_substance.py", line 
> 57, in test_checkreference_exp
>self.assertEqual(subst.checkreference('1'), True)
>  File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line 449, 
> in checkreference
>if checkit(self, ref):
>  File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line 441, 
> in checkit
>val = u"{0}".format(obj.__dict__[field])
> TypeError: __str__ returned non-string (type bytes)

"obj.__dict__[field]" returns an object that has a __str__ method (format() 
calls the __str__ method of the object to convert it to a string). The __str__ 
method should only return unicode data but is returning byte strings. What does 
"obj.__dict__[field]" return, and can you show us the __str__ method of that 
class?

Erik

-- 
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/A41F5598-AC16-411E-8136-52BABB7B3640%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Gunicorn sock file is missing?

2015-02-25 Thread Erik Cederstrand

> Den 25/02/2015 kl. 07.16 skrev Kaloian :
> 
> I have an ansible provisioned VM based on this one 
> https://github.com/jcalazan/ansible-django-stack but for some reason trying 
> to start Gunicorn gives the following error:
> 
> Can't connect to /path/to/my/gunicorn.sock
> 
> [...]
> 
> Can anyone point me to any direction what could be causing the missing 
> gunicorn.sock file ?

Is gunicorn even running? If not, you ned to find out why it failed to start, 
or why it crashed. As a start, try adding the absolute path to gunicorn in your 
gunicorn_start script instead of just "exec gunicorn".

Erik

-- 
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/F5273312-7606-45BD-9042-0807A7F030D1%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: __str__ returned non-string (type bytes)

2015-02-25 Thread James Schneider
What happens when you throw in a print(obj.__dict__[field]) before the val
assignment? You should see on the console what value each iteration of the
loop is using and see if you have a strange attribute that is throwing
things out of kilter.

-James
On Feb 24, 2015 8:33 PM, "Mike Dewhirst"  wrote:

> This is driving me insane so any hints will be greatly appreciated ...
>
> Thanks
>
> Mike
>
> Here is the entire unedited test sequence plus failing code ...
>
> Python:   3.4
> Django:   1.6.9
> SQLite3:  memory
>
> Creating test database for alias 'default'...
> .E.E...
> ==
> ERROR: test_checkreference_exp (substance.tests.test_
> substance.TestSubstance)
> --
> Traceback (most recent call last):
>   File "C:\Users\mike\env\xxdx3\ssds\substance\tests\test_substance.py",
> line 57, in test_checkreference_exp
> self.assertEqual(subst.checkreference('1'), True)
>   File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line
> 449, in checkreference
> if checkit(self, ref):
>   File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line
> 441, in checkit
> val = u"{0}".format(obj.__dict__[field])
> TypeError: __str__ returned non-string (type bytes)
>
> ==
> ERROR: testcheckreference_gas (substance.tests.test_
> substance.TestSubstance)
> --
> Traceback (most recent call last):
>   File "C:\Users\mike\env\xxdx3\ssds\substance\tests\test_substance.py",
> line 75, in test_checkreference_gas
> self.assertEqual(subst.checkreference('1'.encode('utf-8')), True)
>   File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line
> 449, in checkreference
> if checkit(self, ref):
>   File "C:\Users\mike\env\xxdx3\ssds\substance\models\substance.py", line
> 441, in checkit
> val = u"{0}".format(obj.__dict__[field])
> TypeError: __str__ returned non-string (type bytes)
>
> --
> Ran 7 tests in 1.281s
>
> FAILED (errors=2)
> Destroying test database for alias 'default'...
>
> So here is the method in the substance model. The idea is that we check to
> see if the user included a bracketed reference in any field of substance or
> any field of a related object. I'll chop out the middle of the method to
> save space.
>
> def checkreference(self, ref):
> """Check all potential char fields for ref in square brackets eg
> [1]
>
> Give up as soon as it is found. Otherwise raise validation error.
> """
> def checkit(obj, ref):
> """Return True immediately but don't return False unless all
> fields have been checked."""
> for field in obj.__dict__:
> val = u"{0}".format(obj.__dict__[field])
> if ref in val:
> return True
>
> assert(ref)
> ref = "[{0}]".format(ref)
> # first check self - the substance itself
> if checkit(self, ref):
> return True
> # now each of the 1:1 and 1:n objects
> try:
> obj = Solid.objects.get(substance=self)
> if checkit(obj, ref):
> return True
> except Solid.DoesNotExist:
> pass
> 
> raise ValidationError("Reference {0} does not appear in any "
> "field".format(ref))
>
> ... and here is one of the tests (line 57 in the traceback) in error ...
>
> def test_checkreference_exp(self):
> subst = Substance.objects.get(name="Hazsub")
> exp, c = Explosive.objects.get_or_create(substance=subst)
> exp.compatibility = '[1]'
> exp.save()
> self.assertEqual(subst.checkreference('1'), True)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@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/54ED50A5.3030909%40dewhirst.com.au.
> 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/CA%2Be%2BciVZOsEBmy%3D3dBrutJPAhJ2f0

Re:

2015-02-25 Thread James Schneider
A failure in name resolution indicates a DNS query failure.

>From the machine where the script is failing, can you run 'ping portal'
and/or 'nslookup portal' and see if an IP is returned (even if the ping
fails)? Are the failures occurring in the view on the same machine (and
virtual environment if applicable)?

Is 'portal' a static host entry (/etc/hosts on Linux)?

Does using the IP of the server instead of the name work? (it should unless
your code validates SSL certificates and you don't have the IP as the CN or
SAN or it is a self-signed certificate)

Does using the fully qualified name (ie portal.example.com) work?

As an aside, what version/fork of the suds library are you using? I would
recommend against the regular suds library and instead using the suds-jurko
package, also available via PyPi. It should be a drop-in replacement
(almost literally, same imports and everything, so be sure to uninstall the
old library), and has many bug fixes and optimizations. It is a fork of the
original, since the original hasn't seen an update for close to five years.
The fork fixed several WSDL consumption issues I encountered with the
original.

https://bitbucket.org/jurko/suds

-James

I use below code to authenticate in SharePoint in my view:

import sudsimport logging

logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
from suds.client import Client

url = 'http://portal:8080/rashno/_vti_bin/lists.asmx?WSDL'
from suds.transport.https import WindowsHttpAuthenticated

ntlm = WindowsHttpAuthenticated(username='***', password='***')
client = Client(url, transport=ntlm)

But i got this error:



but when do this with python shell , it authenticate me in sharepoint and
after that i can use other sharepoint service with view or shell. can any
one tell me whats the problem?

-- 
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/4425ae16-2624-40ae-aac3-bf687b0f0d1e%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/CA%2Be%2BciUL0-2EoU4witasarmMzbXGDX1Z9t%3Dqh0KoimZOTGy2MQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to save user to foreignKey field for new records in modelFormset case?

2015-02-25 Thread Mike
Hi,
I have created modelFormset using SchoolHistory model and SchoolForm form.

"SchoolFormSet = modelformset_factory(SchoolHistory, form=SchoolForm)"

I get other content from Form, but should save current user to 
SchoolHistory model too.
  
user=models.ForeignKey(User)
school_name = models.CharField(max_length = 100)
rating_average = models.PositiveIntegerField()

I am overriding is_valid or save in order to save user field. 
My question is how to find current user in model or form level as there is 
no request parameter available ( request.user).
request was available in Formset level but I cannot save user to each 
record there, or could I?

-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/19432f21-d928-4878-b6c8-3ac20aaa04ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form Wizard: store the session values

2015-02-25 Thread Karim
I'm trying to get the data from the session. The SessionWizard store the
data in the session

session_data = request.session[wizard_key_form]['step_data']

at this point session_data is the dictionary with the data in the form
filled by the user.

But this doesn't work

ServiceCreationWizard.as_view(
FORMS,
initial_dict=session_data,
)(request)


Working with ipdb and django toolbar and reading the docs here[1] seems to
me that the fields name in the session dictionary are a little different
from the forma requested by the initial_dict

initial_dict wants something like

initial = {
... '0': {'subject': 'Hello', 'sender': 'u...@example.com'},
... '1': {'message': 'Hi there!'}
... }

but session are stored in this way

 u'step_data': {
  u'0': {u'0-subject': u'Hello', u'0-sender': u'u...@example.com'}
  u'1': {u'1-message': u'Hi there!'},
}

Do I have to convert all the keys name to pass the session values to the
initial_dict? Maybe there is a better way to backup and restore the session?

Thank you


[1]
https://docs.djangoproject.com/en/1.7/ref/contrib/formtools/form-wizard/#django.contrib.formtools.wizard.views.WizardView.initial_dict



On Wed, Feb 25, 2015 at 12:14 PM, Karim  wrote:

> When I click on the link for my form,
> ​[...]
>

-- 
Karim N. Gorjux

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


Re: django deployment in a virtual machine.

2015-02-25 Thread aRkadeFR

Hello there,

It's always good to take a look at how prodding a django website.

As George Silva said, you need nginx/apache or other. They will serve
your media and static files. Then for the django server, you need
to run it in uWSGI or another wsgi, and link it to your nginx/apache.

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Have fun :)

On 02/24/2015 10:49 PM, dk wrote:

its just a website with one link =)
basicly shows one graph. and that's it.

On Tuesday, February 24, 2015 at 3:41:14 PM UTC-6, george wrote:

not production i hope.

in prod use nginx. if not on prod use runserver 0.0.0.0:8000


Em 24/02/2015 18:37, "dk" > escreveu:

I got a virtual machine with Linux centos that we are going to
use for our django webpage.
that machine will have the html service on. so when people go
to the computer typing the IP, will show them the webpage. is
there any special trick to do? like make a service that lunch
manage.py with the runserver command?
if any one can point me to a webpage I will appreciate.

thanks guys.
-- 
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/e3255fbf-27c2-4ac5-bec6-939b9a8744cd%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/bf9c8f15-7206-4932-95c9-d5c8bc82af9b%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/54ED85B1.2020507%40arkade.info.
For more options, visit https://groups.google.com/d/optout.