Django TypeError-/SEARCH/

2012-03-01 Thread coded kid
Hi guys, I want to create a search form for my django site. So after
creating it, I input the keyword I want to search, after clicking on
“Search” I’m getting:

TypeError at /search/
Related Field has invalid lookup: icontains
Request Method: GET
Request URL:http://127.0.0.1:8000/search/?q=lordme
Django Version: 1.3.1
Exception Type: TypeError
Exception Value:Related Field has invalid lookup: icontains
Exception Location: C:\Python27\lib\site-packages\django\db\models
\fields\related.py in get_prep_lookup, line 141
Python Executable:  C:\Python27\python.exe
Python Version: 2.7.2

Below are my codes:

Models:
#I just paste this in models.

def normalize_query(query_string,
findterms=re.compile(r'"([^"]+)"|(\S+)').findall,
normspace=re.compile(r'\s{2,}').sub):
''' Splits the query string in invidual keywords, getting rid of
unecessary spaces
and grouping quoted words together.
Example:

>>> normalize_query('  some random  words "with   quotes  "
and   spaces')
['some', 'random', 'words', 'with quotes', 'and', 'spaces']

'''
return [normspace(' ', (t[0] or t[1]).strip()) for t in
findterms(query_string)]

def get_query_set(query_string, search_fields):
''' Returns a query, that is a combination of Q objects. That
combination
aims to search keywords within a model by testing the given
search fields.

'''
query = None # Query to search for every search term
terms = normalize_query(query_string)
for term in terms:
or_query = None # Query to search for a given term in each
field
for field_name in search_fields:
q = Q(**{"%s__icontains" % field_name: term})
if or_query is None:
or_query = q
else:
or_query = or_query | q
if query is None:
query = or_query
else:
query = query & or_query
return query

Views:

from myweb.meekapp.models import get_query_set
def search(request):
query_string = ''
found_entries = None
if ('q' in request.GET) and request.GET['q'].strip():
query_string = request.GET['q']

entry_query = get_query_set(query_string, ['user'])

found_entries =
UserProfile.objects.filter(entry_query).order_by('-pub_date')


return render_to_response('search_form.html',
  { 'query_string': query_string,
'found_entries': found_entries },
  context_instance=RequestContext(request))
Template:



Search









What am I missing?

-- 
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: using django templates to generate and replace a file

2012-03-01 Thread Paul Bunker
Thanks Kurtis,

It seems so obvious now! :-)

I can do ...

t = Template(open('users.template').read())
c = Context([get the users from db])
open('users.cfg','w').write(t.render(c))

Thanks for your speedy response! It seems I couldn't see the wood for
the trees
-Paul

On Feb 29, 8:24 pm, Kurtis Mullins  wrote:
> Hey,
>
> I just thought I'd give you a quick reply. First, you can save the rendered
> output of a template using this:
>
> https://docs.djangoproject.com/en/1.3/ref/templates/api/#rendering-a-...
>
> Then, take that String and write over that 'users.cfg' file. For example,
>
> http://docs.python.org/tutorial/inputoutput.html
>
> Hopefully that helps a little bit. I'm not sure if I understand the problem
> right but I figured I'd give it a shot.
>
> Good luck!
> - Kurtis
>
> On Wed, Feb 29, 2012 at 4:27 PM, Paul Bunker wrote:
>
>
>
>
>
>
>
> > Hi Django Users,
>
> > I'd like to use the django template system to generate a file
> > 'users.cfg' that gets read some dispatching software. Is it possible
> > to get django  to generate this file and replace the existing one?
>
> > Thanks
> > -Paul
>
> > --
> > 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.



EuroPython 2012: Call for Proposal is Open!

2012-03-01 Thread Palla
Hi all,
I'm Francesco and I am writing on behalf of EuroPython Staff
(www.europython.eu). We are happy to announce that the Call for
Proposals is now officially open!

DEADLINE FOR PROPOSALS: MARCH 18TH, 23:59:59 CET

For those who have never been at EuroPython (or similar conferences)
before, the Call for Proposals is the period in which the organizers
ask the community to submit proposals for talks to be held at the
conference.

EuroPython is a conference run by the community for the community: the
vast majority of talks that are presented at the conference will be
proposed, prepared and given by members of the Python community
itself.

And not only that: the process that selects the best talks among all
the proposals will also be public and fully driven by the community:
it's called Community Voting, and will begin right after the Call for
Proposals ends.


CFP: Talks, Hands-On Trainings and Posters
--

We're looking for proposals on every aspect of Python: programming
from novice to advanced levels, applications and frameworks, or how
you have been involved in introducing Python into your organisation.

