Re: How to use CommaSeperatedIntegerList with CheckboxSelectMultiple

2010-04-26 Thread Kevin Renskers
I also used the multiple select field found on http://www.djangosnippets.org/snippets/1200/ with success, until I updated Django to the 1.2 beta release. It now longer works, always giving the validation error. I have no clue how to fix this, so I was hoping you found the answer to your problem an

Authentication backend for Facebook problems

2010-04-26 Thread Martin Lundberg
Hello, I wanted to create an authentication backend for Facebook using their new Graph API. I however found out (after talking to some people on #django IRC) that I could not access the cookies in a authentication backend. Now I can't create it since it works by checking if some cookies are availa

Re: feed decorator

2010-04-26 Thread Nuno Maltez
Have you tried invoking the pyhton debugger inside _wrapped to find out the actual values of req_format and fmt and what's happening in there? Nuno On Mon, Apr 19, 2010 at 4:15 AM, Streamweaver wrote: > I'm having trouble developing a feed decorator. I feel like the > decorator I've come up with

Re: Many-To-Many issue; trying to find a way around conditional id

2010-04-26 Thread Nuno Maltez
Are you saying that: collegelist = college.current_objects.filter(collegechoices__school=highschoolid).exclude(name='Undeclared').distinct().annotate(ccount=Count('collegechoices')) gives you the same results as collegelist = college.current_objects.exclude(name='Undeclared').distinct().annota

Re: modelForm ordering

2010-04-26 Thread Nuno Maltez
I'm not sure I understood correctly what you wanted to achieve, but if you want to order the Persons in the dropdown for the players field by name, you need to change the order of the queryset associated with that field. For a ForeignKey field, a ModelForm generates a ModelChoiceField http://docs.

Track "before" and "after" state of an object when editing in the Admin?

2010-04-26 Thread Derek
The Django docs point to the "hooks" you can use for custom code when saving/deleting objects in the Django admin http://www.djangoproject.com/documentation/models/save_delete_hooks/ What is not clear is how (or rather, where) to create a copy of an object before editing, so that it can be compare

how to display only one instance of an object returned by a query.

2010-04-26 Thread shofty
im really struggling to work out how to phrase this question, which is why i've had zero luck googling it. i'll try and explain it. ive got two models. car and photo in a one to many relationship. my queryset is bringing back all of the photos and the for loop writes them all out. currently the

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread Shawn Milochik
> my queryset is bringing back all of the photos and the for loop writes > them all out. currently the photos come back in order of addition, > since all i've got to sort them on is added_date. (i tried ordering > the photos by the FK which is car.name but that didn't work). Why doesn't this wo

Re: Performing an action on model.save() but not on update

2010-04-26 Thread Jim N
Nick, Thanks very much. That worked! I can't work out why my code didn't though (or rather, worked twice). -Jim On Apr 23, 6:37 pm, Nick Serra wrote: > Try this out and see what happens: > > def _hook_post_save_answer(instance, created, sender, **kwargs): >     if created: >         if instan

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread shofty
hmmm, wasn;t expecting that response. im guessing from it, that you're suggesting it should be possible. I don't have the exact error message to hand, but i will recreate it and post it, as i really just thought i was being silly by trying to link to data from a model linked by PK. give me a few ho

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread ondrey
Hi, if your models look something like this: class Car(models.Model): name = models.CharField() class Photo(models.Model): car = models.ForeignKey(Car) added_date = models.DateField() then you can sort the photo queryset by the related model's (i.e. car's) prope

Re: Performing an action on model.save() but not on update

