Highlighting Active Navigation Link - correct approach?

2012-01-08 Thread Victor Hooi
hi,

I have a project where I'm using Bootstrap 
(www.github.com/twitter/bootstrap) with Django.

I need to add a CSS class ("active") to highlight the active navigation 
link.

Anyhow, I did some Googling:

http://www.turnkeylinux.org/blog/django-navbar
http://ilostmynotes.blogspot.com/2010/03/django-current-active-page-highlighting.html
http://gnuvince.wordpress.com/2007/09/14/a-django-template-tag-for-the-current-active-page/
http://stackoverflow.com/questions/340888/navigation-in-django
http://djangosnippets.org/snippets/1726/
http://stackoverflow.com/questions/7665514/django-highlight-navigation-based-on-current-page

The approach in the above seems to be to either use custom template tag, 
middleware or JS-hackery.

Is there a current consensus in the Django community in terms of what is 
the "correct" approach for this?

Is there a reason something like this isn't part of Django core, or an 
in-built templatetag?

Cheers,
Victor

-- 
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/-/Xx5Rk_rBuxIJ.
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: Problem getting django on mac (10.5/Leopard) working

2012-01-08 Thread Martin Chiteri
I think its because the actual folder is named django-trunk but your
application's import statement is using django to referrence it. The
symbolic link resolved the issue for you.

Martin.

