Re: Easiest way to access MySQL from Django on Mac OS X?...

2012-09-23 Thread Fred Stluka

Chris,

Good info.  Thanks!  I'm hearing lots of good things about Homebrew.
If I go to a package manager, I may try it instead of MacPorts.  For now,
I've succeeded with just installing setuptools and MySQLdb, as described
below, and not re-installing MySQL or Python.

I installed MacPorts, but decided not to use it after doing a dry-run
and seeing that it was planning to re-install a bunch of stuff that it
doesn't know I already have installed and configured:  MySQL,
Python, etc.  Seems like MacPorts is too intrusive if you don't use
it from day one for all Mac installs.  Homebrew would have the
same problem, I guess, as do yum and apt-get on Linux.  It's hard
to start using any of them after a couple years of configuring the
system manually because none of the packages you already
installed are recorded in their records.  I may start using Homebrew
the next time I configure a Mac from scratch, just as I now do all
of my Linux boxes via yum.

For now, I did a manual install of Python setuptools, and then a
manual install of the MySQLdb driver for Python.  Everything's
working fine.  Turned out to be as easy as:
  - Download setuptools-0.6c11-py2.7.egg from
http://pypi.python.org/pypi/setuptools/
  % sh setuptools-0.6c11-py2.7.egg
  - Download MySQL-python-1.2.3.tar.gz from
http://sourceforge.net/projects/mysql-python/
  % gunzip MySQL-python-1.2.3.tar.gz
  % tar -xvf MySQL-python-1.2.3.tar
  % cd MySQL-python-1.2.3
  % python setup.py build
  % sudo python setup.py install

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 9/23/12 11:03 PM, Chris Streeter wrote:
When I'm setting up a new Mac OS system, the process I go through to 
install Python and MySQL.


First, I install Python using this guide: 
http://docs.python-guide.org/en/latest/starting/install/osx/
The guide also installs Homebrew, which works great for me so far and 
is easily removable.


After Python and Homebrew is installed, then you can install mysql with:

brew install mysql

This will get us the proper headers we need to install MySQLdb with 
pip. After MySQL is installed, you can install MySQLdb into a 
virtualenv or system-wide with a simple command:


pip install MySQLdb

Hope that helps,

- Chris

On Sun, Sep 23, 2012 at 6:54 PM, Andrew Macgregor 
> wrote:


Hi Fred,

I've also found HomeBrew to be useful. Here's a good setup guide:


http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/

Cheers, Andrew.


On Monday, September 24, 2012 2:02:37 AM UTC+8, Fred Stluka wrote:

Resolved this on my own.  Here's what I did:

- Downloaded and installed MacPorts, but decided not to use it
   because I have too much software already installed that
   MacPorts doesn't know about and wants to reinstall (MySQL,
   Python, OpenSSL, etc.)

- Downloaded and installed Python setuptools and resumed the
   MySQLdb setup that I'd already begun (see my previous post
   appended below).  It turned out to be easy:
   - Download setuptools-0.6c11-py2.7.egg from
http://pypi.python.org/pypi/setuptools/
   % sh setuptools-0.6c11-py2.7.egg
   % cd MySQL-python-1.2.3
   % python setup.py build
   % sudo python setup.py install

Success!  Now I can access MySQL from my Python/Django apps.

BTW, I also downloaded and installed PyCharm.  Nice Python IDE!

--Fred

Fred Stluka -- mailt...@bristle.com --
http://bristle.com/~fred/ 
Bristle Software, Inc -- http://bristle.com -- Glad to be of
service!
Open Source: Without walls and fences, we need no Windows or
Gates.


On 9/22/12 5:28 PM, Fred Stluka wrote:

Django users,

What's the latest on the easiest way to access MySQL from Django
on Mac OS X 10.6.8 (Snow Leopard)?

I've Googled lots of info, but some may be outdated.  Seems to be
more complicated than it should be, especially since
everything else
to do with Django has been so easy.

Here's what I've done and learned:

  - Followed MYSQLdb link in Django docs:

https://docs.djangoproject.com/en/1.4/topics/install/#database-installation
to:
http://sourceforge.net/projects/mysql-python/
and downloaded:
  MySQL-python-1.2.3.tar.gz
  

Re: Easiest way to access MySQL from Django on Mac OS X?...

2012-09-23 Thread Fred Stluka

Andrew,

Good info.  Thanks!  I'm hearing lots of good things about Homebrew.
If I go to a package manager, I may try it instead of MacPorts.  For now,
I've succeeded with just installing setuptools and MySQLdb, as described
below, and not re-installing MySQL or Python.

I installed MacPorts, but decided not to use it after doing a dry-run
and seeing that it was planning to re-install a bunch of stuff that it
doesn't know I already have installed and configured:  MySQL,
Python, etc.  Seems like MacPorts is too intrusive if you don't use
it from day one for all Mac installs.  Homebrew would have the
same problem, I guess, as do yum and apt-get on Linux.  It's hard
to start using any of them after a couple years of configuring the
system manually because none of the packages you already
installed are recorded in their records.  I may start using Homebrew
the next time I configure a Mac from scratch, just as I now do all
of my Linux boxes via yum.

For now, I did a manual install of Python setuptools, and then a
manual install of the MySQLdb driver for Python.  Everything's
working fine.  Turned out to be as easy as:
  - Download setuptools-0.6c11-py2.7.egg from
http://pypi.python.org/pypi/setuptools/
  % sh setuptools-0.6c11-py2.7.egg
  - Download MySQL-python-1.2.3.tar.gz from
http://sourceforge.net/projects/mysql-python/
  % gunzip MySQL-python-1.2.3.tar.gz
  % tar -xvf MySQL-python-1.2.3.tar
  % cd MySQL-python-1.2.3
  % python setup.py build
  % sudo python setup.py install

Thanks!
--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 9/23/12 9:54 PM, Andrew Macgregor wrote:

Hi Fred,

I've also found HomeBrew to be useful. Here's a good setup guide:

http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/

Cheers, Andrew.

On Monday, September 24, 2012 2:02:37 AM UTC+8, Fred Stluka wrote:

Resolved this on my own.  Here's what I did:

