Re: Limiting file upload type?

2011-03-25 Thread David De La Harpe Golden
On 25/03/11 13:48, Sithembewena Lloyd Dube wrote: > Hi folks, > > I have a model with a FileField, and I need to chech that the file is .mp3 > before it is uploaded. How would I go about this without the hack of getting > the file name and slicing it? > Uh. File names are just names. There's no

Re: Implementing a ldap db backend

2011-03-21 Thread David De La Harpe Golden
On 03/11/10 07:48, sebastien piquemal wrote: > I have thought of many solutions to replace ldapdb. I came to > conclusion than the cleanest, and most useful for the community, would > be to implement a real db backend for ldap. However, I have been told > that it is an awfully big task ! > It wo

Re: Is it safe to change the "id" field of a model from int to bigint in the DB schema?

2011-03-14 Thread David De La Harpe Golden
On 13/03/11 05:02, Andy wrote: > I have a model that may have a lot (billions) of records. I understand > that the "id" field of a model is defined as a 32-bits int. So it may > not be big enough. > > Is it safe to just ALTER the database schema to change the "id" field > from int to bigint? Would

Re: Django 1.2.5 postgres autocommit and contenttype sites tests failures

2011-03-04 Thread David De La Harpe Golden
On 04/03/11 10:01, Tomasz Zieliński wrote: > On 2 Mar, 00:10, Jason Culverhouse wrote: >> Hi, >> It seems that the contenttype framework and the sites contribs >> conflict with using the autocommit:True database option. > > Do you really need that autocommit? Django has its own concept of > aut

Re: multi model forms

