How do I model optional Parent/Child relationships, e.g. not all Tasks are related to a Project?

2009-03-06 Thread Doug
f a Task for the Project field? Here are my models: http://dpaste.com/8321/ Many thanks, Doug --~--~-~--~~~---~--~~ 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

Can I set user=request.user automatically when using create_object Generic View?

2009-03-08 Thread Doug
r = models.ForeignKey(User, editable=False) name = models.CharField(max_length=100) due = models.DateTimeField(blank=True, null=True) # urls.py task_dict = {'model': Task, 'login_required': True} urlpatterns = patterns('', url(r'^create/$', create

Oracle connection "cx_Oracle.DatabaseError: ORA-00911: invalid character"

2009-05-17 Thread Doug
ER = 'django'; DATABASE_PW = 'django'; DATABASE_NAME = 'XE'; >>> conn_str = "%s/%...@%s" % (USER, DATABASE_PW, DATABASE_NAME) >>> conn_str 'django/dja...@xe' >>> myDB = cx_Oracle.connect(conn_str) >>> myDB Can s

Re: Oracle connection "cx_Oracle.DatabaseError: ORA-00911: invalid character"

2009-05-18 Thread Doug
Thanks for your response Karen. And I am so new into Django that there is no real harm is re-installing v1, and trying again. However, I believe that I am experiencing the problem with V1. I'll let you know what I find. Doug On May 17, 4:58 pm, Karen Tracey wrote: > On Sun, May 17,

limiting the scope of a ForeignKey relation to within a model?

2009-09-20 Thread Doug
#x27;lead_image') Is there any way to set up this relationship so that the lead_image choices are limited to only those in the "images" manytomany association of the current instance of Project? Thanks for any advice you have. Doug --~--~-~--~~~

Re: Help customizing the admin functionality

2009-09-21 Thread Doug
://code.google.com/p/django-photologue/ Good luck! Doug On Sep 21, 7:58 am, gustavo wrote: > Hello friends! > > I am changing from php to python. > I am building a website to a photographer and I would like to build > the following functionality: I would like to upload a zip file and >

Re: Possible to create models programatically?

2010-07-20 Thread Doug
I have a similar issue, with a bunch of very similar apps that I need in separate tables that all have the same base structure. I keep the common models in a file called models_base.py and then use execfile in the models.py file for each app. It's basically like a php or c include in that in 'ins

Re: Synching samba users to django users?

2010-09-21 Thread Doug
You could create a secondary python script running as root that polls a queue or config file generated by your django app. Have that script perform the requested actions by running the same executables as a sub process and checking the exit codes. If you need immediate responses, it could run lik

Re: dictionary doesn't get properly updated

2010-10-07 Thread Doug
Could it be that garbage collection is deleting your "tm" instance when it falls out of scope at the end of the view call? If that is the only place you've instantiated it, I'm guessing the reference count would go to zero 'singleton' or not. -- You received this message because you are subscrib

Re: trying to get a cache per request

2010-10-09 Thread Doug
Why not just stick it on the request object? def myview(request): request.mycache=MyCacheClass() then it's available everywhere the request object is. If you are wanting something that can be used in a template tag without explicitly passing the request object (or your cache object) in, you

Re: trying to get a cache per request

2010-10-09 Thread Doug
Look around for python docs on threading.local, which lets you set a 'global' variable for just that thread. Since a request is only going to happen in a single thread, that lets you have a per-request global that can be used for cache storage. With middleware to set the threading local instance

Re: my first (public) app: django-requires_js_css

2010-10-24 Thread Doug
I'm also interested in something like this. I've tried it a couple of different ways, but have not been all the happy with the results/ implementation. It seemed like post-parsing for tokens was trouble since it hurt performance somewhat, and gets ugly if you are serving the occasional big file o

Re: I have an idea for a new tag

2010-11-19 Thread Doug
An easy alternative is to make a sort filter: register.filter('sort',lambda x: sorted(x)) and then do {% for k,v in mydict.items|sort %} {{k}}:{{v}} {% endfor %} I had to look at the docs to realize there isn't a sort filter in django for some reason. I long ago added the one above to built

alternative to model inheritance?

2007-09-03 Thread Doug
go and Python, I was hoping to get some advice on what the alternative methods of handling this situation are. Thanks for your help. Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" gro