- Downloaded and installed MacPorts, but decided not to use it
   because I have too much software already installed that
   MacPorts doesn't know about and wants to reinstall (MySQL,
   Python, OpenSSL, etc.)

- Downloaded and installed Python setuptools and resumed the
   MySQLdb setup that I'd already begun (see my previous post
   appended below).  It turned out to be easy:
   - Download setuptools-0.6c11-py2.7.egg from
http://pypi.python.org/pypi/setuptools/

   % sh setuptools-0.6c11-py2.7.egg
   % cd MySQL-python-1.2.3
   % python setup.py build
   % sudo python setup.py install

Success!  Now I can access MySQL from my Python/Django apps.

BTW, I also downloaded and installed PyCharm.  Nice Python IDE!

--Fred

Fred Stluka -- mailt...@bristle.com  --
http://bristle.com/~fred/ 
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 9/22/12 5:28 PM, Fred Stluka wrote:

Django users,

What's the latest on the easiest way to access MySQL from Django
on Mac OS X 10.6.8 (Snow Leopard)?

I've Googled lots of info, but some may be outdated.  Seems to be
more complicated than it should be, especially since everything else
to do with Django has been so easy.

Here's what I've done and learned:

  - Followed MYSQLdb link in Django docs:
https://docs.djangoproject.com/en/1.4/topics/install/#database-installation


to:
http://sourceforge.net/projects/mysql-python/

and downloaded:
  MySQL-python-1.2.3.tar.gz
  - More info at: http://mysql-python.sourceforge.net/

  - Confirmed it is not already installed:
