Re: Database events?

2006-09-17 Thread cyberco
> The signals are only within the same process, though. They don't wake up > other processes (they are not UNIX signals). Fortunately, the process > started by your cronjob can just import any bits of Django it might need > (e.g. for accessing models) and do the work directly. I currently have th

Documentation on dispatcher/signals?

2006-09-11 Thread cyberco
I can't find any documentation on dispatcher/signals. Is there any documentation or should I just 'fork the code'? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send em

Re: Database events?

2006-09-11 Thread cyberco
I've been looking around and the dispatcher/signals combo seems like a possible solution. I could raise the signals using cronjobs or so. Unfortunately I can't find any decent documentation on dispatcher/signals. Does anybody here have a pointer? --~--~-~--~~~---~--~-

Re: Chain filters on ManyToManyField

2006-09-10 Thread cyberco
Just for the record: ANDing 2 Q-objects doesn't work either... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe

Re: Database events?

2006-09-10 Thread cyberco
OK, thanks for your reply. Both possible solutions you propose are 'polling' solutions. The first is triggered by a in-memory object (a running process), the second by a user-request. I'm interested in the first solution since I can't wait for a user-request before checking for scheduled events. T

Re: Select all instances of a model that have a null ForeignKey value

2006-09-09 Thread cyberco
Thank you! That is a pretty obscure method. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, se

Select all instances of a model that have a null ForeignKey value

2006-09-09 Thread cyberco
Given: =Models== class T(models.Model): pass class Y(models.Model): t = models.ForeignKey(T, blank=True, null=True) I want to select all instances of a Y that have a null value for t. I would say that it should be... Y.o

Database events?

2006-09-09 Thread cyberco
Forgive me if this is a stupid question, I'm a complete newbie when it comes to databases, but how can I make the database generate events? The problem is that one of my models has a DateTimeField that is set to some point in the future. Somehow I want to be notified when that time passes. I can d

Re: Showing the value of a choice instead of the key

2006-09-07 Thread cyberco
Thanks! That is indeed in a non-intuitive location. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this

Showing the value of a choice instead of the key

2006-09-06 Thread cyberco
My model has a choice field: === class Foo(models.Model): STATUS = ( ('C', 'Created'), ('E', 'Edited'), ('F', 'Finished'), ) status = models.CharField(maxlength=1, choices=STATUS) =

Re: Restrict amount of text in a TextField form

2006-09-06 Thread cyberco
Thanks for the pointer, but how can I add a parameter to the textarea formfield, such as: == == if these formfields are automagically generated by Django? --~--~-~--~~~---~--~--

Restrict amount of text in a TextField form

2006-09-05 Thread cyberco
How can I set a maximum for the amount of text a user enters in a TextField form? CharField has a 'maxlength' parameter, but TextField not. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To po

Re: How much text in a db field is acceptable?

2006-09-05 Thread cyberco
There is no formatting whatsoever, so I guess I can feel comfortable storing (max) 5000 characters in a database field. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

Re: How much text in a db field is acceptable?

2006-09-05 Thread cyberco
Thanks for the pointer, but flatpages is not exactly what I am after. To be more specific: one of the fields in my model is a TextField that holds a maximum of 5000 characters. This means that each instance of the model (i.e. each row in the db table) potentially contains 5k characters. Is that to

How much text in a db field is acceptable?

2006-09-04 Thread cyberco
I'm new to database programming and I'm wondering if I should put around 1 page of plain text (<5000 characters) in a database or in files on the filesystem. Any suggestions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

which css files are loaded?

2006-09-01 Thread cyberco
I'm trying to learn how to use CSS in combination with Django (I owe a great deal to Jeff Croft for his LOST theories example site).Unfortunately I ran into the following problem. I am using a 'base.css' that loads other css files, e.g. @import url("homepage.css"); @import url("user.css"); Only

Re: Advice for Rusty Python Programmer and New Django Consumer

2006-08-30 Thread cyberco
Python quick reference (invaluable): http://rgruet.free.fr/PQR24/PQR2.4.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com T

Re: ManyToManyField not populated in form

2006-08-30 Thread cyberco
That works, great! So should I always use 'manipulator.flatten_data()' instead of 'obj.__dict__' for filling forms with existing values? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post

Re: ManyToManyField not populated in form

2006-08-30 Thread cyberco
I'm using manipulators. ==MODELS== class Pizza(models.Model): toppings = models.ManyToManyField(Topping) class Topping(models.Model): name = models.CharField(maxlength=100) === ==VIEW= errors = {} pizza = new_data = pizza.__di

Re: group traffic