On 1/9/12, larry.mart...@gmail.com  wrote:
> On Jan 7, 7:13 pm, "larry.mart...@gmail.com" 
> wrote:
>> On Jan 7, 7:03 pm, David Markey  wrote:
>>
>> > Is there a reason you didnt do easy_install django?
>>
>> Cause I didn't know about it. I just followed the directions I found
>> at:
>>
>> https://docs.djangoproject.com/en/dev/topics/install/
>>
>> Is there some reason that wouldn't work?
>
> I solved this by creating a symlink from /Library/Python/2.5/site-
> packages/django to my django install dir. Still not sure why that
> worked and putting the path in django.pth did not.
>
>
>> > On 8 January 2012 01:50, larry.mart...@gmail.com
>> > wrote:
>>
>> > > I am trying to get django working on my mac. I downloaded it from SVN
>> > > to /usr/local/django-trunk and it's there:
>>
>> > > $ ls /usr/local/django-trunk/
>> > > __init__.py     core            http            templatetags bin
>> > >      db              middleware      test
>> > > conf                    dispatch        shortcuts       utils
>> > >   contrib     forms
>> > > template                views
>>
>> > > I updated my site-packages with a django.pth file:
>>
>> > > $ cat /Library/Python/2.5/site-packages/django.pth
>> > > /usr/local/django-trunk
>>
>> > > python does have this dir in its path:
>>
>> > > $ python -c "import sys; print sys.path"
>> > > ['', '/Library/Python/2.5/site-packages/cx_Oracle-5.0.2-py2.5-
>> > > macosx-10.5-i386.egg', '/System/Library/Frameworks/Python.framework/
>> > > Versions/2.5/lib/python25.zip', '/System/Library/Frameworks/
>> > > Python.framework/Versions/2.5/lib/python2.5', '/System/Library/
>> > > Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
>> > > '/
>> > > System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
>> > > plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.5/
>> > > lib/python2.5/plat-mac/lib-scriptpackages', '/System/Library/
>> > > Frameworks/Python.framework/Versions/2.5/Extras/lib/python', '/System/
>> > > Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-
>> > > tk', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
>> > > python2.5/lib-dynload', '/Library/Python/2.5/site-packages', '/usr/
>> > > local/django-trunk', '/System/Library/Frameworks/Python.framework/
>> > > Versions/2.5/Extras/lib/python/PyObjC']
>>
>> > > But I still can't import it:
>>
>> > > $ python
>> > > Python 2.5.1 (r251:54863, May  5 2011, 18:37:34)
>> > > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
>> > > Type "help", "copyright", "credits" or "license" for more information.
>> > > >>> import django
>> > > Traceback (most recent call last):
>> > >  File "", line 1, in 
>> > > ImportError: No module named django
>>
>> > > What am I missing or doing wrong?
>>
>> > > TIA!
>> > > -larry
>>
>> > > --
>> > > 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.
>
>

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



Could someone who has experience on both Django and Bottle please tell me what are the some differences between those two

2012-01-08 Thread Chen Xu
Hi, everyone:
Could someone who has experience on both Django and Bottle please tell me
what are the some differences between those two?


Thanks very much
Best regards

-- 
⚡ Chen Xu ⚡

-- 
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: Authentication over JSON

2012-01-08 Thread Kevin Anthony
I'm having a problem with authentication from libcurl in C.  This works
fine from my android/iPhone apps, and from the browser, but libcurl can't
authenticate.
here's how i'm doing it
in django:
authentication function:
user = authenticate(username=username, password=password)
request.session['member_id'] = user.id
typical user function:
id = request.session['member_id']
if id is not None:
Do something useful
else:
Return Error Message

in libcurl: auth function
CURL *session = curl_easy_init(); if (session) { curl_easy_setopt(session,
CURLOPT_URL, url); curl_easy_perform(session); } g_free(url);
curl_easy_cleanup(session);
generic function:
*session = curl_easy_init(); if (session) { char* url =
g_strconcat(URL,"/getremotedevice/",NULL); printf("url:%s\n",url);
curl_easy_setopt(session, CURLOPT_URL, url); curl_easy_setopt(session,
CURLOPT_WRITEFUNCTION, get_active_decives_callback);
curl_easy_perform(session); g_free(url); } curl_easy_cleanup(session);


Am i doing something wrong?

Thanks
Kevin


On Sun, Jan 8, 2012 at 12:22 PM, Kevin Anthony wrote:

>
> https://docs.djangoproject.com/en/1.3/topics/auth/#authentication-in-web-requests
>
> On Sun, Jan 8, 2012 at 12:20 PM, Stodge  wrote:
>
>> This link is giving me a Page Not Found.
>>
>> On Jan 7, 1:10 pm, Michael Elkins  wrote:
>> > On Sat, Jan 07, 2012 at 11:52:26AM -0500, Kevin Anthony wrote:
>> > >I have a small exposed json API, currently it doesn't require
>> > >authentication, but i'd like to integrate it with django's
>> authentication.
>> > > A quick google search came up empty, and i was wondering if anyone had
>> > >any recommendations on how to do this?
>> >
>> > I've done this before using forms and POST, but you could easily
>> > put the user credentials in your json object and use
>> > django.contrib.auth as described here:
>> >
>> > https://docs.djangoproject.com/en/1.3/topics/Aauth/#authentication-in.
>> ..
>>
>> --
>> 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.
>>
>>
>
>
> --
> Thanks
> Kevin Anthony
> www.NoSideRacing.com
>
> Do you use Banshee?
> Download the Community Extensions:
> http://banshee.fm/download/extensions/
>
>


-- 
Thanks
Kevin Anthony
www.NoSideRacing.com

Do you use Banshee?
Download the Community Extensions:
http://banshee.fm/download/extensions/

-- 
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: Problem getting django on mac (10.5/Leopard) working

2012-01-08 Thread larry.mart...@gmail.com
On Jan 7, 7:13 pm, "larry.mart...@gmail.com" 
wrote:
> On Jan 7, 7:03 pm, David Markey  wrote:
>
> > Is there a reason you didnt do easy_install django?
>
> Cause I didn't know about it. I just followed the directions I found
> at:
>
> https://docs.djangoproject.com/en/dev/topics/install/
>
> Is there some reason that wouldn't work?

I solved this by creating a symlink from /Library/Python/2.5/site-
packages/django to my django install dir. Still not sure why that
worked and putting the path in django.pth did not.


> > On 8 January 2012 01:50, larry.mart...@gmail.com 
> > wrote:
>
> > > I am trying to get django working on my mac. I downloaded it from SVN
> > > to /usr/local/django-trunk and it's there:
>
> > > $ ls /usr/local/django-trunk/
> > > __init__.py     core            http            templatetags bin
> > >      db              middleware      test
> > > conf                    dispatch        shortcuts       utils
> > >   contrib     forms
> > > template                views
>
> > > I updated my site-packages with a django.pth file:
>
> > > $ cat /Library/Python/2.5/site-packages/django.pth
> > > /usr/local/django-trunk
>
> > > python does have this dir in its path:
>
> > > $ python -c "import sys; print sys.path"
> > > ['', '/Library/Python/2.5/site-packages/cx_Oracle-5.0.2-py2.5-
> > > macosx-10.5-i386.egg', '/System/Library/Frameworks/Python.framework/
> > > Versions/2.5/lib/python25.zip', '/System/Library/Frameworks/
> > > Python.framework/Versions/2.5/lib/python2.5', '/System/Library/
> > > Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin', '/
> > > System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.5/
> > > lib/python2.5/plat-mac/lib-scriptpackages', '/System/Library/
> > > Frameworks/Python.framework/Versions/2.5/Extras/lib/python', '/System/
> > > Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-
> > > tk', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> > > python2.5/lib-dynload', '/Library/Python/2.5/site-packages', '/usr/
> > > local/django-trunk', '/System/Library/Frameworks/Python.framework/
> > > Versions/2.5/Extras/lib/python/PyObjC']
>
> > > But I still can't import it:
>
> > > $ python
> > > Python 2.5.1 (r251:54863, May  5 2011, 18:37:34)
> > > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
> > > Type "help", "copyright", "credits" or "license" for more information.
> > > >>> import django
> > > Traceback (most recent call last):
> > >  File "", line 1, in 
> > > ImportError: No module named django
>
> > > What am I missing or doing wrong?
>
> > > TIA!
> > > -larry
>
> > > --
> > > 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: How many Django web pages does it take . . .

2012-01-08 Thread Lachlan Musicman
On Sat, Jan 7, 2012 at 16:10, Alec Taylor  wrote:
> What you are talking about is a form.
>
> Form: https://docs.djangoproject.com/en/dev/topics/forms/
> Autocomplete: https://code.djangoproject.com/wiki/AutoCompleteSolutions
> Unique fields: https://docs.djangoproject.com/en/1.3/ref/forms/validation/

This last page has what I consider an error/bug but I'm not sure how
to judge that, nor what to report against.

At the top of the page, under the heading, it states:

"Changed in Django 1.2: Please, see the release notes"

because it's the docs for django1.3.

As a native English speaker, I consider the comma incorrectly used - I
felt *compelled* ("Please, see...") to visit the documentation from
1.2 rather than merely advised ("Please see...").

The page in question in svn is here
https://code.djangoproject.com/browser/django/trunk/docs/ref/forms/validation.txt
which refers to the function versionchanged which happens to be search
for since it's on a lot of doc pages...

Anyway, FYI

cheers
L.



>
> On Sat, Jan 7, 2012 at 11:56 AM, Bill Beal  wrote:
>> Hi all,
>>
>> I've been doing Django and mostly backend Python for a few months, and
>> I don't really know the limits of what can be done without resorting
>> to JavaScript and Ajax. Here's what I need to do: the user wants to
>> pick an individual from one of a number of lists and have the detailed
>> information come up editable for the one picked. My top-level list is
>> [Lions, Tigers, Bears, All]. The user picks Tigers, and then I present
>> the second-level Tigers list: [Tony, Hobbes, Tigger, Rajah]. The user
>> picks Hobbes, and then I present the detailed information for Hobbes
>> in an editable form: name, address etc. How clunky does this have to
>> be, in terms of mouse clicks and pages downloaded? I've read in more
>> than one place that if you use JavaScript you'd better have a version
>> of your page that works OK without it.
>>
>> For extra credit, what high-powered tools would be needed to do
>> autocompletion, for example the user starts typing "Hobbes" into the
>> Name field and as soon as I find a unique match I present the details?
>> Or, show a list of possible matches when the partial field is not
>> unique?
>>
>> I've been reading books, but most of them just show me how to build a
>> particular kind of website using Django.
>>
>> Thanks for any help you can lend!
>>
>> Bill Beal
>>
>> --
>> 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.
>

-- 
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: Problem getting django on mac (10.5/Leopard) working

2012-01-08 Thread Python_Junkie
using the terminal window execute the following command for each and
every version of python that you might want to use.

cd into the folder that contains the setup.py file in django and run
the following command  >>/usr/local/bin/pythonw  setup.py install

and all of the components will be moved into the correct python
folders






On Jan 7, 9:13 pm, "larry.mart...@gmail.com" 
wrote:
> On Jan 7, 7:03 pm, David Markey  wrote:
>
> > Is there a reason you didnt do easy_install django?
>
> Cause I didn't know about it. I just followed the directions I found
> at:
>
> https://docs.djangoproject.com/en/dev/topics/install/
>
> Is there some reason that wouldn't work?
>
>
>
>
>
>
>
>
>
> > On 8 January 2012 01:50, larry.mart...@gmail.com 
> > wrote:
>
> > > I am trying to get django working on my mac. I downloaded it from SVN
> > > to /usr/local/django-trunk and it's there:
>
> > > $ ls /usr/local/django-trunk/
> > > __init__.py     core            http            templatetags bin
> > >      db              middleware      test
> > > conf                    dispatch        shortcuts       utils
> > >   contrib     forms
> > > template                views
>
> > > I updated my site-packages with a django.pth file:
>
> > > $ cat /Library/Python/2.5/site-packages/django.pth
> > > /usr/local/django-trunk
>
> > > python does have this dir in its path:
>
> > > $ python -c "import sys; print sys.path"
> > > ['', '/Library/Python/2.5/site-packages/cx_Oracle-5.0.2-py2.5-
> > > macosx-10.5-i386.egg', '/System/Library/Frameworks/Python.framework/
> > > Versions/2.5/lib/python25.zip', '/System/Library/Frameworks/
> > > Python.framework/Versions/2.5/lib/python2.5', '/System/Library/
> > > Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin', '/
> > > System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.5/
> > > lib/python2.5/plat-mac/lib-scriptpackages', '/System/Library/
> > > Frameworks/Python.framework/Versions/2.5/Extras/lib/python', '/System/
> > > Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-
> > > tk', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> > > python2.5/lib-dynload', '/Library/Python/2.5/site-packages', '/usr/
> > > local/django-trunk', '/System/Library/Frameworks/Python.framework/
> > > Versions/2.5/Extras/lib/python/PyObjC']
>
> > > But I still can't import it:
>
> > > $ python
> > > Python 2.5.1 (r251:54863, May  5 2011, 18:37:34)
> > > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
> > > Type "help", "copyright", "credits" or "license" for more information.
> > > >>> import django
> > > Traceback (most recent call last):
> > >  File "", line 1, in 
> > > ImportError: No module named django
>
> > > What am I missing or doing wrong?
>
> > > TIA!
> > > -larry
>
> > > --
> > > 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.



Location of temporary file writes in Django production mode

2012-01-08 Thread wilbur
Hello,

I have recently migrated my Django application from a development server to 
a production server. Everything works pretty well with the exception of a 
PDF generating view that uses Python-PYx. The PyX package uses Tex/LaTex, 
and when I try to generate a PDF, I get the following error:

IOError at /buildMetCatalog/ 

[Errno 13] Permission denied: 'tmpYHNZ4b.tex'


Traceback Switch to copy-and-paste 
view 
   
   - /usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py in 
   get_response 
   1. 
  
  response = callback(request, *callback_args, 
**callback_kwargs)
  
  ...
▶ Local vars  
   - /home/wilbur/IOM/iom_catalog/views.py in buildMetCatalog 
   1. 
  
  c1.text(306, 680, header_text, [text.halign.boxcenter, 
text.halign.center, text.size.Huge])
  
  ...
▶ Local vars  
   - /usr/lib/pymodules/python2.6/pyx/canvas.py in text 
   1. 
  
  return self.insert(self.texrunner.text(x, y, atext, *args, 
**kwargs))
  
  ...
▶ Local vars  
   - /usr/lib/pymodules/python2.6/pyx/text.py in text 
   1. 
  
  self.execute("\\begin{document}", 
self.defaulttexmessagesbegindoc + self.texmessagesbegindoc)
  
  ...
▶ Local vars  
   - /usr/lib/pymodules/python2.6/pyx/text.py in execute 
   1. 
  
  texfile = open("%s.tex" % self.texfilename, "w") # start with 
filename -> creates dvi file with that name
  
  ...
▶ Local vars  
   

>From the file extension, it appears that tex is trying to write some kind 
of temporary file to the filesystem, but I am unclear about where I need to 
look to set permissions. Any guidance would be appreciated

Bill

-- 
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/-/rOUUrEV1CCkJ.
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: Logging into CSRF protected Django site using Curl?

2012-01-08 Thread Stodge

Thanks, appreciate it.


On Jan 8, 12:16 pm, creecode  wrote:
> Hello Stodge,
>
> It seems a bit convoluted on the command line but in reallity not much more
> convoluted if you consider all that a browser does for us in this regard.
> :-)
>
> I've used a similar technique to the one you describe on my Crowdsourcing
> Nutrition Facts website.  Here is an extract from the 
> documentation<%20http://www.crowdsourcingnutritionfacts.info/about/#rest-api-authentic...>
> ...
>
> Get the login webpage and parse the csrf token into the data shell
> variable.
>
> $ data=$(curl -s -c 
> cookies.txthttp://www.crowdsourcingnutritionfacts.info/accounts/login/| grep 
> -o "name=['\"]csrfmiddlewaretoken['\"] value=['\"][^'\"]*" | sed -e 
> "s/name='//" -e "s/' value='/=/")\=*user name*\=*password*
>
>  Log in to the website.
>
> $ curl -b cookies.txt -c cookies.txt -d $data -X POST -H 'Content-Type: 
> application/x-www-form-urlencoded'http://www.crowdsourcingnutritionfacts.info/accounts/login/
>
>  Get brands containing the search term "ea".
>
> $ curl -b 
> cookies.txthttp://www.crowdsourcingnutritionfacts.info/api/auto-complete/brand/?...
>
> This is not a best practices or anything just a sample to show programmers
> the mechanics of interacting with the website with whatever tools they
> choose to use.  I attempted to use tools that I thought would be
> available/familiar to a wide variety of systems/programmers.
>
> Toodle-l...
> creecode

-- 
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: Authentication over JSON

2012-01-08 Thread Kevin Anthony
https://docs.djangoproject.com/en/1.3/topics/auth/#authentication-in-web-requests

On Sun, Jan 8, 2012 at 12:20 PM, Stodge  wrote:

> This link is giving me a Page Not Found.
>
> On Jan 7, 1:10 pm, Michael Elkins  wrote:
> > On Sat, Jan 07, 2012 at 11:52:26AM -0500, Kevin Anthony wrote:
> > >I have a small exposed json API, currently it doesn't require
> > >authentication, but i'd like to integrate it with django's
> authentication.
> > > A quick google search came up empty, and i was wondering if anyone had
> > >any recommendations on how to do this?
> >
> > I've done this before using forms and POST, but you could easily
> > put the user credentials in your json object and use
> > django.contrib.auth as described here:
> >
> > https://docs.djangoproject.com/en/1.3/topics/Aauth/#authentication-in...
>
> --
> 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.
>
>


-- 
Thanks
Kevin Anthony
www.NoSideRacing.com

Do you use Banshee?
Download the Community Extensions:
http://banshee.fm/download/extensions/

-- 
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: Authentication over JSON

2012-01-08 Thread Stodge
This link is giving me a Page Not Found.

On Jan 7, 1:10 pm, Michael Elkins  wrote:
> On Sat, Jan 07, 2012 at 11:52:26AM -0500, Kevin Anthony wrote:
> >I have a small exposed json API, currently it doesn't require
> >authentication, but i'd like to integrate it with django's authentication.
> > A quick google search came up empty, and i was wondering if anyone had
> >any recommendations on how to do this?
>
> I've done this before using forms and POST, but you could easily
> put the user credentials in your json object and use
> django.contrib.auth as described here:
>
> https://docs.djangoproject.com/en/1.3/topics/Aauth/#authentication-in...

-- 
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: Logging into CSRF protected Django site using Curl?

2012-01-08 Thread creecode
Hello Stodge,

It seems a bit convoluted on the command line but in reallity not much more 
convoluted if you consider all that a browser does for us in this regard. 
:-)

I've used a similar technique to the one you describe on my Crowdsourcing 
Nutrition Facts website.  Here is an extract from the 
documentation<%20http://www.crowdsourcingnutritionfacts.info/about/#rest-api-authentication>
...

Get the login webpage and parse the csrf token into the data shell 
variable. 

$ data=$(curl -s -c cookies.txt 
http://www.crowdsourcingnutritionfacts.info/accounts/login/ | grep -o 
"name=['\"]csrfmiddlewaretoken['\"] value=['\"][^'\"]*" | sed -e "s/name='//" 
-e "s/' value='/=/")\=*user name*\=*password*

 Log in to the website. 

$ curl -b cookies.txt -c cookies.txt -d $data -X POST -H 'Content-Type: 
application/x-www-form-urlencoded' 
http://www.crowdsourcingnutritionfacts.info/accounts/login/

 Get brands containing the search term "ea". 

$ curl -b cookies.txt 
http://www.crowdsourcingnutritionfacts.info/api/auto-complete/brand/?term=ea


This is not a best practices or anything just a sample to show programmers 
the mechanics of interacting with the website with whatever tools they 
choose to use.  I attempted to use tools that I thought would be 
available/familiar to a wide variety of systems/programmers.

Toodle-l...
creecode

-- 
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/-/2zB_PjkkOwkJ.
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.



RequestContext(request)

2012-01-08 Thread Hassan
Dear ALL,

i have a form in a page  so i added this to views.py :


from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from globalc.models import newsletter
from django import forms

class newform(forms.Form):
email = forms.CharField(max_length=100)
question = forms.CharField(widget=forms.Textarea)


def index(request):
if request.method == 'POST': # If the form has been submitted...
form = newform(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
p = newsletter(question = "" +
str(request.POST.get('question')) , email = "" +
str(request.POST.get('email')))
p.save()

else:
form = newform() # An unbound form

return render_to_response('index.html', {
'form': form,
},context_instance=RequestContext(request))



but everytime i add the context_instance=RequestContext(request)  all
the images in me website goes away !! why



my html page  index.html :
























http://www.adobe.com/go/getflash;>
http://www.adobe.com/images/shared/
download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>



















About Us
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
Quisque posuere justo sem, posuere lobortis ligula





About Us
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
Quisque posuere justo sem, posuere lobortis ligula





About Us
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
Quisque posuere justo sem, posuere lobortis ligula














Welcome
Lorem ipsum
dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
Quisque posuere justo sem, posuere lobortis ligula. Etiam erat diam,
elementum in dapibus bibendum, ultrices eget enim. Nulla et nibh nec
elit venenatis commodo sit amet pretium eros. Duis vel velit at augue
tristique vehicula. Nulla in lectus quis nisi egestas egestas at ac
lacus. Donec rutrum volutpat rhoncus. Proin condimentum, odio eu
commodo laoreet, turpis leo tincidunt nisi, nec mollis quam justo
vitae velit.




textarea{
background-color:#CC;
border-color:#1B4D90;
width:250px;
height:150px;
margin-left:20px;
}

input[type=text]{
background-color:#CC;
border-color:#1B4D90;
width:250px;
margin-left:20px;

}
input[type=submit]{
background-color:#1B4D90;
color:#ff;
width:100px;
margin-left:170px;

}

{% csrf_token %}
Quick
Question 
{{ form.question }}
E-
Mail
{{ form.email }}









Global (c) 2011 | Privet policy
 Powerd by http://www.gardeniatelco.com;>Gardeniatelco















and my settings.py is :

# Django settings for global project.

import os
PROJECT_ROOT =
os.path.abspath(os.path.dirname(os.path.abspath(__file__)))


DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'sqlite.db',  # Or path to
database file if using sqlite3.
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-
uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 

Re: Logging into CSRF protected Django site using Curl?

2012-01-08 Thread Greg Donald
On Sun, Jan 8, 2012 at 9:35 AM, Stodge  wrote:
> I want to log in to my Django app using something like curl. I know
> that I could send a GET to get the login form and the CSRF token and
> then submit a POST with the username, password and CSRF token. But
> this seems awfully convoluted. Is this the only to login to a Django
> site that uses CSRF protection?

https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#exceptions

I use this on views that my mobile apps post to.


-- 
Greg Donald

-- 
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: Since Django has its own database schema, can we still use sqlalchemy instead?

2012-01-08 Thread sebastien piquemal
Actually the guy in that blog post forgets to mention quite a lot of
stuff. By giving-up Django ORM, not only you loose all the management
commands based on Django-orm (loaddata, dumpdata, syncdb, ...), but
also you loose admin, you loose auth, you loose the generic views, you
loose the model forms, and probably many other stuff that I forget.
I think Django and its orm are very coupled. On the other hand, Django
orm is really good, and loosing all the functionalities above for a
bit of extra control (gained by using slq-alchemy) is probably a huge
trade-off.

On Jan 8, 4:44 pm, James  wrote:
> On Jan 8, 8:43 am, Venkatraman S  wrote:
>
> > On Sun, Jan 8, 2012 at 9:49 AM, Chen Xu  wrote:
>
> > > Since Django has its own database schema, can we still use sqlalchemy
> > > instead?
>
> > Just to correct the nomeclature : Django has an ORM, and *NOT* a database
> > schema. An application has its own schema.
> > And to answer the 'modified' Q : django's orm is pretty good. (but yes, i
> > would expect that you can swap it with sqlalchemy, but I havent done it
> > yet).
>
> > -Vhttp://blizzardzblogs.blogspot.com/
>
> To add to what the above poster said, the blog irrational exuberance
> has an entire series on django's loose coupling philosophy.  href='http://lethain.com/replacing-django-s-orm-with-sqlalchemy/'>This
> article is on using SQLAlchemy. I've really been considering
> switching over to jinja based on his articles (since it seems like it
> won't break anything, other than all my render_to_response and will
> need to longform the return render). For my money, django's ORM seems
> to do a pretty good job. I haven't yet said to myself "wow, it would
> be nice if it did X" but I say that all the time to myself about the
> templating engine (which is why I'm considering the switch).

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



Logging into CSRF protected Django site using Curl?

2012-01-08 Thread Stodge
I want to log in to my Django app using something like curl. I know
that I could send a GET to get the login form and the CSRF token and
then submit a POST with the username, password and CSRF token. But
this seems awfully convoluted. Is this the only to login to a Django
site that uses CSRF protection?

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



Using Elixir with Django

2012-01-08 Thread Tova
Hi, we have current project, DB is oracle, and model is in elixir. we
want to add a web interface to the  current model. it seems that
using the Django build-in ORM is a break of the DRY principle,
using Django with elixir seems complicated (we could not found any
example) and loosing django abilities.
what is the recomended design of work?

-- 
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: Since Django has its own database schema, can we still use sqlalchemy instead?

2012-01-08 Thread James


On Jan 8, 8:43 am, Venkatraman S  wrote:
> On Sun, Jan 8, 2012 at 9:49 AM, Chen Xu  wrote:
>
> > Since Django has its own database schema, can we still use sqlalchemy
> > instead?
>
> Just to correct the nomeclature : Django has an ORM, and *NOT* a database
> schema. An application has its own schema.
> And to answer the 'modified' Q : django's orm is pretty good. (but yes, i
> would expect that you can swap it with sqlalchemy, but I havent done it
> yet).
>
> -Vhttp://blizzardzblogs.blogspot.com/

To add to what the above poster said, the blog irrational exuberance
has an entire series on django's loose coupling philosophy. This
article is on using SQLAlchemy. I've really been considering
switching over to jinja based on his articles (since it seems like it
won't break anything, other than all my render_to_response and will
need to longform the return render). For my money, django's ORM seems
to do a pretty good job. I haven't yet said to myself "wow, it would
be nice if it did X" but I say that all the time to myself about the
templating engine (which is why I'm considering the switch).

-- 
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: Since Django has its own database schema, can we still use sqlalchemy instead?

2012-01-08 Thread Venkatraman S
On Sun, Jan 8, 2012 at 9:49 AM, Chen Xu  wrote:

>
> Since Django has its own database schema, can we still use sqlalchemy
> instead?
>

Just to correct the nomeclature : Django has an ORM, and *NOT* a database
schema. An application has its own schema.
And to answer the 'modified' Q : django's orm is pretty good. (but yes, i
would expect that you can swap it with sqlalchemy, but I havent done it
yet).

-V
http://blizzardzblogs.blogspot.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 admin date and time picker not working

2012-01-08 Thread Praveen Krishna R
*Please check If your media files are served properly, Check either 404
messages in the console, or take View Source option in browser and click on
the media links directly which should bring the js or css or whatever
otherwise it is not serving media files I guess.*
*
*

On Sat, Jan 7, 2012 at 6:57 AM, Santiago Ingold
wrote:

> I'm following the 4 part tutorial at djangoproject.com.
>
> In the 2nd part of it (https://docs.djangoproject.com/en/1.3/intro/
> tutorial02/) im configuring the admin interface, it works fine, except
> for the fact that date and time javascript pickers does not appear.
>
> I've been following the tutorial step by step, so I can't imagine what
> i'm doing wrong.
>
> Also, the widget does not appear in admin/auth/user/1/ neither
>
> Any ideas? Thanks
>
> --
> 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.
>
>


-- 
Thanks and Regards,
*Praveen Krishna R*

-- 
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: Joining Tables

2012-01-08 Thread Swaroop Shankar V
Thanks a lot Anler, that's exactly what I want. I never knew that it was so
simple.

Thanks and Regards,
Swaroop Shankar V



On Sun, Jan 8, 2012 at 4:36 PM, Anler  wrote:

>  Oh sorry, it should be this:
>
> photos = Photos.objects.filter(user__groups__id=the_group_id)
>
> --
> Anler
> Sent with Sparrow 
>
> On Sunday, January 8, 2012 at 12:04 PM, Anler wrote:
>
>  Swaroop I think this is what you're asking for:
>
> photos = Photos.objects.filter(user__groups__name='admin')
>
> --
> Anler
> Sent with Sparrow 
>
> On Sunday, January 8, 2012 at 11:42 AM, Jonas Geiregat wrote:
>
>
>
> Thanks Jonas, the statements you had provided would give me a list of
> users who belong that group, but how can I retrieve the photos of those
> users? Actually I was looking for a single statement which would join all
> these tables and returns the data based on the Group ID.
>
>
> I would recommend reading through
> https://docs.djangoproject.com/en/dev/topics/db/queries/
>
> Getting a row by ID:
>
> Group.objects.get(pk=group_id)
>
> --
> 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.
>

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



App for manage renting/booking management

2012-01-08 Thread Ivo Brodien
Hi,

does anyone know of a Django app that handles the bookings and renting of a 
house that can be rented.

I imagine something like this:
- forms for booking
- in the admin: 
- status management of the booking inquiries
- sending out payment confirmations
- maintaining a calendar to show available/reserved dates in an online 
calendar

Thanks!
Ivo

-- 
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: Is models.DateTime timezone aware ?

2012-01-08 Thread Ivo Brodien
Hi,

I did not read the details of your question, but I can tell you that Django 
will be timezone aware in 1.4.

https://docs.djangoproject.com/en/dev/releases/1.4-alpha-1/#support-for-time-zones

cheers
Ivo

On Jan 8, 2012, at 0:40 , Matěj Cepl wrote:

> I have in my first Django app this model (selection):
> 
> class Post(models.Model):
># ...
>updated = models.DateTimeField(default=datetime.datetime.now())
>published = models.DateTimeField(blank=True)
> 
> When looking at the database dump of the generated database I see that the 
> date is saved as timezone aware:
> 
> '2008-07-10 10:00:00+02:00','2008-07-10 10:00:00+02:00'
> 
> However, when in the test I try
> 
>self.assertEqual(test_entry.updated,
>dateutil.parser.parse(u"2008-07-10T10:00:00+02:00"))
> 
> test fails, and I can use only
> 
>self.assertEqual(test_entry.updated,
>dateutil.parser.parse(u"2008-07-10T10:00:00"))
> 
> What am I missing? Any thoughts, please?
> 
> Thank you,
> 
> Matěj
> 
> -- 
> http://www.ceplovi.cz/matej/, Jabber: mceplceplovi.cz
> GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
> 
> Of all tyrannies, a tyranny exercised for the good of its
> victims may be the most oppressive. It may be better to live
> under robber barons than under omnipotent moral busybodies. The
> robber baron's cruelty may sometimes sleep, his cupidity may at
> some point be satiated; but those who torment us for our own
> good will torment us without end, for they do so with the
> approval of their consciences.
>-- C. S. Lewis
> 
> -- 
> 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: Joining Tables

2012-01-08 Thread Anler
Oh sorry, it should be this: 

photos = Photos.objects.filter(user__groups__id=the_group_id) 

-- 
Anler
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Sunday, January 8, 2012 at 12:04 PM, Anler wrote:

> Swaroop I think this is what you're asking for: 
> 
> photos = Photos.objects.filter(user__groups__name='admin') 
> 
> -- 
> Anler
> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
> 
> 
> On Sunday, January 8, 2012 at 11:42 AM, Jonas Geiregat wrote:
> 
> > 
> > 
> > > Thanks Jonas, the statements you had provided would give me a list of 
> > > users who belong that group, but how can I retrieve the photos of those 
> > > users? Actually I was looking for a single statement which would join all 
> > > these tables and returns the data based on the Group ID.
> > 
> > I would recommend reading through 
> > https://docs.djangoproject.com/en/dev/topics/db/queries/
> > 
> > Getting a row by ID:
> > 
> > Group.objects.get(pk=group_id) 
> > 
> > -- 
> > 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 
> > (mailto:django-users@googlegroups.com).
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com 
> > (mailto: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: Joining Tables

2012-01-08 Thread Anler
Swaroop I think this is what you're asking for: 

photos = Photos.objects.filter(user__groups__name='admin') 

-- 
Anler
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Sunday, January 8, 2012 at 11:42 AM, Jonas Geiregat wrote:

> 
> 
> > Thanks Jonas, the statements you had provided would give me a list of users 
> > who belong that group, but how can I retrieve the photos of those users? 
> > Actually I was looking for a single statement which would join all these 
> > tables and returns the data based on the Group ID.
> 
> I would recommend reading through 
> https://docs.djangoproject.com/en/dev/topics/db/queries/
> 
> Getting a row by ID:
> 
> Group.objects.get(pk=group_id) 
> 
> -- 
> 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 
> (mailto:django-users@googlegroups.com).
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com 
> (mailto: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: Joining Tables

2012-01-08 Thread Jonas Geiregat


> Thanks Jonas, the statements you had provided would give me a list of users 
> who belong that group, but how can I retrieve the photos of those users? 
> Actually I was looking for a single statement which would join all these 
> tables and returns the data based on the Group ID.

I would recommend reading through 
https://docs.djangoproject.com/en/dev/topics/db/queries/

Getting a row by ID:

Group.objects.get(pk=group_id)

-- 
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: particular permission

2012-01-08 Thread Praveen Krishna R
*You can add a Foreign Key in the model to django.contrib.auth.models.User,
 and then in the views or wherever you can filter based on the request.user
object.*
*something like -> SampleModel.objects.filter(user = request.user)
*
On Sat, Jan 7, 2012 at 9:46 PM, mirco fini  wrote:

> hi!
>
> I would like to create a site where the user can read just database
> records written by him or by his group.
> Anybody knows how can I obtain that?
>
> thanks a lot
>
> Mirco
>
> --
> 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.
>
>


-- 
Thanks and Regards,
*Praveen Krishna R*

-- 
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: Joining Tables

2012-01-08 Thread Swaroop Shankar V
Thanks Jonas, the statements you had provided would give me a list of users
who belong that group, but how can I retrieve the photos of those users?
Actually I was looking for a single statement which would join all these
tables and returns the data based on the Group ID.

Thanks and Regards,
Swaroop Shankar V



On Sun, Jan 8, 2012 at 2:34 PM, Jonas Geiregat  wrote:

>
>
> The user field is a foreign key to django auth User model. Each user is
> assigned to a group (django Auth Group model). I want to retrieve all the
> photos which belongs to users of a specific group. How can it be done?
>
>
> from django.contrib.auth.models import Group
>
> group = Group.objects.get(name='your_group')
> users = group.user_set.all()
>
> Haven't tested it, but I think that's what you want/need.
>
>
>  --
> 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: Joining Tables

2012-01-08 Thread Jonas Geiregat


> The user field is a foreign key to django auth User model. Each user is 
> assigned to a group (django Auth Group model). I want to retrieve all the 
> photos which belongs to users of a specific group. How can it be done?
> 

from django.contrib.auth.models import Group

group = Group.objects.get(name='your_group')
users = group.user_set.all()

Haven't tested it, but I think that's what you want/need.


-- 
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: Joining Tables

2012-01-08 Thread Jonas Geiregat


> The user field is a foreign key to django auth User model. Each user is 
> assigned to a group (django Auth Group model). I want to retrieve all the 
> photos which belongs to users of a specific group. How can it be done?
> 

from django.contrib.auth.models import Group

group = Group.objects.get(name='your_group')
users = group.user_set.all()

Haven't tested it, but I think that's what you want/need.


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