% python
  Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
  [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  Type "help", "copyright", "credits" or "license" for more
information.
>>> import MySQLdb
  Traceback (most recent call last):
File "", line 1, in 
File "MySQLdb/__init__.py", line 19, in 
  import _mysql
  ImportError: No module named _mysql
>>>
  % gunzip MySQL-python-1.2.3.tar.gz
  % tar -xvf MySQL-python-1.2.3.tar
  % less README
- Lots of caveats.  

mysql varchar datatype limit?

2012-09-23 Thread Navnath Gadakh
name = models.CharField(max_length=100) and if if give actual name of only 
50 characters ,then it will occupy all 100 chars of only 50?

-- 
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/-/XJUkbL3CX_UJ.
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: Easiest way to access MySQL from Django on Mac OS X?...

2012-09-23 Thread Chris Streeter
When I'm setting up a new Mac OS system, the process I go through to
install Python and MySQL.

First, I install Python using this guide:
http://docs.python-guide.org/en/latest/starting/install/osx/
The guide also installs Homebrew, which works great for me so far and is
easily removable.

After Python and Homebrew is installed, then you can install mysql with:

brew install mysql

This will get us the proper headers we need to install MySQLdb with pip.
After MySQL is installed, you can install MySQLdb into a virtualenv or
system-wide with a simple command:

pip install MySQLdb

Hope that helps,

- Chris

On Sun, Sep 23, 2012 at 6:54 PM, Andrew Macgregor  wrote:

> Hi Fred,
>
> I've also found HomeBrew to be useful. Here's a good setup guide:
>
>
> http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/
>
> Cheers, Andrew.
>
>
> On Monday, September 24, 2012 2:02:37 AM UTC+8, Fred Stluka wrote:
>
>>  Resolved this on my own.  Here's what I did:
>>
>> - Downloaded and installed MacPorts, but decided not to use it
>>because I have too much software already installed that
>>MacPorts doesn't know about and wants to reinstall (MySQL,
>>Python, OpenSSL, etc.)
>>
>> - Downloaded and installed Python setuptools and resumed the
>>MySQLdb setup that I'd already begun (see my previous post
>>appended below).  It turned out to be easy:
>>- Download setuptools-0.6c11-py2.7.egg from
>>   
>> http://pypi.python.org/pypi/**setuptools/
>>% sh setuptools-0.6c11-py2.7.egg
>>% cd MySQL-python-1.2.3
>>% python setup.py build
>>% sudo python setup.py install
>>
>> Success!  Now I can access MySQL from my Python/Django apps.
>>
>> BTW, I also downloaded and installed PyCharm.  Nice Python IDE!
>>
>> --Fred
>> --
>> Fred Stluka -- mailt...@bristle.com -- http://bristle.com/~fred/
>> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
>> Open Source: Without walls and fences, we need no Windows or Gates.
>> --
>>
>> On 9/22/12 5:28 PM, Fred Stluka wrote:
>>
>> Django users,
>>
>> What's the latest on the easiest way to access MySQL from Django
>> on Mac OS X 10.6.8 (Snow Leopard)?
>>
>> I've Googled lots of info, but some may be outdated.  Seems to be
>> more complicated than it should be, especially since everything else
>> to do with Django has been so easy.
>>
>> Here's what I've done and learned:
>>
>>   - Followed MYSQLdb link in Django docs:
>>   https://docs.djangoproject.**com/en/1.4/topics/install/#**
>> database-installation
>> to:
>>   
>> http://sourceforge.net/**projects/mysql-python/
>> and downloaded:
>>   MySQL-python-1.2.3.tar.gz
>>   - More info at:  
>> http://mysql-python.**sourceforge.net/
>>   - Confirmed it is not already installed:
>> % python
>>   Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
>>   [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
>>   Type "help", "copyright", "credits" or "license" for more
>> information.
>>   >>> import MySQLdb
>>   Traceback (most recent call last):
>> File "", line 1, in 
>> File "MySQLdb/__init__.py", line 19, in 
>>   import _mysql
>>   ImportError: No module named _mysql
>>   >>>
>>   % gunzip MySQL-python-1.2.3.tar.gz
>>   % tar -xvf MySQL-python-1.2.3.tar
>>   % less README
>> - Lots of caveats.  Has to be built and installed.  Looks ugly.
>> - Says it requires setuptools Python module.
>>   - Confirmed setuptools is not already installed, by trying the
>> import
>>  statement that setup.py is going to do:
>> % python
>>   >>> from setuptools import setup, Extension
>>   Traceback (most recent call last):
>> File "", line 1, in 
>>   ImportError: No module named setuptools
>>   >>>
>>   % python setup.py build
>> - Got error, as expected:
>> Traceback (most recent call last):
>>   File "setup.py", line 5, in 
>> from setuptools import setup, Extension
>> ImportError: No module named setuptools
>> Exit 1
>>   % sudo python setup.py install
>> - No.  Didn't try.  Not yet built.
>>
>>
>> So now I need setuptools first.  Am I starting down a long dependency
>> chain of installs, or will this be easy?
>>
>> I have a Linux server, where it appears that I could use yum to do
>> a painless install:
>>
>>   % yum list all | grep -i mysql | grep -i py
>> MySQL-python.x86_64 1.2.3-0.3.c1.1.8.amzn1  amzn-main
>>
>> Perhaps there's an easier way for Mac OS X also?  Did some more
>> Googling and found:
>>
>>  http://stackoverflow.com/**questions/1448429/how-to-**
>> 

Re: Does django's built-in comments component support pagination?

2012-09-23 Thread Scarl
Thanks for the answer! 
I have found something on django's official website.
https://code.djangoproject.com/ticket/18143 
It seems that the comments component  are not paginateable with django's 
own paginator...

在 2012年9月24日星期一UTC+8上午1时28分45秒,Pablo Sanfilippo写道:
>
> Sorry, i thought that views handle comments. I see now that comments are 
> handled by the framework itself.
>
> El domingo, 23 de septiembre de 2012 11:12:10 UTC-3, Scarl escribió:
>>
>> I wonder is it possible to display 10 comments on one page? If it can, 
>> how to do it? Using the  django.core.paginator?
>> please help! thx!
>>
>

-- 
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/-/btXzeWANQGMJ.
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: Easiest way to access MySQL from Django on Mac OS X?...

2012-09-23 Thread Andrew Macgregor
Hi Fred,

I've also found HomeBrew to be useful. Here's a good setup guide:

http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/

Cheers, Andrew.

On Monday, September 24, 2012 2:02:37 AM UTC+8, Fred Stluka wrote:
>
>  Resolved this on my own.  Here's what I did:
>
> - Downloaded and installed MacPorts, but decided not to use it
>because I have too much software already installed that 
>MacPorts doesn't know about and wants to reinstall (MySQL,
>Python, OpenSSL, etc.)
>
> - Downloaded and installed Python setuptools and resumed the 
>MySQLdb setup that I'd already begun (see my previous post
>appended below).  It turned out to be easy:
>- Download setuptools-0.6c11-py2.7.egg from 
>   http://pypi.python.org/pypi/setuptools/
>% sh setuptools-0.6c11-py2.7.egg
>% cd MySQL-python-1.2.3
>% python setup.py build
>% sudo python setup.py install
>
> Success!  Now I can access MySQL from my Python/Django apps.
>
> BTW, I also downloaded and installed PyCharm.  Nice Python IDE!
>
> --Fred 
> --
> Fred Stluka -- mailt...@bristle.com  -- 
> http://bristle.com/~fred/ 
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! 
> Open Source: Without walls and fences, we need no Windows or Gates. 
> --
>  
> On 9/22/12 5:28 PM, Fred Stluka wrote: 
>
> Django users,
>
> What's the latest on the easiest way to access MySQL from Django
> on Mac OS X 10.6.8 (Snow Leopard)?
>
> I've Googled lots of info, but some may be outdated.  Seems to be
> more complicated than it should be, especially since everything else
> to do with Django has been so easy.
>
> Here's what I've done and learned:
>
>   - Followed MYSQLdb link in Django docs:
>   
> https://docs.djangoproject.com/en/1.4/topics/install/#database-installation
> to:
>   http://sourceforge.net/projects/mysql-python/
> and downloaded:
>   MySQL-python-1.2.3.tar.gz
>   - More info at:  http://mysql-python.sourceforge.net/
>   - Confirmed it is not already installed:
> % python
>   Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
>   [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
>   Type "help", "copyright", "credits" or "license" for more 
> information.
>   >>> import MySQLdb
>   Traceback (most recent call last):
> File "", line 1, in 
> File "MySQLdb/__init__.py", line 19, in 
>   import _mysql
>   ImportError: No module named _mysql
>   >>> 
>   % gunzip MySQL-python-1.2.3.tar.gz
>   % tar -xvf MySQL-python-1.2.3.tar
>   % less README
> - Lots of caveats.  Has to be built and installed.  Looks ugly.
> - Says it requires setuptools Python module.
>   - Confirmed setuptools is not already installed, by trying the import
>  statement that setup.py is going to do:
> % python
>   >>> from setuptools import setup, Extension
>   Traceback (most recent call last):
> File "", line 1, in 
>   ImportError: No module named setuptools
>   >>> 
>   % python setup.py build
> - Got error, as expected:
> Traceback (most recent call last):
>   File "setup.py", line 5, in 
> from setuptools import setup, Extension
> ImportError: No module named setuptools
> Exit 1
>   % sudo python setup.py install
> - No.  Didn't try.  Not yet built.
>
>
> So now I need setuptools first.  Am I starting down a long dependency
> chain of installs, or will this be easy?
>
> I have a Linux server, where it appears that I could use yum to do
> a painless install:
>
>   % yum list all | grep -i mysql | grep -i py
> MySQL-python.x86_64 1.2.3-0.3.c1.1.8.amzn1  amzn-main
>
> Perhaps there's an easier way for Mac OS X also?  Did some more 
> Googling and found:
>
>  
> http://stackoverflow.com/questions/1448429/how-to-install-mysqldb-python-data-access-library-to-mysql-on-mac-os-x
>
> which is a longish manual set of instructions by an author who wishes 
> there were a better way, but another reply says to just use MacPorts to 
> install it.
>
> Any advice?  Thanks!
>
>  --Fred 
> --
> Fred Stluka -- mailt...@bristle.com  -- 
> http://bristle.com/~fred/ 
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! 
> Open Source: Without walls and fences, we need no Windows or Gates. 
> --
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion 

Re: How to separate data having the same model but belonging to different users?

2012-09-23 Thread Rohit Banga
How about maintaining one database per department and then using "using"
parameter to select the appropriate database?
There are not too many departments. I know it may not scale or seem elegant
but keeping data in separate tables or databases is a requirement.
Using the following command I feel I can sync all models to a new database.

./manage.py syncdb --database=department1

Do you foresee any problem with this solution?
I am planning to have a default database with all users and groups and then
based on the group select the appropriate database.
I do not want to sync django-admin tables to all databases. Is there a way
to restrict models to a specific database?
Let say I have databases 0 ... n.
Departments 1 to n have the same set of tables with different data and
database i corresponds to department i.
database 0 is used to store only admin database tables. Is there a
reasonable way to restrict this within the same app or are there problems
that I cannot foresee?

Thanks
Rohit Banga
http://iamrohitbanga.com/


On Sun, Sep 23, 2012 at 12:56 PM, Dennis Lee Bieber
wrote:

> On Sat, 22 Sep 2012 22:04:41 -0700 (PDT), Bill Beal
>  declaimed the following in
> gmane.comp.python.django.user:
>
> >
> > I should think that if you have a foreign key to the department in all
> > tables that must be segregated by department, you could create a
> decorator
> > that would apply a filter with the department key.  But I don't know how
> to
> > do it.
> >
> Which basically puts it back to what the OP insists they are not
> permitted to do -- have a single set of tables with a selection based on
> the logged in user's department.
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.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.
>
>

-- 
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: Beginner problem linking pages from homepage?

2012-09-23 Thread Vincent Fulco
Thanks all.  Just getting up to speed on regex, need to re-read some 
chapters.  Changing these to the suggested above, fixing the mismatched 
from "mysite.views import hello" by importing * in the urls.py and removing 
the quotes around the func got me to my targeted basic site.  Best, V.

On Sunday, September 23, 2012 4:54:46 PM UTC-5, JirkaV wrote:
>
> Hi Vincent,
>
> Django is telling you what the problem is - none of strings in urls.py 
> matches the requested URL. All lines in your file say that the regular 
> expression fas nothing before the "foo" (the "^" character says that). 
> However the URL you are trying has "homepage/" before "foo". Hence it does 
> not match.
>
> You need to correct this before you can proceed furter. Either remove the 
> "homepage/" from your request (may be in a link on your first page) or 
> change the urls.py accordingly.
>
> HTH
>
> Jirka
> --
> *From: * Vincent Fulco  
> *Sender: * django...@googlegroups.com  
> *Date: *Sun, 23 Sep 2012 12:47:39 -0700 (PDT)
> *To: *
> *ReplyTo: * django...@googlegroups.com  
> *Subject: *Re: Beginner problem linking pages from homepage?
>
> Thank you for the timely advice.  Before I move my "base/homepage" site to 
> its own app dir, thought I would give it another pass using your changes.  
> Verified 'mysite.urls' in settings.py, added 'mysite' to the urlpatterns 
> arg and put quotes around the hello func.  I have had debugging from the 
> outset of installation.  views.py in the mysite/mysite dir is simply:
>
> def hello(request):
> return HttpResponse('Hello World!')
>
> The 404 error which comes up is:
>
> Page not found (404)  Request Method: GET  Request URL: 
> http://192.168.1.126:8000/homepage/foo1  
>  
> Using the URLconf defined in mysite.urls, Django tried these URL 
> patterns, in this order: 
>
>1. ^foo1$ 
>2. ^foo2$ 
>3. ^foo3$ 
>4. ^foo4$ 
>
> The current URL, homepage/foo1, didn't match any of these.
>  
> You're seeing this error because you have DEBUG = True in your Django 
> settings file. Change that to False, and Django will display a standard 
> 404 page.  Could be a permissions thing or some subtle backslashes nuance I 
> haven't picked up on yet?
> Thanks again.  V. 
>
>
> On Saturday, September 22, 2012 7:39:36 PM UTC-5, Sam Lai wrote:
>>
>>
>>
>> I just created a toy project with that urls.py and it worked fine. 
>>
>> > I am not even sure if philosophically this is considered a good 
>> practice of 
>> > django.  Thanks in advance for your assistance.  V. 
>>
>> Generally you would not create a views.py in your project directory 
>> (mysite/mysite is your project directory). You would usually create an 
>> app (mysite/manage.py startapp appname), create your views, app-level 
>> URLs, models etc. in there, and then reference them in your project 
>> urls.py by including your app's urls.py. 
>>
>> Also, generally you would reference the view using a string, instead 
>> of the actual view function itself. This saves you from having to 
>> import every view, and avoid clashes in larger projects where you may 
>> have view functions with the same name in different apps. In the 
>> second urls.py you posted, the first parameter to patterns, where you 
>> have 'homepage' specified, is used to shorten these view function 
>> strings - that parameter is appended to your url definitions, i.e. you 
>> could use the following urls.py instead - 
>>
>> urlpatterns = patterns('mysite', 
>>url(r'^foo1$', 'hello'), 
>>url(r'^foo2$', 'hello'), 
>>url(r'^foo3$', 'hello'), 
>>url(r'^foo4$', 'hello'), 
>> ) 
>>
>> ... and Django will append 'mysite' to all the view function strings, 
>> turning them into 'mysite.hello'. See 
>> https://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix 
>>
>> > 
>> > 
>> > -- 
>> > 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/-/ojFywQSzpYsJ. 
>> > 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. 
>>
>  -- 
> 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/-/_y5eEwalYc8J.
> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on 

BDD 4 Django

2012-09-23 Thread Daniel França
Hi guys,

I just created a package for a better integration between
Morelia(BDD)/Splinter(Browser Test) and Django.
So you can create the features for BDD tests just thinking about the
browser interaction.

You just need to create a class based in BDDTestcCase. The BDDTestCase
already comes with some methods that fill most of browser integration steps
in features (like "I Visit url", "I click the button", "I see the text",
etc).

Besides the already existing features of Morelia, now it's possible to run
some specific scenarios only.

The tests run in a browser accessing the tests database (it requires Django
>= 1.4)

The documentation and source code can be found here:
https://github.com/danielfranca/BDD4Django
It can be installed using pip.


Feel free to ask, criticize or suggest anything.

Best Regards,
Daniel França

-- 
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: Beginner problem linking pages from homepage?

2012-09-23 Thread jirka . vejrazka
Hi Vincent,

  Django is telling you what the problem is - none of strings in urls.py 
matches the requested URL. All lines in your file say that the regular 
expression fas nothing before the "foo" (the "^" character says that). However 
the URL you are trying has "homepage/" before "foo". Hence it does not match.

  You need to correct this before you can proceed furter. Either remove the 
"homepage/" from your request (may be in a link on your first page) or change 
the urls.py accordingly.

 HTH

Jirka

-Original Message-
From: Vincent Fulco 
Sender: django-users@googlegroups.com
Date: Sun, 23 Sep 2012 12:47:39 
To: 
Reply-To: django-users@googlegroups.com
Subject: Re: Beginner problem linking pages from homepage?

Thank you for the timely advice.  Before I move my "base/homepage" site to 
its own app dir, thought I would give it another pass using your changes.  
Verified 'mysite.urls' in settings.py, added 'mysite' to the urlpatterns 
arg and put quotes around the hello func.  I have had debugging from the 
outset of installation.  views.py in the mysite/mysite dir is simply:

def hello(request):
return HttpResponse('Hello World!')

The 404 error which comes up is:

Page not found (404)  Request Method: GET  Request URL: 
http://192.168.1.126:8000/homepage/foo1  
 
Using the URLconf defined in mysite.urls, Django tried these URL patterns, 
in this order: 

   1. ^foo1$ 
   2. ^foo2$ 
   3. ^foo3$ 
   4. ^foo4$ 

The current URL, homepage/foo1, didn't match any of these.
 
You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.  Could be a permissions thing or some subtle backslashes nuance I 
haven't picked up on yet?
Thanks again.  V. 


On Saturday, September 22, 2012 7:39:36 PM UTC-5, Sam Lai wrote:
>
>
>
> I just created a toy project with that urls.py and it worked fine. 
>
> > I am not even sure if philosophically this is considered a good practice 
> of 
> > django.  Thanks in advance for your assistance.  V. 
>
> Generally you would not create a views.py in your project directory 
> (mysite/mysite is your project directory). You would usually create an 
> app (mysite/manage.py startapp appname), create your views, app-level 
> URLs, models etc. in there, and then reference them in your project 
> urls.py by including your app's urls.py. 
>
> Also, generally you would reference the view using a string, instead 
> of the actual view function itself. This saves you from having to 
> import every view, and avoid clashes in larger projects where you may 
> have view functions with the same name in different apps. In the 
> second urls.py you posted, the first parameter to patterns, where you 
> have 'homepage' specified, is used to shorten these view function 
> strings - that parameter is appended to your url definitions, i.e. you 
> could use the following urls.py instead - 
>
> urlpatterns = patterns('mysite', 
>url(r'^foo1$', 'hello'), 
>url(r'^foo2$', 'hello'), 
>url(r'^foo3$', 'hello'), 
>url(r'^foo4$', 'hello'), 
> ) 
>
> ... and Django will append 'mysite' to all the view function strings, 
> turning them into 'mysite.hello'. See 
> https://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix 
>
> > 
> > 
> > -- 
> > 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/-/ojFywQSzpYsJ. 
> > 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. 
>

-- 
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/-/_y5eEwalYc8J.
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: Incorrect string value when running GeoDjango tutorial

2012-09-23 Thread Ron Broberg
I solved this by changing the encoding in the line in the tutorial for 
world/load.py from this ...

#lm = LayerMapping(WorldBorder, world_shp, world_mapping,
#  transform=False, encoding='iso-8859-1')

To the following ...

lm = LayerMapping(WorldBorder, world_shp, world_mapping,
  transform=False, encoding='utf8')

As I am a python, django, and geodjango, I am not sure if that is a good 
workaround or not.
But it did load the name (Åland Islands) into the table correctly.

Ron

On Tuesday, August 14, 2012 5:21:12 AM UTC-6, Matias Burak wrote:
>
> Hi, I was trying to go through the GeoDjango tutorial and when I try to 
> import data with LayerMapping I'm getting the following error:
>
>   Warning: Incorrect string value: '\xC2\x85land...' for column 'name' 
> at row 1
>
> I'm using MySQL and my charset and collation are set to latin1 (I also 
> tried utf8).
>
> Any help is appreciated.
> Matias.
>

