I can't figure it out: "manage.py dbshell" gives "Access denied for user 'ODBC'@'localhost'"

2008-09-15 Thread Jumpfroggy
Hey All, I've had this problem for a while and still can't figure it out. I have django setup and working on my windows machine. I can run manage.py syncdb and other commands, but for some reason the dbshell command doesn't work. It just gives this error: > manage.py dbshell > ERROR 1045

Re: I can't figure it out: "manage.py dbshell" gives "Access denied for user 'ODBC'@'localhost'"

2008-09-15 Thread Jumpfroggy
Alright, after some more searching I figured out my answer. First off, the test statements I posted were wrong. The first argument passed to execlp is the executable name, so: > os.execlp(self.executable_name, "-?") Should be > os.execlp(self.executable_name, self.executable_name, "-?") That

ManyToManyField() causes bugs when using 'ModelName' instead of 'self'

2009-04-02 Thread Jumpfroggy
Summary: django should throw an exception when a model has its own name as the 'to' field of a ManyToMany() insead of 'self'. I had a field like this: def Item(Model): name = CharField(max_length=100) related_items = ManyToManyField('Item', blank=True) But this caused some

Figuring out my memory usage for django + wsgi + apache prefork

2009-07-08 Thread Jumpfroggy
I'm running a bunch of django apps on my shared host with an 80mb memory limit. I have a bunch of very low-traffic sites I want to keep running, but use as little memory as possible, so my goal is to minimize the memory usage for each of these very small sites. I'm just starting to learn about

Using the @login_required() decorator with #hash url's

2009-07-16 Thread Jumpfroggy
Currently, the @login_required() decorator does not preserve any #hash part of the URL. So if I go to /page#section1 without being logged in, I'm redirected to /login?next=/page#section1. After logging in, I'm redirected to /page (without the hash part). I read in another thread here that the

Re: New to unit testing, need advice

2009-07-16 Thread Jumpfroggy
> besides the testing issues (which are certainly a heated debate!), i have to > say that my Django projects became far better organized and a lot more > flexible when i learned to put most of the code on the models, and not on the > views. This is a pretty interesting topic. Coming from a

Re: Using the @login_required() decorator with #hash url's

2009-07-16 Thread Jumpfroggy
On Jul 16, 11:05 am, Javier Guerra wrote: > maybe urlencode()'ing the '/page#section1' parameter? The first problem is that the django server only receives the '/page' part of the URL. The browser itself holds onto the '#hash' part and doesn't transmit that to the django

Re: Using the @login_required() decorator with #hash url's

2009-07-28 Thread Jumpfroggy
> The only way I know around this involves leaning on JavaScript to > get the URL, split off the #hash bit from it, and sneak it in as > a hidden element on the login form. Yeah, I ended up doing this on the /login page. Basically: $(function() {

How do I minimize memory usage with WSGI and Apache?

2009-08-09 Thread Jumpfroggy
I'm hosting a bunch of django apps on a shared host with 80MB of application memory (Webfaction in this case). I've got a bunch of apps that are very infrequently used, but need to be online. I've already changed the httpd.conf: ServerLimit 1 Instead of the default "ServerLimit 2". With

Re: How do I minimize memory usage with WSGI and Apache?

2009-08-10 Thread Jumpfroggy
Wow, lots of good feedback here. Thanks! On Aug 9, 6:17 pm, Graham Dumpleton wrote: > Replace use of mod_python with mod_wsgi. I'm using mod_wsgi for everything already, forgot to say. When I researched, it seemed like the newer/better way to do django. > Ensure

Re: How do I minimize memory usage with WSGI and Apache?

2009-08-10 Thread Jumpfroggy
On Aug 10, 2:24 pm, dartdog wrote: > Big help!! Had just started getting using too much memory notices from > Webfaction yesterday evening... Yeah, I didn't even pay attention till I hit about 120-140MB on my 80MB plan and got everything turned off. Otherwise I would have

