Re: Dynamic template loader with TemplateResponse

2011-05-29 Thread Brian Morton
(ContentView, self).render_to_response(context, **response_kwargs) On May 23, 3:01 pm, Brian Morton <rokclim...@gmail.com> wrote: > I have some legacy code that I used to dynamically load a template based on > url if it exists and render a 404 if it doesn't exist. > > def content(requ

Dynamic template loader with TemplateResponse

2011-05-23 Thread Brian Morton
I have some legacy code that I used to dynamically load a template based on url if it exists and render a 404 if it doesn't exist. def content(request, template_name='index'): try: return direct_to_template(request, '%s.html' % template_name) except TemplateDoesNotExist:

TemplateView and dynamic template_name in urlconf

2011-05-17 Thread Brian Morton
I have a generic view that accepts its template_name attribute from the urlconf dynamic variable: (r'^(?P[^/]+)$', TemplateView.as_view()), But I get an exception: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()' I've read the

Re: Interesting Django or Python Issue

2010-04-28 Thread Brian Morton
Can we see some code? The description of what you're doing sounds just fine, so that leaves open the possibility of a technical error. On Apr 28, 7:42 am, Sam Lai wrote: > Maybe database connections aren't closing properly? Don't know where > to start looking though. > > A

Re: Giving up PHP. ...Can't decide between Django & Rails

2010-04-12 Thread Brian Morton
This is a tough question for sure. If you prefer Ruby syntax, then to me it seems clear. If it feels clunky, it won't flow properly and you won't code as well. Then again, you point out that you built a finished product quickly and you're happy with it compared to what you built with Rails.

Re: inspectdb generates CharFields with 3x max_length

2009-10-09 Thread Brian Morton
and post here and in the ticket if I can figure anything out. On Oct 9, 2:18 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Fri, Oct 9, 2009 at 12:40 PM, Brian Morton <rokclim...@gmail.com> wrote: > > > This is a very strange problem, so I thought I would post here and se

inspectdb generates CharFields with 3x max_length

2009-10-09 Thread Brian Morton
This is a very strange problem, so I thought I would post here and see if anyone else had seen this problem. I introspected a MySQL database with Python2.6 using Django SVN HEAD and it produced my models as expected. However, all CharFields have the max_length set to 3x the actual varchar field

Poor performance on POSTs in production

2009-08-15 Thread Brian Morton
Very strange problem going on with one of my Django sites. This only happens in my production env using Debian stable, Apache 2.2.9 with mod_python and django trunk (updated). All GET requests execute in a timely manner. However, all POSTs take way too long. I've inserted debugging into my

Re: How to include session data in traceback

2009-04-30 Thread Brian Morton
D'oh. Thanks. I was confusing load and loads. I thought they were the same thing. On Apr 30, 12:55 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Thu, 2009-04-30 at 09:47 -0700, Brian Morton wrote: > > Thanks.  That makes perfect sense.  Since my session da

Re: How to include session data in traceback

2009-04-30 Thread Brian Morton
the pickle module accept a string as input and output the unpickled data? I know it does it with file objects via load, but I can't find any reference on how to do this with a string. On Apr 30, 12:43 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Thu, 2009-04-30 at 04:58 -07

How to include session data in traceback

2009-04-30 Thread Brian Morton
I am considering filing an enhancement request but I want to check first to make sure this functionality doesn't already exist. Is there some way to make Django include the contents of session in the traceback email received from a 500 error? It is very useful in the case of debugging an error

Re: Value proposition of Rails

2009-03-19 Thread Brian Morton
Given how expensive developer time is relative to current hardware costs (especially on the x86 server platforms), it is almost always more cost effective to throw hardware at the problem than it is to spend countless hours porting apps from one language or framework to another for performance

Cannot create model objects with file fields from shell

2009-03-03 Thread Brian Morton
I am having trouble getting this script to work. My intent is to load images into the db in bulk from the filesystem. http://pastebin.com/m40565da9 When I execute this, I get the following error: Traceback (most recent call last): File "load_images.py", line 16, in

Re: Media Root & Templates

2009-03-01 Thread Brian Morton
>From the traceback, it would appear that one or more of your processors is named or formed improperly. Can you post the code from your setting.py file where you specify your processors? Not just the strings, but the entire Python structure where you define those. On Mar 1, 7:51 am, AKK

Getting uploaded file content type in model save

2009-02-04 Thread Brian Morton
I am working with PIL to resize and thumbnail images during a model save method. I am using SimpleUploadedFile as a wrapper to facilitate the thumbnail field's save method. SimpleUploadedFile requires that the proper content type be passed in as an argument. The trouble is, I may be working

Marking form field label as safe?

