Re: Switching settings, in a non-webapp?

2015-05-11 Thread Doug Blank
ckpoint.py import sys class ModulesCheckpoint(object): def __init__(self): self.original = sys.modules.copy() def reset(self): # clear modules: for key in list(sys.modules.keys()): del(sys.modules[key]) # load previous: for key in self.origin

Re: Switching settings, in a non-webapp?

2015-05-11 Thread Doug Blank
thon is involved. I need to reset the Django initialization in a Python session. -Doug > > David > > > Am 11.05.2015 um 18:17 schrieb Doug Blank: > > Django users, > > We are using Django for two purposes: its ORM for a single-user desktop > app, and for a regular D

Switching settings, in a non-webapp?

2015-05-11 Thread Doug Blank
Django users, We are using Django for two purposes: its ORM for a single-user desktop app, and for a regular Django webapp. For the desktop ORM, is there a way to switch between different settings.py? For example, we'd like to be able to load the default settings, but then later unload

Re: Need some advise on how to use a RESTful API

2013-12-20 Thread Doug Blank
On Fri, Dec 20, 2013 at 11:45 AM, Mario Osorio wrote: > I need to work on a django app that will eventually benefit from a RESTful > API so it can be used from any web browser as well a from apps writtens for > iOS and Android. > > Being so new to django development I don't

Re: Trying to run jobs in the background using multiprocessing

2013-11-27 Thread Doug Blank
On Wed, Nov 27, 2013 at 2:58 PM, Pau Creixell wrote: > Hi there! > > I am trying to run jobs in the background using the following (minimal) > code: > > Under views.py: > > def submit(request): >model = MyModel() >model.RunInAThread(ReferenceSeparator,

Re: Error in Brand New Django 1.4.1 released Yesterday

2012-08-01 Thread Doug Blank
On Tue, Jul 31, 2012 at 3:15 AM, JJ Zolper wrote: > Hello all, > > I didn't realize a new release was put out until something weird happened. > > I'm installing DJ on my production server now and when I was downloading a > copy from https://www.djangoproject.com/download/

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 <mi...@dewhirst.com.au> wrote: > On 16/08/2010 10:22pm, Doug Blank wrote: >> >> On Mon, Aug 16, 2010 at 7:23 AM, Mark Mooij<markmo...@gmail.com>  wrote: >>> >>> Allright I tried a couple of things with your

Re: Create files and directories from Django 1.2.1

2010-08-16 Thread Doug Blank
ot;mkdir() takes exactly 1 argument > (2 given)"), but again outside Django this works just fine.. Ok, that is very suspicious. It sounds like there is another os module that you are somehow getting, rather than the Python system one. Perhaps have a look at os.__file__ to see if that is the correc

Re: Create files and directories from Django 1.2.1

2010-08-16 Thread Doug Blank
On Mon, Aug 16, 2010 at 7:23 AM, Mark Mooij wrote: > Allright I tried a couple of things with your suggested appraoch: > > - I printed all the strings used to define paths and files, this all > seems correct. > > - The os.mkdir() command is passed without raising an error,

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

2010-01-28 Thread Doug Blank
On Thu, Jan 28, 2010 at 3:53 PM, Saravanan wrote: > I have Django installed in SUSE Linux with postgres. It is working > great. Kudos > I have an issue. I have total database structure containing more than > 100million rows. I have partitions and indexes. It is

Re: search db & if sequences

2010-01-24 Thread Doug Blank
On Sun, Jan 24, 2010 at 1:05 PM, mehdi0016 wrote: > hi > i'm new with python and django and i work on search page of my site. > in my html search form, user can choose table(or field) which want to > search. in server-side i use sequences of 'if' to find chosen table(or >

Re: Foreign Key Across Database in Django multidb

2009-12-31 Thread Doug Blank
On Wed, Dec 30, 2009 at 11:54 PM, malik wrote: > I heard that that multi DB support is now available in Django.Can some > one tell me whether it is possible to have foreign Key across > Databases. > > Please see this thread:

Re: error in the example

2009-12-30 Thread Doug Blank
On Wed, Dec 30, 2009 at 6:24 PM, gintare wrote: > Hello, > > In short > OS Debian Gnu Linux Lenny > Python 2.5 > Installed Django-1.1.1.tar.gz, > /usr/lib/python-django/Django-1.1.1/docs/intro/tutorial01.txt > > command python manage.py sql polls > gives

Re: get_absolute_url not recognized

2009-12-23 Thread Doug Blank
On Tue, Dec 22, 2009 at 2:21 PM, neridaj wrote: > I'm trying to add a get_absolute_url method to a Tweet model from > django-syncr and do not understand why the method is not recognized. > > class Tweet(models.Model): >    pub_time    = models.DateTimeField() >    twitter_id  =

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

2009-12-23 Thread Doug Blank
On Wed, Dec 23, 2009 at 11:15 AM, TiNo wrote: > On Wed, Dec 23, 2009 at 16:53, Bill Freeman wrote: >> >> Are you sure that Lid is defined in this context?  Try putting: >> >> import pdb;pdb.set_trace() >> >> before the super and check. > > As I described, I

Re: Custom Django-Admin commands

2009-12-21 Thread Doug Blank
On Mon, Dec 21, 2009 at 8:10 PM, Justin Steward wrote: > Hi all, > > I've written a custom command to use with manage.py, and from the root > of the project directory, it works great. > > But the problem is, this command is almost never going to be called > from within the

Re: Using Forms to display and edit?

2009-12-15 Thread Doug Blank
the template. That way, I'll have all of the elements there (errors, display information) for all of the modes (display, edit, and add). I'll see how far I can go with this method before having to resort to a more substantial widget-swap. It does seem that this is an area of Django that co

Using Forms to display and edit?

2009-12-15 Thread Doug Blank
Django users, I'm wrestling with how to best create HTML pages that can either be used for displaying or editing data. That is, I'd like the field's values to appear as text in display mode, but in their widgets when in edit/add mode. It appears that Django wasn't designed to do this: the fields

Re: import twice when run test

2009-12-09 Thread Doug Blank
On Thu, Nov 26, 2009 at 6:01 AM, Tom Evans wrote: > On Thu, Nov 26, 2009 at 2:35 AM, fallhunter wrote: >> >> i have this code in my tests.py: >> >> from models import * >> >> and in the models.py I have a signal handler and register it with >> >>

Re: delete every record in a table?

2009-12-04 Thread Doug Blank
On Fri, Dec 4, 2009 at 3:44 PM, Daniel Roseman wrote: > On Dec 4, 8:37 pm, Phlip wrote: >> Django users: >> >> I only ask the question to help improve my esthetics, but others might >> need a performance boost here. >> >> How to delete every record in

Re: Model inheritance - filtering base model only

2009-11-23 Thread Doug Blank
On Mon, Nov 23, 2009 at 9:09 AM, lfrodrigues wrote: > I guess this solution works but for +50 the performance should be > terrible... > > Shouldn't django have some option for this? Could you set a field's value which is true for one, and false for the other?

Re: form fields slicing

2009-11-23 Thread Doug Blank
On Mon, Nov 23, 2009 at 7:16 AM, gentlestone wrote: > why this piece of code doesn't work? > > {% for field in form|slice:":2" %} > > the result is iterating over all fields, not just the first two fields Perhaps break this up into two parts? {% with form|slice:":2" as

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 <doug.bl...@gmail.com> 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)

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 <kmtra...@gmail.com> wrote: > On Fri, Nov 20, 2009 at 6:19 PM, Doug Blank <doug.bl...@gmail.com> wrote: >> >> Some additional data: >> >> I'm using Django 1.1 on Fedora11 with sqlite backend. I get the same >&

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 <doug.bl...@gmail.com> 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 except