-- 
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/-/pL0GXB6VAm8J.
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: Beginner problem linking pages from homepage?

2012-09-23 Thread Vincent Fulco
Addendum: the views.py also has the required 'from django.foo import" lines 
naturally.

On Sunday, September 23, 2012 2:47:39 PM UTC-5, Vincent Fulco wrote:
>
> Thank you for the timely advice.  Before I move my "base/homepage" site to 
> its own app dir, thought I would give it another pass using your changes.  
> Verified 'mysite.urls' in settings.py, added 'mysite' to the urlpatterns 
> arg and put quotes around the hello func.  I have had debugging from the 
> outset of installation.  views.py in the mysite/mysite dir is simply:
>
> def hello(request):
> return HttpResponse('Hello World!')
>
> The 404 error which comes up is:
>
> Page not found (404)  Request Method: GET  Request URL: 
> http://192.168.1.126:8000/homepage/foo1  
>  
> Using the URLconf defined in mysite.urls, Django tried these URL 
> patterns, in this order: 
>
>1. ^foo1$ 
>2. ^foo2$ 
>3. ^foo3$ 
>4. ^foo4$ 
>
> The current URL, homepage/foo1, didn't match any of these.
>  
> You're seeing this error because you have DEBUG = True in your Django 
> settings file. Change that to False, and Django will display a standard 
> 404 page.  Could be a permissions thing or some subtle backslashes nuance I 
> haven't picked up on yet?
> Thanks again.  V. 
>
>
> On Saturday, September 22, 2012 7:39:36 PM UTC-5, Sam Lai wrote:
>>
>>
>>
>> I just created a toy project with that urls.py and it worked fine. 
>>
>> > I am not even sure if philosophically this is considered a good 
>> practice of 
>> > django.  Thanks in advance for your assistance.  V. 
>>
>> Generally you would not create a views.py in your project directory 
>> (mysite/mysite is your project directory). You would usually create an 
>> app (mysite/manage.py startapp appname), create your views, app-level 
>> URLs, models etc. in there, and then reference them in your project 
>> urls.py by including your app's urls.py. 
>>
>> Also, generally you would reference the view using a string, instead 
>> of the actual view function itself. This saves you from having to 
>> import every view, and avoid clashes in larger projects where you may 
>> have view functions with the same name in different apps. In the 
>> second urls.py you posted, the first parameter to patterns, where you 
>> have 'homepage' specified, is used to shorten these view function 
>> strings - that parameter is appended to your url definitions, i.e. you 
>> could use the following urls.py instead - 
>>
>> urlpatterns = patterns('mysite', 
>>url(r'^foo1$', 'hello'), 
>>url(r'^foo2$', 'hello'), 
>>url(r'^foo3$', 'hello'), 
>>url(r'^foo4$', 'hello'), 
>> ) 
>>
>> ... and Django will append 'mysite' to all the view function strings, 
>> turning them into 'mysite.hello'. See 
>> https://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix 
>>
>> > 
>> > 
>> > -- 
>> > 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/-/ojFywQSzpYsJ. 
>> > 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. 
>>
>