2008-08-27 Thread Brian Morton
I am trying to do raw HTML output in a form field's label. I've tried using mark_safe on the string being passed as the label argument, but it is still escaped. Can anyone point me in the right direction please? --~--~-~--~~~---~--~~ You received this message

Re: Bug in ImageFieldFile.save() ?

2008-08-27 Thread Brian Morton
Thanks for the clarification. I will definitely look forward to having file-like objects work this way. I'll keep my eye out for the commit. On Aug 27, 7:23 am, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 12:37 AM, Brian Morton <[EMAIL PROTECTED

Bug in ImageFieldFile.save() ?

2008-08-26 Thread Brian Morton
The docs (and an analysis of the code) indicate that the second argument to save should be the content. http://docs.djangoproject.com/en/dev/ref/files/file/#ref-files-file I am assuming this is binary or text content to be written to the file in question. ImageFieldFile calls

Re: Tricky newforms problem

2008-04-11 Thread Brian Morton
for in cleaned_data. Ideally, I need to capture the song ids that were selected in some kind of iterable datatype, then loop through them and look them up in the model to get info for output. On Apr 11, 6:10 am, "Phil Davis" <[EMAIL PROTECTED]> wrote: > On 11/04/2008, Brian Morto

Tricky newforms problem

2008-04-10 Thread Brian Morton
I have run into an interesting problem with newforms. I am trying to create an arbitrary number of fields on a form based on model data. This works fine. class SonglistForm(forms.Form): def __init__(self, *args, **kwargs): super(SonglistForm, self).__init__(*args,

Re: Problem with encoding and feeds

2008-03-06 Thread Brian Morton
2019 is an right single quote in unicode. Perhaps that title is causing the problem? Did you paste it from some editor that would have created it as that character rather than an apostrophe? Maybe you should correct that by hand if it was pasted. On Mar 6, 7:37 pm, "[EMAIL PROTECTED]" <[EMAIL

Re: Performance of a django website

2007-12-11 Thread Brian Morton
http://www.djangoproject.com/documentation/db-api/#select-related On Dec 11, 1:18 pm, Joe <[EMAIL PROTECTED]> wrote: > I've found the largest memory hog to be the native way related tables > are setup. > > Check class definitions with related tables and edit as such: > > class ...(models.Mode):

Re: Performance of a django website

2007-12-11 Thread Brian Morton
Sorry, just saw your earlier post about debug being turned off. I would say it is definitely time to start profiling your code. On Dec 11, 2:11 pm, Brian Morton <[EMAIL PROTECTED]> wrote: > Joseph raises a good point. I only recently discovered what a > performance killer DE

Re: Performance of a django website

2007-12-11 Thread Brian Morton
ets.org/snippets/93/ > > -joe > > On Dec 11, 2007 10:49 AM, Richard Coleman <[EMAIL PROTECTED]> wrote: > > > > > Brian Morton wrote: > > > Are you serving static content from the same apache instance? Also, > > > what kind of network connectivit

Re: Performance of a django website

2007-12-11 Thread Brian Morton
Are you serving static content from the same apache instance? Also, what kind of network connectivity do you have between your web and mysql servers? It sounds like apache might need some tuning in terms of thread parameters. Have you enabled caching yet? Turn on the cache framework site-wide

Re: Help debugging Django/MySQLdb exception

2007-12-06 Thread Brian Morton
, the "key" would repeat and the row would not be inserted. However, no exception was ever raised about a duplicate primary key on save(). I am puzzled by this. Why would it not complain about a primary key violation? On Dec 5, 12:29 pm, "Karen Tracey" <[EMAIL PROTECTED]>

Help debugging Django/MySQLdb exception

2007-12-04 Thread Brian Morton
I'm not sure what could be causing this problem. This is a loader script that is loading a CSV and using the Django ORM to do lookups and inserts. This is on a workstation with 1GB of memory running Ubuntu Gutsy (the MySQL server is local also). I'm using MySQLdb 1.2.2 and there do not seem to

Re: Expiring cache entries through model save()

2007-11-30 Thread Brian Morton
Thanks for the advice Malcolm. I am going to give this more thought and see if I can come up with a generic high performance hash function. On Nov 30, 3:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2007-11-30 at 12:08 -0800, Brian Morton wrote: > > I have an i

Expiring cache entries through model save()

2007-11-30 Thread Brian Morton
I have an interesting idea that I am not quite sure how to pursue. I'm wondering if any of you have figured this out already. What I would like to do is set the cache expiration for a particular object in the cache to be very high, and then delete the item from the cache when an instance of its

Re: Backend does not find views

2007-10-29 Thread Brian Morton
Deleting your checkout and re-checking out the SVN tree couldn't hurt. Can you tell us more about your environment? What OS? What version of Python? What web server are you using? On Oct 29, 3:53 am, oversize <[EMAIL PROTECTED]> wrote: > Hello, > my (very strange) problem is: When i want to

Re: Problems with deploying django

2007-09-10 Thread Brian Morton
I would remove your source built code and reinstall python2.5 and the development package for it. Make sure any other versions of python are uninstalled unless other packages depend on them. On Sep 10, 3:11 pm, shabda <[EMAIL PROTECTED]> wrote: > I am trying to deploy django on a fedora 7

Re: Django Flatpages With Memcache as storage location

2007-09-09 Thread Brian Morton
What happens if you use a simple or dummy cache? On Sep 9, 2:51 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: > On Sep 9, 6:15 am, Thomas Badran <[EMAIL PROTECTED]> wrote: > > > > > My best guess would be that you are missing the / at the start and end > > of the url > > > Tom > > > On Sat,

Re: Databases, one or many

2007-09-06 Thread Brian Morton
/company/website and put the separate apps (based on function) under the project. On Sep 6, 4:49 pm, "Adam Jenkins" <[EMAIL PROTECTED]> wrote: > On 9/6/07, Brian Morton <[EMAIL PROTECTED]> wrote: > > > > > Well, by its nature, each Django project has its own

Re: sporadic VariableDoesNotExist's...

2007-09-06 Thread Brian Morton
Also, do you have django.core.context_processors.request in your context_processors? It looks like you're trying to overwrite a dict element that already exists. On Sep 6, 12:14 pm, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > Hello Everyone, > > I have a request context which sets

Re: sporadic VariableDoesNotExist's...

2007-09-06 Thread Brian Morton
Can we see your context processor code? On Sep 6, 12:14 pm, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > Hello Everyone, > > I have a request context which sets {'request':request}... > > On windows (dev-server) everything is fine and dandy, but on our live > site (splicemusic.com,

Re: update 2nd model via first when saved

2007-09-05 Thread Brian Morton
class Hardware(models.Model): blah = models.CharField() ... #called every time the model instance is saved def save(): #if you want many hardware history records for a piece of hardware history = HardwareHistory.create(hardware=self, ...) #if you only

Re: A "revision-controlled field" type?

2007-08-16 Thread Brian Morton
It sounds like what you need to build is a custom ForeignKey type of field that creates another table for that field. Then, you can store an arbitrary number of revisions of that field, along with versioning information, and a wrapper around diff that can perform the functions you mention. On

Re: A "revision-controlled field" type?

2007-08-16 Thread Brian Morton
I'm not sure I really understand. It sort of sounds like you are talking about a CharField with a choices argument. Is what you're looking for more complex? Can you describe it in more detail? On Aug 16, 4:06 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > Has there been any work on a

Re: Newforms file upload

2007-08-15 Thread Brian Morton
Malcolm. Resolving it takes newforms forward a giant step. On Aug 15, 8:51 am, "Jonathan Buchanan" <[EMAIL PROTECTED]> wrote: > On 8/15/07, Brian Morton <[EMAIL PROTECTED]> wrote: > > > > > As I understand it, ticket 3297 is closed as resolved. However, I am &

Newforms file upload

2007-08-15 Thread Brian Morton
As I understand it, ticket 3297 is closed as resolved. However, I am still experiencing problems uploading files in newforms as of the latest svn checkout. Am I incorrect in my assumption that this has been fixed? Or am I experiencing issues of my own? Thanks.

Re: Unique=true

2007-07-16 Thread Brian Morton
If you are using NewForms, you should implement this in the clean() method for a field. See the newforms docs and unit tests for more details. On Jul 16, 4:49 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > OK, fixed the above problem -- figured out that it was related to my > setting

Related field has invalid lookup: iexact

2007-07-15 Thread Brian Morton
I am getting the following error in my application's admin area trying to add a record for a particular object. It seems to stem from the fact that I am relating this record to a "member" object, and a member is OneToOne with User. If I relate the object directly to User as a foreignkey, I have

Re: Anyone running Django and MySQL Cluster

2007-07-06 Thread Brian Morton
I have not done this before with Django, but I have set up a MySQL cluster before. It is the same as a standard MySQL server. Just connect to the management node as your SQL server. On Jul 6, 3:01 pm, johnny <[EMAIL PROTECTED]> wrote: > Is it even possible to run Django and MySQL Cluster or I

Multiple models on one form

2006-12-08 Thread Brian Morton
I am trying to write a custom form that will handle updates for several models. What is the best way to do this? Do I have to write a custom manipulator to handle the data? Or can I create a hybrid view of several different default manipulators?

Validation Summary

2006-12-07 Thread Brian Morton
I can't figure out how to make a validation summary on a form. I have examined the code in forms\__init__.py, and it reveals nothing about where the complete list of field/error pairs are stored. I would like to do a for loop on that dictionary and output a validation summary, then mark