There are three different kind of contribution that you can present at
EuroPython:
- Regular talk. These are standard "talk with slides", allocated in
slots of 45, 60 or 90 minutes, depending on your preference and
scheduling constraints. A Q&A session is held at the end of the talk.
- Hands-on training. These are advanced training sessions for a
smaller audience (10-20 people), to dive into the subject with all
details. These sessions are 4-hours long, and the audience will be
strongly encouraged to bring a laptop to experiment. They should be
prepared with less slides and more source code.
- Posters. Posters are a graphical way to describe a project or a
technology, printed in large format; posters are exhibited at the
conference, can be read at any time by participants, and can be
discussed face to face with their authors during the poster session.
We will take care of printing the posters too, so don't worry about
logistics.

More details about Call for Proposal are online here:
https://ep2012.europython.eu/call-for-proposals/


Don't wait for the last day
---

If possible, please avoid submitting your proposals on the last day.
It might sound a strange request, but last year about 80% of the
proposals were submitted in the last 72 hours. This creates a few
problems for organizers because we can't have a good picture of the
size of the conference until that day.

Remember that proposals are fully editable at any time, even after the
Call for Proposals ends. You just need to login on the website, go to
the proposal page (linked from your profile page), and click the Edit
button.

First-time speakers are especially welcome; EuroPython is a community
conference and we are eager to hear about your experience. If you have
friends or colleagues who have something valuable to contribute, twist
their arms to tell us about it!

Please also forward this Call for Proposals to anyone that you feel
may be interested.

All the best,

Francesco

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

2012-03-01 Thread Sébastien Billion
Hi,

You can try something like that:

p = subprocess.Popen(args=[("%s %s") % (script_name,command_args1)],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
output = p.stdout.readlines()
p.wait()

2012/3/1 dummyman dummyman 

> Hi ,
>
> i am using django  s view function to invoke py*thon script* to run in
> background.
> now i want to pass command line args to the script
>
> here is wat i did
>
> subprocess.Popen([sys.executable,"script_name","command_args1"])
>
> i got the error
>
> execv requires arg 2 to be a string
>
> please help me
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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

2012-03-01 Thread Tom Evans
On Thu, Mar 1, 2012 at 11:42 AM, Sébastien Billion
 wrote:
> Hi,
>
> You can try something like that:
>
> p = subprocess.Popen(args=[("%s %s") % (script_name,command_args1)],

Sorry to pick on something seemingly inconsequential, but this really
riles me. If you launch a subprocess using a string like "command arg1
arg2 arg3", then you force the OS to do additional work to spawn the
process via the shell. at which point the shell then has to re-parse
the arguments that you passed to it.

So, what's the big deal?

If command_args1 was the string 'hello world', then the suggested
approach would not work. The argument would be split into two separate
arguments by the shell. You already know which argument you want and
where you want it, so just pass them through appropriately with a
list.

The only 'benefit' going through a shell is that you can rely on the
shell searching $PATH to find the 'right' executable. As I've
intimated, this isn't much of a benefit.

OP:

Are you showing us precisely the code that runs? WFM…

>>> import sys
>>> import subprocess
>>> p=subprocess.Popen([sys.executable, 'hello.py', 'sdfg'], 
>>> stdout=subprocess.PIPE)
>>> p.communicate()
('hello\n', None)


Cheers

Tom

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

2012-03-01 Thread Sébastien Billion
Thanks for the explications Tom. I didn't realize the consequently to use a
string like in my example.
Sorry for my bad post

2012/3/1 Tom Evans 

> On Thu, Mar 1, 2012 at 11:42 AM, Sébastien Billion
>  wrote:
> > Hi,
> >
> > You can try something like that:
> >
> > p = subprocess.Popen(args=[("%s %s") % (script_name,command_args1)],
>
> Sorry to pick on something seemingly inconsequential, but this really
> riles me. If you launch a subprocess using a string like "command arg1
> arg2 arg3", then you force the OS to do additional work to spawn the
> process via the shell. at which point the shell then has to re-parse
> the arguments that you passed to it.
>
> So, what's the big deal?
>
> If command_args1 was the string 'hello world', then the suggested
> approach would not work. The argument would be split into two separate
> arguments by the shell. You already know which argument you want and
> where you want it, so just pass them through appropriately with a
> list.
>
> The only 'benefit' going through a shell is that you can rely on the
> shell searching $PATH to find the 'right' executable. As I've
> intimated, this isn't much of a benefit.
>
> OP:
>
> Are you showing us precisely the code that runs? WFM…
>
> >>> import sys
> >>> import subprocess
> >>> p=subprocess.Popen([sys.executable, 'hello.py', 'sdfg'],
> stdout=subprocess.PIPE)
> >>> p.communicate()
> ('hello\n', None)
>
>
> Cheers
>
> Tom
>
> --
> 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.



How do i view json data returned from django

2012-03-01 Thread Stanwin Siow
Hello,

I want to view the actual json data from django view, is there anyway i can do 
that before i parse it into jQuery?

Below are my two methods



def refresh_list(request):
if request.method == 'POST':
if 'name_input2' in request.POST:
username = request.POST['name_input2']
print username
refresh_keyword = get_keyword_subscription_dict(username)
#message = refresh_keyword
response = simplejson.dumps({'new_list': refresh_keyword})
return HttpResponse(response, mimetype='application/json')
print 'Success'   
else:
response = simplejson.dumps({'success':'False'})
if request.is_ajax():
return HttpResponse(response, mimetype='application/json')
else:
return HttpResponseRedirect("/")



def get_keyword_subscription_dict(userid = None, keyword = None):
try:
keyword_subscription_dict = {}
if(userid):
cf = settings.cf_users_kw
list_of_keywords_for_user_cf = cf.get(userid, columns=['keyword'])
keyword_subscription_dict = 
ujson.decode(list_of_keywords_for_user_cf['keyword'])
if(keyword):
 return simplejson.dumps(keyword_subscription_dict[keyword])
return simplejson.dumps(keyword_subscription_dict)
except:
return simplejson.dumps('\\')

Do appreciate any help i can get

Thanks!

Best Regards,

Stanwin Siow



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



humanized date range and translation

2012-03-01 Thread Emmanuel Beffara
Hello,

I am working on a Django application for handling events with schedules. 
Basically an event has a starting and ending date and contains sessions, 
each with a date and starting and ending time (current code is at 
https://gitorious.org/django-seminar/). The application is 
internationalized.

I want to present the date range of an event in a humanized form, using 
formulations that depend on the particular range at hand, like

   - May 4th, 2012
   - from May 3rd to 5th, 2012 (not sure this is the proper phrasing in 
   English, btw)
   - from April 23rd to May 2nd, 2012
   - from December 27th, 2012 to January 4th, 2013
   
Obviously, I want this to be translated properly. What would be a proper 
way to do this?
I came up with two ideas for solving the question, but neither one is fully 
satisfactory:

   1. use a combination of translatable format strings, like "from 
   %(begin)s to %(end)s" (one for each case) plus one or two translatable 
   strftime format for each case, but that makes for a dozen techincal 
   messages to translate;
   2. use a Python function for formatting, one for each language, stored 
   in a module like locale.en.formats, and use the proper function depending 
   on the context, but that requires some complicated machinery, unless some 
   infrastructure already exists for that.

As a related point, I want to format single dates within this range in a 
humanized fashion that depends on the context (when presenting a schedule, 
or in selection lists in forms). For instance, if the date range is from 
Monday, May 7h to Friday, May 11th, I want to simpy say "Tuesday" or 
"Tuesday 8th" instead of "May 8th, 2012", since the month and year are 
known from the context. This, too, combines translation and context 
dependent formatting.

I am probably not the first one to face this situation. How do people 
usually cope with this?

-- 
Emmanuel

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



How can I use order_by and filter at the same time? (drives me nuts..!!!)

2012-03-01 Thread Tony Kyriakides
How can I use order_by and filter at the same time? (drives me
nuts..!!!)

This is what i tried:

from django.shortcuts import render_to_response
from vidupdate.posts.models import Entry
from datetime import datetime  #( I even imported the date only)


def entry_view(request):
entries = Entry.objects.all().filter(posted.date ==
today).order_by('pushes')

def entry_view(request):
entries =
Entry.objects.all().filter(date.today()).order_by('pushes')

def entry_view(request):
entries =
Entry.objects.all().filter(datetime.date.today()).order_by('pushes')


I think I am wrong at the .filter()...
Thanks in advance..!!

-- 
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 do i view json data returned from django

2012-03-01 Thread Shawn Milochik

On 03/01/2012 07:48 AM, Stanwin Siow wrote:

Hello,

I want to view the actual json data from django view, is there anyway i can do 
that before i parse it into jQuery?




Assuming that you have a dictionary named "return_data," this will do it:

return HttpResponse(simplejson.dumps(return_data), mimetype = 
"application/json")


--
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 can I use order_by and filter at the same time? (drives me nuts..!!!)

2012-03-01 Thread Tom Evans
On Thu, Mar 1, 2012 at 1:21 PM, Tony Kyriakides
 wrote:
> How can I use order_by and filter at the same time? (drives me
> nuts..!!!)
>
> This is what i tried:
>
> from django.shortcuts import render_to_response
> from vidupdate.posts.models import Entry
> from datetime import datetime  #( I even imported the date only)
>
>
> def entry_view(request):
>    entries = Entry.objects.all().filter(posted.date ==
> today).order_by('pushes')
>
> def entry_view(request):
>    entries =
> Entry.objects.all().filter(date.today()).order_by('pushes')

Yep, that is not how you filter a queryset. You must specify which
field to filter, and how you want to filter.

Eg:

Entry.objects.filter(pub_date__lt=date.today())

See the (extensive) docs:

https://docs.djangoproject.com/en/1.3/topics/db/queries/#field-lookups

Cheers

Tom

-- 
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: UnicodeEncodeError in file uploads

2012-03-01 Thread Aljoša Mohorović
if you're using apache please check /etc/apache2/envvars and make sure
that LANG is not C.
if you uncomment system locale it should work as expected.

## Uncomment the following line to use the system default locale instead:
. /etc/default/locale

Aljosa Mohorovic

-- 
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 can I use order_by and filter at the same time? (drives me nuts..!!!)

2012-03-01 Thread Tony Kyriakides
Tom thanks again for helping :)

On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!


On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!


On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!


On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!

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



django facebook api prob

2012-03-01 Thread dummyman dummyman
Hi guys,

Sorry for troubling you. I am not able to make out how to use facebook
social graph and other plugins in django. I am a newbie . I know the basics
of django and i went thru facebook api key s in developers.facebook.com .
It always points out " an error occured . please try again" . Can u please
provide a link which provides a step by step guide as how to use these apis
in django and get the results .?

-- 
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: UnicodeEncodeError in file uploads

2012-03-01 Thread andi-h

Hi, as you suggested I changed that settings. In addition I made a new
MySQL database with an UTF8 collation and copied all the data to that
one.

No change, I still got the same problem :-(

-- 
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: UnicodeEncodeError in file uploads

2012-03-01 Thread Aljoša Mohorović
although it's possible that this is not the problem, could you post
additional details after you restart apache:
1) envvars content
$ cat /etc/apache2/envvars

2) env settings for apache/site user (usually www-data):
$ cat /etc/default/locale
$ sudo su - www-data
$ export

Aljosa

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



Inline formset factory ignores 'exclude=' for foreign key field

2012-03-01 Thread gulrtosk
Hello list,

through trial and error I discovered that it isn't required to pass the 
foreign key form field post data to the constructor of an inline form set. 
Django will fill it in automatically by looking at the primary key of the 
'instance=' given. So I figured I might as well exclude the hidden FK field 
from the form:

class Group(models.Model):
interest = models.CharField(max_length=100)
class Member(models.Model):
name = models.CharField(max_length=100)
group = models.ForeignKey(Group)

MemberFormSet = inlineformset_factory(Group, Member, exclude=('group',))

The 'exclude=' instruction is ignored and the form is printed the same as 
without 'exclude=('group',)'. This is odd, since the FKs aren't strictly 
required in the form set: if you pass post data *with* foreign key fields 
to the constructor MemberFormSet(), Django will use it for validation, but 
if you don't pass them, it's fine too, because Django will simply use the 
instance to fill them in automatically.

So, how can I exclude my 'group' foreign keys from the printed form set?

Thank you and cheers, glts

-- 
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/-/msqQh54-X5oJ.
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: UnicodeEncodeError in file uploads

2012-03-01 Thread andi-h
1) $ cat /etc/apache2/envvars
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid
. /etc/default/locale
export LANG
# comments have been stripped

2) $ cat /etc/default/locale
LANG="en_US.UTF-8"
$ sudo su - www-data
$ export
export HOME='/var/www'
export LANG='en_US.UTF-8'
export LOGNAME='www-data'
export MAIL='/var/mail/www-data'
export PATH='/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games'
export PWD='/var/www'
export SHELL='/bin/sh'
export TERM='xterm'
export USER='www-data'