Re: alternative to model inheritance?

2007-09-03 Thread Doug
ch as the client, discipline, etc.), as Django, IIRC, > isn't yet capable of doing what you've described below. > > -- > Stefan Rimaila > "A few bolts loose and a set of switches broken" > Blog, personal portfolio & fun stuff:http://www.studionyami.com

mod_python help needed

2006-10-13 Thread doug
server with settings is here-> http://oviparo.us Thanks-Doug --~--~-~--~~~---~--~~ 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: mod_python help needed

2006-10-13 Thread doug
1-link above 'is' the test server/ 2-source is linked to svn code directly as described on djangoproject.com 3- 404 is django's see it here: http://oviparo.us/polls - Thanks Doug On Oct 13, 7:57 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2006-10

mod_python

2006-10-13 Thread doug
server with settings is here-> http://oviparo.us Thanks-Doug --~--~-~--~~~---~--~~ 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.c

Re: mod_python

2006-10-13 Thread doug
test server is running at http://oviparo.us with configs listed- Doug On Oct 13, 12:23 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > http://oviparo.us/redirects tohttp://oviparo.us/ > > please post here your VirtualHost config. also, 1st thing to make sure, &g

template error

2006-10-16 Thread doug
Hey- Why am I getting this error if the template file exists? # Template-loader postmortem Django tried loading these templates, in this order: * Using loader django.template.loaders.filesystem.load_template_source: o /home/doug/templates/blog/entry_archive.html

Re: template error

2006-10-16 Thread doug
oh-yea! sudo chmod -R 755 /path-to-templates Thanks- Doug On Oct 16, 10:14 am, Michael Radziej <[EMAIL PROTECTED]> wrote: > doug schrieb: > > > > > Hey- > > > Why am I getting this error if the template file exists? > > > # > &g

Re: mod_python help needed

2006-10-16 Thread doug
mystery solved -kinda- the flatpages url must be LAST in the list of urls to try- not sure why- but that fixed it. Doug thanks- Doug On Oct 15, 12:15 am, "moberley" <[EMAIL PROTECTED]> wrote: > doug wrote: > > I am setting up mod_python on test server and havin

Re: FastCgi / PostgreSQL: FATAL: Ident authentication failed for user "user_name"

2006-10-20 Thread doug
looks like same issure here: http://groups-beta.google.com/group/django-users/browse_thread/thread/19ed1f82b5c80233/897f968eba507165?lnk=gst&q=authentication+failed+for+user&rnum=2#897f968eba507165 Doug On Oct 19, 8:49 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On W

Re: Compiling mod_python 3.2.x on Ubuntu

2006-10-20 Thread doug
just finished setting up djanog-sandbox with ubuntu/ it is here: http://oviparo.us Doug On Oct 20, 1:08 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm trying to compile version 3.2 of mod_python (required by django) on > an Ubuntu Linux box. (Ubuntu off

Best practices for 1.5 configurable user model and profiles

