Re: django.contrib.auth doesn't support template context processors?

2015-01-21 Thread James Schneider
Hmm, I stand corrected:

https://github.com/django/django/blob/1.7.3/django/template/response.py#L156

It does render the context via RequestContext().

However, I can also point out why I thought I was right (in addition to my
apparently flawed/rushed test):

https://github.com/django/django/blob/master/django/template/response.py#L188

In that function definition, you'll see that RequestContext() is never
called/rendered before being passed back to the parent class methods, nor
do they override the resolve_context() method. Doh!

It appears that in the current master branch and 1.8a1, that Context() is
on its way out (or is getting a major refactoring), and everything is
moving to RequestContext(). The RN are a bit sketchy on this topic still.

https://docs.djangoproject.com/en/dev/releases/1.8/#dictionary-and-context-instance-arguments-of-rendering-functions

That aside though, I re-ran my quick test a bit under 1.7.3 a bit more
formally using a blank project with as basic of a config as I could with
the debug toolbar, a single app, and a single template. My urls.py
referenced django.contrib.auth.views.password_reset. The only change to the
default settings was adding django.core.context_processors.request to
TEMPLATE_CONTEXT_PROCESSORS. After throwing a {{ request }} in my template,
a ton of WSGI garbage in the request made me red in the face. Debug toolbar
also confirmed the context processors ran. As would be expected.

Not sure what happened with my other test, I probably ran through it with
too much confidence after viewing the wrong branch of source code.

Apologies.

-James


On Wed, Jan 21, 2015 at 3:19 PM, Tom Evans  wrote:

> On Wed, Jan 21, 2015 at 2:31 PM, Mark Rogaski  wrote:
> > Thanks, James.  I think the call to TemplateResponse is fine, but the
> > context that's passed as a dict needs to be passed as a ContextRequest
> > instead.
>
>
> https://docs.djangoproject.com/en/1.7/ref/template-response/#django.template.response.TemplateResponse
>
> "TemplateResponse is a subclass of SimpleTemplateResponse that uses a
> RequestContext instead of a Context."
>
> So something else is going awry. Fire up a shell and confirm the value
> of settings.TEMPLATE_CONTEXT_PROCESSORS is what you expect it to be.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1%2BcUM13fdrEwXykLuWdsTb7uevz0kMQahY5TCioCv38EA%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%2Be%2BciVOWrNYUVUrtPhRK%3DDOHp9TrvMDCcpydm7VZb8BcRQU1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: sending email

2015-01-21 Thread sum abiut
Thanks,
I am trying to send email to the users that their email address is stored
in the database on the auth_user table. can someone please point me to the
right direction.

Cheers,


On Thu, Jan 22, 2015 at 3:03 PM, Collin Anderson 
wrote:

> Hi,
>
> Yes, this is possible. Something like:
>
> from django.core.mail import send_mail
>
> def authorized_leave(request):
> form = MyForm()
> if request.method == 'POST':
> form = MyForm(request.POST)
> if form.is_valid():
> obj = form.save()
> send_mail('Subject here', 'Here is the message.', '
> f...@example.com', ['t...@example.com'])
> return redirect('/done/')
> return render(request, 'template.html', {form: 'form'})
>
> Collin
>
>
> On Monday, January 19, 2015 at 10:02:45 PM UTC-5, suabiut wrote:
>>
>> Hi,
>> I am trying to send an email to several users once a form is submit. I
>> have done the view.py to update the database once the form is submitted and
>> is working fine. what i want to accomplish when the form is submitted is to
>> update the database and at the same time send out email when a user click
>> on the Authorized leave button.
>>
>> here is the step i want to do:
>>
>>  [image: Inline image 1]
>>
>> 1) user click on the check box and this form below appears
>>
>>
>> [image: Inline image 2]
>>  2) the user then fill up the form and click on authorized leave button.
>> the form will stored the information into the database. which i have
>> already done it. what i wanted to do next is to also send a emails when the
>> authorized leave button is click. is it possible to send emails and also
>> save data to database when the authorized leave button is click. i want to
>> send email to the *Test User* which have his email address store in the
>> database.
>>
>> template.html
>> {%csrf_token%}
>> 
>> {{form.as_table}}
>> 
>> 
>> 
>>
>>
>> 
>>
>> please point me to the right direction.
>>
>> Cheers,
>>
>>   --
> 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/3df19a0c-2afc-4e17-b527-83d38a639611%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/CAPCf-y4fu-Znpem4qJrU8iSh8jeaWNSEa9VfHzn0_fxPfG1wfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: sending email

2015-01-21 Thread Collin Anderson
Hi,

Yes, this is possible. Something like:

from django.core.mail import send_mail

def authorized_leave(request):
form = MyForm()
if request.method == 'POST':
form = MyForm(request.POST)
if form.is_valid():
obj = form.save()
send_mail('Subject here', 'Here is the message.', 
'f...@example.com', ['t...@example.com'])
return redirect('/done/')
return render(request, 'template.html', {form: 'form'})

Collin

On Monday, January 19, 2015 at 10:02:45 PM UTC-5, suabiut wrote:
>
> Hi,
> I am trying to send an email to several users once a form is submit. I 
> have done the view.py to update the database once the form is submitted and 
> is working fine. what i want to accomplish when the form is submitted is to 
> update the database and at the same time send out email when a user click 
> on the Authorized leave button.
>
> here is the step i want to do:
>
>  [image: Inline image 1]
>
> 1) user click on the check box and this form below appears
>
>
> [image: Inline image 2]
>  2) the user then fill up the form and click on authorized leave button. 
> the form will stored the information into the database. which i have 
> already done it. what i wanted to do next is to also send a emails when the 
> authorized leave button is click. is it possible to send emails and also 
> save data to database when the authorized leave button is click. i want to 
> send email to the *Test User* which have his email address store in the 
> database. 
>
> template.html
> {%csrf_token%}
> 
> {{form.as_table}}
> 
> 
>   
>
>
> 
>
> please point me to the right direction.
>
> Cheers,   
>
>  

-- 
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/3df19a0c-2afc-4e17-b527-83d38a639611%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: post_save signal not working in Django 1.7

2015-01-21 Thread Collin Anderson
Hi,

Does the object in post_save have a pk/id?

Are you using transactions?

Collin

On Monday, January 19, 2015 at 1:22:37 PM UTC-5, Luis Matoso wrote:
>
> Something similar is happening with me too: on a post_save of model it 
> isn't created yet on database, so several 
> error are raised by functions which expect that it is already on DB.
>
> When the post_save handler ends, the object is saved normally.
>
>
> On Friday, January 16, 2015 at 4:14:09 PM UTC-2, Zach LeRoy wrote:
>>
>> I have a block of code that works fine in Django 1.6.10 but does not work 
>> at all in Django 1.7.3.  I would expect my log statement to print every 
>> time a Django User is created and this is the behavior in 1.6.10:
>>
>> import logging
>>
>> from django.contrib.auth.models import User
>> from django.db import models
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>>
>> log = logging.getLogger(__name__)
>>
>>
>> class UserProfile(models.Model):
>> uuid = models.CharField(max_length=36)
>> user = models.OneToOneField(User)
>>
>>
>> @receiver(post_save, sender=User)
>> def create_user_profile(sender, instance, created, **kwargs):
>> """
>> When a new user is created, add a UserProfile
>> """
>> log.debug('received post save signal: {}'.format(instance))
>> if created:
>> UserProfile.objects.create(user=instance)
>>
>

-- 
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/f29ac31a-46ee-4b04-8058-d0acac2a5547%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Flood of ''Invalid HTTP_HOST header" mails

2015-01-21 Thread Collin Anderson
Hi,

So django is rejecting hosts even though they are listed in ALLOWED_HOSTS? 
Are you using apache/mod_wsgi by chance? It could be loading the settings 
for the wrong website. I assume you are reloading the server in between 
changes to the file.

Collin

On Monday, January 19, 2015 at 1:18:11 PM UTC-5, andi-h wrote:
>
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA1 
>
> Hi folks, 
>
> after upgrading my project to Django 1.7 it seems my host validation 
> got a bit out of control. I have tried these possibilities, but my web 
> server continues to send lots of mail about invalid HTTP_HOST headers: 
>
> ALLOWED_HOSTS = [ ".example.com" ] # domain name changed ;) 
> ALLOWED_HOSTS = [ "example.com", "www.example.com" ] 
>
> But in each case I get the mails about "www.example.com". Has anybody 
> else encountered this? 
>
> CU Andi 
> - -- 
> Andreas Pritschet 
> Phone:   +49 151 11728439 
> Homepage:http://www.pritschet.me 
> GPG Pub Key: http://goo.gl/4mOsM 
> -BEGIN PGP SIGNATURE- 
> Version: GnuPG v1 
>
> iQIcBAEBAgAGBQJUvUojAAoJEO0gsAalef15wqIP/3BBybnA6ZhBiIw33gnXa/TX 
> vYJrqcLv6mFQ4s7UmR4wxdTo+IfjZhhEx0p4qEqxOArPahdObAoO8KQEoFSanO3f 
> VVCq7EBSS84g26/NrVfudyERgjxPbLvVL9L7vUbSxNuT5HYBW0IXqWOXUhkq8VsK 
> gGGZkbQft8IH3jK28FNnNAJ+6PVY9yL2NDgB475Y6IlLqJHaXZYLl46U9ZbdTrF4 
> apJUmoaorZ1ul5Ga1Xkj8c97RSfyQwK2EH6IQ7Vb2U7Ad/5sDsVKC/Kx6hxt2fbR 
> ZkWPqVXAs7SbZIwAyeUggVEhz6n0XKzAYk7lsbNOzitwAWIXuzqk+5Hu/anDsTmt 
> lS144lIyhuIKNPgwv02eNg4wH5hytXwK+kf1Z/4H+LcNu5szxMtREb2/PBvm/nQC 
> zoJYZV1+sTmSjKKOb8DoX5i+dVdhgbQzvu/XBIJBLbUn4NSQiAlEKnArBeD2H01Z 
> K1u37aIITOgcFqigDnLQEfIfzl+nng/O22W9RISPEOMyjE+9wcmgYXiKAt1RY2C5 
> LjJQwhIkb94Aqzv288ip2131NxZq/eoGO8neQNBRRM4BoYbeP9gDT9D+BF8bnkQL 
> FO5emHWj7oLdtcUteyMKKgdP/ryrwHiAQ2MBUIMVfPmmmCD2PN1M8v6nmPV0mbCH 
> dQ6GeHlr/6Gh3rpoNFb/ 
> =L0Pv 
> -END PGP SIGNATURE- 
>

-- 
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/c6f9d495-54fb-4155-8527-dfbde8bc1dc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Desperately need Django help!

2015-01-21 Thread Collin Anderson
Hi,

A new CSRF token gets generated after you log in, so you'll need to ask 
django for the new one, or simply ready the new value from document.cookie.

Collin

On Monday, January 19, 2015 at 3:08:34 AM UTC-5, Neil Asnani wrote:
>
> Hi, I am trying to build a single page, restful application to track 
> expenses that allows users to sign up, log in, and edit / delete / filter 
> expenses, all on a single page. I am very new to Django, and all other web 
> technologies and this app is making my head spin. I have been working on 
> this for the past week now and have made progress but I am getting errors 
> left and right and do not know how to resolve them. I am also having 
> difficulty finding and following the tutorials online. I am however not new 
> to programming and once I get past this initial road block should pick 
> things up quickly.
>
> The code is here: https://github.com/tested22/Expense-tracker1 I am 
> currently getting a csrf token error when I merged the log in and sign up 
> pages onto home.html, though I have the csrf token tags in the forms.
>
> Could someone please spend some time with me via Skype or Google hangouts 
> to explain Django and help me troubleshoot my application? I would be so 
> thankful and we could work out a form of payment.
>

-- 
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/bdb01abf-9523-4509-8793-17e6f7ffc614%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Canvas OAuth2 From Django View

2015-01-21 Thread Collin Anderson
Hi Henry,

You need to send some kind of response back to the browser and the user. 
Maybe a message? or a maybe redirect to another page?

def final_step(request):
code = request.GET['code']
r = requests.post('https:///login/oauth2/token', {
'code': code, 'client_id': 'etc'}
access_code = r.json()['access_code']
return HttpResponse('Successfully Logged in! Here's your access_code: %s' 
% access_code)

Collin

On Sunday, January 18, 2015 at 7:01:12 PM UTC-5, Henry Versemann wrote:
>
> Collin, thanks for the help. My django application as it is already has 
> the "requests" library installed within it and I have already registered it 
> with the API which I'm trying to authenticate to currently using that API's 
> oauth2 web application flow, which is a three step process (see the oauth2 
> tab for the  Canvas API). I'm able so far to send a redirect-uri to the 
> Canvas Oauth2 api and have it respond back to me with all of the other 
> information I need to get my final access token from then. My application 
> currently uses Python 2.7.8 and Django 1.7 and the piece of the process 
> that I'm having the problem with is sending the final POST request back to 
> the Canvas Oauth2 flow API. The response that up to now I've tried to 
> return back from my django view  has been an HttpResponse which apparently 
> does not allow the sending of a POST request. I've also taken a look at all 
> of the shortcut functions that django offers as options to return back from 
> django views, and none of them appear at least not obviously to offer any 
> options for sending POST requests. Your response below seems to show how I 
> might get the access token back from the final POST request which I need to 
> make to the Canvas Oauth2 flow. Can you show me how to do that POST, 
> and what I need my view to return, to avoid getting and error which says 
> that my view did  not return a valid HttpResponse but instead returned 
> "None" like I've gotten up until now?
> Thanks again for the help.
>
> Henry 
>
> On Saturday, January 17, 2015 at 7:33:40 AM UTC-6, Collin Anderson wrote:
>
>> Hi,
>>
>> Use urllib/urllib2 or requests to POST to other websites. Python can do 
>> it natively.
>>
>> try:  # Python 3
>> from urllib import request as urllib_request
>> except ImportError:  # Python 2
>> import urllib2 as urllib_request
>> from django.utils.http import urlencode
>>
>> def my_view(request):
>> response = urllib_request.urlopen('https://endpoint/', urlencode({
>> 'mytoken': '12345'}))
>> data = response.read()
>> # etc
>>
>> https://docs.python.org/3/library/urllib.request.html
>> https://docs.python.org/2/library/urllib2.html
>>
>> or install requests, which is friendlier:
>> http://docs.python-requests.org/en/latest/
>>
>> Collin
>>
>> On Thursday, January 15, 2015 at 11:51:45 AM UTC-5, Henry Versemann wrote:
>>>
>>> First let me say that I haven't done a lot of stuff with either Python 
>>> or Django, but I think I understand most of the basics. 
>>> I am trying to get an access token back from the OAuth2 Web Application 
>>> Flow of the Canvas' LMS API ( 
>>> https://canvas.instructure.com/doc/api/file.oauth.html ). 
>>> I have successfully sent the request in step 1 of the flow, and 
>>> received back and extracted out of the response all of the data needed for 
>>> step 3, which came back in step 2 of the flow.
>>> So now in step 3 of the flow my problem is how to send a POST of the 
>>> request needed, as described in step 3 of the flow, from a Django View.
>>> I've not found anything definitive saying that I absolutely can't do 
>>> a POST of a request, from a Django View, and have seen some  items which 
>>> seem to indicate that I can do a POST from a view, but none of them seem to 
>>> have detailed code examples or explanations of how to do it if it is 
>>> possible. 
>>> So far I've tried several ways of sending the POST within a 
>>> returned HttpResponse and have not been successful, and if I understand 
>>> things correctly HttpResponse doesn't allow it. 
>>> I have also looked at all of the other Django Shortcut Functions 
>>> documentation, and none of them seem to offer any obvious way of POSTing a 
>>> request either. 
>>> Can someone please point me to a good example of how to do it if it is 
>>> possible, and if it is not maybe point me to one or more examples of how I 
>>> might be able to successfully go through the Canvas OAuth2 Web Application 
>>> Flow using some other module or package, that I can integrate into my 
>>> Django application?
>>> Thanks for the help.
>>>
>>

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

makemigrations complains about a ForeignKey not being Unique

2015-01-21 Thread Samuel Jean

Hi there,

Does anybody know of a way to trick Django 1.7 (or the proper way, if 
any) to modify the property of an inherited field so that it has unique 
property on the children only.


Consider this abstract model :

class UniqueObjectModel(models.Model):
uuid = models.CharField(max_length=36, default=uuid4)
pool = models.ForeignKey('Pool', related_name='+', to_field='uuid')
...

class Meta:
abstract = True
unique_together = (('uuid', 'pool'),)

I would like the Pool model to inherit from UniqueObjectModel *but* have 
its uuid field unique.


class Pool(UniqueObjectModel):
def __init__(self, *args, **kwargs):
super(Pool, self).__init__(*args, **kwargs)
self._meta.get_field('pool').to = 'self'
self._meta.get_field('uuid')._unique = True

However, Django still complains about Pool.uuid field not being unique.

$ python manage.py makemigrations myapp

CommandError: System check identified some issues:

ERRORS:
myapp.Controller.pool: (fields.E311) 'Pool.uuid' must set unique=True 
because it is referenced by a foreign key.


Any ideas?

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


Remote Authentication (out-of-the-box)

2015-01-21 Thread Cristian Bustos
Hello Friends,
Here is my question, Remote Authentication (out-of-the-box) django
I have 2 projects Django:

   1. Users Api Django app (Django framework rest - token authentication) - 
   Server
   2. Django app (I need to authenticate users and consume APIs) - Client
   
I can authenticate user, only use requests-python, but i need do remote 
authentication with django

This is my code:
settings.py

AUTHENTICATION_BACKENDS = ( 
'django.contrib.auth.backends.RemoteUserBackend', )

MIDDLEWARE_CLASSES = ( '...', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.auth.middleware.RemoteUserMiddleware',
 '...', )


view.py
-
class LoginRCS(View):
template_name = 'userprofiles/login.html'

def get(self, request, *args, **kwargs):
return render(request, self.template_name )

def post(self, request, *args, **kwargs):
# inputBp and inputPassword come from login form
if 'inputBp' in request.POST and 'inputPassword' in request.POST:
inputBp = request.POST['inputBp']
inputPassword = request.POST['inputPassword']

# URL to get token from api user
URL_API = 'http://localhost:7000/api/token/'
payload = {'username': inputBp, 'password': inputPassword}
headers = {'content-type': 'application/json'}
r = requests.post(URL_API, data=json.dumps(payload), 
headers=headers)

if r.status_code == requests.codes.ok:
# I have a token
data = json.loads(r.text)
token_auth = 'token ' + data['token']

URL_CHECK_USER = '
http://127.0.0.1:7000/api/users/?username='+inputBp 

payload_login = {'username': inputBp, 'password': 
inputPassword}
headers_login = {
'content-type': 'application/json',
'Authorization': token_auth }
r_user = requests.get(URL_CHECK_USER, 
data=json.dumps(payload_login), headers=headers_login)

if r_user.status_code == request.codes.ok:
# I have a user info (unsername, first_name, last_name, 
email)
data_user = json.loads(r_user.text)

#
# here need authentication
# 
# user = authenticate(username=my_user, password=my_bp)

else:
print 'Error'
return render(request, self.template_name)

thanks in advance,
CB

-- 
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/8b8fac15-a958-4194-9485-af1de580926c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use password hasher snippet in Django?

2015-01-21 Thread Tom Lockhart
On Jan 21, 2015, at 3:07 PM, Supermario  wrote:I am trying to move Druap 7 site to django 1.7 without invalidating user passwords, and this proved to be daunting.Fortunately, I have found this SO question and this hashing snippet but there is no documentation and as a newbie to django, I have no clue how to integrate the snippet into my project.I’ve enclosed a password processor I used in the past for a Drupal conversion; the gist came from a web search and is attributed in the code but has some minor fixes. I’ve actually included two processors, with one disabled with “XXXâ€� in the function name. I think I had trouble getting that one to work.You can create a “drupalâ€� app, which just has an __init__.py and this file as hashers.pyYou will want to add “drupalâ€� as one of your apps, then also define the following in your settings.py:PASSWORD_HASHERS = (    'django.contrib.auth.hashers.PBKDF2PasswordHasher',    'drupal.hashers.DrupalPasswordHasher',    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',    'django.contrib.auth.hashers.BCryptPasswordHasher',)Since you are starting fresh, you can include only the recommended best password hasher from Django plus the drupal hasher. And if you prefer you could fold the hashers.py file into another existing app in your project.Also, the structure of your project may be a bit different from mine since the recommended Django layout has changed a bit over the last few versions.hth, and enjoy getting the heck away from Drupal hell…- 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/B276D536-93E4-4A28-AB5B-9E184685B675%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
import hashlib

from django.contrib.auth.hashers import BasePasswordHasher
from collections import OrderedDict


class DrupalPasswordHasherXXX(BasePasswordHasher):
"""
From dgrtwo at http://djangosnippets.org/snippets/2729
As it stands, this looks for a password which starts with "S"
so needs the leading "$" present in the drupal hashed value removed.
This also fails in the user admin panel; perhaps due to a missing
safe_summary method.
"""
algorithm = "S"
iter_code = 'C'
salt_length = 8
_ITOA64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

def encode(self, password, salt, iter_code=None):
"""The Drupal 7 method of encoding passwords"""
if iter_code is None:
iterations = 2 ** self._ITOA64.index(self.iter_code)
else:
iterations = 2 ** self._ITOA64.index(iter_code)
hash = hashlib.sha512(salt + password).digest()
for i in range(iterations):
hash = hashlib.sha512(hash + password).digest()
pass
l = len(hash)

output = ''
i = 0
while i < l:
value = ord(hash[i])
i = i + 1
output += self._ITOA64[value & 0x3f]
if i < l:
value |= ord(hash[i]) << 8
output += self._ITOA64[(value >> 6) & 0x3f]
if i >= l:
break
i += 1
if i < l:
value |= ord(hash[i]) << 16
pass
output += self._ITOA64[(value >> 12) & 0x3f]
if i >= l:
break
i += 1
output += self._ITOA64[(value >> 18) & 0x3f]
pass
longhashed = "%s$%s%s%s" % (self.algorithm, iter_code, salt, output)
return longhashed[:54]

def verify(self, password, encoded):
hash = encoded.split("$")[1]
iter_code = hash[0]
salt = hash[1:1 + self.salt_length]
return encoded == self.encode(password, salt, iter_code)


class DrupalPasswordHasher(BasePasswordHasher):
"""
From grillermo at http://djangosnippets.org/snippets/2924/
Modified from DrupalPasswordHasher to fix "the issue" whatever that is.
To verify functionality:
>>> h = DrupalPasswordHasher()
>>> h.verify("password1234", "$S$DeIZ1KTE.VzRvudZ5.xgOakipuMFrVyPmRdWTjAdYieWj27NMglI")
True
"""
DRUPAL_HASH_COUNT = 15
DRUPAL_MIN_HASH_COUNT = 7
DRUPAL_MAX_HASH_COUNT = 30
DRUPAL_HASH_LENGTH = 55
_ITOA64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
algorithm = 'drupal'

def verify(self, password, hashed_password):
# django-1.5 passes in password in unicode which causes trouble in hashlib.sha512()
if (isinstance(password, unicode)):
password = password.encode('ascii')
pass
# slight 

Re: Queryset .count() breaks when counting distinct values generated by .extra()

2015-01-21 Thread Collin Anderson
Hi,

I don't use extra() a lot, but it could be that count() clears out extra. 
This doesn't exactly answer your question, but you may want to try your 
query on the 1.8 alpha using the new available expressions. You might be 
able to do this without needing extra() at all in 1.8.

Collin

On Sunday, January 18, 2015 at 3:24:49 PM UTC-5, Mattias Linnap wrote:
>
> Hi all,
>
> I think I've found a strange case where QuerySet.count() does not match 
> len(queryset), and the behaviour is certainly unexpected.
> But I'm not sure whether this is a bug, some mistake on my part, or a 
> known limitation of combining .extra(), .distinct() and .count().
> I am aware of the default ordering interfering with .distinct(), and 
> already add .order_by() to get rid of it.
>
> I have a model called RadioSignal, with an integer field "rssi". I'm 
> interested in finding out how many distinct values for "rssi / 10" there 
> are (-10, -20, -30, etc).
>
> Here is a commented "./manage.py shell" record:
>
> >>> RadioSignal.objects.count()
> 523 
> >>> RadioSignal.objects.order_by().values('rssi').distinct().count() 
> 49
> >>> connection.queries[-1]['sql']
> 'SELECT COUNT(DISTINCT "maps_radiosignal"."rssi") FROM "maps_radiosignal"'
>
> Looks okay so far. But I'm interested in each distinct tens of RSSI 
> values, not every single value. I can compute these with .extra():
>
> >>> len(RadioSignal.objects.order_by().extra({'tens': 'rssi / 
> 10'}).values('tens').distinct())
> 6
> >>> RadioSignal.objects.order_by().extra({'tens': 'rssi / 
> 10'}).values('tens').distinct()
> [{'tens': -8}, {'tens': -4}, {'tens': -5}, {'tens': -9}, {'tens': -6}, 
> {'tens': -7}]
> >>> connection.queries[-1]['sql']
> 'SELECT DISTINCT (rssi / 10) AS "tens" FROM "maps_radiosignal" LIMIT 21'
>
> Also looks good so far. But running len() on a queryset is unnecessary if 
> I only need the count.
>
> >>> RadioSignal.objects.order_by().extra({'tens': 'rssi / 
> 10'}).values('tens').distinct().count()
> 523
> >>> connection.queries[-1]['sql']
> 'SELECT COUNT(DISTINCT "maps_radiosignal"."id") FROM "maps_radiosignal"'
>
> Uhoh. Somehow .count() keeps the .distinct() part, but replaces the 
> .extra() and .values() parts with counting primary keys?
>
> I tried it with values('tens'), values_list('tens'), and 
> values_list('tens', flat=True), as well no change.
> So far I've tested Django 1.6 with Python 2.7 and PostgreSQL 9.3, and 
> Django 1.7 with Python 3.4 and PostgreSQL 9.1, all seem to behave the same.
>
> I can work around this, since the possible resulting querysets are pretty 
> small, and evaluating them with len() isn't too slow. But I'm wondering if 
> it's a bug in Django, or something else I've missed?
>
> Mattias
>
>
>

-- 
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/1b2f6dae-712f-4cb3-b8d3-26560198efaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to use password hasher snippet in Django?

2015-01-21 Thread Supermario


I am trying to move Druap 7 site to django 1.7 without invalidating user 
passwords, and this proved to be daunting.

Fortunately, I have found this 

 SO 
question and this  hashing 
snippet but there is no documentation and as a newbie to django, I have no 
clue how to integrate the snippet into my project.

So greatly appreciate your help about this.

-- 
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/3ed080a2-0a71-4e8d-afe5-c4d953746d24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.contrib.auth doesn't support template context processors?

2015-01-21 Thread Tom Evans
On Wed, Jan 21, 2015 at 2:31 PM, Mark Rogaski  wrote:
> Thanks, James.  I think the call to TemplateResponse is fine, but the
> context that's passed as a dict needs to be passed as a ContextRequest
> instead.

https://docs.djangoproject.com/en/1.7/ref/template-response/#django.template.response.TemplateResponse

"TemplateResponse is a subclass of SimpleTemplateResponse that uses a
RequestContext instead of a Context."

So something else is going awry. Fire up a shell and confirm the value
of settings.TEMPLATE_CONTEXT_PROCESSORS is what you expect it to be.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1%2BcUM13fdrEwXykLuWdsTb7uevz0kMQahY5TCioCv38EA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export DJANGO_SETTINGS_MODULE

2015-01-21 Thread Bill Freeman
It looks like you are typing "*django-admin.py startproject WebSite*" at
the python prompt, which is incorrect.  You type it at the shell.  If you
get command not found, then instead type "python
full/path/to/django-admin.py startproject WebSite".  And in any case, the
current directory must be the one under which you want WebSite created.

On Wed, Jan 21, 2015 at 5:03 PM,  wrote:

>
> Hello
>
> i have sesinstalled django and re installed withdebian package
> when i lauch command django-admin.py startproject website here is what i
> get:
>
>
>
>
>
>
>
>
>
>
>
>
>
> *python3.4Python 3.4.2 (default, Dec 27 2014, 13:16:08) [GCC 4.9.2] on
> linuxType "help", "copyright", "credits" or "license" for more
> information.>>> django-admin.py startproject WebSite  File "", line
> 1django-admin.py startproject WebSite
> ^SyntaxError: invalid syntax*i moved dist-packages from python3 directory
> to python3.4 directory but without any result
> What can i do???
> Please help
>
> Thanks
>
> Le mercredi 21 janvier 2015 13:19:49 UTC+1, th.gr...@free.fr a écrit :
>>
>> Hello
>>
>> i have just installed django 1.7 on Debian jessie via synaptic
>>
>> when i start a console,
>>
>> import django is OK
>>
>> print(django.get_version()) ---> version 1.7.2
>>
>> Now i try to launch the command "django-admin.py startproject WebSite"
>> i get the error:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *Traceback (most recent call last):  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 94,
>> in __init__mod = importlib.import_module(self.SETTINGS_MODULE)  File
>> "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)  File "> importlib._bootstrap>", line 2254, in _gcd_import  File "> importlib._bootstrap>", line 2237, in _find_and_load  File "> importlib._bootstrap>", line 2212, in _find_and_load_unlocked  File
>> "", line 321, in _call_with_frames_removed
>> File "", line 2254, in _gcd_import  File
>> "", line 2237, in _find_and_load  File
>> "", line 2224, in
>> _find_and_load_unlockedImportError: No module named 'WebSite'During
>> handling of the above exception, another exception occurred:Traceback (most
>> recent call last):  File "/usr/local/bin/django-admin.py", line 5, in
>> management.execute_from_command_line()  File
>> "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py",
>> line 385, in execute_from_command_lineutility.execute()  File
>> "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py",
>> line 345, in executesettings.INSTALLED_APPS  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 46,
>> in __getattr__self._setup(name)  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 42,
>> in _setupself._wrapped = Settings(settings_module)  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 98,
>> in __init__% (self.SETTINGS_MODULE, e)ImportError: Could not import
>> settings 'WebSite.settings' (Is it on sys.path? Is there an import error in
>> the settings file?): No module named 'WebSite'*it seems that the
>> variable *SETTINGS_MODULE *is not properly initialized.
>> I don't know what to 
>>
>> Thanks for your help
>>
>> PS: the directory WebSite is empty but created
>>
>>  --
> 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/006aca02-67f1-4447-9faa-65fc01039f05%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/CAB%2BAj0uDomQbsk76izJ9FSDuYhWtuc45v4p716oj%3DbjKByD6ww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export DJANGO_SETTINGS_MODULE

2015-01-21 Thread th . granier

Hello

i have sesinstalled django and re installed withdebian package
when i lauch command django-admin.py startproject website here is what i 
get:













*python3.4Python 3.4.2 (default, Dec 27 2014, 13:16:08) [GCC 4.9.2] on 
linuxType "help", "copyright", "credits" or "license" for more 
information.>>> django-admin.py startproject WebSite  File "", line 
1django-admin.py startproject WebSite   
^SyntaxError: invalid syntax*i moved dist-packages from python3 directory 
to python3.4 directory but without any result
What can i do???
Please help

Thanks

Le mercredi 21 janvier 2015 13:19:49 UTC+1, th.gr...@free.fr a écrit :
>
> Hello
>
> i have just installed django 1.7 on Debian jessie via synaptic
>
> when i start a console,
>
> import django is OK
>
> print(django.get_version()) ---> version 1.7.2
>
> Now i try to launch the command "django-admin.py startproject WebSite" 
> i get the error:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *Traceback (most recent call last):  File 
> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 94, 
> in __init__mod = importlib.import_module(self.SETTINGS_MODULE)  File 
> "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)  File " importlib._bootstrap>", line 2254, in _gcd_import  File " importlib._bootstrap>", line 2237, in _find_and_load  File " importlib._bootstrap>", line 2212, in _find_and_load_unlocked  File 
> "", line 321, in _call_with_frames_removed  
> File "", line 2254, in _gcd_import  File 
> "", line 2237, in _find_and_load  File 
> "", line 2224, in 
> _find_and_load_unlockedImportError: No module named 'WebSite'During 
> handling of the above exception, another exception occurred:Traceback (most 
> recent call last):  File "/usr/local/bin/django-admin.py", line 5, in 
> management.execute_from_command_line()  File 
> "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", 
> line 385, in execute_from_command_lineutility.execute()  File 
> "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", 
> line 345, in executesettings.INSTALLED_APPS  File 
> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 46, 
> in __getattr__self._setup(name)  File 
> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 42, 
> in _setupself._wrapped = Settings(settings_module)  File 
> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 98, 
> in __init__% (self.SETTINGS_MODULE, e)ImportError: Could not import 
> settings 'WebSite.settings' (Is it on sys.path? Is there an import error in 
> the settings file?): No module named 'WebSite'*it seems that the variable 
> *SETTINGS_MODULE 
> *is not properly initialized.
> I don't know what to 
>
> Thanks for your help
>
> PS: the directory WebSite is empty but created
>
>

-- 
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/006aca02-67f1-4447-9faa-65fc01039f05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re-Order rendering of input fields of django-contact-form?

2015-01-21 Thread Tobias Dacoir
Ah it works. After I restarted Django and hit F5 again it re-orders it now. 
So the code above is the solution. 
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/49953ca8-9cf5-4eae-acfa-ecfc40f4ad44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re-Order rendering of input fields of django-contact-form?

2015-01-21 Thread Tobias Dacoir
It still complained about the request, but I was finally able to get it to 
work using this code:
def __init__(self, request, *args, **kwargs):
super(CustomContactForm, self).__init__(request=request, *args, **
kwargs)
fields_keyOrder = ['name', 'reason', 'email', 'body']
if (self.fields.has_key('keyOrder')):
self.fields.keyOrder = fields_keyOrder
else:
self.fields = OrderedDict((k, self.fields[k]) for k in 
fields_keyOrder)


However it still does not re-order the fields, I searched stackoverflow 
again and found this for Django 1.7: 
https://github.com/pennersr/django-allauth/issues/356#issuecomment-24758824
But it still does not work. The order doesn't change it all. sigh :(

-- 
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/f9ad446d-432d-40bd-90c7-7bbb9d484b5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{% url ... %} does not work for callable?

2015-01-21 Thread Torsten Bronger
Hallöchen!

I cannot get the following working:

In urls.py:

url(r"^samples/(?P.+)/edit/$", sample.edit),

In the template:

{% url 'samples.views.sample.edit' sample_name="whatever" %}

I constantly get a NoReverseMatch, even if I pass the view function
with its full path samples.views.sample.edit in urls.py.  I know
that a named url() solves the problem.  Is this the only way if I
use a callable in url() (which will become mandatory in Django 2.0)?

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

-- 
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/87wq4g2cfa.fsf%40physik.rwth-aachen.de.
For more options, visit https://groups.google.com/d/optout.


Re: Using jquery ajax POST method with django

2015-01-21 Thread carlos
if you comment middleware csrf this is a risk security problem in your app
maybe you need read this part of documentation

https://docs.djangoproject.com/en/1.7/ref/contrib/csrf/#ajax

Cheers

On Sat, Jan 17, 2015 at 10:44 PM, Hossein Rashnoo  wrote:

> I correct my code and it's worked. Thank you guys for your help.
>
> Ajax Code:
>
> function checkuser() {
> var myObject = new Object();
> myObject.username = $('#username').val();
> myObject.password = $('#password').val();
> $.ajax({
> url: 'http://10.252.84.159/ajaxrecivelogin/',
> type: 'POST',
> data: JSON.stringify(myObject),
> context: this,
> dataType: 'json',
> success: function (data) {
> alert( data.status );
> },
> error: function ()
> {
> alert( "Error" );
> }
> });};
>
> Django Code:
>
> def ajaxrecivelogin(request):
> import json
> import ast
> x = ast.literal_eval(request.body)
> response_data = {}
> response_data['status'] = username
> return HttpResponse(json.dumps(response_data), 
> content_type="application/json")
>
> *And i comment out django.middleware.csrf.CsrfViewMiddleware in setting*
>
> On Saturday, January 17, 2015 at 9:16:32 AM UTC+3:30, Hossein Rashnoo
> wrote:
>>
>> I use this code to send a request:
>>
>> function checkuser() {
>> $.ajax({
>> url: 'http://10.252.84.159/ajaxrecivelogin',
>> //type: 'POST',
>> data: "{'username': 'aa', 'password' : 'bb'}",
>> context: this,
>> dataType: 'json',
>> success: function (data) {
>> $("#resp").html("success");
>> },
>> error: function ()
>> {
>> $("#resp").html("error");
>> }
>> });};
>>
>> And its worked But when i add type:POST part it cause error.
>>
>> I use this django code to response that request:
>>
>> def ajaxrecivelogin(request):
>> import json
>> response_data = {}
>> response_data['status'] = '1'
>> return HttpResponse(json.dumps(response_data), 
>> content_type="application/json")
>>
>> Is it about my django code?
>>
>>  --
> 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/7c7b115e-73f8-4a8b-bc38-8bf2ec2481ae%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/CAM-7rO1ue1JkAA9nyk8P-zdkG-mKq%2BEEB1dtwLC0pazTXnRE4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANNOUNCE] Django 1.8 alpha 1 released

2015-01-21 Thread carlos
Fabio yes i see
https://docs.djangoproject.com/en/dev/releases/1.8/#management-commands


   - inspectdb
   

now
   introspects database views on all database backends. In previous versions,
   only tables (not views) were inspected.


On Fri, Jan 16, 2015 at 7:31 PM, Fabio Caritas Barrionuevo da Luz <
bna...@gmail.com> wrote:

>
> Em sexta-feira, 16 de janeiro de 2015 20:10:37 UTC-3, Tim Graham escreveu:
>>
>> We've made the first release on the way to Django's next long-term
>> support release, Django 1.8! With only two and a half months until the
>> scheduled final release, we'll need prompt testing from the community to
>> ensure a timely and stable release. Check out the blog post:
>>
>> https://www.djangoproject.com/weblog/2015/jan/16/django-18-
>> alpha-1-released/
>>
>
>
> Wow, many new things. Very good.
>
> I have not seen in the release-notes that the inspectdb now supports
> inspect "database views" to the backends where it is supported.
>
> This change was made in this commit:
>
>
> https://github.com/django/django/commit/b8cdc7dcc3fc6897fb2a75f90023f5c67aad327f
>
>
> See the "get_table_list" function in introspection.py file, in each
> database backend
>
> I look forward a day, that Django has support for inspecting "multiple
> database schemas" and work properly with an official api to do this.
>
> https://code.djangoproject.com/ticket/22673
> https://code.djangoproject.com/ticket/6148
>
> I was trying to figure out ways to solve this old problem of django.
> Also i know that adding support for multiple database schemas is not
> something trivial for Django, because if it was, I'm sure that would be
> already been implemented.
>
> https://gist.github.com/luzfcb/e5f67e9c940e4833b798
>
> http://dba.stackexchange.com/questions/87463/in-oracle-how-to-get-a-list-with-the-names-of-schemas-that-a-user-has-read-perm
>
>
>
>  --
> 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/8e1efdd2-b8d4-4f7d-a498-188f06ff8999%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/CAM-7rO2jbF81OW5tgYo-86BOa6fJSFweWmHNepm6VrRgwKsN%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: can't install the pillow library on my first attempt to add an ImageField to my model

2015-01-21 Thread aseds
thanks again...

On Wednesday, January 21, 2015 at 8:59:30 AM UTC-8, Vijay Khemlani wrote:
>
> Since you are using the system-wide python installation you need to run 
> pip as superuser
>
> sudo pip install pillow
>
> You could also create a virtualenv instead of installing packages 
> system-wide, which is the recommended way of creating development 
> environments.
>
> On Wed, Jan 21, 2015 at 1:53 PM, aseds  > wrote:
>
>> thank you Vijay, the error has changed. now i've got
>>
>> error: could not create '/usr/local/lib/python2.7/dist-packages/PIL': 
>> Permission denied
>>  
>> 
>> Cleaning up...
>>
>> Command /usr/bin/python -c "import setuptools, 
>> tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize,
>>  'op
>>
>> en', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" 
>> install --record /tmp/pip-p5GAWn-record/install-record.txt --single
>>
>> -version-externally-managed --compile failed with error code 1 in 
>> /tmp/pip_build_aseds/pillow
>> Storing debug log for failure in /home/aseds/.pip/pip.log
>>
>> so, should i change the Permission for "dist-packages"?? is it safe to 
>> run the below command?
>> chmod 777 dist-packages
>> or what should i do?
>>
>> On Wednesday, January 21, 2015 at 6:13:23 AM UTC-8, Vijay Khemlani wrote:
>>>
>>> You need to install the development python package for your distro
>>>
>>> For example, in Ubuntu
>>>
>>> sudo apt-get install python-dev
>>>
>>> in Fedora
>>>
>>> sudo yum install python-devel
>>>
>>> On Wed, Jan 21, 2015 at 10:44 AM, aseds  wrote:
>>>
 hi,
  this is the first time i tried and added an ImageField to my model. 
 then i did makemigrations
 ./manage.py makemigrations

 but it said that i should do:
 pip install pillow
 (the django documentation says it's a required library too...)

 doing so, it gave me some errors:
 ~/W/d/mysite> pip install pillow   
 Downloading/unpacking pillow
   Downloading Pillow-2.7.0.tar.gz (7.4MB): 7.4MB downloaded
   Running setup.py (path:/tmp/pip_build_aseds/pillow/setup.py) egg_info
  for package pillow
 Single threaded build, not installing mp_compile: 1 processes
 
 Installing collected packages: pillow
   Running setup.py install for pillow
 Single threaded build, not installing mp_compile: 1 processes
 
 building 'PIL._imaging' extension
 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwr
 apv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/l
 ibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 
 -I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_6
 4-2.7/_imaging.o
_imaging.c:76:20: fatal error: Python.h: No such file or directory
  #include "Python.h"
 ^
 compilation terminated.
 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
 Complete output from command /usr/bin/python -c "import setuptools,
  tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(
 getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'),
  __file__, 'exec'))" install --record /tmp/pip-GeeYvn-record/install-re
 cord.txt --single-version-externally-managed --compile:
 Single threaded build, not installing mp_compile: 1 processes
  
 running install

 running build
  
 running build_py
  
 creating build
  
 creating build/lib.linux-x86_64-2.7
  
 creating build/lib.linux-x86_64-2.7/PIL
  
 copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL
 *:*
 *:*
 *:*
 i thought probably not all of it is important...
 *:*
 *:*
 *:*
 creating build/temp.linux-x86_64-2.7/libImaging
  
 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv 
 -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/libIm
 aging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/u
 sr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.
 7/_imaging.o
  
 _imaging.c:76:20: fatal error: Python.h: No such file or directory
  
  #include "Python.h"
  
 ^
  
 compilation terminated.
  
 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
 
 Cleaning up...
 Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/
 pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize, 'open',
  open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
 all --record /tmp/pip-GeeYvn-record/install-record.txt --single-version
 -externally-managed 

Re: can't install the pillow library on my first attempt to add an ImageField to my model

2015-01-21 Thread Vijay Khemlani
Since you are using the system-wide python installation you need to run pip
as superuser

sudo pip install pillow

You could also create a virtualenv instead of installing packages
system-wide, which is the recommended way of creating development
environments.

On Wed, Jan 21, 2015 at 1:53 PM, aseds  wrote:

> thank you Vijay, the error has changed. now i've got
>
> error: could not create '/usr/local/lib/python2.7/dist-packages/PIL': 
> Permission denied
>
> 
> Cleaning up...
>
> Command /usr/bin/python -c "import setuptools, 
> tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize,
>  'op
>
> en', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" 
> install --record /tmp/pip-p5GAWn-record/install-record.txt --single
>
> -version-externally-managed --compile failed with error code 1 in 
> /tmp/pip_build_aseds/pillow
> Storing debug log for failure in /home/aseds/.pip/pip.log
>
> so, should i change the Permission for "dist-packages"?? is it safe to run
> the below command?
> chmod 777 dist-packages
> or what should i do?
>
> On Wednesday, January 21, 2015 at 6:13:23 AM UTC-8, Vijay Khemlani wrote:
>>
>> You need to install the development python package for your distro
>>
>> For example, in Ubuntu
>>
>> sudo apt-get install python-dev
>>
>> in Fedora
>>
>> sudo yum install python-devel
>>
>> On Wed, Jan 21, 2015 at 10:44 AM, aseds  wrote:
>>
>>> hi,
>>>  this is the first time i tried and added an ImageField to my model.
>>> then i did makemigrations
>>> ./manage.py makemigrations
>>>
>>> but it said that i should do:
>>> pip install pillow
>>> (the django documentation says it's a required library too...)
>>>
>>> doing so, it gave me some errors:
>>> ~/W/d/mysite> pip install pillow
>>> Downloading/unpacking pillow
>>>   Downloading Pillow-2.7.0.tar.gz (7.4MB): 7.4MB downloaded
>>>   Running setup.py (path:/tmp/pip_build_aseds/pillow/setup.py) egg_info
>>>  for package pillow
>>> Single threaded build, not installing mp_compile: 1 processes
>>>
>>> Installing collected packages: pillow
>>>   Running setup.py install for pillow
>>> Single threaded build, not installing mp_compile: 1 processes
>>>
>>> building 'PIL._imaging' extension
>>> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwr
>>> apv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/l
>>> ibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7
>>> -I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_6
>>> 4-2.7/_imaging.o
>>>_imaging.c:76:20: fatal error: Python.h: No such file or directory
>>>  #include "Python.h"
>>> ^
>>> compilation terminated.
>>> error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>>> Complete output from command /usr/bin/python -c "import setuptools,
>>>  tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(
>>> getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'),
>>>  __file__, 'exec'))" install --record /tmp/pip-GeeYvn-record/install-re
>>> cord.txt --single-version-externally-managed --compile:
>>> Single threaded build, not installing mp_compile: 1 processes
>>>
>>> running install
>>>
>>> running build
>>>
>>> running build_py
>>>
>>> creating build
>>>
>>> creating build/lib.linux-x86_64-2.7
>>>
>>> creating build/lib.linux-x86_64-2.7/PIL
>>>
>>> copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL
>>> *:*
>>> *:*
>>> *:*
>>> i thought probably not all of it is important...
>>> *:*
>>> *:*
>>> *:*
>>> creating build/temp.linux-x86_64-2.7/libImaging
>>>
>>> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv
>>> -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/libIm
>>> aging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/u
>>> sr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.
>>> 7/_imaging.o
>>>
>>> _imaging.c:76:20: fatal error: Python.h: No such file or directory
>>>
>>>  #include "Python.h"
>>>
>>> ^
>>>
>>> compilation terminated.
>>>
>>> error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>>>
>>> 
>>> Cleaning up...
>>> Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/
>>> pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize, 'open',
>>>  open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
>>> all --record /tmp/pip-GeeYvn-record/install-record.txt --single-version
>>> -externally-managed --compile failed with error code 1 in /tmp/pip_buil
>>> d_aseds/pillow
>>> Storing debug log for failure in /home/aseds/.pip/pip.log
>>>
>>> i don't know exactly what is wrong cause i'm still a newbie with
>>> python.
>>>
>>> and at the end i should thank you for spending time
>>> helping 

Re: can't install the pillow library on my first attempt to add an ImageField to my model

2015-01-21 Thread aseds
thank you Vijay, the error has changed. now i've got
error: could not create '/usr/local/lib/python2.7/dist-packages/PIL': 
Permission denied
 

Cleaning up...
Command /usr/bin/python -c "import setuptools, 
tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize,
 'op
en', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install 
--record /tmp/pip-p5GAWn-record/install-record.txt --single
-version-externally-managed --compile failed with error code 1 in 
/tmp/pip_build_aseds/pillow
Storing debug log for failure in /home/aseds/.pip/pip.log

so, should i change the Permission for "dist-packages"?? is it safe to run 
the below command?
chmod 777 dist-packages
or what should i do?

On Wednesday, January 21, 2015 at 6:13:23 AM UTC-8, Vijay Khemlani wrote:
>
> You need to install the development python package for your distro
>
> For example, in Ubuntu
>
> sudo apt-get install python-dev
>
> in Fedora
>
> sudo yum install python-devel
>
> On Wed, Jan 21, 2015 at 10:44 AM, aseds  > wrote:
>
>> hi,
>>  this is the first time i tried and added an ImageField to my model. 
>> then i did makemigrations
>> ./manage.py makemigrations
>>
>> but it said that i should do:
>> pip install pillow
>> (the django documentation says it's a required library too...)
>>
>> doing so, it gave me some errors:
>> ~/W/d/mysite> pip install pillow   
>> Downloading/unpacking pillow
>>   Downloading Pillow-2.7.0.tar.gz (7.4MB): 7.4MB downloaded
>>   Running setup.py (path:/tmp/pip_build_aseds/pillow/setup.py) egg_info
>>  for package pillow
>> Single threaded build, not installing mp_compile: 1 processes
>> 
>> Installing collected packages: pillow
>>   Running setup.py install for pillow
>> Single threaded build, not installing mp_compile: 1 processes
>> 
>> building 'PIL._imaging' extension
>> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwr
>> apv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/l
>> ibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 
>> -I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_6
>> 4-2.7/_imaging.o
>>_imaging.c:76:20: fatal error: Python.h: No such file or directory
>>  #include "Python.h"
>> ^
>> compilation terminated.
>> error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>> Complete output from command /usr/bin/python -c "import setuptools,
>>  tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(
>> getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'),
>>  __file__, 'exec'))" install --record /tmp/pip-GeeYvn-record/install-re
>> cord.txt --single-version-externally-managed --compile:
>> Single threaded build, not installing mp_compile: 1 processes
>>  
>> running install
>>
>> running build
>>  
>> running build_py
>>  
>> creating build
>>  
>> creating build/lib.linux-x86_64-2.7
>>  
>> creating build/lib.linux-x86_64-2.7/PIL
>>  
>> copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL
>> *:*
>> *:*
>> *:*
>> i thought probably not all of it is important...
>> *:*
>> *:*
>> *:*
>> creating build/temp.linux-x86_64-2.7/libImaging
>>  
>> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv 
>> -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/libIm
>> aging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/u
>> sr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.
>> 7/_imaging.o
>>  
>> _imaging.c:76:20: fatal error: Python.h: No such file or directory
>>  
>>  #include "Python.h"
>>  
>> ^
>>  
>> compilation terminated.
>>  
>> error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>>  
>> 
>> Cleaning up...
>> Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/
>> pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize, 'open',
>>  open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
>> all --record /tmp/pip-GeeYvn-record/install-record.txt --single-version
>> -externally-managed --compile failed with error code 1 in /tmp/pip_buil
>> d_aseds/pillow
>> Storing debug log for failure in /home/aseds/.pip/pip.log
>>
>> i don't know exactly what is wrong cause i'm still a newbie with python. 
>> 
>> 
>> and at the end i should thank you for spending time helping me! 
>> thank you so much! 
>> 
>> 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> 

Re: Re-Order rendering of input fields of django-contact-form?

2015-01-21 Thread Paul Royik

>
> So pass the request
>

def __init__(self, request, *args, **kwargs):

self.request=request
super(CustomContactForm, self).__init__(*args, **kwargs) 

self.fields.keyOrder = ['name', 'reason', 'email', 'body'] 

-- 
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/f0dea9b0-9269-430f-8dd1-5cf20fb3a64d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re-Order rendering of input fields of django-contact-form?

2015-01-21 Thread Tobias Dacoir
Unfortunately this doesn't work as the contact form needs to be passed the 
request as well. I tried to modify the call to super but it didn't work.

As a workaround what I did now was to look at the HTML Code that the tag {{ 
form.as_p }} creates, and copy and paste that into the HTML template 
instead of using {{ form.as_p }}. Then I can freely shuffle around my 
fields, however for stuff like Choice Widgets, I need to supply the options 
in the HTML code as well, which is quite troublesome. 

So far I still haven't found a real solution. :(

-- 
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/080a9ff8-2a05-4af6-aba6-075530e40f8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Map Django Model to Legacy multi-join query

2015-01-21 Thread Scot Hacker
On Tuesday, January 20, 2015 at 8:02:57 AM UTC-8, Fred wrote:
>
> I've got a complex 1000+ table vendor read-only MS SqlServer database and 
> only have SELECT privileges.  I can connect with pymssql no problem.
>
> Of all these tables, I probably care about 50 or less.
>
> I cannot create views unless I introduce another physical server and use 
> the "Linked Server" option.  
>

I am working in a similar environment - 800+ tables in an external 
read-only  mysql db, plus whatever internal tables I need. To set it up, I 
used inspectdb to generate starter models for all 800 tables and piped the 
results to a text file. Then I manually copy out just the model definitions 
for the tables I actually interact with, and remove the many rows I don't 
need access to, and paste those into standard Django models. Massaged those 
as necessary. Then used Django's routers system for getting those 
definitions to appear in the admin (read only of course). And am able to 
create custom views via the .using() syntax. It's working so far, but I 
haven't gotten much farther than initial setup yet. Not sure what you mean 
by "linked server" - I don't see that mentioned in the docs. 

./s

-- 
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/c8b11988-efe0-4197-86ec-2d81dfd04228%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.contrib.auth doesn't support template context processors?

2015-01-21 Thread Mark Rogaski
Thanks, James.  I think the call to TemplateResponse is fine, but the 
context that's passed as a dict needs to be passed as a ContextRequest 
instead.

Heck, this looks like a simple exercise to practice navigating the patch 
submission process. ;)

On Tuesday, January 20, 2015 at 12:32:15 AM UTC-5, Mark Rogaski wrote:
>
> Hello,
>
> I'm coming back to Django after working with 1.4/1.5.  Within a custom 
> template for auth.views.password_reset, I'd like to access the request 
> data using django.core.context_processors.request.  But it doesn't look 
> like any template context processors are applied.
>
> It's not a big problem for me, but it seems that the contrib packages 
> should support this ... it's really a lovely feature.  Has anyone else run 
> into this or know if this is something that is slated to be added?
>
> Thanks,
> Mark
>

-- 
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/b87e747b-929a-4042-80aa-0e2a47f87abe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: can't install the pillow library on my first attempt to add an ImageField to my model

2015-01-21 Thread Vijay Khemlani
You need to install the development python package for your distro

For example, in Ubuntu

sudo apt-get install python-dev

in Fedora

sudo yum install python-devel

On Wed, Jan 21, 2015 at 10:44 AM, aseds  wrote:

> hi,
>  this is the first time i tried and added an ImageField to my model. then
> i did makemigrations
> ./manage.py makemigrations
>
> but it said that i should do:
> pip install pillow
> (the django documentation says it's a required library too...)
>
> doing so, it gave me some errors:
> ~/W/d/mysite> pip install pillow
> Downloading/unpacking pillow
>   Downloading Pillow-2.7.0.tar.gz (7.4MB): 7.4MB downloaded
>   Running setup.py (path:/tmp/pip_build_aseds/pillow/setup.py) egg_info
>  for package pillow
> Single threaded build, not installing mp_compile: 1 processes
>
> Installing collected packages: pillow
>   Running setup.py install for pillow
> Single threaded build, not installing mp_compile: 1 processes
>
> building 'PIL._imaging' extension
> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwr
> apv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/l
> ibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7
> -I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_6
> 4-2.7/_imaging.o
>_imaging.c:76:20: fatal error: Python.h: No such file or directory
>  #include "Python.h"
> ^
> compilation terminated.
> error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
> Complete output from command /usr/bin/python -c "import setuptools,
>  tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(
> getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'),
>  __file__, 'exec'))" install --record /tmp/pip-GeeYvn-record/install-re
> cord.txt --single-version-externally-managed --compile:
> Single threaded build, not installing mp_compile: 1 processes
>
> running install
>
> running build
>
> running build_py
>
> creating build
>
> creating build/lib.linux-x86_64-2.7
>
> creating build/lib.linux-x86_64-2.7/PIL
>
> copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL
> *:*
> *:*
> *:*
> i thought probably not all of it is important...
> *:*
> *:*
> *:*
> creating build/temp.linux-x86_64-2.7/libImaging
>
> x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv
> -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/libIm
> aging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/u
> sr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.
> 7/_imaging.o
>
> _imaging.c:76:20: fatal error: Python.h: No such file or directory
>
>  #include "Python.h"
>
> ^
>
> compilation terminated.
>
> error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>
> 
> Cleaning up...
> Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/
> pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize, 'open',
>  open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
> all --record /tmp/pip-GeeYvn-record/install-record.txt --single-version
> -externally-managed --compile failed with error code 1 in /tmp/pip_buil
> d_aseds/pillow
> Storing debug log for failure in /home/aseds/.pip/pip.log
>
> i don't know exactly what is wrong cause i'm still a newbie with python.
>
>
> and at the end i should thank you for spending time helping me!
> thank you so much!
>
>
>
> --
> 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/b5db0e6e-0d16-45bb-aec3-ac6e63bdd957%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/CALn3ei2f%2B7%3Dr8pAohBRZ3kxDJoFkcisjF-%2B5f-67coT4rnqfUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


can't install the pillow library on my first attempt to add an ImageField to my model

2015-01-21 Thread aseds
hi,
 this is the first time i tried and added an ImageField to my model. then i 
did makemigrations
./manage.py makemigrations

but it said that i should do:
pip install pillow
(the django documentation says it's a required library too...)

doing so, it gave me some errors:
~/W/d/mysite> pip install pillow   
Downloading/unpacking pillow
  Downloading Pillow-2.7.0.tar.gz (7.4MB): 7.4MB downloaded
  Running setup.py (path:/tmp/pip_build_aseds/pillow/setup.py) egg_info
 for package pillow
Single threaded build, not installing mp_compile: 1 processes

Installing collected packages: pillow
  Running setup.py install for pillow
Single threaded build, not installing mp_compile: 1 processes

building 'PIL._imaging' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwr
apv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/l
ibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 
-I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_6
4-2.7/_imaging.o
   _imaging.c:76:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools,
 tokenize;__file__='/tmp/pip_build_aseds/pillow/setup.py';exec(compile(
getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'),
 __file__, 'exec'))" install --record /tmp/pip-GeeYvn-record/install-re
cord.txt --single-version-externally-managed --compile:
Single threaded build, not installing mp_compile: 1 processes
 
running install

running build
 
running build_py
 
creating build
 
creating build/lib.linux-x86_64-2.7
 
creating build/lib.linux-x86_64-2.7/PIL
 
copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL
*:*
*:*
*:*
i thought probably not all of it is important...
*:*
*:*
*:*
creating build/temp.linux-x86_64-2.7/libImaging
 
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv 
-O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_aseds/pillow/libIm
aging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/u
sr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.
7/_imaging.o
 
_imaging.c:76:20: fatal error: Python.h: No such file or directory
 
 #include "Python.h"
 
^
 
compilation terminated.
 
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
 

Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/
pip_build_aseds/pillow/setup.py';exec(compile(getattr(tokenize, 'open',
 open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
all --record /tmp/pip-GeeYvn-record/install-record.txt --single-version
-externally-managed --compile failed with error code 1 in /tmp/pip_buil
d_aseds/pillow
Storing debug log for failure in /home/aseds/.pip/pip.log

i don't know exactly what is wrong cause i'm still a newbie with python.   


  and at the end i should thank you for spending time helping me! 
thank you so much! 



-- 
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/b5db0e6e-0d16-45bb-aec3-ac6e63bdd957%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


export DJANGO_SETTINGS_MODULE

2015-01-21 Thread th . granier
Hello

i have just installed django 1.7 on Debian jessie via synaptic

when i start a console,

import django is OK

print(django.get_version()) ---> version 1.7.2

Now i try to launch the command "django-admin.py startproject WebSite" 
i get the error:


































*Traceback (most recent call last):  File 
"/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 94, 
in __init__mod = importlib.import_module(self.SETTINGS_MODULE)  File 
"/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)  File "", line 2254, in _gcd_import  File "", line 2237, in _find_and_load  File "", line 2212, in _find_and_load_unlocked  File 
"", line 321, in _call_with_frames_removed  
File "", line 2254, in _gcd_import  File 
"", line 2237, in _find_and_load  File 
"", line 2224, in 
_find_and_load_unlockedImportError: No module named 'WebSite'During 
handling of the above exception, another exception occurred:Traceback (most 
recent call last):  File "/usr/local/bin/django-admin.py", line 5, in 
management.execute_from_command_line()  File 
"/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", 
line 385, in execute_from_command_lineutility.execute()  File 
"/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", 
line 345, in executesettings.INSTALLED_APPS  File 
"/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 46, 
in __getattr__self._setup(name)  File 
"/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 42, 
in _setupself._wrapped = Settings(settings_module)  File 
"/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 98, 
in __init__% (self.SETTINGS_MODULE, e)ImportError: Could not import 
settings 'WebSite.settings' (Is it on sys.path? Is there an import error in 
the settings file?): No module named 'WebSite'*it seems that the variable 
*SETTINGS_MODULE 
*is not properly initialized.
I don't know what to 

Thanks for your help

PS: the directory WebSite is empty but created

-- 
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/216ab4d0-7b77-450b-af41-052c6aedaf82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Admin Portal Help (Django Tutorial)

2015-01-21 Thread Ed Volz
I've been following the Django tutorial and cannot get the Admin portal to 
work.  Django is running via passenger in a shared environment on a virtual 
env with Python 2.7.  The main page and admin portal load static resources 
(from static_url) just fine.  Logging in with correct credentials yields a 
new session, but an error code of:

ERR_EMPTY_RESPONSE

An incorrect login yields the same error without a session.  Users are 
is_active and is_staff (verified through shell).  Any ideas?

settings.py 

passenger_wsgi.py 


-- 
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/9c8e8198-fe1a-42fe-acd5-3ecd04e75ae3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Strange Behavior from the Django Admin (following tutorial on a shared server)

2015-01-21 Thread Ed Volz
Hi all,

New to Django so I was following along with the tutorial and can get to the 
point of logging into the Administration portal (the main page works as 
well).  Django is running with passenger in a virtualenv (python 2.7) on a 
shared host.  I immediately receive a ERR_EMPTY_RESPONSE   when I click log 
in, regardless of whether or not the credentials are correct.  The db 
records a session on a correct log in even though the ERR_EMPTY_RESPONSE 
remains.  I've confirmed the user is both is_active and is_staff using the 
shell.  

What's puzzling me is that the log in page loads the css files from the 
STATIC_URL just fine, but there's nothing once served up the form is 
submitted.  Any help would be appreciated.

settings.py file 

passenger_wsgi.py file:
#!/usr/bin/env python2.7
import sys,os
# Tell Passenger to run our virtualenv python
INTERP = "/home//djangoenv/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
# Set up paths and environment variables
sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = 'mynewsite.settings'
# Set the application
import django.core.handlers.wsgi
# Use paste to display errors
from paste.exceptions.errormiddleware import ErrorMiddleware
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
application = ErrorMiddleware(application, debug=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/1d1bebac-af1a-4953-b088-73c2333d2a26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: block php requests

2015-01-21 Thread hinnack
Hi,
thanks for your reply.
Blocking all requests in Apache seems to be the best way. Can you give an 
example how to do that?
As / is mapped to the wsgi app ( 
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/modwsgi/ )
and a new files section does not the trick:

 #PHP protection

order allow,deny

deny from all

satisfy all




Am Dienstag, 20. Januar 2015 12:55:40 UTC+1 schrieb hinnack:
>
> Hi,
>
> I get a lot of intrusion checks on my website - especially for PHP 
> (wordpress, joomla, …).
> Today they all raise a 404 errors in python-django - so if you have emails 
> enabled for 404 errors…
>
> What is the best way to block those requests in a standard apache 
> deployment?
> ( https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/modwsgi/ )
>
> regards
>
> Hinnack
>

-- 
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/aa96b4c6-63cc-4eff-9fa0-95c7bf71dfd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.