By the way, I have the same django project running on a Debian5 server
with locale de_DE.UTF-8 and the upload of filenames containing German
umlauts is working.
Would it help to change the locale settings on this Ubuntu server to
de_DE.UTF-8, too?

-- 
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: UnicodeEncodeError in file uploads

2012-03-01 Thread Aljoša Mohorović
On Thu, Mar 1, 2012 at 6:16 PM, andi-h  wrote:
> Would it help to change the locale settings on this Ubuntu server to
> de_DE.UTF-8, too?

don't know, but give it a shot.
also, what's the output of:
$ locale -a

Aljosa

-- 
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: Going crazy with WSGI

2012-03-01 Thread Sells, Fred
I paid my dues, here are a few working files from my system that may
help you.

Note that I use flex for my frontend and thus don't use all the django
features as intended.

Some of these files may be out of date with latest practice and current
docs.  So use them as you will.


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



test1.wsgi
Description: test1.wsgi


test2
Description: test2


wsgi.conf
Description: wsgi.conf


Re: django facebook api prob

2012-03-01 Thread yati sagade
I tried just now, and even I'm getting the same error. Perhaps you should
ask this question on http://stackoverflow.com under the "facebook" tag - a
team of FB engineers monitors this tag, and may offer more insight. Most
probably, it's some bug/maintenance glitch.

On Thu, Mar 1, 2012 at 9:01 PM, dummyman dummyman wrote:

> Hi guys,
>
> Sorry for troubling you. I am not able to make out how to use facebook
> social graph and other plugins in django. I am a newbie . I know the basics
> of django and i went thru facebook api key s in developers.facebook.com .
> It always points out " an error occured . please try again" . Can u please
> provide a link which provides a step by step guide as how to use these apis
> in django and get the results .?
>
> --
> 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.
>



