Re: DB Router not working on production machine, works on dev.

2014-06-03 Thread Doug Ballance
The problem turned out to be an bug with an custom manager class based on djorm_pgfulltext search mixin. I'd found an issue with it last week, and patched in the development environment but forgotten to patch the other machine. -- You received this message because you are subscribed to the

DB Router not working on production machine, works on dev.

2014-06-03 Thread Doug Ballance
I've got a weird one I just can't figure out. I'd love some help while I'm still sane. On my development machine all is well. On the other machine the database router seems to be getting the parent class (which is an abstract model in another app). I determined this with some print

Re: Do I need an API?

2014-02-04 Thread Doug Ballance
I'm not clear on your question. I can't tell if you are wanting to allow them to edit the site layout (templates) or content that happens to contain html? Either way, you might look into using the Ace javascript based code editor http://ace.c9.io/ If you are talking about letting them modify

Re: Honest feedback

2014-01-30 Thread Doug Ballance
There have been small, well thought out changes over the last 4 years but fundamentally most still remains pretty much the same. I have several installs running an patched old .96 version, as well as newer stuff with later versions. It all feels about the same to work with. I recently

Re: Need Direction for Web App

2013-12-25 Thread Doug Ballance
I was waiting on Christmas dinner, and had an hour to kill so I threw together a quick, incomplete skeleton app. Maybe it can be of use to get you started on the django side. It relies on the django-macaddress package, but is otherwise standalone. It's very basic - the less there is of

Re: Hosting multiple sites on a single application

2013-09-18 Thread Doug Ballance
I can't recommend either of those solutions specifically, but I have been using an approach similar to that of django-multisite running on a threaded fastcgi instance since django .96 days and it has worked well for us. My main concern would be with third-party apps that set static data

Re: Is Celery the best option?

2013-07-19 Thread Doug Ballance
Celery is a good option, and probably the most used. There are a couple of other options that may be worth looking into: Huey https://github.com/coleifer/huey Rq http://python-rq.org/ Personally I've never gotten on well with celery. It's just not at all intuitive to me (it's heavy use of

Re: Big Picture?

2013-07-16 Thread Doug Ballance
A suggestion: Make the return arrow from views more clearly indicate that return path goes through the middleware (since it passes through once as a request, and back through the middleware in reverse with the response) and back through the webserver layers. I'm probably asking for a lot, but

Re: django search query

2013-07-01 Thread Doug Ballance
On Saturday, June 29, 2013 11:32:19 PM UTC-5, Harjot Mann wrote: > > Is there any search query in django which can ignore vowels like I want to > make a query which displays all the clients name who writes their name as > 'amanjit' or 'amanjeet'. > It should take take ee=i or anything like

Re: django doesnt accept the serializeArray POST data

2012-10-22 Thread Doug Ballance
I'm guessing it is a result of not having a csrf token set for the post: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Variable # of fields in a form

2012-07-25 Thread Doug Ballance
It seems to me that two fields might be the simple solution? class SomeForm(Form): internal = forms.ModelMultipleChoiceField( , widget=forms.CheckboxSelectMultiple) externa = forms.ModelMultipleChoiceField( , widget=forms.CheckboxSelectMultiple) Then

Re: Understanding Django for PHP developer

2012-06-03 Thread Doug Ballance
I should have looked a little harder, I found the blog post. It is about a much older version of Django. Some of the references to django internals are surely a bit different now, but the fundamentals are the same. It really helped me when I first started. I'd love to see it updated for the

Re: Understanding Django for PHP developer

2012-06-03 Thread Doug Ballance
http://www.twistedcommons.com/2008/12/how-django-works.html There was a blog post several years ago that followed, in detail, the life of a response with all the gory details. Unfortunately I can't locate the link. The above page is brief, but has a nice picture that is easy to follow. A huge

Re: Scaling django installation

2012-05-31 Thread Doug Ballance
I don't think anyone will be able to give you a good evaluation without knowing more about the requests. Django itself could probably handle 10k requests per second returning a simple "hello world" response, or less than 10 if you are returning very large/difficult to generate responses. It is

Re: PythonScript(Zope) like in a django app, any tips?

2012-04-15 Thread Doug Ballance
You might also try a different scripting language, for example Lua. I've a python module "lupa" bookmarked for a project on my todo list that requires user scripting. It appears you can have a relatively sandboxed access to python objects. I'm hoping that with some careful compiling of the