2006-08-30 Thread cyberco
-1 Look at the list now, most posts are general Django questions that most users are interested in (at least at one point). Splitting them up would mean monitoring different lists for most of us. --~--~-~--~~~---~--~~ You received this message because you are subs

ManyToManyField not populated in form

2006-08-29 Thread cyberco
In a form for changing a model instance all fields get correctly filled with existing values except the ManyToManyField form fields (which renders as a choice list in a form). It shows the correct list of options, but none of the options is selected, even though the instance of the model should ha

Re: Limit view to group members: what function for the @user_passes_test decorator?

2006-08-29 Thread cyberco
Great! Thanks for the excellent reply. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send em

Limit view to group members: what function for the @user_passes_test decorator?

2006-08-27 Thread cyberco
I want to limit a view to certain group members, so I'm using the following decorator: @user_passes_test(lambda u: Group.objects.get(name='admin') in u.groups.all(), login_url='/accounts/login/') This seems a little verbose. Is there a better way? --~--~-~--~~~---~-

Re: Removing old permissions from auth_permission

2006-08-24 Thread cyberco
Anybody? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For m

Re: Passing user.is_superuser through form

2006-08-24 Thread cyberco
Sean: Thanks, man, that link saved my day (at least a few hours)! This should definitely be mentioned in the Django documentation asap. Scott: yup, and I can now just say follow = {'date_joined': False} instead of specifying both date_joined_date and date_joined_time by hand (as I described above

Re: Passing user.is_superuser through form

2006-08-24 Thread cyberco
OK, I got the dates working now that I've converted them to strings. But I can't set the value for the 'is_superuser' attribute using the same mechanism: ==VIEW== userManipulator = User.ChangeManipulator(request.user.id) origUser = userManipulator.original_object new_data_

Re: Passing user.is_superuser through form

2006-08-24 Thread cyberco
OK, I got the dates working now that I've converted them to strings. But I can't set the value for the 'is_superuser' attribute using the same mechanism: ==VIEW== userManipulator = User.ChangeManipulator(request.user.id) origUser = userManipulator.original_object new_data_

Re: Passing user.is_superuser through form

2006-08-24 Thread cyberco
What works is this: = new_data_user['date_joined_date'] = str(origUser.date_joined.date()) = Not sure if that is wise... cyberco wrote: > Besides, if I don't pass all attributes I have to set them manually. In > case of User.date_j

Re: Passing user.is_superuser through form

2006-08-24 Thread cyberco
Besides, if I don't pass all attributes I have to set them manually. In case of User.date_joined somehow none of the following works: = new_data_user['date_joined'] = origUser.date_joined new_data_user['date_joined_date'] = origUser.date_joined_date new_data_user['date_joined_

Re: Passing user.is_superuser through form

2006-08-24 Thread cyberco
Besides, if I don't pass all attributes I have to set them manually. In case of User.date_joined somehow none of the following works: = new_data_user['date_joined'] = origUser.date_joined new_data_user['date_joined_date'] = origUser.date_joined_date new_data_user['date_joined_

Re: Passing user.is_superuser through form

2006-08-23 Thread cyberco
Thanks to everyone here, this really helped me out. One thing I still have questions about it Eric's remark: > --- > Take note that, since the is_superuser is not a required field, iirc, > you don't have to set it in new_data if your intent leave the value the > same. > --- I indeed want to keep

Re: Passing user.is_superuser through form

2006-08-22 Thread cyberco
Max, I'm not sure I fully understand your reply. Currently I got things working by passing the user object to the template and returning its attribute values: Is this a security hole? --~--~-~--~~~---~--~~ You received this mes

Removing old permissions from auth_permission

2006-08-22 Thread cyberco
Once permissions are added to the auth_permission table it doesn't matter how often I invoke 'manage.py syncdb app' or 'manage.py reset app', stale records are never deleted. Is this normal behaviour? --~--~-~--~~~---~--~~ You received this message because you are

Image validation works only once

2006-08-22 Thread cyberco
In my model: = image = models.ImageField(upload_to='pics', validator_list=[validators.isValidImage], blank=True) = I am able to upload an image once using an appropriate form: = Image: {{form.image}}{{form.image_file}}

In a form: fill the ImageField with path

2006-08-22 Thread cyberco
In my form I want to enable users to change an image (ImageField), but although I can fill fields of other types with their existing values, this is not the case with an ImageField. How can I accomplish that? --~--~-~--~~~---~--~~ You received this message because

Passing user.is_superuser through form

2006-08-22 Thread cyberco
I want to pass the user.is_superuser attribute through a form without enabling the user to edit it, so I use a hidden field. Like this: TEMPLATE= = Weird enough this results in the following HTML: =HTML " /> = And when submit

FileField shows as instead of

2006-08-22 Thread cyberco
With the following model and template: ==MODEL videoFile = models.FileField (upload_to='videoupload', blank=True) ==TEMPLATE= Video File: {{form.videoFile}} {{form.videoFile_file}} The HTML output rende

Re: NULL for TextField

2006-08-22 Thread cyberco
Ah! Thanks for the tip. That didn't cross my mind. Learning all the time, I guess. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups

NULL for TextField

2006-08-21 Thread cyberco
Given the model: === myText = models.TextField(blank=True) === In case this TextField has no text I want to hide it from my form. Template code: === {% if form.myText.text %}

Re: Login not working: Site matching query does not exist.

2006-08-21 Thread cyberco
Thank you very much! That was indeed the issue. There was a site in the db, but apparently things were corrupt. Removing all sites and adding a new one via the admin interface solved the problem. Not sure if that is a bug or a feature :) Your query works as well (although 'domain' and 'name' shou

Re: Login not working: Site matching query does not exist.

2006-08-21 Thread cyberco
I'm still having this problem (neglected it for a while, but now is the time I MUST solve it). Has anybody here a suggestion in which direction to search? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django user

Re: 1062, "Duplicate entry '1' for key 2"

2006-08-16 Thread cyberco
I found the error. I was using the ipython shell to run 'run manage.py reset myapp' but unfortunatly things got cached. Running 'sqlreset' instead of 'reset' showed me that some old SQL was used, so updating the models didn't change the SQL. :( Restarting IPython fixed the problem. --~--~---

IPython shell caching SQL/models?

2006-08-16 Thread cyberco
I was using the ipython shell to run 'run manage.py reset myapp' (because I was using IPython anyway) but unfortunatly it seemed like IPython cached the models or SQL. Running 'sqlreset' instead of 'reset' showed me that some old SQL was used, so updating the models didn't change the SQL. that IPy

Re: 1062, "Duplicate entry '1' for key 2"

2006-08-15 Thread cyberco
Hmmmit turns out that the problem is with a ForeignKey. The example above (unfortunately) doesn't show it, but my model T also contains 2 ForeignKeys. The database (mysql) accepts the same value (in different rows) for one ForeignKey, but not for the other. That baffles me. I've tried everythi

Re: 1062, "Duplicate entry '1' for key 2"

2006-08-15 Thread cyberco
> Did you used to specify it in your model and then you removed it from > the Python code without altering the database table? Nope. I DID change the table (removed 'unique=True'), but I also altered the db tables (syncdb, reset app, dropped tables by hand). > Have you made any > other alteratio

1062, "Duplicate entry '1' for key 2"

2006-08-14 Thread cyberco
Somehow creating 2 instances of a model constantly gives me the following error: -- 1062, "Duplicate entry '1' for key 2" -- The code in the view method is: -- def new(request): t = T(userID=request.user.id) t.save() -- It seems that userID should be unique, but

Re: Shell not picking up db changes

2006-08-14 Thread cyberco
Wow, that does the trick! Thank you very much. I'm not exactly sure what this command does, though --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to djang

Re: Shell not picking up db changes

2006-08-14 Thread cyberco
Yes, but the disadvantage of using 'import x.y.z as mymodel' instead of 'import x.y.z'b is that instead of using a = A() I have to say a = mymodel.A(). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Re: Shell not picking up db changes

2006-08-13 Thread cyberco
I may have cheered to early: what if I don't use 'import as', but 'site.app.models import *'? If I do 'reload(models)' the Django models are reloaded, and doing 'reload(site.app.models)' throws an exception saying 'site' does not exist... --~--~-~--~~~---~--~~ You

Re: Shell not picking up db changes

2006-08-13 Thread cyberco
Ah! Thanks for the tip! I totally forgot about Python's reload method because my mind was on a 'db-track' all the time. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, se

Re: Chain filters on ManyToManyField

2006-08-13 Thread cyberco
Ai, really? I'm a n00b when it comes to SQL and the SQL statement of a chained filter (as listed by connection.queries) is about 8 (!) lines of SQL abacadabra. Sure there is no other way to solve this issue? Will the bug be fixed in the next release? --~--~-~--~~~---~

Shell not picking up db changes

2006-08-13 Thread cyberco
Using the ipython started from manage.py I noticed that changes to the db are not automatically picked up (added values for instance). I have to restart the shell to pick them up, which also means I have to reimport everything and I loose my shell history. Is there a way to pick up the changes w

Chain filters on ManyToManyField

2006-08-13 Thread cyberco
Having: ___ class Pizza(models.Model): name = models.TextField() toppings = models.ManyToManyField(Topping) class Topping(models.Model): name = models.TextField() ___ ...and for instance having toppings 'tomato' and 'cheese', how do I select all pizza's with

Re: Login not working: Site matching query does not exist.

2006-08-03 Thread cyberco
Is anybody else having this problem? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send emai

Re: Creating 2 linked models from one page

2006-08-03 Thread cyberco
OK, but what to do with the following in case of 2 models: === new_data = request.POST.copy() errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) == The complete method is: === def new(request): manipulato