-- 
Yati Sagade 

(@yati_itay )

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



how to use formwizard with parametrized urls

2012-03-01 Thread danoro
How do I use formwizard within parametrized URLs ?

This is my urls.py

from accounts.jobs.views.wizard import JobWizardView

named_job_forms = (
('narrative', JobNarrativeForm),
('location', JobLocationForm),
('dedication', JobDedicationForm),
('preferences', JobPreferencesForm),
('notifications', JobNotificationsForm),
('promotion', JobPromotionForm),
('gallery', ListForm),
)

job_wizard = JobWizardView.as_view(named_job_forms,
url_name='job_step', done_step_name='job_wizard')

urlpatterns += patterns('accounts.jobs.views.wizard',
url(r'^wizard/(?P\d+)/(?P.+)/$', job_wizard,
name='job_step'),
url(r'^wizard/(?P\d+)/$', job_wizard, name='job_wizard'),
)


However job_id is not passed-on by the formwizard code itself.

Shown below you can see kwargs is only given 'step' when constructing
the URL

formwizard/views.py
class NamedUrlWizardView(WizardView):
def get(self, *args, **kwargs):
"""
This renders the form or, if needed, does the http redirects.
"""
step_url = kwargs.get('step', None)
if step_url is None:
if 'reset' in self.request.GET:
self.storage.reset()
self.storage.current_step = self.steps.first
if self.request.GET:
query_string = "?%s" % self.request.GET.urlencode()
else:
query_string = ""
next_step_url = reverse(self.url_name, kwargs={
'step': self.steps.current,
}) + query_string
return redirect(next_step_url)
   and continues...

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



null field issue

2012-03-01 Thread Marc Aymerich
I have a model with a filed like
name = models.CharField(max_length=255, blank=True, null=True)

With Django admin I've created some instances of that model without
filling name field. Now I'm querying that model with name__isnull=True
and the filter doesn't return any single object!! acctually on the
database (postgresql) the name field is an empty string '' instead of
the expected NULL.

Why the admin fills name field with an empty string? Is this a normal
behaviour?

-- 
Marc

-- 
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: Inline formset factory ignores 'exclude=' for foreign key field

2012-03-01 Thread gulrtosk
Right, I don't know whether this is a bug or done on purpose ... It looks 
like it was done on purpose so I'd be happy to hear the experts on this. 
I'm using Django 1.3. I hope I got this right.

On line 752 of django.forms.models (development trunk), in the add_fields() 
method of BaseInlineFormSet it says:

name = self.fk.name
...
form.fields[name] = InlineForeignKeyField(self.instance, **kwargs)

This is *after* all processing of 'fields=' and 'exclude=' kwargs has been 
done on the form. Consequently, for all inline form sets the foreign key 
field is always included. It is not possible to 'exclude=' it. Any opinions 
on why this should be so?

-- 
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/-/ZBqnjPrqj80J.
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: null field issue