Django dev server (runserver) takes 5 seconds after reloading new code?

2009-09-01 Thread Jumpfroggy
I have a strange problem that's popped up just recently, and it's puzzling to me. I'm running the "manage.py runserver" dev server for development. Normally, right after I save a file, the server reloads the new code and is ready to go right away. However, recently one of my apps has a strange

Model.objects.values('some_column').distinct() returns the wrong results

2009-10-02 Thread Jumpfroggy
I have a model with a field, and I wanted to pull all the unique values of that field. So I do this: distinct_values = Model.objects.values('some_column').distinct() print 'distinct_values.count()', distinct_values.count() print 'len(distinct_values)', len(distinct_values) Which

Re: Starting a daemon thread from Django view

2009-10-28 Thread Jumpfroggy
I'm in the same boat here. My plan is similar. >From views.py, record the job in the DB. Start the daemon thread. Return a "Processing..." response to the browser. When the daemon thread is done, it records it in the DB. The browser page uses AJAX to query the DB and update the status. When the

Unable to filter a query on >1 ManyToMany relationships

2010-10-25 Thread Jumpfroggy
I have a class like this: class Node: name = models.CharField() parents = models.ManyToManyField('self', symmetrical=False, related_name='child_nodes', null=True, blank=True) This allows a basic parent(s)/children hierarchy. A node can have >= 0 parents. A parent can have >= 0

Re: What does an ideal django workflow setup look like?

2010-10-25 Thread Jumpfroggy
This is such a great thread! I'd love to see a wiki page detailing some good setup ideas. It's such a leap forward from the nuts & bolts of "How do I install django" and "How do I run a complex query" to this... "How do I use django more effectively, end to end?" I agree - most of these tips

Re: ManytoMany initial values

2010-10-25 Thread Jumpfroggy
Giancarlo, I've run into this trouble myself. The problem here is the widget itself. It does exactly what you described: -Shows all possible values for the ManyToMany field. -Highlights the "active" or "selected" values. These correspond to items in that list/array/queryset. For any more than

Re: ManytoMany initial values

2010-10-25 Thread Jumpfroggy
On Mon, Oct 25, 2010 at 2:23 PM, Giancarlo Razzolini wrote: > James, > First of all thank you for the fast response. I'll take a look into the > admin forms widgets. I'm already looking for third party applications field > types and widgets to see if I find one that does

Re: Unable to filter a query on >1 ManyToMany relationships

2010-10-28 Thread Jumpfroggy
Tom, Thanks for the link, I read through that and it makes sense. So if both conditions are in the same filter, they are both applied simultaneously. Since I wanted two separate conditions, I needed two separate filter() statements. In other words, my method, is "Find a node who's parent is

How do I filter/exclude custom queryset fields created by .extra()?

