Hi there,
I'm reading the django book and they say that you can validate a form
like this in one line, checking for missing keys and missing data:
if not request.POST.get('subject', ' ')
errors.append('enter a subject')
I'm not sure how to read that line of code, though. Can someone
On Sun, Mar 21, 2010 at 8:17 AM, Henrik Genssen
wrote:
> No one any comment on this?
> is this the expected behavior?
...
>>Now is there a way to force select_related tables any way in a count?
select_related() is an optimization for data retrieval. It allows you
to
On Mar 24, 12:53 pm, Tim Shaffer wrote:
> No, it would just be one instance of the project with 20 different
> configuration files.
There is the single instance of the code files on disk, but there
would be multiple instances of the loaded application in memory where
each
Hi Everyone,
Django noob here. How do I write a view function that can modify
database records without changing the html on the screen? Also, from
a best-practices standpoint, is there any reason I shouldn't be
attempting this?
Cheers,
DG
--
You received this message because you are subscribed
No, it would just be one instance of the project with 20 different
configuration files.
On Mar 23, 5:29 am, Tom Evans wrote:
> On Mon, Mar 22, 2010 at 5:53 PM, Tim Shaffer wrote:
> > It gives you multiple sites from one codebase with multiple
On Wed, Mar 24, 2010 at 5:35 AM, jrs wrote:
> Clifford,
>
> Ask the previous engineering staff of Twitter if it's dangerous.
When you're using the wrong shovel to hammer in a screw, you don't
blame the shovel.
Yours,
Russ Magee %-)
--
You received this message because you
On Wed, Mar 24, 2010 at 6:22 AM, jrs wrote:
> Another great example... If PostgreSQL has referential integrity on by
> default, is django still hammering the db with unnecessary queries?
In this case, for two reasons - MySQL, and generic foreign keys.
Fisrtly, we aim to
No when I run the shell in the directory where django lives I can
import. I untared django into a sub-directory of the desktop and
installed it there because I'm just starting and I feel like when I
figure it out I'm going to want to start from scratch.
Ya it is really weird, it just silently
Yes, the django directory is symlinked to Python/2.6/site-packages and
django-admin.py is linked to /usr/local/bin
On Mar 23, 5:59 pm, irishsteve wrote:
> Have you set up the necessary sym links?
>
> See points 3 & 4 at the bottom of this
>
I don't have a working sample (never did this), but you may be looking for
something like this:
class Media:
js = get_path()
And in the class where you keep use_editor:
def get_path(self)
if self.use_editor:
return path1
else:
return path2
This is just an idea,
On Tue, Mar 23, 2010 at 6:38 PM, John wrote:
> I have encountered a Unit Test error while using a reverse url lookup
> for i18n. All is running fine in the development environment. Issues
> only occur during testing. It appears to possibly be an issue with
> shared contexts
On Wed, Mar 24, 2010 at 5:01 AM, jrs wrote:
> Thanks Preston.
>
> I'm not using django's messaging... at all. My problem is that for
> every ajax request, the query-
>
> {'time': '0.000', 'sql': u'SELECT `auth_message`.`id`,
> `auth_message`.`user_id`,
On Wed, Mar 24, 2010 at 4:56 AM, Phlip wrote:
> Djangoists:
>
> Suppose I want a test to fail if the database would respond to a given
> QuerySet without using my favorite index.
>
> This test case would attempt, at developer test time, to solve the
> same problem as a "soak
Hi All,
This topic has been discussed before. But Have not found a solution .
I want to add a schema search path to my connection object at the time
of creating the django connection object for Postgres.
I know that in models.py I can set the db_table =
'"schema"."table_name"' . This works fine
Just to clarify: if you run a python shell in
/Library/Python/2.6/site-packages you can import django, but if you run
anywhere else you can't?
It seems weird that you can't cd into django's directory.
- Paulo
On Tue, Mar 23, 2010 at 9:13 PM, Riley wrote:
> Hey all,
>
>
You should run the command as an administrator, as mentioned. In any case,
if you type something like:
python /usr/bin/django-admin.py startproject project_name
it should work (where /usr/bin/ is the path to the django executable).
- Paulo
On Tue, Mar 23, 2010 at 10:05 PM, irishsteve
I have encountered a Unit Test error while using a reverse url lookup
for i18n. All is running fine in the development environment. Issues
only occur during testing. It appears to possibly be an issue with
shared contexts between contrib.auth and views.i18n.
Template Code
Unit Test
Are you writing these commands as root? If not there might be something
fishy going on there. Can you move django-admin.py to somewhere else?
On Wed, Mar 24, 2010 at 12:05 AM, irishsteve wrote:
> Hi
>
> I've caused myself some problems by updating python then trying to
>
Have you tried typing "sudo python -V" or restarting your shell session?
On Tue, Mar 23, 2010 at 11:59 PM, irishsteve wrote:
> Have you set up the necessary sym links?
>
> See points 3 & 4 at the bottom of this page:
> http://docs.djangoproject.com/en/dev/topics/install/
>
>
On 03/23/2010 06:22 PM, jrs wrote:
Another great example... If PostgreSQL has referential integrity on
by default, is django still hammering the db with unnecessary
queries? I've already seen that it does when MySQL has referential
integrity on... It seems people are confirming the django
Another great example... If PostgreSQL has referential integrity on by
default, is django still hammering the db with unnecessary queries?
I've already seen that it does when MySQL has referential integrity
on... It seems people are confirming the django problem... I'm not
trying to argue doing
Hi
I've caused myself some problems by updating python then trying to
change back.
I'm nearly back up and running now, except I'm getting permission
denied errors when I try to run django-admin.py commands. For example:
$ django-admin.py syncdb
-bash: /usr/bin/django-admin.py: Permission denied
Have you set up the necessary sym links?
See points 3 & 4 at the bottom of this page:
http://docs.djangoproject.com/en/dev/topics/install/
On 23 Mar, 21:13, Riley wrote:
> Hey all,
>
> I've done some extensive searching around this site, but no one's
> advice seems to
On Tue, Mar 23, 2010 at 3:57 PM, jrs wrote:
> It is precisely due to this that I'm surprised the ORM has
> cascading deletes on by default. Seems to me that cascades should
> only happen when the app developer specifies, not the other way
> around... it's dangerous and I'm
yes, this util helped a lot! 300 down to 20 i think. I had a SQL
query ready, but then you lose all the ORM goodness.
I would think this should be part of the ORM, no?
In the SQL, I just had to add another join to the query generated by
the select_related() method. The problem is you get
Given an admin media class that sets up a rich text editor, like:
class TutorialAdmin(admin.ModelAdmin):
fields...
class Media:
js = ['/paths/...',]
I would like the ability to selectively override js. I've added a
"use_editor" boolean to the Tutorial model. The question is,
Clifford,
Ask the previous engineering staff of Twitter if it's dangerous.
On Mar 23, 5:26 pm, CLIFFORD ILKAY wrote:
> On 03/23/2010 04:57 PM, jrs wrote:
>
> > Russ and Javier,
>
> > Just to be clear... the reason for my initial note was due to my
> > already having
Hey all,
I've done some extensive searching around this site, but no one's
advice seems to apply/fix the problem :(
Basically, I have python 2.6 and 2.5 installed on my mac (snow
leopard). I installed django from a tarball, using 'sudo python
setup.py install'. I'm pretty sure that this uses
On 03/23/2010 04:57 PM, jrs wrote:
Russ and Javier,
Just to be clear... the reason for my initial note was due to my
already having a work queue which performs cleanup and maintains
data integrity. It is precisely due to this that I'm surprised the
ORM has cascading deletes on by default.
On Tue, Mar 23, 2010 at 5:41 AM, berryp wrote:
> Yes, this is exactly the problem. My code above takes care of
> everything in one instance. It's starting to sound like this will be
> the best solution. Building a custom sites framework may be overkill
> for the sake of
Thanks Preston.
I'm not using django's messaging... at all. My problem is that for
every ajax request, the query-
{'time': '0.000', 'sql': u'SELECT `auth_message`.`id`,
`auth_message`.`user_id`, `auth_message`.`message` FROM `auth_message`
WHERE `auth_message`.`user_id` = 1 '}
is being run. I
Russ and Javier,
Just to be clear... the reason for my initial note was due to my
already having a work queue which performs cleanup and maintains data
integrity. It is precisely due to this that I'm surprised the ORM has
cascading deletes on by default. Seems to me that cascades should
only
Djangoists:
Suppose I want a test to fail if the database would respond to a given
QuerySet without using my favorite index.
This test case would attempt, at developer test time, to solve the
same problem as a "soak test" would, at acceptance testing time. So
the earlier a test fails - without
On Tue, Mar 23, 2010 at 10:21 AM, Vinicius Mendes | meiocodigo.com
wrote:
> integrated to the framework. I think the queryset should keep track of
> it self. It knows what is the filter, so why can't it negate this
> filter?
Given an already-existing QuerySet which has
On Mar 23, 5:32 pm, Pep wrote:
> Well, following the doc, this code works :
>
> {% get_comment_list for myModule.News 1 as comment_list %}
>
> But I don't want to have to write the object_id in my template !
>
> def index(request, name, cp):
> news_content =
> I want to be able to answer your question, forever. Is there a way,
> from a developer test, to query "what SQL statement does this QuerySet
> generate"?
Oh, duh, it's QuerySet.query, as a string.
Brand X makes that one inconceivably hard, due to poor factoring...
> --
> Phlip
>
Do you really need to show the message for the remainder of the
session? Or just when the page loads
right after the user has successfully subscribed? in this case you
could just delete the value after being "used":
if request.session.get('signed_up', True):
form.thanks = True
On Mar 23, 8:20 am, jrs wrote:
> Is there a flag somewhere which will allow me to disable django
> messaging?
>
> Thanks
You give too few details. The messaging system is something that is
opt in, you have to create messages, and then display them in your
template. Are
On Mon, Mar 22, 2010 at 5:53 PM, Tim Shaffer wrote:
> It gives you multiple sites from one codebase with multiple settings
> files. They are using the same project module. So your project would
> look like this:
>
> project
> - app1
> - app2
> - settings.py
> -
as far as I could tell, select_related did not follow m2m
relationships, only FK.
On Mar 18, 2:12 am, bruno desthuilliers
wrote:
> On Mar 18, 8:42 am, koenb wrote:
>
> > Take a look at something like django-selectreverse [1] for
Well, following the doc, this code works :
{% get_comment_list for myModule.News 1 as comment_list %}
But I don't want to have to write the object_id in my template !
def index(request, name, cp):
news_content = News.objects.order_by('id')
return render_to_response('index.html', {
Many thanks, Dan! I shall have a look at this app.
On 03/23/2010 08:27 PM, Dan Carroll wrote:
You might want to look at memcache_status. It uses a one line
statement in admin.py to switch to admin to use a different template
for its main page. Then, the custom template extends
On Mar 23, 5:07 pm, Pep wrote:
> Hi everybody,
>
> An error occured when I want to use the comment framework. Django
> debug says me : "Caught an exception while rendering: 'str' object has
> no attribute '_meta'"
>
> I don't understand why because when I use the comment
Hi everybody,
An error occured when I want to use the comment framework. Django
debug says me : "Caught an exception while rendering: 'str' object has
no attribute '_meta'"
I don't understand why because when I use the comment framework on the
same project with Diario module, it works fine !
My
On Mon, Mar 22, 2010 at 12:26 PM, Ivan Uemlianin wrote:
>
> I'm now thinking a fixture might not be the right way to go: it might
> be better to have a little script to add users once syncdb is done.
> As well as allowing me to provide plain text passwords, I could easily
> add
Matt Schinckel wrote:
> Are you sure it hits the db twice?
Of course not. But (modulo "Premature Optimization") I would be
suspicious of any such statement, as I wrote it.
I want to be able to answer your question, forever. Is there a way,
from a developer test, to query "what SQL statement
Hi Django community,
Wanted to see if you might be able to help out with a near-term
project.
We're looking for a freelance contractor for front-end implementation
for our Django site. The implementation should be done using Django
template language.
Required skills: strong familiarity with
You might want to look at memcache_status. It uses a one line
statement in admin.py to switch to admin to use a different template
for its main page. Then, the custom template extends admin/index.html
to insert extra information (including graphs) at the top of the
page. That should give you
On Tue, Mar 23, 2010 at 11:04 PM, jrs wrote:
> Thanks Russ
>
> On Mar 23, 10:33 am, Russell Keith-Magee
> wrote:
>> On Tue, Mar 23, 2010 at 10:21 PM, jrs wrote:
>>
>> > On Mar 23, 10:05 am, "ge...@aquarianhouse.com"
>> >
On Tue, Mar 23, 2010 at 11:04 AM, jrs wrote:
> The recommendation to avoid web requests for long-chain deletes, most
> of the time, makes no sense. There are frequently valid cases of long-
> chain deletes being basic to web requests.
those cases are best served by an
You'll need add a stylesheet Media class to your admin class:
class ResizeFilterAdmin(admin.ModelAdmin):
#
class Media:
css = { 'all': ('/relative/path/to/supplemental.css'), }
Then, in that CSS file you'll need to specify the width of your
element:
/* by class */
Matt,
I know I can do this, but if I want to write a generic view that
receives a queryset and deletes everything that isn't in this
queryset? I'm not having this problem right now. I just thought that
this was a feature that would be interesting to have in the ORM. And I
am asking if it already
Is there a flag somewhere which will allow me to disable django
messaging?
Thanks
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
Very sorry everybody: I googled around tons, but I didn't search this
group! LOL. I'll know next time.
Adding an "invalid" choice to a ChoiceField?
http://groups.google.com/group/django-users/browse_thread/thread/dd6d8eb11f915c94/77aa6fbea94af4c4?lnk=gst=choicefield#77aa6fbea94af4c4
This works:
Thanks Russ
On Mar 23, 10:33 am, Russell Keith-Magee
wrote:
> On Tue, Mar 23, 2010 at 10:21 PM, jrs wrote:
>
> > On Mar 23, 10:05 am, "ge...@aquarianhouse.com"
> > wrote:
> >> Filter would be better :)
>
> >>
Dear All
I have a choiceField in one of my forms, and I'd like to have it
rendered displaying a prompt. I think the html would be something
like this:
Please choose a colour:
Red
Green
Blue
This would display a drop-down menu showing "Please choose a
On Tue, Mar 23, 2010 at 10:21 PM, jrs wrote:
>
>
> On Mar 23, 10:05 am, "ge...@aquarianhouse.com"
> wrote:
>> Filter would be better :)
>>
>> Container.objects.filter(
>> pk=container_id
>> ).delete()
>
> Why is filter better here,
Dear Ian
That's great! Exactly my use case. Thanks very much for your help.
Best wishes
Ivan
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this
If it doesn't exist it would throw an exception.
On Mar 23, 3:21 pm, jrs wrote:
> On Mar 23, 10:05 am, "ge...@aquarianhouse.com"
>
> wrote:
> > Filter would be better :)
>
> > Container.objects.filter(
> > pk=container_id
> >
On Mar 23, 10:05 am, "ge...@aquarianhouse.com"
wrote:
> Filter would be better :)
>
> Container.objects.filter(
> pk=container_id
> ).delete()
Why is filter better here, since it's a one record delete?
Also, am I correct is believing that this creates a
I had the same issue but I also wanted to create additional data for
each user. It was straightforward to create a script to add users.
I needed to import some bits to set up the Django environment and then
I was able to create users with standard Django calls. Here is
extracts from my code
Filter would be better :)
Container.objects.filter(
pk=container_id
).delete()
On Mar 23, 2:55 pm, jrs wrote:
> I have a statement---
>
> Container.objects.get(
> pk=container_id
> ).delete()
>
> This seemingly trivial operation hammers the
On Tue, Mar 23, 2010 at 9:55 PM, jrs wrote:
> I have a statement---
>
> Container.objects.get(
> pk=container_id
> ).delete()
>
> This seemingly trivial operation hammers the db with 581 queries!!
> The reason being that the django orm has decided that it will
I have a statement---
Container.objects.get(
pk=container_id
).delete()
This seemingly trivial operation hammers the db with 581 queries!!
The reason being that the django orm has decided that it will enforce
referential integrity as a default behavior. As you could imagine,
Is there some way you can keep track of the queryset? I understand it's
dynamic, and maybe complex, for you to be looking for this kind of solution,
but if it were possible to have a variable or dictionary keeping track of
what you add to the queryset, it might be possible to use it to build the
On Mar 23, 11:23 pm, "Vinicius Mendes | meiocodigo.com"
wrote:
> Ok. The code proposed by Tim Shaffer works and gives only one query.
> But it makes use of subselects, what is heavy for the database. Take a
> look at the generated SQL:
>
> 'SELECT `auth_user`.`id`,
Ok. The code proposed by Tim Shaffer works and gives only one query.
But it makes use of subselects, what is heavy for the database. Take a
look at the generated SQL:
'SELECT `auth_user`.`id`, `auth_user`.`username`,
`auth_user`.`first_name`, `auth_user`.`last_name`,
`auth_user`.`email`,
On Tue, Mar 23, 2010 at 5:26 AM, Russell Keith-Magee wrote:
> On Tue, Mar 23, 2010 at 5:53 AM, David Cramer wrote:
> > One of the recent changes in trunk was a change to how querysets were
> > cloned. Due to this, some old code we had is no longer
I'll try to answer myself :-)
because widget=forms.HiddenInput() is invalid widget for
DateTimeField.
Changed in Django 1.0: The DateTimeField used to use a TextInput
widget by default. This has now changed.
So I left the original DateTimeInput for this field and used
{{
Hi to all
I am using Jython 2.5.1 and Django 1.1 ..plz help which is the compatable
schema migration
Thanks in advance
--
View this message in context:
http://old.nabble.com/Jython-Compatable-Schema-migration-tp27999390p27999390.html
Sent from the django-users mailing list archive at
oh, great, you were right, thank you
"Validation errors are hold back until the clean method returns the
cleaned_data dict."
really the some_hidden_field was invalid, I included {{ form.errors }}
to my template and the validation error appeared suddenly :-)
What I still don't understand, why
I will certainly look into this as it may give me a lot more control
but I don't want to end up with lots of added complexity for the sake
of conformity.
On Mar 23, 10:02 am, Bjunix wrote:
> You could also build your own "Sites framework" relying on other
> things than settings
Hi,
I have an application with a model and a modelform.
I have another application and in a a specific case I would like to
override one attribute from the modelform in the original application.
Example:
class Article(models.Model):
identifier: = models.CharField(max_length=10)
headline
Yes, this is exactly the problem. My code above takes care of
everything in one instance. It's starting to sound like this will be
the best solution. Building a custom sites framework may be overkill
for the sake of altering a few settings variables at run time. Hard to
know if my solution will
You could also build your own "Sites framework" relying on other
things than settings files. Django's sites framework is not too
complex and if does not fit your need, I would just rebuild it
tailored to your needs.
On Mar 23, 10:29 am, Tom Evans wrote:
> On Mon, Mar
> I thought my def clean(self) is the third step in your explanation:
Yes that's right. But this clean methods gets called even if your
Field raised a ValidationError. Validation errors are hold back until
the clean method returns the cleaned_data dict. Try to 'get' the key
(not calling it
Hi list,
anyone got some ideas how to improve the newforms-way to deal with
"splitted/grouped"-html fields (Radiobuttons & Checkbox) ?
The handling/rendering of those fields/widgets definitely could see
some improvement. It's a common requirement to access/show individual
"fields" in a template
On Mon, Mar 22, 2010 at 5:53 PM, Tim Shaffer wrote:
> It gives you multiple sites from one codebase with multiple settings
> files. They are using the same project module. So your project would
> look like this:
>
> project
> - app1
> - app2
> - settings.py
> -
On Tue, Mar 23, 2010 at 5:53 AM, David Cramer wrote:
> One of the recent changes in trunk was a change to how querysets were
> cloned. Due to this, some old code we had is no longer working. This
> was a custom aggregate which relied on "aggregate_select" (see below).
> I
On Tue, Mar 23, 2010 at 10:10 AM, Grigory Javadyan wrote:
> On 03/23/2010 12:53 PM, Sven Richter wrote:
>>
>> Hi,
>>
>> i just mentioned that in the admin interface, in the user and groups
>> section i still can see all the applications i once installed, but
>> that are deleted
On 03/23/2010 12:53 PM, Sven Richter wrote:
Hi,
i just mentioned that in the admin interface, in the user and groups
section i still can see all the applications i once installed, but
that are deleted now from my project. How can i get rid of them?
Greetings
Sven
Are you sure you removed
Hi,
i just mentioned that in the admin interface, in the user and groups
section i still can see all the applications i once installed, but
that are deleted now from my project. How can i get rid of them?
Greetings
Sven
--
You received this message because you are subscribed to the Google
Hi Tim,
On Tue, Mar 23, 2010 at 1:03 AM, Tim Shaffer wrote:
> Ah, yes I see the problem. Good catch. I hadn't tested that
> functionality. Luckily it is a simple change to admin.py. It's a
> matter of removing line 25:
>
once again, thanks for the good work. Now it works
I thought my def clean(self) is the third step in your explanation:
1. run the clean method of the form field itself. Here:
DateTimeField.clean()
2. then run the clean_() method of the form if available
3. once those two methods are run for every field, run the clean()
method of the form
So I
84 matches
Mail list logo