Re: Localizing database textarea fields using gettext chokes on \r\n.

2010-01-22 Thread Doug Van Horn
to open a ticket for this? Maybe bring this up in Django Developers? doug. On Jan 22, 10:50 am, Doug Van Horn <dougvanh...@gmail.com> wrote: > I'm trying to avoid changing my database around to accommodate > localized strings.  I'm putting all strings from the database into a &g

Localizing database textarea fields using gettext chokes on \r\n.

2010-01-22 Thread Doug Van Horn
I'm trying to avoid changing my database around to accommodate localized strings. I'm putting all strings from the database into a holding file (db_messages.py) which get dumped into my django.po file. The problem is that textarea fields contain "\r\n" as line endings, and running something

Re: django monitoring page

2008-11-14 Thread Doug Van Horn
Is the username/password prompt from Django or Apache Auth? If it's Django, change the view to accept username/password params on the query string (removing decorators and/or changing middleware to allow access to that url). e.g., http://example.com/some/url/?username=foo=bar If it's Apache

Re: Figuring out prefork v. worker

2008-10-17 Thread Doug Van Horn
On Oct 16, 5:31 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Oct 17, 7:14 am, Doug Van Horn <[EMAIL PROTECTED]> wrote: > What is the mod_wsgi configuration you are using and how many > processes/threads are you using for Apache child processes and > mod_wsgi dae

Re: Query to display ManyToOne Bi-Directional associations?

2008-10-16 Thread Doug Van Horn
I think you'd rather use the default serialization behavior and write the Choice and Poll objects, letting the Choice objects contain the FK back to the Poll. However, if you write your own serializer you'd want to look for *class* attributes of type

Figuring out prefork v. worker