MemoryError when adding a lot of data

2009-11-20 Thread Doug Blank
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 (most recent call last): ... event = models.Event.objects.get(handle=ref) File

Re: Automatic swapping of field data?

2009-11-19 Thread Doug Blank
y django code and never 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 <doug.bl...@gmail.com> wrote: &g

Automatic swapping of field data?

2009-11-18 Thread Doug Blank
Django users, I have data that needs to be handled in two different manners, depending on if the user has certain permissions or not. For example, if a record is marked "private" and a user is not permitted, I want to substitute the word "PROTECTED" for a particular field's value. Now, of course

Re: Using variables as keywords in QuerySet

2009-10-21 Thread Doug Blank
On Wed, Oct 21, 2009 at 5:12 AM, Arthur Metasov wrote: > > 2009/10/21 valler <180...@gmail.com>: >> >> Hello. I want to know, if something like that possible: >>  MyModel.objects.filter(name__contains='foo',status__exact='bar') => >> It's OK. >> >> But I want to use dynamic

Re: settings.configure vs DJANGO_SETTINGS_MODULE

2009-10-14 Thread Doug Blank
On Tue, Oct 13, 2009 at 10:06 PM, Doug Blank <doug.bl...@gmail.com> 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=Tru

settings.configure vs DJANGO_SETTINGS_MODULE

2009-10-13 Thread Doug Blank
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 mysettings.py originally just contained those in the default settings.py file. However, I keep

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 > ... > >

Re: Dates with varying specificity?

2009-08-23 Thread Doug Blank
On Sat, Aug 22, 2009 at 12:24 PM, ringemup wrote: > > Has anyone here ever written an application that needed to be able to > take a date field where the month or day was sometimes but not always > known? How would you handle this? Using separate day/month/year > fields

Re: db api

2009-08-21 Thread Doug Blank
On Fri, Aug 21, 2009 at 4:22 AM, luca72 wrote: > > I have solved using : > Model.object.filter(id=2)values('columnname') > Note that it should have a dot: Model.object.filter(id=2).values('columnname') and that returns the item you want in a list. The proper way to do

Re: Bulk data insert

2009-08-20 Thread Doug Blank
I do not want to rewrite 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: Bulk data insert

2009-08-20 Thread Doug Blank
On Aug 20, 2:50 pm, Alex Gaynor wrote: > On Thu, Aug 20, 2009 at 1:46 PM, Abiel wrote: > > > Is there an efficient way to use Django models to load a large number > > of records into a database without falling back on raw SQL? Creating a > > large number

Concurrent Web Access and Edits

2009-08-11 Thread Doug Blank
New Django user here with a question about the client side: Is there built-in support for dealing with concurrent edits? I'm not referring to the database issues (locking, etc) but is there Django support for handling a request to access or edit data for which another user is editing? I'm