2011-03-01 Thread David De La Harpe Golden
On 28/02/11 23:13, django wrote: > hi guys > I am new to django. > > I have got two model User(Django built in ) and a model customer, user > is foreign key in customer > > class Customer(models.Model): > user = models.ForeignKey(User, related_name='customers') > street = models.CharField(max

Re: Django pagination is repeating results

2011-02-18 Thread David De La Harpe Golden
On 18/02/11 17:38, diogobaeder wrote: > Hi, > Any ideas of what might be happening? > Have you set a Meta.ordering on your Model (or applied an .order_by() to the QuerySet?) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this gro

Re: External Javascript Files

2011-02-17 Thread David De La Harpe Golden
On 17/02/11 17:44, hank23 wrote: > Is it possible to use external javascript files with a django app? Certainly - The django admin itself does it, for example, bundling a version of jquery and a bunch of stuff in admin/media/js/ > If > so what folder does the javascript file need to be placed in?

Re: Django User Permissions

2011-02-15 Thread David De La Harpe Golden
On 15/02/11 17:31, hank23 wrote: > So my question is what type of object is returned by user.user_permissions? First, N.B. you probably want to look at user.get_all_permissions(). user_permissions in particular doesn't represent all permissions a user "has" in the django.contrib.auth system, only

Re: KeyError at /save/ 'tags'

2011-02-14 Thread David De La Harpe Golden
On 14/02/11 13:58, corden wrote: > tag_names = form.cleaned_data['tags'].split() ^^^ tags > tag = forms.CharField(label=u'Tags', required=False, ^^^ tag ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this grou

Re: handler500 not working

2011-02-10 Thread David De La Harpe Golden
On 10/02/11 15:15, vamsy krishna wrote: > Hi, > > I've defined the following in my root urls and also defined the > corresponding views and templates. The 404 handler picks up the > template correctly but the 500 handler doesn't. The control never > reaches the view function though apache logs rep

Re: Submitting Django forms with AJAX

2011-02-04 Thread David De La Harpe Golden
On 04/02/11 01:41, mf wrote: > I'm very confused about > how to approach ajax forms submission with django. I would suggest the ajaxForm plugin. http://jquery.malsup.com/form/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this gr

Re: templates - pulling child templates

2011-01-21 Thread David De La Harpe Golden
On 21/01/11 12:08, km wrote: > Hi all, > > I am trying to display a parent django template (base.html) with a view > function called "base" like this: > > def base(request): >return render_to_response('base.html') > > The base.html gets displayed in the browser(firefox 3.x) but the child ht

Re: a chicken and egg - help please?

2011-01-18 Thread David De La Harpe Golden
On 18/01/11 07:26, Jani Tiainen wrote: > It's just not possible to run any arbitrary Python code > in a database. Well, technically there's a pl/python module for postgresql. ;-) (doesn't really help, I'm just saying) http://www.postgresql.org/docs/9.0/interactive/plpython.html -- You receive

Re: Closing or resetting long-running connections

2010-12-13 Thread David De La Harpe Golden
On 12/12/10 12:10, Craig Trader wrote: > What I would like to be able to do is to have my background process > close and/or reset its database connection, as often as necessary. > > Thank you in advance for any assistance you can render. Yeah, note that django normally actually closes the conne

Re: IN clause in raw sql

2010-12-08 Thread David De La Harpe Golden
On 08/12/10 17:42, dgmyrs wrote: > That's a simplified sql just as an example. The actual one I need the > in clause is a lot more complex and can't be handled in the ORM. > [Are you _sure_? name__in=... is so much handier, django sorts it out for you...] Anyway, see also http://code.djangoproj

Re: Django in production on Windows

2010-12-02 Thread David De La Harpe Golden
On 02/12/10 14:22, ashdesigner wrote: > Guys, > > As I can judge from the posts and links above, an ISAPI plugin > (PyISAPIe) which is declared the best and fastest way to run Django > apps on Windows and primarily intended to be used with IIS Hmm. Fastcgi looked most promising to me, not that I

Re: Error in ajax request

2010-11-30 Thread David De La Harpe Golden
On 29/11/10 22:17, Daniel Roseman wrote: > (Actually I'm not sure that 'callable decorator' is the right term > here, but I can't think of a better one. Is there a canonical name for > this sort of thing?) PEP 318 just says "function that returns a decorator" (which is a bit of a mouthful) "The

Re: Javascript and template rendering problem

2010-11-30 Thread David De La Harpe Golden
On 29/11/10 20:03, Anderson Goulart wrote: > Hi, > > How can I render to a javascript code a variable set in a view? > I tried {{ variable }} but it returns nothing in the html source code. > When I put this {{ variable }} outside

Re: umlaut

2010-11-29 Thread David De La Harpe Golden
On 29/11/10 13:20, Thomas Rega wrote: > Hi, > > is there a recommended way to deal with German 'umlauts' (like ü.ö.etc.) > I was lookingfor some kind of template filter but without success :( > The data is stored as utf-8 format. What I am looking for is an > automatic transformation into 'ü, ö et

Re: How do I get tracebacks printed to terminal?

2010-11-24 Thread David De La Harpe Golden
On 23/11/10 20:48, Markus Barth wrote: > I am using quite a lot of asynchronous calls for updating a page. The > problem is that this way you never see a traceback. In turbogears the > development server prints all tracebacks to the terminal. Is there any > way to get a similar behaviour with djang

Re: Is there a way to create a new database table other than model?

2010-11-23 Thread David De La Harpe Golden
On 23/11/10 13:55, Li You wrote: > Because I want to save user's info about each game. And the best way > is to save the info by each game. > It sounds like you have some db modelling confusion here. Are you sure you don't just want a many-to-many between Game and User with some data on an expli

Re: restrict downloading files based on user-permission

2010-11-22 Thread David De La Harpe Golden
Looked into this a bit (will undoubtedly bite us soon): On 22/11/10 13:54, Torsten Bronger wrote: > Is there a standard at all for how non-ASCII in the header field > "Content-Disposition" is supposed to be encoded? The rfc5987 [1] based filename*=UTF-8''bl%c3%a4h mechanism very recently exists,

Re: Variable extends tag

2010-11-19 Thread David De La Harpe Golden
extends can take a variable arg, set the variable to the base you want. {% extends base %} http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#extends -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email t

Re: Whoosh: 'module' object has no attribute 'FileStorage'

2010-11-03 Thread David De La Harpe Golden
On 03/11/10 08:41, sureronald wrote: > Hi all, > > I am using Whoosh version 1.2.5 to allow for full text search on my > models. I was using this guideline from here > http://www.arnebrodowski.de/blog/add-full-text-search-to-your-django-project-with-whoosh.html Note that django-haystack [1] has a

Re: Model Inheritance.

2010-10-29 Thread David De La Harpe Golden
On 29/10/10 00:04, Tom Eastman wrote: That's correct, but I want to take a 'Place' object, that doesn't have a 'restaurant', and turn it *in to* a 'Restaurant' by adding the corresponding row to the Restaurant table. So you have a place. p = Place(name="3rd Circle of Hell") p.save() This sh

Re: What does an ideal django workflow setup look like?

2010-10-26 Thread David De La Harpe Golden
On 25/10/10 19:04, Jumpfroggy wrote: > - +1 on using "settings.py" and "local_settings.py". The problem with > keeping local settings files in the VCS is when you have multiple > servers with different settings. You could store each file as > local_settings_test_server.py and so on. We use a

Re: moving from Postgres to MySQL

2010-10-26 Thread David De La Harpe Golden
On 22/10/10 17:34, Kevin Monceaux wrote: > I think the OP was referring to mysqldump's --compatible option which > one could use, for example, as mysqldump --compatible=postgresql ... Doesn't Work, btw. (really doesn't help much, at least in my experience - you just end up with dump that's neithe

Re: moving from Postgres to MySQL

2010-10-21 Thread David De La Harpe Golden
On 21/10/10 15:06, Chris Withers wrote: > ...bt, why would dumpdata dump out something invalid? Why indeed, but that doesn't mean it isn't. (aside: of course the dumb regex match I suggested wasn't a proper date parse either, you might want to try an actual parse in the loop - which is what

Re: moving from Postgres to MySQL

2010-10-21 Thread David De La Harpe Golden
On 21/10/10 13:31, Chris Withers wrote: > ...which is a little odd, given that the file was created by 'dumpdata'. > Any ideas? > Do you see any genuine wierdness in the format of any stringified datetimes in the dumped json? Yes I know you've got 132 megs, but I don't mean check totally manuall

Re: Comments and cascade delete

2010-10-21 Thread David De La Harpe Golden
On 21/10/10 08:22, shacker wrote: > Thanks David, but I'm not sure I'm getting this. I've added that line > to the class, but it doesn't give me cascade delete behavior (I can > still delete a row and the comments linked to it remain in the db). Is > there something else I need to do? Hmm. Appe

Re: Comments and cascade delete

2010-10-19 Thread David De La Harpe Golden
On 19/10/10 17:16, shacker wrote: > If Django comments are attached to a record (like a news item) and > that item is deleted, the comment remains in the database. In other > words, comments don't get cascade delete treatment like foreign key > relationships do. The django comments contrib uses t

Re: Different logins in same browser session and login_required

2010-10-19 Thread David De La Harpe Golden
On 19/10/10 17:03, Bill Freeman wrote: > This is a limitation of the browser. It does not keep separate credentials > for separate windows. This is usually desirable because you may choose > to open a link in a new window (or tab) and you still expect to be logged in. > IE8 (and probably other

Re: Legacy database with a table, which has no separate primary key

2010-10-15 Thread David De La Harpe Golden
On 15/10/10 12:15, Alexander wrote: > As you can see the 'rating' table has no separate primary key field. Yeah, that is pretty commonplace (though not presently supported by django), the natural primary key for a table may be composite... > Here are the models created by Django with some my cor

Re: How do I use JQuery UI tabs with Django (or other tab-solution)?

2010-10-13 Thread David De La Harpe Golden
On 13/10/10 17:55, David De La Harpe Golden wrote: > it's one > place you could put the ajaxification script since jquery takes pains sorry, meant to finish that sentence - "takes pains to make dom injection of scripts tags work" - see discussion @ http://api.jquery.co

Re: How do I use JQuery UI tabs with Django (or other tab-solution)?

2010-10-13 Thread David De La Harpe Golden
On 13/10/10 16:17, Torbjorn wrote: > Thanks for the replies. > > Jonathan: No I'm not stuck to JQuery, I will consider dojango. Thanks > [Another thing to be aware of is dajaxproject.com] > Third Okay, so you _are_ using the tabs' ajax mode. > That works, but when I choose tab Third and post

Re: How do I use JQuery UI tabs with Django (or other tab-solution)?

2010-10-13 Thread David De La Harpe Golden
On 13/10/10 08:14, Torbjorn wrote: > In my first shot > I got the tabs nice looking, one template for each tab and I can > navigate between the tabs, but, when I do something on a tab, for > instance posting a form, I would like to get back to that tab. How do > I do that? > Well, django is serv

Re: How to specify NULL as the default of a model field.

2010-10-11 Thread David De La Harpe Golden
On 09/10/10 08:06, Tim Diggins wrote: > It may seem odd but I want to explicitly specify NULL as the default > for a particular field / column. (This is so that South picks up that > the default value is null, rather than there being no default > specified, which is what happens if you specify "nul

Re: Separating application media from project media

2010-09-29 Thread David De La Harpe Golden
On 29/09/10 09:34, Benedict Verheyen wrote: > In my template i add this: > href="{{MEDIA_URL_CALLTRACKING}}/style/login.css" /> > (I'd favour prefix rather than suffix if you're going to pseudo-namespace) Did you introduce such a MEDIA_URL_CALLTRACKING variable into the template context by any

Re: Three Django forms in different tabs in one template?

2010-09-13 Thread David De La Harpe Golden
On 13/09/10 12:48, Stodge wrote: > one view can't support > three forms? Uh, it certainly can if you want to write it that way: Multiple django "form" objects can validate different parts of some request.POST dataset, you're not limited to one post one form. You can even use multiple instances o

Re: How to add a FileField to a dynamically created form

2010-09-08 Thread David De La Harpe Golden
On 07/09/10 20:56, ranjan.kumar wrote > forms.FileField(upload_to='some_dir/') > > The error message that i'm getting is: init() got an unexpected > keyword argument ‘upload_to’ > You're confusing forms.FileField [1] and models.FileField [2] The latter is the one that takes the upload_to

Re: Does anyone have the completed and fully-working code from the Tutorial?

2010-09-07 Thread David De La Harpe Golden
On 07/09/10 16:44, Erskine wrote: > I've spent a few days working through the First App tutorial, and have > mostly got everything working, but I haven't been able to figure out > why I'm getting an extra slash appended after 'polls' when clicking on > the name of the poll > The current URL, poll

Re: Model validation for non-django-orm databases

2010-08-30 Thread David De La Harpe Golden
On 30/08/10 15:12, Owen Nelson wrote: > I just started to wonder if the ORM would, I don't > know... "freak out" on the off-chance I run a query that returns a set of > objects with duplicate values on what is supposed to be the pk. Nah, you just get multiple objects back with the same "pk", map

Re: Model validation for non-django-orm databases

2010-08-30 Thread David De La Harpe Golden
On 30/08/10 06:07, onelson wrote: > I've read that a "hack" around this kind of issue is to use the meta > unique_together property and almost arbitrarily set primary_key on one > of the fields. That sounds great, except for the fact that I've got > no guarantee that any given field will actually

Re: Get request path without having a request object

2010-08-27 Thread David De La Harpe Golden
On 27/08/10 14:22, Sells, Fred wrote: > I'm not sure of the thread safety of Django and wonder if I could store > this object as a local variable of some module like No, that is not likely to work except in a single-threaded* context, and even then it's a bit fraught (just being single-threaded s

Re: duplicate post_save signals

2010-08-18 Thread David De La Harpe Golden
On 18/08/10 07:48, Kenneth Gonsalves wrote: > hi, > > I am using a two post_save signal handlers for two different models. On > certain conditions they have to send emails to me and others. At times > one signal is generated, at other times two or even in one instance 4 > signals were generated, w

Re: Jquery-ui in admin: c is undefined

2010-08-05 Thread David De La Harpe Golden
On 05/08/10 08:59, Alessandro Ronchi wrote: > Is there a way to avoid attaching two times the same jquery library in > admin? Well, the noConflict(true) is a Feature, deliberately decoupling the bundled jquery the admin uses from any jquery (and other "$" snaffling libraries - the "true" stops it

Re: generate cache by visiting protected links

2010-07-29 Thread David De La Harpe Golden
On 29/07/10 16:58, Benedict Verheyen wrote: > So calling a thread once from within a view is not safe ? Depends on what your expectations are... I haven't managed to dig up the paragraph discussing the issue that I recall existing. I've a strong feeling it was by Graham Dumpleton, he mentions in

Re: generate cache by visiting protected links

2010-07-29 Thread David De La Harpe Golden
On 29/07/10 16:16, Jirka Vejrazka wrote: > I personally don't like spawning another thread in a > request-response cycle, but if it works for you, be happy with it :) IIRC it's not really safe, at least in the django/apache case, the whole serving process may be considered fair game to be killed

Re: HTTP POST sent from app to Django Server returns 403 Forbidden

2010-07-28 Thread David De La Harpe Golden
On 28/07/10 03:45, Kieran Farr wrote: > Finally figured out what's going on. > > My hypothesis: > An HTTP request with POST method sent to a Django view wrapped with > @csrf_exempt will still raise a 403 CSRF error if the wrapped view > raises an Http404 exception. > Ah, but was your handler404

Re: What goes in 500.html?

2010-07-26 Thread David De La Harpe Golden
On 24/07/10 20:14, Michael Hipp wrote: > What should go in a proper 500.html page? As little as you can get away with; it's for when your server has screwed up. However, you probably want to make it distinguishable from the apache-level 500 page, in a manner you can ask a user reporting a failur

Re: custom tag and filtered value

2010-07-21 Thread David De La Harpe Golden
On 20/07/10 22:57, owidjaya wrote: > how can i pass a filtered value to a custom tag? > > ie > if i do this > > > {% somecustomtag template_variable|lower %} > The django sources for the standard tags show the method, make sure you are calling parser.compile_filter() on the relevant arg. htt

Re: import model from other module

2010-07-21 Thread David De La Harpe Golden
On 20/07/10 20:04, Andreas Pfrengle wrote: > I've tried it with and without installing in settings.INSTALLED_APPS, > didn't work, table wasn't created vis syncdb. > > David, nevertheless the link you've posted gave me the clue how to > solve the problem. I've defined my external module's class a

Re: Not reflecting MEDIA_URL value

2010-07-20 Thread David De La Harpe Golden
On 20/07/10 12:11, barun wrote: > > [gallery/views.py] > def index(request): > return render_to_response('base.html', {}) > You have to pass through a RequestContext() for the template context processor that injects MEDIA_URL ('django.core.context_processors.media') into to the template

Re: Django memory requirements

2010-07-19 Thread David De La Harpe Golden
On 19/07/10 14:41, Tereno wrote: > Hi there, > > I have a few questions about Django deployment on production so > hopefully you can help me sort it out. > > Firstly, what's the minimum memory requirements for a Django + Apache > + mod_wsgi setup? It seems like my server ran out of memory when I

Re: import model from other module

2010-07-19 Thread David De La Harpe Golden
On 18/07/10 20:58, Andreas Pfrengle wrote: > This should import a database-based timer I've written. In fact, code > from django_timer seems to be imported, since 'test' is printed when I > execute "manage.py syncdb" - however, the database table is not > created. Why? What would I need to change

Re: Jquery nav disabled in Django base template??? help please

2010-07-15 Thread David De La Harpe Golden
On 15/07/10 18:00, natebeacham wrote: > Or, if you don't want to over complicate things... Heh. yes, well. :-) Though doing it on the server does mean it stays working for people who disable javascript. -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Jquery nav disabled in Django base template??? help please

2010-07-15 Thread David De La Harpe Golden
On 15/07/10 16:31, justin jools wrote: > I thought I had solved but I haven't. > [...] > using seperate block nav for evey page seems like a lot of > duplication... Well, you could also pass through a context variable to the template from each of your view functions telling what item in your navba

Re: Jquery nav disabled in Django base template??? help please

2010-07-15 Thread David De La Harpe Golden
On 15/07/10 15:19, justin jools wrote: > > $(document).ready(function() { > $('#nav li a').click(function() { > $('.active').removeClass('active'); > $(this).addClass(

Re: Jquery nav disabled in Django base template??? help please

2010-07-15 Thread David De La Harpe Golden
On 15/07/10 13:40, justin jools wrote: > 2. base.html with jquery nav, exactly the same except for > {{ MEDIA_URL }} which is correct. > FWIW, we use a jquery load line in our base template and it works fine (pretty disastrous for us if it didn't). You're 100% sure the pathss correct (like when

Re: altering the sessions class

2010-07-15 Thread David De La Harpe Golden
On 14/07/10 19:42, T.L wrote: > So, I am using request.sessions in one of my views functions but I > want to add a few more fields to the Session class so it will be > customized for my project. > To sum it up, can anyone tell me some way to customize the Session > class to my liking? > It see

Re: reversing admin urls

2010-07-12 Thread David De La Harpe Golden
On 12/07/10 11:27, bigfudge wrote: > Hi - is it possible to reverse admin urls for user-apps? For example, > if I have an app named "Survey" and a model named "Question", is there > a consistent format for reversing the url to edit this model in the > admin interface (by default this would be /admi

Re: Dajax or Jquery

2010-07-12 Thread David De La Harpe Golden
On 12/07/10 11:36, Imad Elharoussi wrote: > Hi, > > I want to know what's the best plugin of Ajax to use with django Dajax or > Jquery (for someone who just began in developping with such technologies) > They don't do the same thing? jquery is a purely client-side javascript toolkit, whereas daj

Re: Is {% cycle ... as ... %} supposed to output a value?

2010-07-07 Thread David De La Harpe Golden
On 07/07/10 17:27, Bill Freeman wrote: > I agree that the "as" clause makes me expect it to render nothing, but it > has worked this way at least back to 1.0, so I guess changing it is not > an option. hypothetical, could add an "only" clause maybe to preserve backward compat? {% cycle 'odd' 'eve

Re: Django logging

2010-06-23 Thread David De La Harpe Golden
On 23/06/10 16:48, thusjanthan wrote: Hi, I am creating a new django framework and figured django would come with its own logging feature. I found this one that Fraser wrote but is no longer in development (http://code.google.com/p/django-logging/ wiki/Overview) That's wasn't really for loggin

Re: Actions after HttpResponse rendered?

2010-06-21 Thread David De La Harpe Golden
On 21/06/10 06:46, DaNmarner wrote: There's a similar question as mine on stackoverflow.com: http://stackoverflow.com/questions/1081340/how-do-you-do-something-after-you-render-the-view-django and there isn't a satisfactory answer there. Basically, how do I do some thing after a view returns t

Re: Dumping large database

2010-06-14 Thread David De La Harpe Golden
On 14/06/10 04:15, Jeff Green wrote: I was wondering what would be the best method of trying to dump a large database. I am trying to migrate from postgresql to oracle, using django 1.2.1 I have been unsucessful in using dumpdata. One interesting point - django 1.2 supports multiple connections

Re: limit on date in postgres/django

2010-06-09 Thread David De La Harpe Golden
On 09/06/10 12:23, Wim Feijen wrote: Hello, Do you know whether there is a minimum to a date? Well there is, at the postgresql level, dates are supported between 4713 BC and 5874897 AD http://www.postgresql.org/docs/8.4/static/datatype-datetime.html Maybe there's some text to date parser lev

Re: New product django-queries

2010-05-31 Thread David De La Harpe Golden
On 31/05/10 11:55, Guthy Peter wrote: Dear Django users, I have written a new module for Django: it's called django-queries, and is sort of a mix between the Admin and the Databrowse products. While the Admin interface is for entering data, django-queries is intended for searching the entered in

Re: Django Sphinx Foreign key search

2010-05-20 Thread David De La Harpe Golden
On 13/04/10 09:04, urukay wrote: Hi, I'm trying to create full text search on model, everything goes fine when searching TextFields but I have a problem with ForeignKey field. How can i do that? Can anyone point me to the right direction? Do you mean you want the results for Model2 searches

Re: How create M2M through with out PK?

2010-05-19 Thread David De La Harpe Golden
On 19/05/10 10:42, Daniel Roseman wrote: How remove PK from table "libs_content_has_people" and don't use it? You can't. Why would you want to? Well, the natural primary key for a M2M table is quite typically composite and django's ORM just doesn't support composite primary keys right now

Re: usage of TIME_ZONE and zone-to-zone conversion

2010-04-28 Thread David De La Harpe Golden
Thanks for the tip on pytz. It might be what I need. See django-timezones, django-related helpers around pytz: http://github.com/brosner/django-timezones its LocalizedDateTimeField model/form fields construct non-naive python datetimes with pytz tzinfo. (see its tests.py for some additio

Re: Why doesn't my isinstance() work?

2010-04-23 Thread David De La Harpe Golden
On 22/04/10 04:34, Lachlan Musicman wrote: I presume this will make you all wince, but while appreciating the discussion I've caused I've solved it thusly: views.py def index(request): all_authors = Author.objects.all() all_origAuthors = [] all_translators = Transl

Re: Using external dbs... is django 1.2 the best solution?

2010-04-21 Thread David De La Harpe Golden
On 21/04/10 11:21, Massimiliano della Rovere wrote: I am developing a web site that has some of its models in a private database (the one specified in settings.py, populated by the admin interface) but, it has to fetch and filter (etc) data from 2 different databases So what is you opinion, sh

Re: How do you rollback a transaction outside the context of a request?

2010-04-15 Thread David De La Harpe Golden
On 14/04/10 23:15, Bill Freeman wrote: The trouble is, I don't know how. Just calling django.db.transaction.rollback() doesn't work, and neither do several other guesses. N.B. Despite eventually signalling a TransactionManagementError if django doesn't "think" it's in a transaction-managed

Re: how to achieve the break tag in django template

2010-04-12 Thread David De La Harpe Golden
On 09/04/10 12:42, CCC wrote: now i have a finished template which wrote by j2ee,like this: Your template stuff (FreeMarker I think?), well, it is not Django. And Now i want to changeit,write by django,anyone know how to achieve the "<#break>" in this tenplate thanks! Well, you can't (IIRC

Re: Why is django returning only naive datetimes?

2010-04-12 Thread David De La Harpe Golden
On 09/04/10 19:05, Paweł Roman wrote: I've noticed that django always fetches 'naive' datetimes from the database. Tzinfo property on a datetime object is always set to null, even if the database stores a value WITH a timezone. This is a bit tedious because such datetime cannot be later converte

Re: CSRF error while working through tutorial part 4

2010-04-08 Thread David De La Harpe Golden
On 07/04/10 18:59, Gang Fu wrote: Following the instruction, my settings.py has Invalid block tag: 'csrf_token' You're likely looking at the development version of the tutorial but using a released version of django. csrf_token is new, and not used with django 1.1.1. contrast: http://docs

Re: Let Django form render field's with custom attributes (e.g CSS)?

2010-03-26 Thread David De La Harpe Golden
On 26/03/10 13:18, Thierry wrote: Hi, I want to differentiate CSS style of fields from the style of RadioSelects elements (as rendered through RadioFieldRenderer). Immediate action: I could create my RadioFieldRenderer/RadioInput classes to display inner labels as. Any direction you could

Re: Multiple host-based settings file

2010-03-16 Thread David De La Harpe Golden
On 16/03/10 14:27, Gustavo Narea wrote: Hello, Even if there was a reliable way to reuse the same code base with different settings on a per request basis, which I doubt, I believe the safest and easiest way to extend a base configuration with twod.wsgi: http://packages.python.org/twod.wsgi/manu

Re: How execute erlang code ?

2010-03-12 Thread David De La Harpe Golden
On 12/03/10 03:02, nameless wrote: Hi at all. I need to create a blogging system with Django+Apache+Postgresql and a twitter-like app with Erlang+Yaws+Mnesia. How can I execute erlang code through django views ? Well, one option I would seriously consider would be coupling through a message

Re: Form initial data is not dynamic

2010-03-05 Thread David De La Harpe Golden
On 05/03/10 01:30, NaMaK wrote: class DateTest(forms.Form): ... in_date=forms.DateTimeField(initial=datetime.datetime.now()) ... Well, note that the now() was executed when python first saw it, which was just a bit after it first saw the class definition. Think about it - it does make se

Re: building a form with multiple filters

2010-03-04 Thread David De La Harpe Golden
On 03/03/10 22:10, Nick wrote: I am trying to build a search form with multiple filters/input objects. Basically, i want to be able to allow for a simple searhc based on one criteria or multiple. So if someone searches the name field(q) they can filter by political party, or city, etc. Also, I w

Re: Restricting Access to Uploaded Files

2010-03-04 Thread David De La Harpe Golden
On 03/03/10 23:35, Merrick wrote: I wanted to give users who are authenticated the ability to upload files, that's the easy part that I can handle. What I cannot figure out is how to restrict the viewing/downloading of files. Links, tips, code are appreciated. This is become quite the FAQ...

Re: session key

2010-02-26 Thread David De La Harpe Golden
On 26/02/10 16:50, Sumanth wrote: Hi , I was trying to access the session key using request.session object in django. To do this we can use request.session._session_key or request.session.session_key out of this which is the right one to use ? The latter, without the leading underscore. This

Re: debugging server code problems in server code that is invoked via ajax request

2010-02-25 Thread David De La Harpe Golden
Possibly useful tip: Note that if you use request.is_ajax() in your django views, you can also use e.g. the "Modify Headers" firefox plugin to simply pretend to django that an ordinary request you've e.g. typed into your browser address bar is an "ajax" request, with a rule e.g. Action Nam

Re: Best practices for restricting media?

2010-02-22 Thread David De La Harpe Golden
On 22/02/10 16:48, Brice Leroy wrote: Hello Brett, If you use nginx you can use the X-Accel-Redirect function. Minor: if you _don't_ use nginx but rather apache or lighttpd, similar feature is called "X-Sendfile". -- You received this message because you are subscribed to the Google Groups "Dj

Re: one form, many submits

2010-02-20 Thread David De La Harpe Golden
On Sat, Feb 20, 2010 at 06:42:11AM -0800, Tom wrote: > Hi all, > > I have a view that iterates over a queryset to produce a list of > items. I have added a checkbox next to each item (from within the > template) and have multiple 'submit' buttons that will do different > things with the items sel

Re: Database relations concepts

2010-02-19 Thread David De La Harpe Golden
On 19/02/10 08:32, Le Quoc Viet wrote: Hi Tim, Thanks for reply. I mean if I want Samurai to be out of all rooms? ForeignKey disallows Null. minor point - ForeignKey(null=True, blank=True) will merrily allow null if your database allows nullable foreign keys at all (chances are it does). It

Re: Best way to access 'request' in pre_save

2010-02-18 Thread David De La Harpe Golden
On 18/02/10 15:55, Paul Stone wrote: I'm trying to find the best way to update a model using data from the request object (e.g request.user) before it is saved. One use case for this is updating an 'updated_by' field on a model. I've come across http://www.djangosnippets.org/sn/ippets/476 which

Re: Multiple user types

2010-02-18 Thread David De La Harpe Golden
On 18/02/10 08:31, Sander wrote: Can you explain yourself a little bit more about the other one to one fields? Well, django has a "OneToOneField" field type, that is like ForeignKey" only assumes the two models are, well, one to one. And thus, the generated reverse relation accessor returns

Re: Multiple user types

2010-02-17 Thread David De La Harpe Golden
On 17/02/10 08:53, bruno desthuilliers wrote: user.get_profile().student.student_number or user.get_profile().teacher.gender - but it works. I'm becoming pretty vague on what advantage the userprofile mechanism offers over other one to one fields to User. Is it just a convention at this stag

Re: Custom commands called outside project path

2010-02-10 Thread David De La Harpe Golden
(I'm not sure about that "root" in creecode's version. Editing crontab with crontab -e on a linux box has no user specification because it edits the crontab of the invoking user. Perhaps it's different for a directly edited root crontab.) The system-wide /etc/crontab is different to individu

Re: Date-based generic views - UTC handling

2010-02-08 Thread David De La Harpe Golden
On 07/02/10 18:28, Wayne Dyck wrote: Is there an easy way to format this date_field to my local time zone i.e. PST? I have also tried using the "date" and "time" filters within the template itself, however, those are still UTC. Any pointers would be appreciated. Well, django-timezones has a

Re: Unicode/ASCII problems

2010-02-04 Thread David De La Harpe Golden
On 04/02/10 14:46, bruno desthuilliers wrote: On Feb 4, 9:18 am, Nohinder wrote: Hello, i ran into this problem too, the solution was to specify the page coding from the very begining: " # -*- coding: latin-1 -*-" This is for .py files, not templates. well, just to note, a similar declara

Re: django and ldap

2010-02-04 Thread David De La Harpe Golden
On 04/02/10 08:33, andreas schmid wrote: @brad: can you show me some sample code for this? @david: i tried different configuration options but with no luck, i can bind and search manually over python-ldap so i can definitely connect. There are logging calls liberally sprinkled through the sou

Re: django and ldap

2010-02-03 Thread David De La Harpe Golden
On 03/02/10 14:45, andreas schmid wrote: AUTH_LDAP_BIND_DN = "" AUTH_LDAP_BIND_PASSWORD = "" AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)") You're using uid here, but # Set up the basic group parameters. #

Re: django and ldap

2010-02-03 Thread David De La Harpe Golden
On 03/02/10 13:41, andreas schmid wrote: hi, i need to authenticate users through ldap but i need also to store their preferences in the database, i cant really understand if django-auth-ldap (http://packages.python.org/django-auth-ldap) only authenticats the users over ldap or if it creates a r

Re: Static files in development and deployment

2010-02-01 Thread David De La Harpe Golden
On 01/02/10 14:48, Eugene Wee wrote: This works very well for admin media, uploaded files, and static files referenced from within templates (as I pass MEDIA_URL to the templates), Just in case: note 'django.core.context_processors.media' exists to do that for you. but for static files refe

Re: Admin calendar popups on datefield suddenly missing

2010-01-22 Thread David De La Harpe Golden
Walt wrote: > Okay, we're getting somewhere. It can find the JS file(s) just fine The static files maybe. > and I see that the calendars are added dynamically. However, I'm > have found that it is generating a javascript error when the page > loads: > > Error: gettext is not defined Now, I'm wo

Re: problem with multiple database with django 1.1.1 please help

2010-01-19 Thread David De La Harpe Golden
chiranjeevi.muttoju wrote: > Hi friends, > > i am working with django1.1.1, now i want to connect django with > multiple database, could you people please help me how to achieve > this. Django 1.1.1 /does not support/ multiple databases. You therefore cannot expect much in the way of help with 1

  1   2   >