2013-02-22 Thread Doug
I am curious how people are handling the new 1.5 user model with regard to User Profiles. Is it best to add all profile information to a custom user model? Or keep the user model for authentication information only and create a one-to-on or foreign key to a profile model (similar to the pre-1.5

Re: Best practices for 1.5 configurable user model and profiles

2013-02-27 Thread Doug
quot;? On Saturday, February 23, 2013 11:15:20 PM UTC-5, Russell Keith-Magee wrote: > > Hi Doug, > > Obviously, it's still early days, so "best practice" hasn't really evolved > yet. However, based on what I've done with custom user models so far, my > a

Re: Best practices for 1.5 configurable user model and profiles

2013-02-27 Thread Doug
Thanks Shawn. So what is your take? Only authentication data in User? Separate Profile model and app? On Wednesday, February 27, 2013 12:07:55 PM UTC-5, Shawn Milochik wrote: > > Do a search on the history of the django-developers mailing list. > There are many reasons, and they were discussed

Re: Problem with translations

2013-09-05 Thread Doug
I've found some other people with the same issue. Looking at the source, the issue is directly related to IOError, so your assumption sounds correct, django

Re: Problem with translations

2013-09-05 Thread Doug
Follow-up: just for good measure could you tell me what you have in your settings for `LANGUAGE_CODE` and what languages you are trying to support? If by some small chance you are trying to support a language not apart of this set ,

Re: my models are remembering old fields that I have since deleted

2011-05-10 Thread Doug
Got it. I was assuming that snycdb was dropping the old tables for me. All of the crazy stuff that was happening seems to be explained. Thanks. On 5/7/2011 9:50 PM, George Silva wrote: Just drop the old tables and run syncdb again! Cheers On Sat, May 7, 2011 at 10:45 PM, Nick Arnett

Re: Error related to googlebot?

2014-01-24 Thread Doug
I am having this same exact problem. Did you ever find a resolution? Thanks. Doug On Monday, July 12, 2010 2:10:49 PM UTC-4, Tor Nordam wrote: > > I'm currently writing a blog framework in django, and I have it up an > running (on www.presskanne.com). During the last 20 hours or

Re: Error related to googlebot?

2014-01-25 Thread Doug
Thanks for the response. I'm not doing any user agent sniffing, and I don't have a robots.txt. On Monday, July 12, 2010 2:10:49 PM UTC-4, Tor Nordam wrote: > > I'm currently writing a blog framework in django, and I have it up an > running (on www.presskanne.com). During the last 20 hours or so

Re: Error related to googlebot?

2014-01-25 Thread Doug
Here's an example stack trace: Traceback (most recent call last): File "/home/possiblecity/.virtualenvs/prod/lib/python2. 7/site-packages/django/core/handlers/base.py", line 103, in get_response resolver_match = resolver.resolve(request.path_info) File "/home/possiblecity/.virtualenvs/pr

Re: Error related to googlebot?

2014-01-25 Thread Doug
Also, if I spoof the user agent (using a chrome plugin), I don't get the error. On Monday, July 12, 2010 2:10:49 PM UTC-4, Tor Nordam wrote: > > I'm currently writing a blog framework in django, and I have it up an > running (on www.presskanne.com). During the last 20 hours or so, I > have gott

Re: Turn off migrations completely in Django 1.7

2015-11-20 Thread doug
ce=footer [3] https://groups.google.com/d/optout Please forgive this simple question . How can I change the email address associated with this group ? I want to keep getting the emails but to a different address. Thanks doug -- You received this message because you are subscribed to the Google Groups &q

Re: Receiving emails via app

2008-10-26 Thread Doug B
poplib is pretty easy to work with: def check_pop3(server,user,password): import email,poplib,string messages=[] s=poplib.POP3(server) s.user(user) s.pass_(password) resp, items, octets = s.list() todelete=[] for item in items: id,size=item.split()

Re: Sending mass, yet personalised email newsletters using Django

2008-11-10 Thread Doug B
I can't claim best way, but the way we do it is to have a few django models for storing the messages, and some help from the email, and smptlib libraries. Models: Mailserver: model for storing connection information for connecting to a standard smtp server, with mixin class using smtplib to provi

Re: Different settings.py files for server and development

2008-11-11 Thread Doug Harris
One thing I've noticed is that some settings don't stick if I override them in local_settings.py. One key example is CACHE_BACKEND. Has anybody seen this sort of behavior? On Oct 23, 5:54 pm, felix <[EMAIL PROTECTED]> wrote: > at the very bottom of settings.py : > > from local_settings import *

Re: help, ORM memory problems

2008-11-23 Thread Doug B
One thing that has bitten me more times than I care to remember is forgetting to disable DEBUG in settings.py before processing large datasets. The SQL queries build up in connection.queries until the process dies. I ended up patching my django install to store queries in a wrapper around buffer

Re: I don't even know where to begin writing this template-tags

2009-01-21 Thread Doug B
I went the hideous route, but tried to make it general enough I could reuse. I'm still on .96, but it shouldn't be too much trouble to make it work with 1.0. In [2]: template.Template("{% load kwtag %}{% do_kwtagtest foo foo=bar %}").render(template.Context()) Out[2]: "['foo']{'foo': 'bar'}" In

Re: Dynamic routing

2009-07-13 Thread Doug B
It's not very efficient, but it's possible. I just finished up an app where dynamic urls was an unfortunate requirement, but simple to implement. A view is just a function within which can call another view, so it's easily possible to have a catchall view that captures the url (using the normal

Concurrent Web Access and Edits

2009-08-11 Thread Doug Blank
um. Thanks for any pointers! -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, se

Re: Render template tags together

2009-08-16 Thread Doug B
I don't know if it's the best approach or not, but what I've done in the past is to have the first call to the tag do any expensive stuff and store it in a dict under a special name in the context (I usually use __tagname). Subsequent calls to the tag use the data from the context variable rather

Re: Bulk data insert

2009-08-20 Thread Doug Blank
s to do saves in bulk in the first pass? Thanks for any pointers! -Doug > Alex > > -- > "I disapprove of what you say, but I will defend to the death your > right to say it." -- Voltaire > "The people's good is the highest law.&quo

Re: Bulk data insert

2009-08-20 Thread Doug Blank
ewrite what I have as raw SQL, I am just looking for anything that I can do, such as turn off indexing, write to the db in batches, or similar django-level optimizations. I don't think what you mentioned can help in this situation, right? -Doug > > - Benjamin > > > > >

Re: db api

2009-08-21 Thread Doug Blank
st. The proper way to do that is: Model.object.get(id=2).columnname where get returns an object, and all of the columnnames are just attributes of it. -Doug > > Thanks > > Luca > > On 21 Ago, 10:14, luca72 wrote: > > Thanks for your reply but i get this error: > > Model object has

Re: Dates with varying specificity?

2009-08-23 Thread Doug Blank
any of the date model coded yet, so this is just an FYI. -Doug > > Thanks! > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to dj

Re: Skinning a project with pre-designed DIV?

2009-03-30 Thread Doug B
Django is pretty flexible, so it's impossible to say exactly how to integrate with your existing design since the original developer could have done the template layout in a number of different ways. Since the development process is a bit different that php, you might want to step through the tut

Re: how to django to request a page of the other domain

2009-04-01 Thread Doug B
It might be better to use the rewrite/proxy capability of your webserver rather than try to proxy using django. If you do end up trying to do it in python, I found pycurl to be much easier to deal with for any requests requiring cookies, authentication, or anything besides a simple url get despit

Re: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread Doug B
Take a look at this part of the documentation: http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: Template Variables as Indexes

2009-04-24 Thread Doug B
Might not be the easiest way, but you could use a custom filter: def formsbyfield(forms,field): """ Given a list of similar forms, and a field name, return a list of formfields, one from each form. """ return [form.fields.get(field,'') for form in forms] register.filter('forms

Re: how to handle database down time gracefully?

2009-04-24 Thread Doug B
This has been on my todo list of a while now, so I thought I'd trying to figure it out. I -think- the proper way to go about this would be in a custom middleware with a process_exception handler that checks to see if the exception is an instanace of the database defined exceptions. Looking in dj

Re: Disabling PRG Pattern

2009-04-26 Thread Doug B
Maybe the APPEND_SLASH setting is causing it (along with a missing slash at the end of your url)? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-user

Re: Client requests Django capacities

2009-05-06 Thread Doug B
There is no way you can give an answer based on an application that doesn't exist, and a server that doesn't exist. What I would do is give them real numbers based on an application you -can- test. Build a tiny Django application that does something resonably representitive of what the real appl

Re: newbye question

2009-09-14 Thread Doug Blank
On Mon, Sep 14, 2009 at 7:17 AM, Nicola Manica wrote: > Hi, I'm a student that try to learn geodjango. > I have the following code in one view: > ... > for t_path in path.the_geom: > print t_path.json > print t_path.wkt > print t_path.kml > ... > > path.the_geom is a multilinestr

settings.configure vs DJANGO_SETTINGS_MODULE

2009-10-13 Thread Doug Blank
setting, and it isn't there. Everything works fine if I set the DJANGO_SETTINGS_MODULE env variable. I've read: http://docs.djangoproject.com/en/dev/ref/settings/ and the older version for 1.0, but they both suggest that what I'm doing is correct. I'

Re: settings.configure vs DJANGO_SETTINGS_MODULE

2009-10-14 Thread Doug Blank
On Tue, Oct 13, 2009 at 10:06 PM, Doug Blank wrote: > I'm trying to use django without resorting to setting the environment > variable, by doing this: > > from django.conf import settings > import mysettings > settings.configure(mysettings, DEBUG=True) > > The

Re: Using variables as keywords in QuerySet

2009-10-21 Thread Doug Blank
'name' > b='status' > keyword_arguments = {} > keyword_arguments[a+'__contains']='foo'; > keyword_arguments[b+'__exact']='bar'; > MyModel.objects.filter(**keyword_arguments) > Or, more concisely as: MyModel.objects.filter(**{a+

Automatic swapping of field data?

2009-11-18 Thread Doug Blank
entally slips out. Does Django have any built in support that does this, or could be adapted to do this? Any ideas appreciated! -Doug -- 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...@go

Re: Automatic swapping of field data?

2009-11-19 Thread Doug Blank
have to worry that the value of fieldname will ever accidentally not be protected as this is the only way to get it. See any problems with this (other than taking a small hit on every field access)? -Doug > On Nov 18, 4:17 pm, Doug Blank wrote: >> Django users, >> >> I have da

MemoryError when adding a lot of data

2009-11-20 Thread Doug Blank
t the chapter on cache from the book: http://www.djangobook.com/en/beta/chapter14/ but I'm not sure how this is related. Although, if there was a Python command to turn off caching while importing, that might be something to try. Any ideas appreciated, -Doug -- You received this message beca

Re: MemoryError when adding a lot of data

2009-11-20 Thread Doug Blank
On Fri, Nov 20, 2009 at 6:32 AM, Doug Blank wrote: > I'm filling my Django tables with data through a regular Python > program (not through the browser). After it runs for a few hours, I > get: > > 10557896: ERROR: gramps.py: line 121: Unhandled exception > Traceback

Re: MemoryError when adding a lot of data

2009-11-21 Thread Doug Blank
On Fri, Nov 20, 2009 at 10:22 PM, Karen Tracey wrote: > On Fri, Nov 20, 2009 at 6:19 PM, Doug Blank wrote: >> >> Some additional data: >> >> I'm using Django 1.1 on Fedora11 with sqlite backend. I get the same >> kind of spiking of memory usage if I ju

Re: MemoryError when adding a lot of data

2009-11-21 Thread Doug Blank
On Sat, Nov 21, 2009 at 7:44 AM, Doug Blank wrote: [snip] > It does seem that: > > Table.objects.all().delete() > > is "leaking" memory (eg, continues to use memory) and is very slow. > I'm trying to find a better (faster, less memory) method similar to > th

Re: form fields slicing

2009-11-23 Thread Doug Blank
quot;:2" as formslice %} (% for field in formslice %} -Doug > -- > > 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 th

Re: Model inheritance - filtering base model only

2009-11-23 Thread Doug Blank
e, could you just have two tables? I wonder if ContentType could help? obj_type = ContentType.objects.get_for_model(player) source_refs = PlayerM.filter(object_type=obj_type) (object_type gets created with generic relations) -Doug > On 23 Nov, 04:53, Preston Holmes wrote: &

Re: delete every record in a table?

2009-12-04 Thread Doug Blank
nt in statements: cursor.execute(statement) transaction.commit_unless_managed() I don't know of any bad side effects... -Doug > -- > DR. > > -- > > You received this message because you are subscribed to the Google Groups > "Django users"

Re: import twice when run test

2009-12-09 Thread Doug Blank
gt; >>> import mytest as yourtest >>> It may be loaded twice (or more) by different threads or by another import mechanism (which seems to be the case here): http://code.djangoproject.com/wiki/Signals See section on "Help, post_save seems to be emitted twice for each save!&

Using Forms to display and edit?

2009-12-15 Thread Doug Blank
me|render_field:mode }} where render_field would either return the field's HTML widget, or just the value as text, based on the mode. Have I missed something, or is this a viable solution? -Doug -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Using Forms to display and edit?

2009-12-15 Thread Doug Blank
> it at render time. > > Anyway, hope this helps and am curious if others use this same > mechanism or if there is some alternate preferred approach. > > Margie Thanks Margie for this example. I may come to something similar to this, but for the time being I think I'll just

Re: Custom Django-Admin commands

2009-12-21 Thread Doug Blank
e.py >       app/ >         management/ >           commands/ >             custom.py > > Is there something I'm missing? You probably just need to set your PYTHONPATH: cd /home/user PYTHONPATH=proj python proj/manage.py custom -Doug > > ~Justin > > -- > &

Re: super() argument 1 must be type, not None

2009-12-23 Thread Doug Blank
looking at this is that an import statement is atomic... no code will (should) run until all imports have completed, then the code runs. I would try importing just some parts, or maybe changing the import order. Just some ideas. Good luck! -Doug > -- > > You received this message because

Re: get_absolute_url not recognized

2009-12-23 Thread Doug Blank
                                                           'slug': > self.tweet.twitter_id }) > > >>>> from syncr.twitter.models import Tweet >>>> t = Tweet.objects.get(pk=1) >>>> t > >>>> t.url > > >>>> t.get_absolute_

