howto Single Sign-On with django on windows

2012-11-17 Thread Anton
Hi,

I am using in windows 7 64bit:
 - python 2.7.3 32bit !!
 - django 1.4.2

If use my internet explorer in my company,
it does an automatic login on some services.

Is there a possibilty to:
 - add an user named "john" to my django
 - if john goes to my django app with his
   internet explorer:
   to check that he is john and authenticated
   (without to need the knowledge of his
windows password)?

Any hint would be helpful :-)

Anton


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: howto Single Sign-On with django on windows

2012-11-17 Thread Tim Sawyer

See

https://docs.djangoproject.com/en/dev/howto/auth-remote-user/#howto-auth-remote-user

Tim.

On 17/11/12 09:13, Anton wrote:

Hi,

I am using in windows 7 64bit:
  - python 2.7.3 32bit !!
  - django 1.4.2

If use my internet explorer in my company,
it does an automatic login on some services.

Is there a possibilty to:
  - add an user named "john" to my django
  - if john goes to my django app with his
internet explorer:
to check that he is john and authenticated
(without to need the knowledge of his
 windows password)?

Any hint would be helpful :-)

Anton




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What used @models.permalink and get_absolute_url? Please an example to better understand this. An example of the documentation is not clear to me

2012-11-17 Thread Tomas Ehrlich
Hi there,
the key idea is: *Let's have URLs defined at one and only one place.*

So, when you have urls.py like this:

urlpatterns = patterns('',
'^blog/(?P\w+)', BlogDetail.as_view(), name='blog-detail',
'^articles/(?P\w+)', ArticleDetail.as_view(),
name='article-detail'
'^$', HomepageView.as_view(), name='homepage')

Your urls are defined:

/ -- Homepage
/blog/ -- Blog detail (eg. one entry)
/artices/ -- Article detail (eg. one article)


Imagine you want to point some link to one of these pages. Hard-coded
links, like:


Homepage
{{ blog.title }}
{{ article.title }}

are bad. Because now are your urls defined at two places -- urls.py and
navigation.html. When you change urls.py, you have to update
navigation.html also. Right now, it's not such a problem, just two
files. Imagine that your project contains lot of templates, lot of
views and you have to change everything everytime when you change
urls.py. That's 1) boring and 2) very fragile. You'll probably spend a
huge amount of time with fixing bugs.

So, there's a solution:

Reverse url from urls.py for given parameters. Let's say you want link
to blog entry and you know the slug:

url = reverse('blog-detail', [], {'slug': slug})

So, our template could look like this:


{% load url from future %}

{{ blog.title }}
{{ article.title }}

Now all links are "reversed" from urls.py. That's good, but again: When
you change urls.py, let's say you change blog url to:

/blog///

you'll have to change all your templates again! And that's boring.

So, another improvement: Every model instance should have it's own url
(every model instance should be identified somehow). Therefore it's
convenient to define get_absolute_url method:

def get_absolute_url(self):  # return url which points to this instance
return reverse('blog-detail', [], {'slug': slug})

But usually we use 'reverse' function every time, so it's probably
easier to use method decorator:


@models.permalink
def get_absolute_url(self):
return ('blog-detail', [], {'slug': slug})

and return only arguments for 'reverse' function.


Now, in you template, you can use:


{% load url from future %}

{{ blog.title }}
{{ article.title }}

and be happy ever after :)


Note: For me the documentation was clear. Could you please suggest any
improvement?

Link:
https://docs.djangoproject.com/en/1.5/ref/models/instances/#get-absolute-url


Cheers,
 Tom

http://www.tomas-ehrlich.cz/en/

"Půjdu kamkoliv, pokud je to kupředu." - J. London


Dne Fri, 16 Nov 2012 07:03:08 -0800 (PST)
enemytet  napsal(a):

>  
> 
> How (and why) to use @models.permalink and get_absolute_url? 
> 
> Please an example to better understand this. An example of the 
> documentation is not clear to me
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What used @models.permalink and get_absolute_url? Please an example to better understand this. An example of the documentation is not clear to me