Re: Much the same code, different businesses

2012-03-26 Thread Doug Ballance
There are a few choices that I'm familiar with. 1) Create a separate project/settings file for each of your stores, overriding templates as needed by placing assigning a template path for the project. I think this is pretty much the recommended way to do things, especially if the number of sites

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread Doug Ballance
> Doug, I don't see how the LazyFetch you wrote is much different than > what akaariai shared? Can you explain to me what the difference is? > And I'm not saying that in a condescending way, I'm saying I'm just > not sharp enough on my Python to recognize the difference. Slightly different

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Doug Ballance
I made an error when I changed a variable name just before posting. Replace "self._age" with "self._last_updated". -- 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

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Doug Ballance
A method similar to what Anssi describes is what we use for local caching of data that is too large to comfortably fetch from cache/ parse from file every time we need it. A Doing a lazy fetch with a maximum age like that also helps with load times since it is only fetched when accessed. Of

Re: rendering CSV in response; need a little help

2011-12-09 Thread Doug Ballance
If you have a dataset that is too large to fit in memory comfortably, the ability to pass a generator to an httpresponse means you can break it up into multiple smaller queries (outside the template system anyway): def queryset_to_csv(queryset,delimiter=',',steps=500): """ generator for large

Re: custom attributes of model field

2011-12-07 Thread Doug Ballance
Just to clarify that last bit about a mapping on the model since it's closest to what you originally described. Just pseudo-code, but you can see the idea. class Model1(models.Model): FIELD_DISPLAY={ 'foo': ['a'], 'bar': ['b','c'] } a = models.CharField() b =

Re: custom attributes of model field

2011-12-07 Thread Doug Ballance
I may not be clear on what you are trying to accomplish, but maybe something like class Form1(forms.ModelForm): class Meta: model=Model def type_one_fields(self): return [self.fields['a']] # Or use whatever criteria you want for type_one fields. def

Re: How to make a query form depend on a field?

2011-09-26 Thread Doug Ballance
There are also a few third-party apps that can assist you with the form->query process such as this one: https://github.com/alex/django-filter -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: When is a good time to use db_index? Rule of thumb?

2011-09-16 Thread Doug Ballance
Another clarification: It tells django to create an index on that field when you run syncdb to create the tables for your apps. Adding it to an existing model won't change anything by itself. If you decide a field needs an index you can add it to the model definition, and then you can use the

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-07 Thread Doug Ballance
I would agree with Donald, and expand on that to say that an installer would probably be best written in php for widest compatibility. A php based installer would run outof the box on most webservers, and be able to give a guided overview of the python/web environment setup. It would easily be

Re: Security implications of using the form.fields dictionary directly

2011-09-03 Thread Doug Ballance
The most elegant way I've seen specialized form rendering handled was the use of template tags and filters. The django uni-form project is a good example. By using the filter and template tags you gain full access to all the form elements, and can do easy manipulation in python, but leave the

Re: Argh: templates, admin, and app loading order

2011-08-30 Thread Doug Ballance
Can you use the filesystem loader as the first template loader, then set TEMPLATE_DIRS in settings.py to specify a template directory outside any app? Use this location for all of your overrides, just make sure the path is right... ie each app you override would have its own subdirectory. --

Re: find_template Django 1.3

2011-08-25 Thread Doug Ballance
I haven't moved to 1.3 yet, but we do a few things with the template source too so this is definitely of interest. It looks like most of the template loaders define a load_template_source method implementation that does return the source, except for the cached loader. As a work around you could

Re: Work in memory instead of BD, how to?

2011-08-18 Thread Doug Ballance
You probably don't want to cache changes. Or if you do, it would be better done elsewhere (like a caching raid controller/w battery on your database machine). The usual cache patterns I've seen are: 1) Fetch from database 2) Store in cache with a reasonable timeout to that changes are reflected

Re: How to store variable timedeltas in a Django model?

2011-08-14 Thread Doug Ballance
Depending on the resolution and maximum duration, you could just use an integerfield containing either the number of seconds or minutes, and then recreate it. That way you can also base queries off of the value, which you can't do with just a pickle field. Of you could subclass the integerfield

Re: How do I apply a filter in a custom template tag?

2011-08-13 Thread Doug Ballance
I'd like to see you model structure, but based on what I think it is: class Entry(model.Model): categories=models.ManyToManyField(Category) class Content(models.Model): entry=models.ForeignKey(Entry) You have a Content Instance You want to see other entries belonging to one or more of

Re: Django for a front end designer

2011-08-05 Thread Doug Ballance
I don't think it's necessarily a choice between learning php or learning python. Most programming languages are fairly similar in concept, and once you've mastered one it's reasonably easy to pick up a new one. Python is a great language, but I think it's especially great as a first language.

Re: Most stable Linux distribution for Django - Python development

2011-08-01 Thread Doug Ballance
I'll second the use of something like LXC (new to me) or OpenVZ (what we use), allowing you to run/test multiple distros at once. If you want to try debian (or pretty much any linux distro), download a container skeleton for it and install in a few seconds. I've used virtualbox/kvm, but I found

Re: Doesn't render templates any longer

2011-07-27 Thread Doug Ballance
def main(request): context=Context()     this_is_the_template_object = loader.get_template("main/ start.html") this_is_the_template_rendered=this_is_the_template_object.render(context)     return HttpResponse(this_is_the_template_rendered) What you are feeding HttpResponse is the

Re: Implementing a User Search Feature

2011-07-02 Thread Doug Ballance
**filters is python for expand the dict 'filters' into keyword arguments. ie filters={'foo':1} model.objects.filter(**filters) is the same as model.objects.filter(foo=1) The filters variable is just temporary dictionary for building the keyword arguments from the form data, electing to omit any

Re: Implementing a User Search Feature

2011-06-30 Thread Doug Ballance
If you just want a simple user search (which seems to be what you are asking for), it really depends on your models - but a basic approach I usually use is to define a django form to use for the search, and instead of defining a save method, make a method that returns a queryset. As an off the top

Re: How to implement multi-tenant, single DB, single site?

2011-06-04 Thread Doug Ballance
For our setup we created a separate user,site framework since we do a form of vhosting that serves multiple sites from one instance. We have a Site model that serves as the root tying all of our other models together. No abstract models or anything fancy, just a FK in each model class pointing

Re: Our new startup site build on Django and GAE is now live!

2011-06-03 Thread Doug Ballance
I actually authorized, but got a little creeped out by being asked for three cities in which I'd lived before being able to continue. I entered one, but it still wouldn't let me pass without another two. I couldn't conceived of ANY legitimate reason to need anything more than my current location

Re: Is there an HTML editor that's Django-aware

2011-05-27 Thread Doug Ballance
Everyone has different requirements, but I'm one of those strange people who don't care about having a powerful editor. I don't want completion, or auto-anything. Just something that gets out of my way and lets me work. If something complex needs to be done on occasion, that's what the shell

Re: How to reduce DB queries?

2011-02-27 Thread Doug Ballance
Could you do a ManyToMany relationship through an intermediary model, and then query the intermediary using select related? -- 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

Re: compiled regex as attribute

2011-02-11 Thread Doug Ballance
Have you done any performance testing? From what I understand pythons re.compile caches internally, so after the first call subsequent calls will use the pre-compiled expression. Serializing the compiled expression using pickle isn't 'free', so I'm wondering how much difference there is in

Re: django-ttag -- an easier way to write template tags

2011-01-13 Thread Doug Ballance
Thank you! I've been wishing something like this was a part of Django since trying to write my first tag. I've been using something in house that provides similar functionality for a couple of years and couldn't live without it. Your implementation is much more complete (validation) and I'm

Re: Django's documention is horrible

2011-01-11 Thread Doug Ballance
The reason I chose django in the first place was the documentation. Compared to everything out there, it was incredible. Back then it also had a helpful comments section on each page where people chimed in to clarify various parts of the document. It reads like a text book, which is a big help

Re: Confused about thread locals... again.

2010-12-16 Thread Doug Ballance
@ringemip Thanks for the reply. I've been considering something like that, but given the number of views and tags involved, it would be a very long process. Especially since I used a new context instance in most of my custom tags that render another template, rather the pushing, rendering,

Confused about thread locals... again.

2010-12-15 Thread Doug Ballance
First, I'd like to find out if there is a better way than thread locals to do what I want to do. From what I can tell, it isn't possible any other way. Finally, I don't understand why my thread locals implementation/hack works - which scares me, so I would like to ask the wiser gurus out there