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 (2800
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 wo
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 a
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 h
> 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 PH
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 server at all, so the
l
> 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() {
$('#url-hash').attr('va
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 the
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 you use prefork MPM
> for Apa
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 just
let it grow, not
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 p
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 v
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 giv
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
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 children
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 wil
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
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 what I want. I was eve
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 bot
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 appname_node
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 = Project.objects.all().select_r
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 sel
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={
>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 filte
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 djang
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 "/account/activat
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
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 mo
> 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)
model.file1.n
feature
reading & 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 wrote:
> > you could do it manually. first use os.rename to rename
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, instance=item
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,
@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 ever
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 vie
> 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
35 matches
Mail list logo