2012-11-17 Thread Victor Rocha
In order to use get_absolute_url, first of all you need to have named urls. 
Lets imagine we have the following named url.

  url(r'^accounts/(P?d+)/$',
DetailView.as_view(
  template_name='accounts/details.html',
), name='account_details')

In order to referece this url in a template you have to alternatives, 
actually 3:
  1) You can hardcode the url, eg. /accounts/1
  2) Do a reverse url lookup, eg. {% url account_details pk=1%}
  3) Use the get_absolute_url method on your instance, eg. 
account.get_absolute_url

As you can see, using the get_absolute_url makes for a less hardcoded url; 
changin parameters in your view wouldn't mean having to go back in your 
templates and updating each one of the references to the url.

In order to define a get_absolute_url in your model you need to use the 
@permalink decorator.

@models.permalink
def get_absolute_url(self):
  return ('account_details', #name of the view you are reversing
  (), # a tuple of all the positional parameter your view takes
  {'pk':self.id}, # a dict of all the named arguments your view takes
)



On Friday, November 16, 2012 10:03:08 AM UTC-5, enemytet wrote:
>
> How (and why) to use @models.permalink and get_absolute_url? 
>
> Please an example to better understand this. An example of the 
> documentation is not clear to me
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vxjgwK838d4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Reason for not allowing spaces in usernames?

2012-11-17 Thread Paul von Hoesslin
I'm puzzled with this too. Did anyone manage to find a solution to 
resolving spaces in usernames.

Generally a user, these days logs in with their email - that's 
predominately how I've setup all my django projects. People don't remember 
usernames. It is legacy, facebook connects with emails, so does gmail and 
the rest of the world. Username really has fallen back to a NickName / 
Alternative / Alias kind of field. You'd use it if you knew that in your 
application people wouldn't want their real, full names to be displayed.


On Friday, June 12, 2009 4:08:12 PM UTC+2, Wiiboy wrote:
>
>
>
> On Jun 12, 6:55 am, Marco Louro  wrote: 
> > As long as you trim start and trailing spaces, there shouldn't be any 
> > problem, but personally I wouldn't use spaces in usernames at all. 
>
>  Why not?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UGdOmEepavIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ModelForm excluded one field but it excludes another field

2012-11-17 Thread Sandeep kaur
On Tue, Nov 13, 2012 at 1:17 PM, Rohit Banga  wrote:
> Hi All
>

>  model = ConcreteModel2
>  exclude = ('field3_test')
>
>
> Now as you can see there are parallels between the two model forms.
> The problem is that in my template field1 is visible for ConcreteModel1Form
> (expected behavior)

> But in another template field3 is not visible for ConcreteModel2Form
> (unexpected behavior).
>
> If I comment out exclude=('field3_test') then field3 is visible in the
> template (expected behavior) but form validation fails since field3_test is
> None and is a required field.
>
> What am I missing? This seems to be a problem with my code that i can't
> figure out. This behavior is clearly inconsistent and I am not able to see
> the difference in my code.
>
> Any ideas how to debug this? What could be the problem?
>
When we exclude a field from a form, that field become invisible. But
as we know, that it is mandatory to fill the foreign key value (else
the form will become invalid), so you should by some way give some
value to foreign key field.

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

2012-11-17 Thread Sandeep kaur
On Fri, Nov 16, 2012 at 10:59 AM, Cj Taylor  wrote:
> Hello all,
>   I'm new to Django and somewhat Python (a PHP refugee).  I have been
> learning Python 3.0 so decided to give 1.5 a run.  I tried to run the
> command below and mysqldb is missing.  I noticed on
> http://mysql-python.blogspot.com/ that mysqldb won't be ready for 3.0 until
> the 1.3 release.  So I guess the question is if there's any kind of
> workaround at the moment?
>

> raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module:
> No module named MySQLdb
>
Try this :
sudo apt-get install python-mysqldb

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



psycopg2

2012-11-17 Thread Jun Tanaka
I run a django program with psycopg2 on Mac and then it works fine. Now, I 
am trying to run the same program on Windows. Then "ImportError: No module 
named psycopg2.extensions" shows up. I installed the same version of 
django, postgres, psycopg2. 

Please give me a help. 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/lBccIlvFh6EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: too much customization - ldap user model