2008-10-16 Thread Doug Van Horn
I run several applications on a Slicehost VPS and I recently switched them to run the worker MPM and mod_wsgi. After switching, I ran into an issue with the worker MPM leaking timezone information across django applications (actually the timezone leaks under both mod_python and mod_wsgi/embedded

Re: Is it bad to use GET parameters for model entities management in my views?

2008-06-19 Thread Doug Van Horn
I would say first that there's more than one way to skin this cat. So if what you're doing works for your team and your users, stick with it. Regarding RESTful URLs, my understanding is that the URL is the noun and the request method is the verb. E.g., http://example.com/somepage/ is your

Re: One choice field depending on another choice field in new forms?

2008-04-30 Thread Doug Van Horn
It looks like you have it there in your snippet, you just need to define your 'selected_a' var. Maybe something like: if 'a1' in kwargs: selected_a = kwargs['a1'] Then set your b1 choices based on the group and optional a attribute. On Apr 30, 4:58 pm, ydjango <[EMAIL PROTECTED]>

Re: "data" is a reserved field in newforms?

2008-04-30 Thread Doug Van Horn
See http://www.djangoproject.com/documentation/newforms/#accessing-clean-data, check the 'Note' section. This was a problem in the old newforms where you couldn't have a field called 'data' due to the clean_ functions clashing with the clean_data dictionary. Also see:

Re: Session/Varibale and HttpResponseRedirect help please

2008-04-29 Thread Doug Van Horn
before you push the variable into the template, to see if it's making it through the redirect. If it is, then the issue is with your template, if it's not then the issue is with the session. Doug Van Horn http://maydigital.com/ On Apr 29, 12:04 am, Brandon Taylor <[EMAIL PROTECTED]>

Re: Images and Stylesheets

2008-04-15 Thread Doug Van Horn
Your previous description sounds pretty close. Check your URLs in your HTML (mentioned by Karen Tracey in this thread). As a quick reference, here are the relevant entries in my settings.py: import os ROOT_DIR = os.path.normpath(os.path.dirname(__file__)) MEDIA_ROOT = os.path.join(ROOT_DIR,

Re: Images and Stylesheets

2008-04-11 Thread Doug Van Horn
/ to serve up your static content via Apache, the above urls.py entry will work fine under Apache. It's more a matter of you /should/ (see the static_files link, they give a better explanation...). Hope this helps. -- Doug Van Horn http://maydigital.com/ On Apr 11, 9:19 pm, "Greg Lin

Re: alternative to (r'^house/edit/(\d+)/$',ediHouse)?

2008-04-11 Thread Doug Van Horn
FWIW, I don't see a security issue with exposing a surrogate primary key to the public... If you're hung up on the issue, though, take Tom's advice and use a slug for each house as an unique key. You might find the street address of a house to be a good slug candidate... On Apr 11, 6:28 pm,

Re: Article Count

2008-04-04 Thread Doug Van Horn
I've done something similar for an e-commerce store. We maintiain the number of times the product is viewed via search results as well as the individual product page, as two separate numbers. I update the fields in the managing views, e.g.: product.page_view += 1 product.save() or for p in

Re: business logic and good practices

2008-04-04 Thread Doug Van Horn
ollow my model 1, because it's generic code and it could be > reusable. > > What about a good practices reference guide... Any suggestion? > > On Apr 3, 4:54 pm, Doug Van Horn <[EMAIL PROTECTED]> wrote: > > > On Apr 3, 9:19 am, bcurtu <[EMAIL PROTECTED]> wrote:

Re: business logic and good practices

2008-04-03 Thread Doug Van Horn
On Apr 3, 9:19 am, bcurtu <[EMAIL PROTECTED]> wrote: > Hi again, > > I come form j2ee world, this is my first project in Django and usually > I feel a bit lost about general concepts. > > My project has bit too much business code, it's a kind of datamining > tool. I have created a set of

*Occasional* PostgreSQL Error

2008-01-24 Thread Doug Van Horn
I recieve the following error very *occasionally* from a couple of different django apps running against Postgres (some backtrace included for context): File "/opt/django/trunk/django/db/models/query.py", line 188, in iterator cursor = connection.cursor() File

Re: How do you serialize a newform.errors dictionary?

2008-01-11 Thread Doug Van Horn
nd my original problem getting the errors serialized to json, here's what I did: errors = {} for field in form: errors[field.auto_id] = {'errors': [unicode(e) for e in field.errors]} simplejson.dumps(errors) Doug Van Horn www.maydigital.com --~--~-~--~~~---~--

Re: "Between" bug when using SQLite?

2007-12-05 Thread Doug Van Horn
On Dec 5, 8:29 pm, Doug Van Horn <[EMAIL PROTECTED]> wrote: > On Dec 5, 5:31 pm, Doug Van Horn <[EMAIL PROTECTED]> wrote: > [snip snip snip] I opened: http://code.djangoproject.com/ticket/6141 and added some patches. Hopefully it'll get looked at a

Re: "Between" bug when using SQLite?

2007-12-05 Thread Doug Van Horn
On Dec 5, 5:31 pm, Doug Van Horn <[EMAIL PROTECTED]> wrote: > I'm running into a funny issue when testing with SQLite3 (Python 2.5). > > I have a model with the following (simplified): > > class Event(models.Model): > event_title = models.CharField() > event_f

Re: How do you manage your django sources?

2007-10-17 Thread Doug Van Horn
On Oct 17, 1:06 pm, stv <[EMAIL PROTECTED]> wrote: > really? I'm researching Django for a potentially large project, I was > thinking of having a layout like this: > > mainproject > |--core # models reused everywhere: Person, Address, etc > |--apply # models only for application: Questions,

Re: How to convert 92.5698 to 92.57

2007-10-17 Thread Doug Van Horn
On Oct 17, 9:44 am, Greg <[EMAIL PROTECTED]> wrote: > Doug, > Thanks for the reply. It's weird, because in my admin when I show the > amount in my list_display (list_display = ('b_name', 'thirdtime', > 'amount', 'customer', 'id')). I see the two zeroes. However, when I > drill down on a

Re: How to convert 92.5698 to 92.57

2007-10-17 Thread Doug Van Horn
On Oct 16, 11:19 pm, Greg <[EMAIL PROTECTED]> wrote: > Michael, > Yea I'm already using stringformat in my template. However, in my > view code is where I create the order. When the order is added in the > view and I then look at it in the admin the price is displayed as 74.0 > instead of

Re: How do you manage your django sources?

2007-10-17 Thread Doug Van Horn
On Oct 17, 2:23 am, Manoj Govindan <[EMAIL PROTECTED]> wrote: > How many here follow the django axiom of 'one project, multiple apps'? > If you do, how do you control the sources? Do you map one project to > one source code repository or do individual apps get their own > repositories? I've

Re: Request data is lost between two views

2007-10-16 Thread Doug Van Horn
On Oct 16, 5:35 am, Divan Roulant <[EMAIL PROTECTED]> wrote: > Hello, > > I loose request data when I call a view with reverse from a previous > view. Here is what I do: [snip] > Is request data supposed to follow or is it normal to loose it? Is > there another way to preserve request data

Re: Better FileField

2007-10-16 Thread Doug Van Horn
On Oct 16, 7:06 am, "Fco. Javier Nievas" <[EMAIL PROTECTED]> wrote: > Could you give a link to that patch? > > Thanks I wrote a post about how I handled including a model ID in the path of an uploaded file: http://dougblog.com/articles/2007/oct/11/dynamic-upload/ I didn't address any other

Re: select choices

2007-10-16 Thread Doug Van Horn
On Oct 15, 3:11 pm, onno <[EMAIL PROTECTED]> wrote: > Arn't stings slower against integers? A datatype of varchar versus integer isn't what's going to slow you down. If you don't have an index on a column and you use that column in your predicate (i.e., where clause) you will end up doing a

Re: select choices

2007-10-15 Thread Doug Van Horn
On Oct 15, 1:51 pm, onno <[EMAIL PROTECTED]> wrote: > The most annoying thing about using: > > TYPE = (('1', 'foo'),('2', 'BAR')) > type = models.IntegerField(choices=TYPE) > > Is that you can't do this in your views when you need to select > something > > Foo.objects.filter(type='BAR') > > you

Re: Managing django projects

2007-10-15 Thread Doug Van Horn
On Oct 15, 10:01 am, Rytis Sileika <[EMAIL PROTECTED]> wrote: > Hi, > > I was just wondering, what are the best practices to setup/manage > django projects? [snip] > Thanks! > > Rytis To expand on Chris' answer, here's what I would recommend: Create your project in Subversion (or CVS, or what

Re: age in years calculation

2007-08-03 Thread Doug Van Horn
On Aug 3, 11:50 am, Doug Van Horn <[EMAIL PROTECTED]> wrote: > On Aug 3, 6:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]> > wrote: [snip] You see, you learn something new every day. Based on Nis Jørgensen's post above, here's a refined age function using the fancy tuple c

Re: age in years calculation

2007-08-03 Thread Doug Van Horn
On Aug 3, 6:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > Hey Everyone, > > does anyone have a good age in years calculation function for usage with > datetime.date that returns the age in nr of years of a person? > > We were using: > > def get_age(self): > now = datetime.today()

Re: understanding request.user

2007-08-01 Thread Doug Van Horn
If you take a look at the LazyUser object you will see that the User is only loaded when request.user is accessed. Hope that helps (and is accurate :-). Doug Van Horn www.maydigital.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

Re: Authentication for application with subdomains

2007-07-19 Thread Doug Van Horn
On Jul 19, 2:19 pm, David Marko <[EMAIL PROTECTED]> wrote: > I know this topis has been discussed already but I stiil havent find > solution. We would like to build up the application that will be used > by many customers. After registration the customer will access > application via its

Re: Stopping second form post if refresh is hit?

2007-07-05 Thread Doug Van Horn
: import uuid uuid.uuid4() That should give you less false positives in identifying duplicate form submissions. Doug Van Horn --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To po

Re: prettier html

2007-06-29 Thread Doug Van Horn
On Jun 29, 12:20 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: > for instance, how can I make this: > > {% ifequal day.day day.today %} class="today"{% endifequal %}> > > Not put the CR inside the ? Is that line broken by a line

Re: Django Template

2007-06-29 Thread Doug Van Horn
On Jun 29, 12:59 pm, dystopia <[EMAIL PROTECTED]> wrote: > [snip]... Would I > then have have to implement the functionality of this in every view by > calling an cartSummary method and pushing that out into the template? > Or is it better to somehow compile all this functionality into a >

Using a closure as a callback.

2007-06-29 Thread Doug Van Horn
I have a design approach I've been kicking around and thought the group might have some opinions on the subject. Here's the scenario. You're on a web page and you're filling in data for a new Widget to add to your inventory. In the middle of the form you see that you need to create a new Type

Re: Including [django-users] in subject line?

2007-06-10 Thread Doug Van Horn
You should install this plugin for Firefox. It'll help you with your myriad GMail accounts: https://addons.mozilla.org/en-US/firefox/addon/1320 Of course it may be that you only use IE, so you may need to join that project's mailing list and request them to rewrite it to support your browser

Re: Announcing Flutterbox

2007-06-04 Thread Doug Van Horn
Have you considered OpenID? I'm no expert but it might provide you with the authentication you're looking for, without having to collect passwords. doug. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

Re: how to select from a huge set of data?

2007-06-04 Thread Doug Van Horn
On Jun 4, 5:56 am, Ulf Dambacher <[EMAIL PROTECTED]> wrote: > Am Mittwoch, 2. Mai 2007 20:02 schrieb Ulf Dambacher:> Hi > > > I need some kind of widget which can narrow the select by using > > cateogries. But how can this be done in django? > > > Java? Sorry... > > > Ideas, Anyone ? > >

Re: Best Place To Start Learning Django/Python

2007-05-23 Thread Doug Van Horn
It's probably a little bit more advanced, and it's certainly not a tutorial, but the Python Challenge (http://www.pythonchallenge.com/) is a good way to get familiar with the language and its tools. I think I made it through 17 or so when I was first learning Python. doug.

Re: django vps hosting

2007-05-15 Thread Doug Van Horn
I use rimuhosting.com. I'm pretty sure they have a Data Center in London, so that might be the right up your alley. I'm in St. Louis, where Slicehost is located, but they have a ridiculous waiting list. So I can't even try them out. I've been happy with Rimu, though. doug. On May 15,

Re: Database design question

2007-04-25 Thread Doug Van Horn
On Apr 25, 3:16 pm, "Kai Kuehne" <[EMAIL PROTECTED]> wrote: > > I'm a bit confused on how do it 'right(tm)'. Is there a > rule or how would you do it? > You're asking about surrogate and natural keys: http://en.wikipedia.org/wiki/Surrogate_key http://en.wikipedia.org/wiki/Natural_key

Re: Need guidance on multiple domain site configuration.

2007-04-24 Thread Doug Van Horn
On Apr 24, 5:59 pm, Nick Tidey <[EMAIL PROTECTED]> wrote: > Thanks for the help Robin. I'm new to Python also, so wasn't too sure > about how to reuse the apps. > > I'll see if I can't use triggers to propagate the user information > between databases. Unless there's a better way? > You could

Re: Dumb URL question

2007-04-14 Thread Doug Van Horn
On Apr 14, 11:15 am, "Mike Hostetler" <[EMAIL PROTECTED]> wrote: > > Does anyone need more info? Because I'm stuck. > I'm not seeing the same problem. I set up a little example app with the following urls.py: urlpatterns = patterns('', (r'^admin/myapp/mymodel/',

Re: tuples into a select list

2007-03-23 Thread Doug Van Horn
food = forms.ChoiceField(choices=FOODS, label='Favorite Food') Then just render the form field like you normally would: {{ form.food }} Check it for syntax, but I'm pretty sure that will work. Hope that helps. Doug Van Horn http://www.maydi

Re: selecting site from hostname in URL

2007-02-28 Thread Doug Van Horn
you're looking for, though. Maybe someone else will post something more helpful. :-) Doug Van Horn http://www.maydigital.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post

Re: Different subdomain for each application

2007-01-31 Thread Doug Van Horn
On Jan 31, 4:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > How would you go about using seperate subdomains for certain apps in a > project? What I would like to do is something like this: > > urlpatterns = patterns('', > (r'^weblog\.[a-z0-9-]+\.[a-z0-9-]{3}', >

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Doug Van Horn
update the 'last_request' variable to now." Please apply a liberal amount of sodium chloride to this as I haven't done this in the past and I certainly haven't coded and tested it. But, from the psuedo-code above, it reads correct, I think. :-) Doug Van Horn http://

Re: Help with Last Seen (why doesn't this work???)

2007-01-30 Thread Doug Van Horn
there is no 'last_request' (and thus no last_seen), and you should be good. Hope that helps. And remember the advice listed by an earlier post-er. Design your algorithm on paper. Think it through. Write some psuedo code. Run some mental 'unit tests'. Then go code it. Regards, Doug Van H

Re: Project organization and decoupling

2007-01-16 Thread Doug Van Horn
David Abrahams wrote: ...One problem is that the name of the Django project folder (and thus root module) always seems to creep into the code in the app-specific directories. IANADE (django-expert), but from what I've gleaned you can put the path of each individual application into the python

HttpResponseRedirect Weirdness

2006-12-27 Thread Doug Van Horn
I could do to shed some light on the problem. Thanks for your help... Doug Van Horn --~--~-~--~~~---~--~~ 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

Re: HttpResponseRedirect Weirdness

2006-12-27 Thread Doug Van Horn
Nevermind. I found Ticket #3089 [http://code.djangoproject.com/ticket/3089] after a little Google-ing. I'll be interested in seeing what that one is all about. Meanwhile, I'll continue to repeat to myself: "Google is my friend." Thanks.

Projects in Postgres

2006-12-11 Thread Doug Van Horn
chemas. I interpret that to mean that having multiple databases in a cluster does not cost much... Remember, if you have an opinion you'd like to share, I'm interested in reading it! Thanks! Doug Van Horn May Digital Solutions http://www.maydigital.com/ [i

Re: manipulating images

2006-06-21 Thread Doug Van Horn
I'm no expert either, but this seems to work for me: fp = StringIO() myImage.save(fp, 'jpeg') # or whatever format self.save_thumbnail_file(myName, fp.getvalue()) Nice thread. I was just fixin' to get to this for my demo app. Thanks! doug.

Backing HTML 'Compnents'

2006-06-06 Thread Doug Van Horn
I'm not sure if this has been discussed. My searches yielded no fruit. I have page components that are common across many of my pages. Here are a few of them: == A user specific menu, cached in the session. == A shopping cart, cached in the session. == A list of recently visited items,

Q behavior with filter() and exclude()

2006-05-26 Thread Doug Van Horn
I posted this here to: http://www.djangoproject.com/documentation/db_api/ It seems that when you pass a Q() object into .filter() or .exclude(), you end up with the same results. That is, the context of the method, filter or exclude, is ignored when it receives a Q object. For example: In

Re: SQL Unions with QuerySets?

2006-05-26 Thread Doug Van Horn
Thanks! I ended up seeing that after my original post. I knew I was missing something. Unfortunately that behavior does exactly what you would expect, one query, yielding mixed results. In other words, if I search for 'zo' my results would be ordered ['Bozo', 'Zorro']. I'd like for the

Re: SQL Unions with QuerySets?

2006-05-26 Thread Doug Van Horn
I wish I could edit my post. I see that & and | do work. I posted to early. I think you can pretty much disregard my post. I'm probably going to have to get clever in joining up my data for 'relevence'. Sorry for the disturbance. I'll be sure to google better next time.

SQL Unions with QuerySets?

2006-05-26 Thread Doug Van Horn
I thought I'd post this as I'm not seeing anything obvious in the documentation (that is to say, I cannot /find/ anything, not that it /isn't/ there in an obvious place). I'm making a particular object searchable from my customer UI. I will have a field titled: 'Quick Search' which will search

Re: Post data for multi step form

2006-05-19 Thread Doug Van Horn
For what it's worth, I have a similar concept in storing the contents of a shopping cart. I created a 'ShoppingCart' object which can hold items and their quantities, plus it adds some convenience methods like getting the list of items, the total cost, etc. I store this object in the user's

Re: Overthinking urls.py?

2006-03-30 Thread Doug Van Horn
> I hate to say it, but Routes and most of the other schemes presented > _do_ feel over-engineered. The current URL patterns system is fast > and clean. I actually agree 100%. And my earlier post indeed smacks of overengineering. And in my current smallish project I don't intend to do any of

Re: Overthinking urls.py?

2006-03-30 Thread Doug Van Horn
I'm going to type out loud for a little bit. I'm hoping to better define the problem so we can think about solutions more clearly (or go find ones as solved by other frameworks). Django has the concept of an application, a reusable chunk of functionality which can be reused in many different

Re: Overthinking urls.py?

2006-03-28 Thread Doug Van Horn
A sed won't work in all situations as it relies on the fact that you constuct the URL in a particular way. What if the URL is constructed dynamically in a template? Or in code? Not to mention the fact that it breaks application encapsulation. If I have ten integrated apps deployed a syntax

Overthinking urls.py?

2006-03-27 Thread Doug Van Horn
Disclaimer: I'm new to Python and Django, but I've been coding Java since '98. In thinking about the url definitions in urls.py, it occurs to me that a major rewrite of the url patterns could prove to be a pain. For example, I have an app where the urls are deployed under /foo/, and I have a

Re: Eclipse based Django IDE???

2006-03-16 Thread Doug Van Horn
For the record, I'm using IDE rather loosely. I'm certainly not looking for a VB-esque tool. At one point I was slinging Java in Emacs with JDE. Now I find Eclipse extremely useful. It pretty much stays out of the way. I get me editors with autocomplete, Ant deploys, and external run targets