Arbitrary Properties from code

2010-07-01 Thread Doug Warren
Let's say I have some models that look like: class Emotion(models.Model): mood = CharField(unique=True) class Person(models.Model): emotions = ManyToManyField(Emotion) name = CharField() angry = Emotion(mood='angry') angry.save() sad = Emotion(mood='sad') sad.save() bob = Person(nam

Debugging Django under wsgi and pydev

2010-07-04 Thread Doug Warren
;d take as being a first step towards it but not the actual solution. Thanks, -Doug -- 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 group, s

update least syntax?

2010-07-10 Thread Doug Warren
Can Django support an update by setting a field to the least of two args? I have a model that looks like: class Bar maxval = models.FloatField() rate = models.FloatField() class Foo(models.Model): bar = models.ForeignKey(Bar) current = models.FloatField() and i'd like to increas

Re: update least syntax?

2010-07-11 Thread Doug Warren
do. You've > already discovered F which is about as complicated as it gets, bt the > update syntax is pretty much limited to setting a field's value to a > consant. > > Looping over the minimum set of things and calling save on each one if > your only option without resorti

Queryset returning modelinstances of manytomany relationship?

2010-07-12 Thread Doug Warren
Say I have 2 classes as: class Bar(models.Model): prop = IntegerField() class Foo(models.Model): bar = ManyToManyField(Bar) I want to return a QuerySet containing model instances of bar that match the query: QuerySetOfFoos.objects.filter(bar__prop__gt=0) Is there an easy way to do this?