2012-11-17 Thread Anil Jangity
So, the bottom line is, what do I need to do after I do a authenticate() to 
have the login persist in the session and in the other views? 

Thanks

On Nov 15, 2012, at 8:23 PM, Anil Jangity  wrote:

> I am trying to build a custom User model with a custom authentication backend 
> (ldap).
> Here is what I've done so far:
> 
> Custom LDAP authentication backend:
> 
> class LDAPBackend:
>def get_user(self, user_id):
>try:
>return LDAPUser.objects.get(pk=user_id)
>except LDAPUser.DoesNotExist:
>return None
> 
> 
>def authenticate(self, dn=None, password=None):
>   conn = DS(settings.AUTH_LDAP_SERVER) 
>   conn.connect(dn, password)
>   try:
>user = LDAPUser.objects.get_or_create(dn=dn)
>return user
>except LDAPUser.DoesNotExist:
>   pass
>   return None
> 
> =
> 
> Custom User model:
> 
> class LDAPUserManager(BaseUserManager):
> 
>def get_or_create(self, dn):
>user = LDAPUser(dn)
>return user
> 
> 
> class LDAPUser(AbstractBaseUser):
>dn = models.CharField(max_length=128)
> 
>is_active = models.BooleanField(default=True)
>is_admin = models.BooleanField(default=False)
> 
>objects = LDAPUserManager()
>USERNAME_FIELD = 'dn'
> 
>def __unicode__(self):
>return self.dn
>…
> 
> 
> 
> =
> 
> 
> 
> Based on that, in my view I have:
> def do_login():
>   user = authenticate(dn=dn, password=password)
>   user.is_authenticated()<--- returns True
>   return HttpResponseRedirect("/manage")
> 
> def manage():
>print request.session['dn']
>print request.user
> 
> 
> Shouldn't the request.user in manage() be my LDAPUser instance? It shows 
> AnonymousUser. Where is the session stored (if any) when I do the 
> authenticate() ?
> Sorry for these basic questions, I am new to Django.
> 
> Also, I feel like I am going to end up having to customize every aspects of 
> the User model… am I going about this the wrong way?
> 
> What I am really trying to do is create a LDAP based users as well as LDAP 
> based database (no SQL database) for all my data. I looked at 
> Django_auth_ldap, but that won't cut it, I need to have a little bit more 
> customization on it (I think).
> 
> Thanks for any help!
> Anil
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: psycopg2

2012-11-17 Thread Ovnicraft
On Sat, Nov 17, 2012 at 11:07 AM, Jun Tanaka  wrote:

> I run a django program with psycopg2 on Mac and then it works fine. Now, I
> am trying to run the same program on Windows. Then "ImportError: No module
> named psycopg2.extensions" shows up. I installed the same version of
> django, postgres, psycopg2.
>

Hello, can you pastebin the traceback ?

Regards,

>
> Please give me a help.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/lBccIlvFh6EJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Cristian Salamea
@ovnicraft

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Reason for not allowing spaces in usernames?

2012-11-17 Thread Tomas Neme
> I'm puzzled with this too. Did anyone manage to find a solution to resolving
> spaces in usernames.
>
> Generally a user, these days logs in with their email - that's predominately
> how I've setup all my django projects. People don't remember usernames. It

Well, I can't really agree, but whatever, it shouldn't be hard to do..
just override the forms... at the worse of cases, the User model...

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Noobe alert

2012-11-17 Thread Gerald Klein
Hi, I finally got a project in Django and I have a "what I hope is an easy
question" I started to set up a production server and yes the admin css
dissappeared, I went though the docs and followed them. I used the Collect
Static Files method and still no joy. Here is my info:

#settings.py
MEDIA_ROOT = '/var/www/virtualenv-test/ENV/testsite/media/'
MEDIA_URL = 'http://localhost/media/'
STATIC_ROOT = '/var/www/virtualenv-test/ENV/testsite/static/'
STATIC_URL = 'http://localhost/static/'

#niginx


root /var/www/virtualenv-test/ENV/testsite;

location /media/ {
root /var/www/virtualenv-test/ENV/testsite/media;
}