Re: Creating 2 linked models from one page

2006-08-03 Thread cyberco
Yes, but I want only one 'submit' button on the html page. This means that the POST data goes to one 'view' method. How can I first create an instance of A and then an instance of B (with A's id) with the same POST data? --~--~-~--~~~---~--~~ You received this mes

Creating 2 linked models from one page

2006-08-03 Thread cyberco
I want to enable users to fill out two forms (textareas) on one page, where each form creates a new instance of a model/class. I have the 2 following models: class A(models.Model): text = models.TextField() class B(models.Model): a = models.ForeignKey(A) text

Login not working: Site matching query does not exist.

2006-08-01 Thread cyberco
Login a user out works fine, but I can't get logging in working (0.95). I keep getting 'Site matching query does not exist'. What I got: urls.py: (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'registration/login.html'}), (r'^accounts/logout/$', 'django.c

Re: file upload example?

2006-07-28 Thread cyberco
> use the ordinary addmanipulator example from the docs > remember that the fileinfo is in request.FILE and not request.POST > form type should be multipart/mime-encoded > > with these changes you are set Thanks, together with the example of the link I posted I got it working now. What I was afte

file upload example?

2006-07-28 Thread cyberco
I'm having troubles understanding the logic of uploading files. I saw a lot of code snippets, but nowhere I can find an example that explains all the steps. This article comes close but is lacking some info as well: http://blog.go4teams.com/?p=56 I hope somebody here has a pointer to a good examp

Re: have urlpatterns in urls.py changed?

2006-07-26 Thread cyberco
Found my error: the 'include' should be removed: (r'^proj/', 'proj.app.views.index), More about this can be read here: http://www.djangoproject.com/documentation/tutorial3/#decoupling-the-urlconfs --~--~-~--~~~---~--~~ You received this message because you are su

Re: have urlpatterns in urls.py changed?

2006-07-26 Thread cyberco
Found my error: the 'include' should be removed: (r'^proj/', 'proj.app.views.index), More about this can be read here: http://www.djangoproject.com/documentation/tutorial3/#decoupling-the-urlconfs --~--~-~--~~~---~--~~ You received this message because you are su

Re: have urlpatterns in urls.py changed?

2006-07-26 Thread cyberco
Oh yeah, and the exception is: Traceback (most recent call last): File "C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py" in get_response 65. callback, callback_args, callback_kwargs = resolver.resolve(path) File "C:\Python24\lib\site-pa

Re: have urlpatterns in urls.py changed?

2006-07-25 Thread cyberco
Oh yeah, and the exception is: == * C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py in get_response 58. for middleware_method in self._request_middleware: 59. response = middleware_method(request) 60. if response:

Re: have urlpatterns in urls.py changed?

2006-07-25 Thread cyberco
Anybody? What should go in urls.py if my project is called 'proj', my app 'app' and there is a method 'index' in views.py? I would say the following, but that doesn't work: (r'^proj/', include('proj.app.views.index)), Thanks any suggesting about what I'm doing wrong here?! --~--~-~--~-

have urlpatterns in urls.py changed?

2006-07-24 Thread cyberco
Using Django .95 I'm trying to create a simple view based on the examples in tutorial 3, but somehow things don't work. The syntax of the examples is also different than what's in urls.py. Is there any updated documentation somewhere? --~--~-~--~~~---~--~~ You rec

Exception adding a FileField

2006-07-24 Thread cyberco
I'm trying to add a FileField to one of my models, but I keep getting an exception whenever I try to open the admin page. The code is: class Test(models.Model): fileUploadField = models.FileField(upload_to='tmp/', core=True) The stacktrace is below. Tra

Re: IPython not default shell

2006-07-16 Thread cyberco
Sorry, I had an old version of Django installed which caused the problems. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To

IPython not default shell

2006-07-16 Thread cyberco
I've checked out the latest SVN version of Django, but when I try 'python manage.py shell' I get the standard shell, not IPython. But I have IPython installed on my computer. At the shell's command prompt I can just type 'import IPython' without a problem. I have IPython installed with readline, c