Re: Create files and directories from Django 1.2.1

2010-08-16 Thread Doug Blank
h = os.path.join(basepath, game_id) as different OS's have different path formats. Or perhaps it is the kml string that you are creating that has other issues (unicode?) I would print out the mkdirs string to see what you are creating. HTH, -Doug > Mark > > On 16 aug, 08:32, Mik

Re: Create files and directories from Django 1.2.1

2010-08-16 Thread Doug Blank
On Mon, Aug 16, 2010 at 9:49 AM, Mark Mooij wrote: > Hi Doug, > > Thanks for your reply. I tried your suggestion: > .. > import createKML > .. > def createKML(id, basepath=os.getcwd()): >   ... >   try: >        kmlpath = os.path.join(basepath, "templates")

Re: Create files and directories from Django 1.2.1

2010-08-21 Thread Doug Blank
On Mon, Aug 16, 2010 at 8:51 PM, Mike Dewhirst wrote: > On 16/08/2010 10:22pm, Doug Blank wrote: >> >> On Mon, Aug 16, 2010 at 7:23 AM, Mark Mooij  wrote: >>> >>> Allright I tried a couple of things with your suggested appraoch: >>> > >

Re: error in the example

2009-12-30 Thread Doug Blank
ce or two in front of the word "class". Spaces are meaningful in Python. -Doug > > --- > trying according example: > /usr/lib/python-django/Django-1.1.1/docs/intro/tutorial01.txt > &g