location /static/ {
root /var/www/virtualenv-test/ENV/testsite/static;
}

My project is located in /var/www/virtualenv-test/ENV/

the project is testsite so the hierarchy inside ENV is:

testsite/
media/
static/all files from collect static files
testsite/
__init__.py
settings.py
urls.py
wsgi.py
manage.py

I am using version (1, 4, 2, 'final', 0).

If somebody can point out the probably obvious problem that I am missing I
would greatly appreciate it.

thanks in advance for your help

--jerry

-- 

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

2012-11-17 Thread Cj Taylor
That package installs into my python directory but not python3.  I'm 
currently trying to get Django 1.5 to work with python3.  Are there other 
ways currently to get mysql to work with django and the python3 environment?

Try this : 

> sudo apt-get install python-mysqldb 
>
> -- 
> Sandeep Kaur 
> E-Mail: mkaur...@gmail.com  
> Blog: sandymadaan.wordpress.com 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VfrRmTUUQrgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Fwd: Noobe alert [solved]

2012-11-17 Thread Gerald Klein
Hi, Yea got it, the nginx static had to be removed from the alias url.

thanks

-- Forwarded message --
From: Gerald Klein 
Date: Sat, Nov 17, 2012 at 1:27 PM
Subject: Noobe alert
To: django-users@googlegroups.com


Hi, I finally got a project in Django and I have a "what I hope is an easy
question" I started to set up a production server and yes the admin css
dissappeared, I went though the docs and followed them. I used the Collect
Static Files method and still no joy. Here is my info:

#settings.py
MEDIA_ROOT = '/var/www/virtualenv-test/ENV/testsite/media/'
MEDIA_URL = 'http://localhost/media/'
STATIC_ROOT = '/var/www/virtualenv-test/ENV/testsite/static/'
STATIC_URL = 'http://localhost/static/'

#niginx


root /var/www/virtualenv-test/ENV/testsite;

location /media/ {
root /var/www/virtualenv-test/ENV/testsite/media;
}

location /static/ {
root /var/www/virtualenv-test/ENV/testsite/static;
}

My project is located in /var/www/virtualenv-test/ENV/

the project is testsite so the hierarchy inside ENV is:

testsite/
media/
static/all files from collect static files
testsite/
__init__.py
settings.py
urls.py
wsgi.py
manage.py

I am using version (1, 4, 2, 'final', 0).

If somebody can point out the probably obvious problem that I am missing I
would greatly appreciate it.

thanks in advance for your help

--jerry

-- 

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580






-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

geraldklein.wordpress.com

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ANN: Gnotty 0.1

2012-11-17 Thread Stephen McDonald
Hi all,

I've just released Gnotty 0.1 - it's a Django app that provides a web
client, searchable message archive and bot framework, all based around an
IRC channel. It uses Django for the message store and search interface,
WebSockets and gevent for the IRC bridge, and Twitter's Bootstrap for the
interface, allowing the web client to work on mobile devices too.

Check out the project page for more detail:
https://github.com/stephenmcd/gnotty

And also my related blog post about it:
http://blog.jupo.org/2012/11/18/mobile-irc-with-bonus-robots/

Cheers,
Steve



-- 
Stephen McDonald
http://jupo.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: psycopg2

2012-11-17 Thread Jun Tanaka
Thank you for your advise. I used the trace back and it says 
'exceptions.ImportError'. On Windows, cay you not easy_install psycopg2? 
When I did, it seems that it was done correctly. 

Please help!!!






2012年11月18日日曜日 2時11分23秒 UTC+9 ovnicraft:
>
>
>
>
> On Sat, Nov 17, 2012 at 11:07 AM, Jun Tanaka 
> > wrote:
>
>> I run a django program with psycopg2 on Mac and then it works fine. Now, 
>> I am trying to run the same program on Windows. Then "ImportError: No 
>> module named psycopg2.extensions" shows up. I installed the same version of 
>> django, postgres, psycopg2. 
>>
>
> Hello, can you pastebin the traceback ?
>
> Regards, 
>
>>
>> Please give me a help. 
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/lBccIlvFh6EJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Cristian Salamea
> @ovnicraft
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rXd8_WuUhDgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.