-- 
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/-/Nn11fTWKCMkJ.
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: Beginner problem linking pages from homepage?

2012-09-23 Thread Vincent Fulco
Thank you for the timely advice.  Before I move my "base/homepage" site to 
its own app dir, thought I would give it another pass using your changes.  
Verified 'mysite.urls' in settings.py, added 'mysite' to the urlpatterns 
arg and put quotes around the hello func.  I have had debugging from the 
outset of installation.  views.py in the mysite/mysite dir is simply:

def hello(request):
return HttpResponse('Hello World!')

The 404 error which comes up is:

Page not found (404)  Request Method: GET  Request URL: 
http://192.168.1.126:8000/homepage/foo1  
 
Using the URLconf defined in mysite.urls, Django tried these URL patterns, 
in this order: 

   1. ^foo1$ 
   2. ^foo2$ 
   3. ^foo3$ 
   4. ^foo4$ 

The current URL, homepage/foo1, didn't match any of these.
 
You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.  Could be a permissions thing or some subtle backslashes nuance I 
haven't picked up on yet?
Thanks again.  V. 


On Saturday, September 22, 2012 7:39:36 PM UTC-5, Sam Lai wrote:
>
>
>
> I just created a toy project with that urls.py and it worked fine. 
>
> > I am not even sure if philosophically this is considered a good practice 
> of 
> > django.  Thanks in advance for your assistance.  V. 
>
> Generally you would not create a views.py in your project directory 
> (mysite/mysite is your project directory). You would usually create an 
> app (mysite/manage.py startapp appname), create your views, app-level 
> URLs, models etc. in there, and then reference them in your project 
> urls.py by including your app's urls.py. 
>
> Also, generally you would reference the view using a string, instead 
> of the actual view function itself. This saves you from having to 
> import every view, and avoid clashes in larger projects where you may 
> have view functions with the same name in different apps. In the 
> second urls.py you posted, the first parameter to patterns, where you 
> have 'homepage' specified, is used to shorten these view function 
> strings - that parameter is appended to your url definitions, i.e. you 
> could use the following urls.py instead - 
>
> urlpatterns = patterns('mysite', 
>url(r'^foo1$', 'hello'), 
>url(r'^foo2$', 'hello'), 
>url(r'^foo3$', 'hello'), 
>url(r'^foo4$', 'hello'), 
> ) 
>
> ... and Django will append 'mysite' to all the view function strings, 
> turning them into 'mysite.hello'. See 
> https://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix 
>
> > 
> > 
> > -- 
> > 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/-/ojFywQSzpYsJ. 
> > 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. 
>