Re: Foreign Key Across Database in Django multidb

2009-12-31 Thread Doug Blank
e_thread/thread/74bcd1afdeb2f0?hl=en -Doug > -- > > 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 group, send email to

Re: search db & if sequences

2010-01-24 Thread Doug Blank
"Author": Author, "Book": Book,} if requst.GET['table'] in tables: matches = tables[requst.GET['table']].objects.filter(title__icontains=requst.GET['query']) You can make this more sophisticated and even allow them to select the fi

Re: Reg. Improving Django response time (i.e throughput)

2010-01-28 Thread Doug Blank
th Django, anything you are familiar with it? > The first thing you should look at is what queries are being run. You might be running too many queries, or it might be that you need to add some indexes to your database. Try looking at django-toolbar. The fact that you have 100 million rows s

Re: InternalError: current transaction is aborted, commands ignored until end of transaction block PROBLEM

2010-03-07 Thread Doug Whitesell
On Mar 7, 2:36 am, Alexis Selves wrote: > Hello, > When I try to use raw SQL commands to simple selects from db I get > this: > InternalError: current transaction is aborted, commands ignored until > end of transaction block If you make an error in an SQL statement, Postgres will refuse to do any

Re: newforms, form.save(), and getting the object I just saved

2007-06-28 Thread Doug B
If you are using the helper functions like form_for_model, form.save() should return the saved object. The helper functions build the save method for you based on the model definition. If you are doing custom forms, it's up to you to make the form.save() method to handle the form->model mappings