2012-03-01 Thread jirka . vejrazka
Hi Marc, 

  if I remember correctly (can't check now), the documentation clearly states 
that you should avoid using null=True on CharField unless you have a good 
reason. Your example is a textbook reason why is it recommended - having two 
distinct states for "empty string" (i.e. "blank" and "null") leads to 
inconsistencies and confusion.

  HTH

 Jirka

-Original Message-
From: Marc Aymerich 
Sender: django-users@googlegroups.com
Date: Thu, 1 Mar 2012 22:43:19 
To: 
Reply-To: django-users@googlegroups.com
Subject: null field issue

I have a model with a filed like
name = models.CharField(max_length=255, blank=True, null=True)

With Django admin I've created some instances of that model without
filling name field. Now I'm querying that model with name__isnull=True
and the filter doesn't return any single object!! acctually on the
database (postgresql) the name field is an empty string '' instead of
the expected NULL.

Why the admin fills name field with an empty string? Is this a normal
behaviour?

-- 
Marc

-- 
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: null field issue

2012-03-01 Thread Marc Aymerich
On Fri, Mar 2, 2012 at 12:15 AM,   wrote:
> Hi Marc,
>
>  if I remember correctly (can't check now), the documentation clearly states 
> that you should avoid using null=True on CharField unless you have a good 
> reason. Your example is a textbook reason why is it recommended - having two 
> distinct states for "empty string" (i.e. "blank" and "null") leads to 
> inconsistencies and confusion.
>

Hi Jirka, thanks for the answer!! you're totally right :) I've missed
this pice of documentation
thanks again.
-- 
Marc

-- 
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: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

2012-03-01 Thread Python_Junkie
Just to get you past the error and display your data, I suggest hard coding 
the directory path in your view.
The work your way backwards to the settings file


try 

t = 
loader.get_template('C:\\Python27\\my_Djando_projects\\mysite\\My_Templates\\polls\\index.html'')
 


You could also add a little bit of python into your view to list the 
directory and print out the variable in the template just for a sanity check

path=C:\\Python27\\my_Djando_projects\\mysite\\My_Templates\\polls\\'
var=os.lisdir(path)

 c = Context({
   'latest_poll_list': latest_poll_list,"var":var,
   })

and then add the dictionary value {{var}} in your template


On Wednesday, February 29, 2012 2:48:53 PM UTC-5, atm wrote:
>
> You have to give template directories, not template names in the 
> settings.py.
> Thanks,
> Anoop
> atm
> ___
> Life is short, Live it hard.
>
>
>
>
> On 1 March 2012 01:16, Django_for_SB  wrote:
>
>> Hello All,
>>
>> I'm going through the tutorial on djangoproject.com, and can't seem to
>> hurdle over this section that reads "Write views that actually do
>> something"
>>
>> Here's the code I have so far, which is directly copied from the
>> tutorial or prescribed by the tutorial:
>>
>> views.py:
>> "from django.template import Context, loader
>> from polls.models import Poll
>> from django.http import HttpResponse
>>
>> def index(request):
>>latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
>>t = loader.get_template('polls/index.html')
>>c = Context({
>>'latest_poll_list': latest_poll_list,
>>})
>>return HttpResponse(t.render(c))"
>>
>>
>>
>> settings.py:
>> "...
>> TEMPLATE_DIRS = (
>># Put strings here, like "/home/html/django_templates" or "C:/www/
>> django/templates".
>># Always use forward slashes, even on Windows.
>># Don't forget to use absolute paths, not relative paths.
>>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
>> base_site.html'
>>'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
>> index.html'
>>'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/
>> index.html'
>> )
>> ..."
>>
>>
>> index.html:
>> "{% if latest_poll_list %}
>>
>>{% for poll in latest_poll_list %}
>>{{ poll.question }}> li>
>>{% endfor %}
>>
>> {% else %}
>>No polls are available.
>> {% endif %}
>> "
>>
>>
>>
>>
>> I keep getting the same error, which reads:
>>
>>
>> TemplateDoesNotExist at /polls/
>>
>> polls/index.html
>>
>> Request Method: GET
>> Request URL:http://localhost:8000/polls/
>> Django Version: 1.3.1
>> Exception Type: TemplateDoesNotExist
>> Exception Value:
>>
>> polls/index.html
>>
>> Exception Location: C:\Python27\lib\site-packages\django\template
>> \loader.py in find_template, line 138
>> Python Executable:  C:\Python27\python.exe
>> Python Version: 2.7.2
>> Python Path:
>>
>> ['C:\\Python27\\my_Djando_projects\\mysite',
>>  'C:\\Windows\\system32\\python27.zip',
>>  'C:\\Python27\\DLLs',
>>  'C:\\Python27\\lib',
>>  'C:\\Python27\\lib\\plat-win',
>>  'C:\\Python27\\lib\\lib-tk',
>>  'C:\\Python27',
>>  'C:\\Python27\\lib\\site-packages']
>>
>> Server time:Wed, 29 Feb 2012 11:32:54 -0800
>> Template-loader postmortem
>>
>> Django tried loading these templates, in this order:
>>
>> Using loader django.template.loaders.filesystem.Loader:
>> c:\python27\my_djando_projects\mysite\my_templates\admin
>> \base_site.html
>> c:\python27\my_djando_projects\mysite\my_templates\admin\index.html
>> c:\python27\my_djando_projects\mysite\my_templates\polls\index.html
>> \polls\index.html (File does not exist)
>> Using loader django.template.loaders.app_directories.Loader:
>> c:\python27\lib\site-packages\django\contrib\admin\templates\polls
>> \index.html (File does not exist)
>>
>>
>>
>>
>> What on earth am I doing wrong here? I've so many different variations
>> of my settings.py, views.py, and index.html. Any help would be much
>> appreciated.
>>
>>
>> Thanks,
>>
>> SB
>>
>> --
>> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7pKyULz9dxYJ.
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: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

2012-03-01 Thread Python_Junkie


On Wednesday, February 29, 2012 2:46:11 PM UTC-5, Django_for_SB wrote:
>
> Hello All, 
>
> I'm going through the tutorial on djangoproject.com, and can't seem to 
> hurdle over this section that reads "Write views that actually do 
> something" 
>
> Here's the code I have so far, which is directly copied from the 
> tutorial or prescribed by the tutorial: 
>
> views.py: 
> "from django.template import Context, loader 
> from polls.models import Poll 
> from django.http import HttpResponse 
>
> def index(request): 
> latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] 
> t = loader.get_template('polls/index.html') 
> c = Context({ 
> 'latest_poll_list': latest_poll_list, 
> }) 
> return HttpResponse(t.render(c))" 
>
>
>
> settings.py: 
> "... 
> TEMPLATE_DIRS = ( 
> # Put strings here, like "/home/html/django_templates" or "C:/www/ 
> django/templates". 
> # Always use forward slashes, even on Windows. 
> # Don't forget to use absolute paths, not relative paths. 
> 'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ 
> base_site.html' 
> 'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/ 
> index.html' 
> 'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/ 
> index.html' 
> ) 
> ..." 
>
>
> index.html: 
> "{% if latest_poll_list %} 
>  
> {% for poll in latest_poll_list %} 
> {{ poll.question }} li> 
> {% endfor %} 
>  
> {% else %} 
> No polls are available. 
> {% endif %} 
> " 
>
>
>
>
> I keep getting the same error, which reads: 
>
>
> TemplateDoesNotExist at /polls/ 
>
> polls/index.html 
>
> Request Method: GET 
> Request URL: http://localhost:8000/polls/ 
> Django Version: 1.3.1 
> Exception Type: TemplateDoesNotExist 
> Exception Value: 
>
> polls/index.html 
>
> Exception Location: C:\Python27\lib\site-packages\django\template 
> \loader.py in find_template, line 138 
> Python Executable: C:\Python27\python.exe 
> Python Version: 2.7.2 
> Python Path: 
>
> ['C:\\Python27\\my_Djando_projects\\mysite', 
>  'C:\\Windows\\system32\\python27.zip', 
>  'C:\\Python27\\DLLs', 
>  'C:\\Python27\\lib', 
>  'C:\\Python27\\lib\\plat-win', 
>  'C:\\Python27\\lib\\lib-tk', 
>  'C:\\Python27', 
>  'C:\\Python27\\lib\\site-packages'] 
>
> Server time: Wed, 29 Feb 2012 11:32:54 -0800 
> Template-loader postmortem 
>
> Django tried loading these templates, in this order: 
>
> Using loader django.template.loaders.filesystem.Loader: 
> c:\python27\my_djando_projects\mysite\my_templates\admin 
> \base_site.html 
> c:\python27\my_djando_projects\mysite\my_templates\admin\index.html 
> c:\python27\my_djando_projects\mysite\my_templates\polls\index.html 
> \polls\index.html (File does not exist) 
> Using loader django.template.loaders.app_directories.Loader: 
> c:\python27\lib\site-packages\django\contrib\admin\templates\polls 
> \index.html (File does not exist) 
>
>
>
>
> What on earth am I doing wrong here? I've so many different variations 
> of my settings.py, views.py, and index.html. Any help would be much 
> appreciated. 
>
>
> Thanks, 
>
> SB 
>
>

-- 
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/-/klXbEFxYWH4J.
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 do i view json data returned from django

2012-03-01 Thread Bill Freeman
On Thu, Mar 1, 2012 at 8:29 AM, Shawn Milochik  wrote:
> On 03/01/2012 07:48 AM, Stanwin Siow wrote:
>>
>> Hello,
>>
>> I want to view the actual json data from django view, is there anyway i
>> can do that before i parse it into jQuery?
>>
>
>
> Assuming that you have a dictionary named "return_data," this will do it:
>
> return HttpResponse(simplejson.dumps(return_data), mimetype =
> "application/json")
>

Or, if you want to see it coming from the django site, use curl (always there
on linux, available if not there on OS/x, there are versions for Windows, I'm
sure but there is also cygwin.

Or you can use urllib2 to fetch it from a python prompt.

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



how can I use Tabularinline outside of the admin ?

2012-03-01 Thread Lestak
class Interprise( Model ):
id = AutoField( primary_key = True )
description = CharField( max_length = 50 )

def __unicode__(self):
return self.description

class Client_Interprise( Model ):
id = AutoField( primary_key = True )
activitie = ForeignKey( Activitie )
interprise = ForeignKey( Interprise )
full_name = CharField( max_length = 100, blank = True ,null= True)
telephon_number = CharField( max_length = 20, blank = True ,null=
True)

class Activitie( Model ):
id = AutoField( primary_key = True )
begin_date = DateTimeField()
end_date = DateTimeField()
collaborator = ManyToManyField( Interprise,
related_name="collaborator")
client = ManyToManyField( Interprise, through='Client_Interprise')

### END MODEL ##

from django.forms import ModelForm, Textarea
from django.contrib.admin.widgets import AdminSplitDateTime,
FilteredSelectMultiple

class ActivitieForm( ModelForm ):

class Meta:
model = Activitie
fields=[
'begin_date', 'end_date', 'collaborator',
'client',
]

widgets={
'collaborator':
FilteredSelectMultiple( verbose_name = "collaborator",
is_stacked=False ),
'begin_date': AdminSplitDateTime(),
'end_date':
AdminSplitDateTime(),
'description': Textarea( attrs={ 'cols':50, 'rows':
10 } ),
'client': ?? HELP HELP
}

class ActivitieCreateView( CreateView ):
template_name = "create_journal_activity.xhtml"
context_object_title = 'Activitie'
form_class = ActivitieForm

-- 
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 facebook api prob

2012-03-01 Thread dummyman dummyman
has anyone tried before and is it working ? please help me out if u have
got it working

On Fri, Mar 2, 2012 at 12:11 AM, yati sagade  wrote:

> I tried just now, and even I'm getting the same error. Perhaps you should
> ask this question on http://stackoverflow.com under the "facebook" tag -
> a team of FB engineers monitors this tag, and may offer more insight. Most
> probably, it's some bug/maintenance glitch.
>
> On Thu, Mar 1, 2012 at 9:01 PM, dummyman dummyman wrote:
>
>> Hi guys,
>>
>> Sorry for troubling you. I am not able to make out how to use facebook
>> social graph and other plugins in django. I am a newbie . I know the basics
>> of django and i went thru facebook api key s in developers.facebook.com. It 
>> always points out " an error occured . please try again" . Can u
>> please provide a link which provides a step by step guide as how to use
>> these apis in django and get the results .?
>>
>> --
>> 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.
>>
>
>
>
> --
> Yati Sagade 
>
> (@yati_itay )
>
>
>  --
> 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.



Haystack and Xapian

2012-03-01 Thread coded kid
Hi guys, I want to use Django Haystack with Xapian on my django site
for search function. After setting all the necessary settings. I went
ahead to input: manage.py rebuild_index , after inputting 'y' I'm
getting an error saying: No module named xapian_backend.

I can see the xapian backend module in site-packages, but I don't know
why Django is not seeing it. How Can I make it work?

Below is my settings:

import os
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.xapian_backend.XapianEngine',
'PATH': 'C:/Python27/Scripts/myweb/xapian_index',
'INCLUDE_SPELLING': True,
'BATCH_SIZE': 100,
},
}

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



Seeking sample template code for iterating nested QuerySet

2012-03-01 Thread brycenesbitt
The documentation at:
https://docs.djangoproject.com/en/1.3/topics/db/queries/

Speaks of "Spanning multi-valued relationships", with an QuerySet
returning all Entries (and their Blogs) where the Blog matches a
pattern.

What does the view code look like?



When I do something similar:

facets= models.Category.objects.
filter(facetquestion__facetanswer__subject='test').
select_related()
{% for category in answers %}
{% for q in category.facetquestion_set.all %}
{% for a in q.facetanswer_set.all %}
{% endfor %}
{% endfor %}
{% endfor %}

Each '_set.all" returns the entire set, not just those entries that
matched a pattern.



Back to the django documentation: how would I write the view for the
example given:
Blog.objects.filter(entry__headline__contains='Lennon',entry__pub_date__year=2008)
Where I want the view to print:

   Blog1
Entry1 "Lennon On Ice"
Entry2 "Lennon In Love"
  Blog4
Entry9 "Lennon is Killed"

-- 
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: Seeking sample template code for iterating nested QuerySet

2012-03-01 Thread Matthias Kestenholz
On Fri, Mar 2, 2012 at 08:04, brycenesbitt  wrote:
> The documentation at:
> https://docs.djangoproject.com/en/1.3/topics/db/queries/
>
> Speaks of "Spanning multi-valued relationships", with an QuerySet
> returning all Entries (and their Blogs) where the Blog matches a
> pattern.
>
> What does the view code look like?
>
>
>
> When I do something similar:
>
> facets= models.Category.objects.
>    filter(facetquestion__facetanswer__subject='test').
>    select_related()
> {% for category in answers %}
>        {% for q in category.facetquestion_set.all %}
>            {% for a in q.facetanswer_set.all %}
>            {% endfor %}
>        {% endfor %}
> {% endfor %}
>
> Each '_set.all" returns the entire set, not just those entries that
> matched a pattern.
>
>
>
> Back to the django documentation: how would I write the view for the
> example given:
> Blog.objects.filter(entry__headline__contains='Lennon',entry__pub_date__year=2008)
> Where I want the view to print:
>
>   Blog1
>    Entry1 "Lennon On Ice"
>    Entry2 "Lennon In Love"
>  Blog4
>    Entry9 "Lennon is Killed"
>

You are mainly listing entries here, not blogs. Because of that it's
easier to write the code like this:

blogs = SortedDict()
for entry in Entry.objects.filter(headline__contains='Lennon',
...).select_related('blog'):
blogs.setdefault(entry.blog, []).append(entry)


Your example might be better written in a similar way too:


categories = SortedDict()
for answer in 
FacetAnswer.objects.filter(subject__icontains='test').select_related('question__category'):
category = categories.setdefault(answer.question.category, SortedDict())
category.setdefault(answer.question, []).append(answer)

I hope something like this gets you started.

Btw, the BIG advantage of the approach outlined above is that you only
need one SQL query to fetch all results you need instead of dozens.


Matthias

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