-- 
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/-/_y5eEwalYc8J.
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: Can I simply disable the CSRF? crazy

2012-09-23 Thread puneet loya
Hi 

I was trying to disable csrf . I am calling post using ajax.

I have used the csrf token placed it below the form.  

In my views file i m using the csrf exempt.

I am still getting the network forbidden error. :(

If you require more information i will share it :) 

On Thursday, 19 August 2010 06:49:02 UTC+5:30, chenge wrote:
>
>
>
> On 8月18日, 上午4时29分, Rolando Espinoza La Fuente  
> wrote: 
> > On Tue, Aug 17, 2010 at 8:01 AM, chenge  wrote: 
> > > I'm new to django. CSRF let me crazy! 
> > 
> > Can't use {% csrf_token %} tag inside your 's? 
> > 
> > See csrf_exempt decorator:
> http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions 
> > 
> > Regards, 
> > 
> > Rolando Espinoza La fuentewww.insophia.com 
>
> Thanks, I decide try flask first, that seems simple. Maybe I'll try 
> the exempt.

-- 
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/-/BQ5RpafQK3EJ.
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: Easiest way to access MySQL from Django on Mac OS X?...

2012-09-23 Thread Fred Stluka

Resolved this on my own.  Here's what I did:

- Downloaded and installed MacPorts, but decided not to use it
   because I have too much software already installed that
   MacPorts doesn't know about and wants to reinstall (MySQL,
   Python, OpenSSL, etc.)

- Downloaded and installed Python setuptools and resumed the
   MySQLdb setup that I'd already begun (see my previous post
   appended below).  It turned out to be easy:
   - Download setuptools-0.6c11-py2.7.egg from
  http://pypi.python.org/pypi/setuptools/
   % sh setuptools-0.6c11-py2.7.egg
   % cd MySQL-python-1.2.3
   % python setup.py build
   % sudo python setup.py install

Success!  Now I can access MySQL from my Python/Django apps.

BTW, I also downloaded and installed PyCharm.  Nice Python IDE!

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 9/22/12 5:28 PM, Fred Stluka wrote:

Django users,

What's the latest on the easiest way to access MySQL from Django
on Mac OS X 10.6.8 (Snow Leopard)?

I've Googled lots of info, but some may be outdated.  Seems to be
more complicated than it should be, especially since everything else
to do with Django has been so easy.

Here's what I've done and learned:

  - Followed MYSQLdb link in Django docs:
https://docs.djangoproject.com/en/1.4/topics/install/#database-installation
to:
http://sourceforge.net/projects/mysql-python/
and downloaded:
  MySQL-python-1.2.3.tar.gz
  - More info at: http://mysql-python.sourceforge.net/
  - Confirmed it is not already installed:
% python
  Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
  [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  Type "help", "copyright", "credits" or "license" for more 
information.

>>> import MySQLdb
  Traceback (most recent call last):
File "", line 1, in 
File "MySQLdb/__init__.py", line 19, in 
  import _mysql
  ImportError: No module named _mysql
>>>
  % gunzip MySQL-python-1.2.3.tar.gz
  % tar -xvf MySQL-python-1.2.3.tar
  % less README
- Lots of caveats.  Has to be built and installed.  Looks ugly.
- Says it requires setuptools Python module.
  - Confirmed setuptools is not already installed, by trying the 
import

 statement that setup.py is going to do:
% python
>>> from setuptools import setup, Extension
  Traceback (most recent call last):
File "", line 1, in 
  ImportError: No module named setuptools
>>>
  % python setup.py build
- Got error, as expected:
Traceback (most recent call last):
  File "setup.py", line 5, in 
from setuptools import setup, Extension
ImportError: No module named setuptools
Exit 1
  % sudo python setup.py install
- No.  Didn't try.  Not yet built.


So now I need setuptools first.  Am I starting down a long dependency
chain of installs, or will this be easy?

I have a Linux server, where it appears that I could use yum to do
a painless install:

  % yum list all | grep -i mysql | grep -i py
MySQL-python.x86_64 1.2.3-0.3.c1.1.8.amzn1  amzn-main

Perhaps there's an easier way for Mac OS X also?  Did some more
Googling and found:

http://stackoverflow.com/questions/1448429/how-to-install-mysqldb-python-data-access-library-to-mysql-on-mac-os-x

which is a longish manual set of instructions by an author who wishes
there were a better way, but another reply says to just use MacPorts to
install it.

Any advice?  Thanks!

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

--
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: Does django's built-in comments component support pagination?

2012-09-23 Thread Pablo Sanfilippo
Sorry, i thought that views handle comments. I see now that comments are 
handled by the framework itself.

El domingo, 23 de septiembre de 2012 11:12:10 UTC-3, Scarl escribió:
>
> I wonder is it possible to display 10 comments on one page? If it can, how 
> to do it? Using the  django.core.paginator?
> please help! thx!
>

-- 
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/-/7vl2dZHeRiYJ.
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.



Setting up Django 1.4 for a production environment

2012-09-23 Thread Zach
I am new to django and I am having trouble following the instructions on 
setting up django with apache and mod_wsgi. Apache 2.2.22, Python 2.7.2 and 
mod_wsgi are all install on my machine running Mac os X 10.8.2 (mountain 
lion). I have imported a conf file to my httpd file with the following

WSGIScriptAlias / /Users/Zachary/Sites/django/project/project/wsgi.py
 


Order deny,allow
Allow from all



I just want to get the initial django project setup so it goes to the "it 
works" page. My wsgi.py is the default file with the following

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

I am sure I am missing a lot, so if anyone can just point me in the right 
direction that would be awesome! I do know mod_wsgi is installed and 
running because I was able to get the hello world file from their 
configuration tutorial to work

-- 
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/-/foi5DE1zsWYJ.
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: Setting an unusable password on an existing user

2012-09-23 Thread Nandakumar Chandrasekhar

Thanks Russ for your explanation.

You are right I did not understand Andrew correctly. Forgive me for my 
ignorance. :-)


I did not know there were so many ways to do the same thing.

Thank you very much for the example.

nav


On Sunday 23 September 2012 05:16 AM, Russell Keith-Magee wrote:

On Sat, Sep 22, 2012 at 3:18 PM, Nandakumar Chandrasekhar
 wrote:

Thanks Andrew but I have a requirement where I have to programmatically set
it to an unusable password based on a particular condition.


Andrew's given you the answer - it's just not clear that you've
understood what the answer is.

There are two ways to set a password on a user object:

  * Use the set_password() method on the user object.

  * Set the underlying password attribute directly.

The set_password() method is just applying the password hashing logic
and then saving the password field directly. If you want to set the
hashed value -- or set an "unusable" value -- directly, you can do the
same thing:


from django.contrib.auth.models import User, UNUSABLE_PASSWORD
user = User.objects.get(username='frank')
user.password

u'sha1$911ee$25e954dc93f920c134ebaa067da7827922e474a6'

user.has_usable_password()

True

user.set_password('foo')
user.password

'sha1$7h9Fpv6nLJt4$99f05f9b65569b617f32a448431736108e83be36'

user.has_usable_password()

True

user.password = UNUSABLE_PASSWORD
user.save()
user.password

'!'

user.has_usable_password()

False

Yours,
Russ Magee %-)



--
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: Does django's built-in comments component support pagination?

2012-09-23 Thread Scarl
Should I rewrite django.contrib.comments.models? Or I just need to rewrite 
my_django_project.myapp.models?

在 2012年9月23日星期日UTC+8下午10时38分41秒,Pablo Sanfilippo写道:
>
>
> https://docs.djangoproject.com/en/dev/topics/pagination/?from=olddocs#using-paginator-in-a-view
>  This 
> is a perfect example. You have to replace de model by the model of your 
> comments.
>
> On Sunday, September 23, 2012 11:12:10 AM UTC-3, Scarl wrote:
>>
>> I wonder is it possible to display 10 comments on one page? If it can, 
>> how to do it? Using the  django.core.paginator?
>> please help! thx!
>>
>

-- 
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/-/hK4hzH8fidQJ.
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: Using a drop down list as widget for filter in admin

2012-09-23 Thread Ibrahim Lawal
Here's how I achieved it.

{% load i18n %} 
{% if choices|length > 9  %}
{% blocktrans with title|escape as filter_title %} By {{ filter_title 
}} {% endblocktrans %} 

 
{% for choice in choices %} 
{{ choice.display|escape }} 
{% endfor %} 
 

{% else %}
{% blocktrans with title as filter_title %} By {{ filter_title }} {% 
endblocktrans %}