2010-10-28 Thread Jumpfroggy
I have something like this: class Node(Model): widgets = ForeignKey(Widget) And I want to retrieve all nodes that have >0 widgets. I have an .extra() query like this: nodes = Node.objects.all().extra( select={ 'num_widgets': 'SELECT COUNT(*) FROM

Re: adding field to query set

2010-10-28 Thread Jumpfroggy
What's your motive? Are you worried about performance? If performance is not an issue, you can just do this: for project in Project.objects.all(): print project.user.first_name + ' ' + project.user.last_namea This might speed things up: projects =

Re: adding field to query set

2010-10-29 Thread Jumpfroggy
If it were my project, I'd probably add this kind of custom field to your mapping: mapping = { # list the normal columns first... then: 'full_name': ['user__first_name', 'user__last_name'], } Then your render code would be something like this: def render(self): for row in

Aggregates are giving the wrong numbers for .annotate()? What am I doing wrong?

2010-10-29 Thread Jumpfroggy
Hi all, I've been working in django for a while now, but am still wrapping my head around the more complex queryset features. I have something like this: class Foo: name = CharField() bars = ForeignKey(Bar) widgets = ForeignKey(Widget) I can do this: Foo.objects.extra(select={

Re: How do I filter/exclude custom queryset fields created by .extra()?

2010-10-29 Thread Jumpfroggy
>From a raw SQL standpoint, I've figured out that these constraints need to be in the HAVING clause, not the WHERE clause. But it looks like HAVING is not exposed through the .extra() function, which would seems logical. It appears you can create extra fields, but due to this lack you can't

Reloading a single model object from .py file... keeps getting cached results?

2010-11-24 Thread Jumpfroggy
I want to run a script outside of the django server for maintenance purposes, but it still accesses some of the models. The problem is that I can't seem to get the model object to reload it's data from the DB - it always seems cached. # Setup django. import project.settings from

Re: absolute url in template and url name

2010-11-24 Thread Jumpfroggy
I always do something like this: abs_activate_url = request.build_absolute_uri(reverse('account_activate', args=user.id)) That's an absolute URL, so it's like "http://domain.com/account/ activate/2" instead of the normal reverse() or {% url %} which gives a relative URL like

Re: absolute url in template and url name

2010-11-29 Thread Jumpfroggy
As a followup, I had to do something similar and ended up using this: # Gets the http://domain.com without the trailing / base_url = request.build_absolute_uri('/')[:-1] And in the template I can do this: ... The benefits: -You only have to create the base_url in the view, the rest

How do I rename a FileField() that's attached to a model?

2010-03-13 Thread Jumpfroggy
I've gone through the documentation a ton, been trying different techniques, and I know I'm just missing something obvious. I have a model like this: class MyModel(Model): file1 = FileField(...) So I can do this: model = MyModel.objects.get(id=1) print

Re: How do I rename a FileField() that's attached to a model?

2010-03-13 Thread Jumpfroggy
> you could do it manually. first use os.rename to rename the file on the disk, > and then update your model instance with the new name and save it. I think this is what I'm missing. What's the code for this? Can I just do: os.rename(model.file1.name, new_filename)

Re: How do I rename a FileField() that's attached to a model?

2010-03-13 Thread Jumpfroggy
& rereading the docs trying to figure out how things work. A few good examples would have saved me tons of time. Who do I talk to about possibly contributing to the docs? On Mar 14, 3:10 am, Jumpfroggy <rocketmonk...@gmail.com> wrote: > > you could do it manually. first use os.

form.is_valid() changes a ModelForm's associated instance now?

2011-03-02 Thread Jumpfroggy
I discovered the recent changes to the "is_valid()" model form method in 1.2, and I'd love to hear thoughts on the rationale behind this change. I have this kind of code: item = Item.objects.get(id=1) print 'item.value: %s' % item.value form = ItemModelForm(request.POST,

How do I run test and get results programmatically? (django, south, fixtures, sqlite)

2011-03-11 Thread Jumpfroggy
I have an app that I'm starting to write tests for. The app uses south for all migrations and mysql for the db. I wrote some tests and also created an initial_data.json fixture to provide some default data. If I run "python manage.py test", the database is created via sqlite, the tests are run,

Re: How do I run test and get results programmatically? (django, south, fixtures, sqlite)

2011-03-14 Thread Jumpfroggy
@gladys, While that didn't solve my original question, it did solve another related problem. Before, I had issue with migrations failing since they depended on pre-existing data (which did not exist in the blank testing database). But if I added an initial_data.json fixture, it gets run for

How can I integrate performance measurements with unit tests?

2011-03-28 Thread Jumpfroggy
I have django testing setup, and it runs a few tests. I would like to measure the time each test takes to run, and record that in a data file I can access later. How do I record the time each test takes? If this is not (easily) possible with unit tests, then is there another easy way to test

Re: Just started Django - please help clarify web site configuration strategy

2011-03-28 Thread Jumpfroggy
> Basically, the question is - when a web > application starts there is a number of things that needs to be > available any time any request. Some of them are really static in > nature - for example, pagination parameters; If these are static values, a good place to put them is in the settings.py