Re: Re-rendering same page

2007-06-28 Thread Doug B
Are you sure the request is actually being made, and not ignored by the browser? If you do GETs to the same url with the same parameters (your boolean I assume) the browser will simply ignore the request. I ran into that trying to do some ajax stuff, and ended up appending a timestamp number as

Re: How to use Admin modules in my application

2007-07-07 Thread Doug B
admin != user Atleast that's my view. As tempting as the pretty admin interface might be, I think you would be better off rolling your own form and view for end users. Then you have complete control. Using the form_for_* functions you could have the whole thing done in a few minutes. fetch us

Re: How to display all my post data

2007-07-22 Thread Doug B
Assuming you just want to debug and are using the dev server you can just do "print request.POST" and it will show up on the dev server console. The results aren't all that pretty, but usable. --~--~-~--~~~---~--~~ You received this message because you are subscr

Re: newforms: default Model values

2007-07-24 Thread Doug B
I don't know how others have approached it, but I have a 'settings' file with defaults defined in one place and reference those values via imports in the form file and model file. For values specific for the app, I stick them in the models file. models.py - POST_DEFAULTS = {'status':'pub

Re: using javascript to update a ChoicesField: getting "not one of the available choices."

2007-07-24 Thread Doug B
Don't use a ChoiceField, but do use the select widget. class TF(forms.Form): blah=forms.IntegerField(widget=forms.Select(choices=((1,'one'), (2,'two'))), initial = 2) post = {'blah': 42} form = TF(post) form should validate. It would be up to you to make sure that the Integer value is in

Re: DB-Lookup on dynamically created fieldname

2007-07-24 Thread Doug B
Maybe you could do something like this? filterargs = {} filterargs[fieldname] = some value # or for other types of filtering filterargs["%s__istartswith" % fieldname] = somevalue mdl.objects.filter(**filterargs) You might also want to take a look at the function get_model() from django.db.mode

Re: How to pick a template based on the request object?

2007-07-26 Thread Doug B
Using threadlocals and a custom template loader would probably work, just put your loader first in settings.py. http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: accessing request attributes in templatetags?

2007-07-26 Thread Doug B
Just pass them in as context variables, either the whole thing or just the parts you need. This is kind of a snippet from my current project that might show what I mean. I say kind of because I use a handler object that wraps request and a few other things instead of request directly, but the pr

Re: newforms: common constraints

2007-07-26 Thread Doug B
Garg, hit enter too fast. Class MyForm(forms.Form): username = forms.CharField(max_length=12) def clean_username(self): username = self.clean_data['username'] if username == 'bob': raise ValidationError("Bob is not allowed here") return username If so

Re: newforms: common constraints

2007-07-26 Thread Doug B
newforms does that, but it's up to you do take care of the details by either subclassing one of the existing fields like this snippet shows: http://www.djangosnippets.org/snippets/115/ Or by making a specially named method on the form definition like this: Class MyForm(forms.Form) username

Re: complex form => Newforms vs template

2007-07-27 Thread Doug B
> So my question is am I missing something or I was just expecting too > much from the newforms? I had similar problems initially, and after hundreds of forms built I still get annoyed every time I have to build a newforms form. On the other hand, I can't really think of a better way to do it ei

Re: POST variable bug?

2007-07-27 Thread Doug B
To get a list out of post you need to do: request.POST.getlist('fieldname') and not request.POST['fieldname'] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: caching and "hello username" on each page

2007-07-29 Thread Doug B
You could also make your own render_to_response() function that renders and caches the generic part of the page, and then passes that in as a context for your base layout with the non-cacheable stuff like the username. Or make some of the generic stuff tags that cache themselves using the lower l

  1   2   3   4   >