{% for choice in choices %}

{{ choice.display }}
{% endfor %}

{% endif %}

The else option is simply a duplication of djangos own admin/filter.html





On Friday, 1 February 2008 10:55:21 UTC+1, Julien wrote:
>
> Hello there, 
>
> The list_filter meta attribute lets you add filters in the admin 
> interface. It's great, but the problem is that the field I'm filtering 
> (a ForeignKey) has thousands of values, so I get thousands of links 
> put in the right end side of the page. 
>
> Is it possible to have a drop down list or something that compresses 
> the space taken by that list of values? 
>
> Thanks a lot! 
>
> Julien

-- 
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/-/iPh_aOn2qssJ.
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: Does django's built-in comments component support pagination?

2012-09-23 Thread Pablo Sanfilippo
https://docs.djangoproject.com/en/dev/topics/pagination/?from=olddocs#using-paginator-in-a-view
 This 
is a perfect example. You have to replace de model by the model of your 
comments.

On Sunday, September 23, 2012 11:12:10 AM UTC-3, Scarl wrote:
>
> I wonder is it possible to display 10 comments on one page? If it can, how 
> to do it? Using the  django.core.paginator?
> please help! thx!
>

-- 
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/-/Dlo9SlyyfScJ.
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: custom upload handlers

2012-09-23 Thread Karen Tracey
Have you read the entire Note under
https://docs.djangoproject.com/en/1.4/topics/http/file-uploads/#modifying-upload-handlers-on-the-flywhich
discusses how the CSRF protection accesses request.POST and therefore
prevents changing upload handlers in a view which is CSRF protected? It
includes an example of how to change the upload handlers in a view that is
not CSRF protected and then forward the request onto a view function which
is CSRF protected.

Karen
-- 
http://tracey.org/kmt/

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



Does django's built-in comments component support pagination?

2012-09-23 Thread Scarl
I wonder is it possible to display 10 comments on one page? If it can, how 
to do it? Using the  django.core.paginator?
please help! thx!

-- 
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/-/THn6TjIUk2EJ.
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.



ForeignKey save method admin panel

2012-09-23 Thread Johannes Frey
Hi!

One question about the topic above.
I'm just wandering what's going on in the admin panel when creating an 
instance of a ForeignKey in a special case.

I've got two models. One regular one with the regular fields (like name, 
date etc.) an one who holds the ForeignKey to that class.
the regular one inherits a save method (in this one a "get_slug" method is 
called to generate a slug) and overrides that "get_slug" method in order to 
create a slug the way I want.

If I create an instance via terminal and fill the fields and type 
"object.save()" and look at the slug "object.slug" the slug gets created 
with the overriden "get_slug" method.
Also when creating the instance directly in the admin panel that works too.

But if I want to create an instance of the class which holds the 
foreinkey-field to that described class and want to create an instance of 
the above inside this process (by hitting that little green + sign in the 
admin panel)  the slug gets created wrong (I assume that the save button 
there does not call the save method of that class but from the parent 
class?) 
Am I missing something? Could someone elaborate?
Thanks

-- 
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/-/1hIBtvPztDkJ.
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: Installing a django project, database issue ?

2012-09-23 Thread Babatunde Akinyanmi
Hi,
Are you sure brisket was installed properly? Try importing it from
your python console. Also, can you show your settings.py
INSTALLED_APPS setting?

On 9/22/12, new_user  wrote:
> I am installing the sunlight fondation's brisket and I am really new to
> python, and even more to django. So I downloaded on github the project :
> https://github.com/sunlightlabs/brisket.
>
> So, when I run the ./manage.py run server command, I get an error message.
> But I know nothing from python and django.
>
> Here's my database config :
>
> DATABASE_ENGINE = 'django.db.backends.mysql'
> DATABASE_NAME = 'brisker'
> DATABASE_USER = 'root'
> DATABASE_PASSWORD = 'euler;.'
> DATABASE_HOST = '127.0.0.1'
> DATABASE_PORT = ''
>
> So now here's the error message, am I supposed to install a package ?
>
>
>
> Unhandled exception in thread started by  Command.inner_run of  object at 0x976b84c>>
> Traceback (most recent call last):
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py",
>
> line 88, in inner_run
> self.validate(display_num_errors=True)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 249, in validate
> num_errors = get_validation_errors(s, app)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py",
>
> line 36, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
> 146, in get_app_errors
> self._populate()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
> 61, in _populate
> self.load_app(app_name, True)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line
> 76, in load_app
> app_module = import_module(app_name)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line
> 35, in import_module
> __import__(name)
> ImportError: No module named brisket.influence
>
>   Could some one help ?
>
> Best,
> M.
>
> --
> 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/-/fJRgT-Cka1wJ.
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: language in field description in forms won't change

2012-09-23 Thread Patrick
Tomas, you are right. This fixed the problem for me.

Thanks so much!

Op zondag 23 september 2012 03:18:53 UTC+2 schreef Tomas Neme het volgende:
>
> you probably are using ugettext and should be using ugettext_lazy 
>
> On Sat, Sep 22, 2012 at 8:44 PM, Patrick  
> wrote: 
> > When I change language on my Django-powered site, everything works fine 
> > except the translation of the field descriptions in the forms. The 
> > description is still displayed in the old language. Only the forms 
> already 
> > visited that session are affected. 
> > 
> > It seems like some sort of caching problem, but I don't use any caching 
> (as 
> > far as I know) and all other parts of the site behave as expected 
> (templates 
> > and random text using django.utils.translaction.ugettext work just 
> fine). 
> > 
> > Summarized: 
> > 
> > When I open the site and change language, and then visit a form: 
> everything 
> > works as expected. All text is translated. 
> > When I visit a form, change language and return to the form: everything 
> is 
> > translated, but the form stays in the old language. 
> > Restarting the web server forces the language to change: then Django 
> behaves 
> > as in (1) for the current session. Until the language is changed again. 
> > 
> > Help is appreciated! 
> > 
> > Kind regards, Patrick 
> > 
> > -- 
> > 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/-/P3sRNFd-aaAJ. 
> > 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. 
>
>
>
> -- 
> "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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/FUJQ5m8q_JUJ.
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.