Using data migration to create initial users errors

2014-10-14 Thread BenW
I am trying to create initial users in Django 1.7 via a simple data migration like so: # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.conf import settings from django.contrib.auth import get_user_model from django.db import models, migrations def populate_initial_d

Re: Middleware stored locally

2009-10-14 Thread BenW
I think every dir on the import path needs and __init__.py On Oct 14, 5:10 pm, When ideas fail wrote: > If i have a lib folder in my app what is the correct way to reference > it in settings.py? > > I've tried this > > MIDDLEWARE_CLASSES = ( >     'myapp.lib.django_authopenid.middleware.OpenIDMi

Django-ModelStore: Turn your Django models into Dojo data stores

2009-10-12 Thread BenW
I've been working on a reusable app to easily serialize my Django models into JSON data that can be used in Dojo data stores. The result is a set of classes that allow you to define a Store nearly the same as you define a Model or a Form. It also includes a JSON-RPC v1.1 service method dispatche

Re: Securing files held by FileField.

2009-08-13 Thread BenW
If you want to prevent hotlinking to your documents or illicit access, then I would suggest writing a view that generates a unique URL per access. For instance, a user hits your view, they get a randomly generated link to access the file. You store that random link in their session as a one-to-o

Re: Custom model field and Django-admin -- error

2009-08-10 Thread BenW
Excellent that it was reported, but bad that it's not considered a 'bug' -- Any suggestions on how to use date_hierarchy (and probably others) with my field? On Aug 10, 8:04 am, Alex Gaynor wrote: > On Mon, Aug 10, 2009 at 8:45 AM, BenW wrote: > > > Hello, >

Custom model field and Django-admin -- error

2009-08-10 Thread BenW
Hello, I'm working with a legacy database that stores datetimes as unsigned ints. Rather than do the conversion with properties on the model I've written a custom Field 'UnixDateTimeField': class UnixDateTimeField(models.DateTimeField): __metaclass__ = models.SubfieldBase def get_inte

Managed attributes with 'filter()' and 'exclude()'

2009-08-08 Thread BenW
Hello, I am working with a legacy database that stores IP addresses as 32bit packed integers. Is there a way I can use 'managed' attributes with filter() and exclude() etc? Please see example below: Thanks! class Host(models.Model): id = models.AutoField(primary_key=True, db_column='id')

Re: Ajax with JSON-RPC -- new Django handler

2009-07-10 Thread BenW
I fixed the above problem with URL reversing by refactoring the JSONRPCService.__call__ method to grab it from the request object. def __call__(self, request, extra=None): if request.method == "POST": return HttpResponse(self.process(request), mimetype="ap

Re: Ajax with JSON-RPC -- new Django handler

2009-07-09 Thread BenW
Sorry for digging up this thread but I fell off the list a bit and just checked back today. I really like the Pyjamas jsonprc implementation. In fact, I like it so much I've gone ahead and modified a few things to do the SMD generation and service URL resolution. However, I have a problem with

Re: One to Many+foreign key Query: best way to build the optimal result

2009-06-18 Thread BenW
I'm not sure I completely understand the problem, but I'll give it a stab: events = Event.objects.filter(start__gte=datetime.today()) locations = Location.objects.filter(location__in=events) results = [ {'start': loc.location.start, 'title': loc.location.title, 'id': loc.location.id, 'state_i

Re: Using Django authentication for web pages outside Django?

2009-06-05 Thread BenW
I did something similar while migrating an old app to Django. Since auth was the first step for me in the migration, I set up the users and session data in a table accessible by both apps and used Django for auth while I migrated the rest. This method requires sharing a secret between three enti

Re: Ajax with JSON-RPC -- new Django handler

2009-06-04 Thread BenW
;m not sure how to make it cleaner. Suggestions are welcome! Thanks, Ben On Jun 4, 7:47 am, BenW wrote: > Ahh yes, I had not considered calling them from Python since in my use > case they are treated more like an extension into the browser than > anything else.  I will definitely r

Re: Ajax with JSON-RPC -- new Django handler

2009-06-04 Thread BenW
the input! Ben On Jun 4, 12:02 am, Artem Egorkine wrote: > On Wed, Jun 3, 2009 at 9:18 PM, BenW wrote: > > > Sorry about the example having bad syntax (doh!) -- I will get that > > fixed.  I chose the public__ prefix because it makes it easier to > > introspect the suppl

Re: Ajax with JSON-RPC -- new Django handler

2009-06-03 Thread BenW
; On Wed, Jun 3, 2009 at 12:14 PM, BenW wrote: > > > I just posted a JSON-RPC handler I've been working with on the wiki: > > >http://code.djangoproject.com/wiki/Jsonrpc > > > I'd be interested in feedback from anyone doing async javascript with > > Django

Ajax with JSON-RPC -- new Django handler

2009-06-03 Thread BenW
I just posted a JSON-RPC handler I've been working with on the wiki: http://code.djangoproject.com/wiki/Jsonrpc I'd be interested in feedback from anyone doing async javascript with Django over RPC. Thanks! Ben --~--~-~--~~~---~--~~ You received this message be

Re: TypeError at admin: unpack non-sequence

2008-12-13 Thread benw
I have the exact same problem with Django 1.0.2 Final on Debian Etch (Apache 2.2.3-4+etch6 / mod_python 3.2.10-4) -- My settings.py, vhost and urls.py are nearly exactly the same as above (the relelant parts anyway.) On Dec 12, 3:00 am, Bluemilkshake wrote: > Of course. > urls.py below: > > Unde