2010-04-26 Thread Nick Serra
:) On Apr 26, 9:48 am, Jim N wrote: > Nick, > > Thanks very much.  That worked!  I can't work out why my code didn't > though (or rather, worked twice). > > -Jim > > On Apr 23, 6:37 pm, Nick Serra wrote: > > > > > > > Try this out and see what happens: > > > def _hook_post_save_answer(instance,

Re: Track "before" and "after" state of an object when editing in the Admin?

2010-04-26 Thread Nick Serra
There are a couple ways to do this. You can either override the model methods like save and init, or you can use signals and tie into the pre_save, post_save, etc. Signals are here: http://docs.djangoproject.com/en/dev/ref/signals/ If using signals, you will have an instance of the object being s

Re: Many-To-Many issue; trying to find a way around conditional id

2010-04-26 Thread Nick Serra
Can you be more clear on the exact result you're trying to achieve? Do you want to see, for a given high school, how many recruit objects are foreign keyed to it? On Apr 26, 7:38 am, Nuno Maltez wrote: > Are you saying that: > > collegelist = > college.current_objects.filter(collegechoices__scho

Re: feed decorator

2010-04-26 Thread Nick Serra
Seems very odd how you're trying to implement this. Unless your pseudocode has me confused. Can you give us the view functions too? Seems like you're trying to use a decorator function on two views. Why don't you just bail on the decorator, and just check for request.GET.get('format') == 'rss', and

Adding unique_together attribute after database is created

2010-04-26 Thread filias
Hi, I would like to add the unique_together attribute of the Meta class for a model in my app. My question is: my database already exists with several records, it is possible to just add the attribute and not do anything in the database level? does it work? I have tried in a app using sqlite and

Re: Adding unique_together attribute after database is created

2010-04-26 Thread Shawn Milochik
Assuming that none of the old data violates your unique_together rule it will work. However, your database will not be configured correctly, and that could lead to problems. After your initial syncdb which created that table, Django will not make any changes to the database. The best thing to

Re: How to use CommaSeperatedIntegerList with CheckboxSelectMultiple

2010-04-26 Thread Bill Freeman
Kevin, I've not used Djanog 1.2 yet, so I haven't seen and fixed any similar problem. I can offer 2 suggestions: 1. pdb is your friend. Learn it, love it. (Very tasty under Gnu Emacs with python mode, start runserver from an emacs shell window with a pdb.set_trace() style breakpoint installed

Re: OS X install, not in home directory?

2010-04-26 Thread Bill Freeman
Are you running setup using the system python, or a separate one tied to your account (such as in a virtual env)? If the latter then try specifying the full path to the system python to run setup. Also, if you have the PYTHONPATH environment variable set, you might try unsetting it while running

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread greatlemer
> finally when i write out the vehicles, i'd like to write a different > line for the first of each type of vehicle. to explain that, the > output should be an image linked to a fancybox gallery. because of the > amount of different vehicles, i'd like to only show one image of each > vehicle, but t

Re: Authentication backend for Facebook problems

2010-04-26 Thread Joe
On Apr 26, 5:42 am, Martin Lundberg wrote: > I was told to create a middleware which I did but it feels wrong since > it is called on every request for everything. And if I add > authentication by Twitter and maybe Google, there will be even more > middleware that is called everytime. > > What is

Re: Oracle cursor.execute problem

2010-04-26 Thread Ian
On Apr 25, 11:13 am, Tim Sawyer wrote: >  >>> import cx_Oracle >  >>> from django.db import connection >  >>> cursor = connection.cursor() >  >>> lOutput = cursor.var(cx_Oracle.STRING) >  >>> cursor.execute("BEGIN %s := 'N'; END;", [lOutput]) > Traceback (most recent call last): >    File "", lin

Re: django authentication system

2010-04-26 Thread Leo
I've done any number of authentication-integration adapters, and it's best to just use django.contrib.auth.models.User. In your authentication backend, just auto-create an instance of User if the supplied username and password pass authentication. You can use a constant password, after all you're

make a timeline on Django

2010-04-26 Thread alivad
how to make a Timeline in Django, something like: http://newstimeline.googlelabs.com/ Thanks you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this gro

Re: make a timeline on Django

2010-04-26 Thread Shawn Milochik
On Apr 26, 2010, at 12:23 PM, alivad wrote: > how to make a Timeline in Django, something like: > http://newstimeline.googlelabs.com/ > > Thanks you. > > -- How to search Google? Thanks you. -- You received this message because you are subscribed to the Google Groups "Django users" gro

Re: modelForm ordering [SOLVED]

2010-04-26 Thread backdoc
Yes, you understood my problem. Thanks. That helped. I tried both suggestions. Your second suggestion looked a little easier. So, I tried it first. I couldn't get it to work. I assume I wasn't doing something just right. But, I was able to get your first solution to work with little fuss.

difficulty with 1.2 CSFR processing

2010-04-26 Thread jeff
so i have some views and forms done without using the CsrfViewMiddleware. now i am converting to a 1.2 project using this middleware. read the doc, looked for examples, still can't process the POST function from my form. the example i have is very simple. hoping for someone who knows this to take

Re: difficulty with 1.2 CSFR processing

2010-04-26 Thread Nick Serra
Include request context: from django.template import RequestContext ...and then pass it in with the render. That should include the token in the template. return render_to_response('add_pair.html', {}, context_instance=RequestContext(request)) On Apr 26, 12:45 pm, jeff wrote: > so i have some

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread shofty
On Apr 26, 2:51 pm, ondrey wrote: > for details > seehttp://docs.djangoproject.com/en/1.1/ref/models/querysets/#order-by-f... > i honestly read that aricle a couple of times and totally missed it. straight in there and working, thanks for pointing it out in plain english. @G thanks for that

How to return an audio file in django

2010-04-26 Thread Dexter
Hi there, I want to send an audio file via a django view, but I don't know how. This doesn't seem to work: return HttpResponse(open(song.path).read(), mimetype = "audio/mpeg") Can you guy's help me? Grtz, Dexter -- You received this message because you are subscribed to the Google Groups

Re: How to return an audio file in django

2010-04-26 Thread Nick Serra
Interesting. If the file is an mp3, maybe try: file = open("/path/to/my/song.mp3", "rb").read() response['Content-Disposition'] = 'attachment; filename=filename.mp3' return HttpResponse(file, mimetype="audio/mpeg") On Apr 26, 1:20 pm, Dexter wrote: > Hi there, > > I want to send an audio file v

I think I will need some more help concerning forms in django

2010-04-26 Thread xpanta
Hi, I am trying hard to understand how the forms work. It seems for me easier to create an html form with some hidden fields during runtime. and then parse them one-by-one by request.POST.keys() when the view is called. I understand, however, that django forms have great importance in building we

Re: I think I will need some more help concerning forms in django

2010-04-26 Thread Shawn Milochik
It sounds like a case for formsets. http://docs.djangoproject.com/en/1.1/topics/forms/formsets/ Assuming you have models for these shopping cart items, you can use a formset of those items. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" grou

Re: How to return an audio file in django

2010-04-26 Thread Christophe Pettus
Another possibility, if you are using either Apache or Lighttpd, is the X-Sendfile header, so that the Python process does not have to handle the content. For lighttpd: http://blog.lighttpd.net/articles/2006/07/02/x-sendfile For Apache: http://tn123.ath.cx/mod_xsendfile/ On Apr 26, 20

adding foreign key attributes to the admin editing screen

2010-04-26 Thread Jesse
Table LOINCCode has loinc_obr4 (a number) and a description field (describing the number). Model Statement: Class StandardCode(models.Model): loinc_obr4 = models.ForeignKey(LOINCCode, null=True, default=1, related_name='loinccodeobr4') In the Admin: fieldsets =[ (None, {'fields': [(

Re: M2M Manager -- how to get primary key of join table?

2010-04-26 Thread Nick Serra
You could create a model that references the join table itself. class ArticlePublicationsJoin(models.Model): id = models.AutoField() publicaiton_id = models.IntegerField() article_id = models.IntegerField() class Meta: db_table = 'article_publications' then just query on

Re: adding foreign key attributes to the admin editing screen

2010-04-26 Thread Nick Serra
Are you trying to interface django with an existing table? Why do you have the StandardCode class foreign key-ing to the table, instead of just making a model that references the table exactly? On Apr 26, 2:43 pm, Jesse wrote: > Table LOINCCode has loinc_obr4 (a number) and a description field >

Re: How to return an audio file in django

2010-04-26 Thread Dexter
I'm using both, I'm not familiar with X-Sendfile, But my situation is this: I have a folder with my music collection, I scan the folder and record the pathnames. Because I don't want to set this folder public, I want to manage the user login with django so not everyone can download my music. Is

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread greatlemer
> @G > > thanks for that. the code im writing will wait til dev version becomes > 1.2 so at least i know there is a way to do it in the next version. > must check when 1.2 is gonna land. You probably noticed anyway but ifchanged is actually in the current version (and has been since at least 1.0)

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread Dexter
It doesn't seem to work very good. On Mon, Apr 26, 2010 at 8:53 PM, greatlemer wrote: > > @G > > > > thanks for that. the code im writing will wait til dev version becomes > > 1.2 so at least i know there is a way to do it in the next version. > > must check when 1.2 is gonna land. > > You probab

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread Dexter
Oops, wrong post On Mon, Apr 26, 2010 at 9:23 PM, Dexter wrote: > It doesn't seem to work very good. > > > On Mon, Apr 26, 2010 at 8:53 PM, greatlemer wrote: > >> > @G >> > >> > thanks for that. the code im writing will wait til dev version becomes >> > 1.2 so at least i know there is a way to d

Re: How to return an audio file in django

2010-04-26 Thread Dexter
It doesn't seem to work very good. I'll read about X-Sendfile, don't know if it suits my purpose. On Mon, Apr 26, 2010 at 8:52 PM, Dexter wrote: > I'm using both, > > I'm not familiar with X-Sendfile, > > But my situation is this: I have a folder with my music collection, I scan > the folder and

multi-language capabilities of Django/Satchmo

2010-04-26 Thread django_jedi
Hi All, I'm interested in finding out more about practical use of django's multi-language capabilities for international sites. Do any of you have experience with this? And can you point towards resources/apps etc. for utilizing these features? Thank you. -- You received this message because

Re: How to return an audio file in django

2010-04-26 Thread Dexter
X-Sendfile doesn't work (yet), Although I got the ugly way working now. When I try to download it manually, it seems to be getting an empty file. even though I have set the Content-Length value. Any suggestions? Grtz, Dexter On Mon, Apr 26, 2010 at 9:24 PM, Dexter wrote: > It doesn't seem to wo

Re: How to return an audio file in django

2010-04-26 Thread Christophe Pettus
On Apr 26, 2010, at 11:52 AM, Dexter wrote: But my situation is this: I have a folder with my music collection, I scan the folder and record the pathnames. Because I don't want to set this folder public, I want to manage the user login with django so not everyone can download my music. Is t

Redirect to named url pattern not working

2010-04-26 Thread Daniel Klein
Hi, I'm trying to avoid hardcoding a URL in a redirect call, but I can't for the life of me make redirect work. The relevant code segments first: >From urls.py: url(r'^game/(\d+)/$', 'views.game', name='gameview'), >From the view: return redirect("gameview", id

Re: Redirect to named url pattern not working

2010-04-26 Thread Javier Guerra Giraldez
On Mon, Apr 26, 2010 at 4:16 PM, Daniel Klein wrote: > From urls.py: > >        url(r'^game/(\d+)/$', 'views.game', name='gameview'), the parameter extracted from the url doesn't have a name. change to: url(r'^game/(?P\d+)/$', 'views.game', name='gameview'), -- Javier -- You recei

While trying to set up Django on Windows: AttributeE rror: ‘Settings’ object has no attribute ‘DATABASES’

2010-04-26 Thread cornflake
Dear Django users, Although my question is about the installation of Django and not about its usage, I really hope you can help me, because I've been struggling with this for hours. I'm following the Django on Windows Howto. I have installed Python 2.6, PostgreSQL 8.4, Psycopg 2.0.14 for Python 2

need help sapnwrfc on django

2010-04-26 Thread nerv82
Hi Django Users, I'm trying to use sapnwrfc to comunicate with SAP. Everything works fine in the python shell. But when i put the same code on the views.py nothing happens or doesn't wait to finish the connection? I'm newbie to django so maybe i'm passing in the wrong way the variable to the temp

Re: While trying to set up Django on Windows: Attrib uteError: ‘Settings’ object has no attribute ‘DATABASE S’

2010-04-26 Thread andy saksena
Maybe you should try looking in your settings.py file and check for database field there and see if you defined that field. On Tue, Apr 27, 2010 at 9:26 AM, cornflake wrote: > Dear Django users, > Although my question is about the installation of Django and not about > its usage, I really hope y

Intersection of two querysets (i.e., AND, &, joining, concatenating) not working

2010-04-26 Thread Daniel
Hi guys, I am confused as to why the intersection of my two querysets keeps returning the empty set. I have two querysets, let's call them query1 and query2. query1 | query2 "adds" them, i.e., union just fine. That works great. query1 & query2 leaves no results, no matter the test case. Could

Re: While trying to set up Django on Windows: Attrib uteError: ‘Settings’ object has no attribute ‘DATABASE S’

2010-04-26 Thread cornflake
Thank you, the problem is solved! Turns out in the development version of Django some settings have been changed, so I had to declare DATABASES instead of DATABASE_ENGINE, DATABASE_HOST etc. http://docs.djangoproject.com/en/dev/ref/settings/ On Apr 27, 3:49 am, andy saksena wrote: > Maybe you sh

Re: How to use CommaSeperatedIntegerList with CheckboxSelectMultiple

2010-04-26 Thread Preston Holmes
On Apr 26, 2:28 am, Kevin Renskers wrote: > I also used the multiple select field found > onhttp://www.djangosnippets.org/snippets/1200/ > with success, until I updated Django to the 1.2 beta release. It now > longer works, always giving the validation error. I have no clue how > to fix this, s

Re: Authentication backend for Facebook problems

2010-04-26 Thread Martin Lundberg
That will improve the situation a lot, thanks! It doesn't change the fact that it would feel more correct to have it in an authentication backend :) On Mon, Apr 26, 2010 at 5:40 PM, Joe wrote: > > On Apr 26, 5:42 am, Martin Lundberg wrote: > > I was told to create a middleware which I did but i

Django DatabaseError when using sqlall and syncdb

2010-04-26 Thread larsendt
I'm having issues creating a new database for my app. I'm using the Django 1.2 beta. I wrote the "people" app on another computer, and now I'm trying to get it working on a little server I have set up. When I try: ./manage.py sqlall people I get the error: django.db.utils.DatabaseError: