Re: __init__() got an unexpected keyword argument 'max_digits'
On Thu, 2007-06-28 at 12:06 -0700, adamjspooner wrote: > Hello all, > > I'm adding a DecimalField to a preexisting app: > > foo_bar = models.DecimalField(max_digits=5, decimal_places=2, > blank=True, null=True, default=0.0, unique=True) > > I've added a row in the table: > > foo_bar DECIMAL(5,2) UNI NULL; > > But when I try to syncdb or even validate the app I get: > > my_site.foo_bar: __init__() got an unexpected keyword argument > 'max_digits' > > I reversed all changes and still get the error. Is the error really coming from the line you indicate? You should see the same problem if you run "manage.py shell" and import that model. What does the full traceback say in the latter case? Reading the error messsage, it looks like you've left a FloatField in the code somewhere that still has the max_digits parameter being passed to its constructor (FloatField fields no longer take max_digits or decimal_places arguments). The only other thing I can think of is that somehow your source code is corrupted. Have a look in django/db/models/fields/__init__.py where the DecimalField class is defined. The __init__ method should look like this: def __init__(self, verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs): You can see that "max_digits" is certainly allowed there. Regards, Malcolm -- On the other hand, you have different fingers. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using newforms to create multiple related objects?
Hello, I am trying to use newforms and templates, together with the following models, to mimic what the admin application does with num_in_admin : provide a form for Person's fields, and multiple Phone forms. With just one Phone form things are quite straightforward: validate the Person form, and if that passes, save the object, get its ID, fill the ID field of the Phone object and then save it. With multiple Phone forms, however, I have not been able to customize the HTML IDs of the various fields -- form_for_model generates identical forms! One can modify form_for_model with a custom formfield_callback function, but as far as I can tell, it maps a field name to a field object, so it won't be enough to override that. Is there a way to do this sort of things cleanly, short of using the newforms-admin branch of Django? Or do I have to do something like changing the form's fields attribute by hand? Thanks, -- M. Sylvan class Person(models.Model): firstName = models.CharField(maxlength=32) lastName = models.CharField(maxlength=32) class Phone(models.Model): person = models.ForeignKey(Person) number = models.CharField(maxlength=24, core=True) --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Searching for strings and URLconfs
On Thu, 2007-06-28 at 18:46 +, Ryan K wrote: > Hi. I'm trying to setup an re pattern for /search in my URL conf. How > can I match an entire string like "red fox" e.g. > http://example.com/django/search/red%20fox? > I noticed that Google replaces their query parameter q's spaces with > '+'s using Javascript. Is that a better way to go? One way, based on your example, would be r'^/search/(?P.*)$' which captures everything up to the end of the line and will pass it to your view function as the "param" keyword argument. Regards, Malcolm -- Depression is merely anger without enthusiasm. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newforms makes unicode String from a dictonary
On Thu, 2007-06-28 at 17:57 +0300, Alexander Pugachev wrote: > I still have them as unicode strings in [5559] Then please file a ticket with a simple example showing how to repeat the problem so this doesn't get forgotten. I can't repeat this (I obviously tested the first attempt at a fix). Regards, Malcolm -- The early bird may get the worm, but the second mouse gets the cheese. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: One-to-one relationship (model inheritance) or generic relations?
On 6/28/07, Jamie Pittock <[EMAIL PROTECTED]> wrote: > > I don't want to code myself into a corner, so when I start looking at > features such as allowing users to search all venues would I be best > with one parent model or will I be ok keeping them separate? The > different types of venues have quite a number of different attributes > btw which is why they are different models rather than simply > categoried. Model inheritance sounds good on paper, but in practice, it gets somewhat inconvenient - lots of table joins to get at basic attributes, etc. If you have very few common attributes anyway, generic relations are probably worth investigation. However, as always, YMMV. My only reservation in recommending generic relations is that they aren't fully integrated with admin yet (though there is a patch floating around to integrate them with newforms-admin), and they're not fully documented. However, if you're willing to put up with those limitations, it sounds like they could be a good match for your needs. A third approach that you haven't mentioned is to have a single 'object' table that is sparse; i.e., instead of class Bar(Model): name = CharField() number_of_bartenders = IntegerField() class Club(Model): name = CharField() music_style = CharField() you have a single model that has all the fields: class Venue(Model): name = CharField() venuetype = CharField(choices=(('b','bar'),('c','club')) number_of_bartenders = IntegerField(null=True) music_style = CharField(null=True) This way you spend a little more time in data validation (making sure that you have all the columns that you need for any given row), and you waste a little space in the database, but lookups will be a little faster (as no joins are required). Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin for Table of Foreign Keys
On 6/28/07, JimR <[EMAIL PROTECTED]> wrote: > > below. When I include the 'def __str__(self)' it displays the user id > in the admin interface, but when I access the record I get an error > "__str__ returned non-string (type Userid)" The error message is telling you the exact problem. Your __str__ defintion: > def __str__(self): > return self.user_id Is not returning a string. self.user_id is not a string, it is an integer. If you change this to return a string, the error will go away. You have a number of options. any of the following would work: return str(self.user_id) # Return the user ID number as a string return str(self.user) # Return the stringified version of the user return self.user.username # Return the users username, which is a string. There are many other alternatives - it just depends what you want to display. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Variables available to all templates
Take a look at this: http://www.djangoproject.com/documentation/authentication/#authentication-data-in-templates You can use this to put something in a base template that all your site templates can be based on. Derek --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Variables available to all templates
Do you want to show the user all your content without authentication? Why not just use @login_required decorator to have then login when needed? Below are the commands you need. from django.contrib.auth.decorators import login_required @login_required def myfunction(request): # do stuff Vincent On 6/28/07 4:51 PM, "Kirk Strauser" <[EMAIL PROTECTED]> wrote: > > Is there a list of variables that all templates can access? I'm > asking out of general interest, but the problem I'm trying to solve is > that I want to have a "login" or "logout" link on every page of the > site, depending on whether a visitor is currently authenticated, and I > don't want to have to pass in { 'username': request.user.username } in > every single view. Is there a django-ish way to do this? > > > > -- Vincent R. Nijs Assistant Professor of Marketing Kellogg School of Management, Northwestern University 2001 Sheridan Road, Evanston, IL 60208-2001 Phone: +1-847-491-4574 Fax: +1-847-491-2498 E-mail: [EMAIL PROTECTED] Skype: vincentnijs --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django authorization of apache
Look at the FastCgiAuthenticator directive for mod_fastcgi module. The FASTCGI protocol does have mechanisms for allowing backend process to do the authentication, but have no idea how it used or whether it would work. Graham On Jun 29, 12:13 am, Robin Becker <[EMAIL PROTECTED]> wrote: > I see from this documentation > > http://www.djangoproject.com/documentation/apache_auth/#configuring-a... > > that it is conceptually possible to configure apache authorization using > django. > > However, we have recently decided to de-couple django frommod_pythonby using > fastcgi. This is because we wish to allow our django apps to use which ever > python might be appropriate and not restrict to the one for which we have > compiled apache+mod_python. > > Is there any way to havemod_pythonstuck on Python-2.4 with the controlling > django app use Python-2.5 and do configuration for apache. The only way I can > think of is to create a stub project which runs the auth only. > > I know that theoretically we can advance the apache, but that implies > re-installing wikis etc etc etc and when Python-2.6 comes out and the boss > wants > to use new feature X we'll go through the whole process again. > > Alternatively is there a way to do the reverse ie get django to use a database > controlled by apache? > -- > Robin Becker --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Variables available to all templates
Is there a list of variables that all templates can access? I'm asking out of general interest, but the problem I'm trying to solve is that I want to have a "login" or "logout" link on every page of the site, depending on whether a visitor is currently authenticated, and I don't want to have to pass in { 'username': request.user.username } in every single view. Is there a django-ish way to do this? --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
crosstabs
I've recently deployed my first non-trivial (by my standards) world accessible django app. Its not perfect. However, there comes a point when you just have to get'er done, and so it is. I bugged a lot of people on #django and got some good feedback, but just couldn't communicate my question well enough without a visual. So here it is: http://webapps.ubuntu.com/course_locator/ Click on Canada, and see what would ideally be a cross tab. The problem is, I'd like to have the event dates for training events for the same course in the same town on the same row (notice that several rows there differ only in the fact that the training date is in August instead of July). I know how to do this in SQL just fine, but as I've found, the SQL way is not always the ideal way in Django. I'm happy to share my model and view code, but just imagine a non- normalized, ultra-simple model, and that's what I've done. (two models, Partners and Events) The end goal is to display all events in the next three months for a given country. Can anyone share some suggestions on how to get a cross tab the Django way? --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: AttributeError: 'bool' object has no attribute 'get'
thanks James! i just applied the fix manually since it was so small, and it did the trick. i'm sure looking forward to multi-db catching up to trunk... :) On Jun 28, 3:41 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 6/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > i'm using 0.96pre, the multi-db branch. > > The bug was in the oldforms system, and has been fixed in trunk and in > the older releases we maintain support for; the multi-db branch went > stagnant for a long time, and is only now being picked up by a > maintainer again, so you'll want to either: > > A) Hold on until multi-db is synced up with the bugfixes in trunk, or > > B) Look at Django changeset 4676[1] and apply the changes there to > your copy of multi-db. > > [1]http://code.djangoproject.com/changeset/4676 > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: AttributeError: 'bool' object has no attribute 'get'
On 6/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > i'm using 0.96pre, the multi-db branch. The bug was in the oldforms system, and has been fixed in trunk and in the older releases we maintain support for; the multi-db branch went stagnant for a long time, and is only now being picked up by a maintainer again, so you'll want to either: A) Hold on until multi-db is synced up with the bugfixes in trunk, or B) Look at Django changeset 4676[1] and apply the changes there to your copy of multi-db. [1] http://code.djangoproject.com/changeset/4676 -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Searching for strings and URLconfs
Note - I know that I am not using a parameter and it's much easier to do that (I was searching without having created the form yet so this slipped my mind). But how would you capture something like "red fox" in a URLconf pattern? On Jun 28, 2:46 pm, Ryan K <[EMAIL PROTECTED]> wrote: > Hi. I'm trying to setup an re pattern for /search in my URL conf. How > can I match an entire string like "red fox" > e.g.http://example.com/django/search/red%20fox? > I noticed that Google replaces their query parameter q's spaces with > '+'s using Javascript. Is that a better way to go? > > 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
AttributeError: 'bool' object has no attribute 'get'
see http://dpaste.com/13161/ the error pops up when i try to edit a single User in the admin interface. when i remove those two lines i marked in the second model, it works ok. i'm using 0.96pre, the multi-db branch. i hope you can help! thanks in advance. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Password Logistics Help Needed
I wrote a quick off-list reply to this last night, but thought it might be worth pointing out parts of it publicly as well so anyone who searches the archives with similar problems will spot this: 1. Django does still support plain old unsalted md5 passwords for login (for backwards compatibility reasons), but the first time a user successfully logs in it'll be transparently converted and re-stored as a salted SHA1. Disabling that is a minor change in Django's auth code, and is one approach. 2. But a better approach would probably be a custom auth backend; this would let you continue to use all the features of Django's authentication system, while checking credentials directly against the legacy database for maximum compatibility. Auth backends aren't terribly hard to write, and the documentation makes it pretty clear what needs to be done: http://www.djangoproject.com/documentation/authentication/#other-authentication-sources -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django authorization of apache
Robin Becker wrote on 06/28/07 19:44: > Steven Armstrong wrote: >> Robin Becker wrote on 06/28/07 16:13: >>> I see from this documentation >>> >>> http://www.djangoproject.com/documentation/apache_auth/#configuring-apache >>> >>> that it is conceptually possible to configure apache authorization using >>> django. >>> >>> However, we have recently decided to de-couple django from mod_python by >>> using >>> fastcgi. This is because we wish to allow our django apps to use which ever >>> python might be appropriate and not restrict to the one for which we have >>> compiled apache+mod_python. >>> >>> Is there any way to have mod_python stuck on Python-2.4 with the >>> controlling >>> django app use Python-2.5 and do configuration for apache. The only way I >>> can >>> think of is to create a stub project which runs the auth only. >>> >>> I know that theoretically we can advance the apache, but that implies >>> re-installing wikis etc etc etc and when Python-2.6 comes out and the boss >>> wants >>> to use new feature X we'll go through the whole process again. >>> >>> Alternatively is there a way to do the reverse ie get django to use a >>> database >>> controlled by apache? >> You could directly access the database using something like >> mod_auth_mysql or the like. But the way django stores passwords may be a >> problem. > yes it seems harder than setting up a dummy project. > > On the other hand our current scheme uses require group xxx and I cannot seem > to > get validation done that way. > > I have this in a .htaccess file > > AuthType basic > AuthName "djauth test" > Require valid-user > Require group XXX > SetEnv DJANGO_SETTINGS_MODULE djauth.settings > PythonOption DJANGO_SETTINGS_MODULE djauth.settings > PythonAuthenHandler django.contrib.auth.handlers.modpython > > > I see the request for a user, but the validation seems to ignore the Require > Group clause entirely. I don't think the 'Require group' stuff will work. Guess you'll have to write your own auth handler based on django.contrib.auth.handlers.modpython. You could then pass the groups, or whatever else you need, to the handler using PythonOption directives. e.g. AuthType basic AuthName "djauth test" Require valid-user SetEnv DJANGO_SETTINGS_MODULE djauth.settings PythonOption DjangoGroups XXX group2 group3 PythonAuthenHandler path.to.my.auth.handler Have a look at django.contrib.auth.handlers.modpython. Should be easy to do. Good luck. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
__init__() got an unexpected keyword argument 'max_digits'
Hello all, I'm adding a DecimalField to a preexisting app: foo_bar = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, default=0.0, unique=True) I've added a row in the table: foo_bar DECIMAL(5,2) UNI NULL; But when I try to syncdb or even validate the app I get: my_site.foo_bar: __init__() got an unexpected keyword argument 'max_digits' I reversed all changes and still get the error. Any help is greatly appreciated! Adam --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Announcing the birth of Fluther.com
Thanks for the compliments, Leif! We're running a LAMP VPS (currently with ServerAxis). We use memcache (right now our traffic doesn't warrant mutliple servers or squid). We use the built-in django default user paired with a custom userprofile as detailed in the b-list article. Thanks for looking at the site! On Jun 27, 5:51 pm, leif strickland <[EMAIL PROTECTED]> wrote: > Looks great. Good work! > > For those of us still stuck in alpha, can you share a bit about your > implementation? Are you using Apache? Squid? What's your approach to > caching? Did you use Django's built-in User model for your registered > site users? What DB did you opt for? > > Any information would be a great help to all the Django newbies. Plus, > you might get some valuable feedback from the pros on this board. > > Again, congrats! --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Searching for strings and URLconfs
Hi. I'm trying to setup an re pattern for /search in my URL conf. How can I match an entire string like "red fox" e.g. http://example.com/django/search/red%20fox? I noticed that Google replaces their query parameter q's spaces with '+'s using Javascript. Is that a better way to go? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: nasa site on django
On 6/28/07, Vance Dubberly <[EMAIL PROTECTED]> wrote: > Django suffers from running under mod_python in > a prefork environment where every process loads a full copy of django. So > as I'm sure you can imagine RAM gets chewed up very quickly. Are you running Django behind a load balancer like Perlbal or nginx? One side-effect of propper LB is that you can drastically lower MaxClients (because each backend client spends less time serving a request). Look up "spoonfeeding" for more about this problem. Even if you've only got a single web server you should always use Perlbal or friends. Jacob --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
RE: test client login problems
> > Ahhh. So after I've used login() once in a test, get() will pass the > > existing session cookie, in which case my test to retrieve two pages > while > > logged in would look like : > > client.login(...) > > client.get(...) > > Does that sound right ? I'll try that later today. > > Sounds like you have the idea. And for the record, that was indeed the answer. I effectively had to replace my second (and subsequent) call to login() (within the one test case) with a call to get(). An alternative is to split them into separate test cases, of course. Thanks for the help ! Chris --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: nasa site on django
On 6/28/07, Vance Dubberly <[EMAIL PROTECTED]> wrote: > However resource intensity is a very big deal. RAM is a huge factor > here. Thanks for clearing up the issue. It's true that the process-per-request model is heavier in terms of RAM than alternatives, but it's generally fast. Maybe your available processes are bottlenecking on something that could be addressed. See here for an example of what you should expect: http://www.davidcramer.net/curse/44/what-powers-curse.html http://www.davidcramer.net/other/43/rapid-development-serving-50-pageshour.html They did make some changes to django for their specific need, but they're not too exotic, and I doubt you're pushing that hard. For more common performance tuning, have a look here: http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/ In particular, make sure KeepAlive is off for the django domain and serve media with something lighter than apache. ... > Frankly I think a generic python application server similar to tomcat > would do a world of good for python apps in general. Something similar to > cherrypy... but this is beyond the responsibilities of the django community > which have plenty great work left. Similar to CherryPy but not it? How come? In any case, if you're thinking this way, consider Aspen/Stephane: http://www.zetadev.com/software/aspen/ It appears to be thread-per-request. I haven't used it, but Chad's been specifically trying to gain acceptance w/ the Django community; I'm sure your interest would be appreciated. > I really wish I could talk more about this provide actual benchmarks At least you've described, roughly, your beef. I still think you should be in the same ballpark, but I'm not even sure what you're measuring. Cheers, Jeremy --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms, form.save(), and getting the object I just saved
Yup, I'm suing form_for_model. I guess when I assigned it to foo (foo=form.save()), then I was really assigning the returned object to foo and that's how I can reference what I want from foo. On Jun 28, 10:00 am, Doug B <[EMAIL PROTECTED]> wrote: > If you are using the helper functions like form_for_model, form.save() > should return the saved object. The helper functions build the save > method for you based on the model definition. If you are doing custom > forms, it's up to you to make the form.save() method to handle the > form->model mappings, call save, and return the saved object. You > could also skip form.save() and simply create the object from the > form.clean_data dict in the view. When you call object.save() it will > get an id. I prefer sticking that stuff in form.save(). --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: nasa site on django
Jeremy, I don't know about Java vs Python speeds. I've little doubt Java is alot faster if for no other reason than the amount of resources Sun puts behind it. However resource intensity is a very big deal. RAM is a huge factor here. The Tomcat App was running in a VM limited 256 meg and serving roughly 8x the number of requests. Django suffers from running under mod_python in a prefork environment where every process loads a full copy of django. So as I'm sure you can imagine RAM gets chewed up very quickly. I've not read good things about running django in fastcgi so we've not tried that, frankly I don't trust fastcgi. As for optimizations neither version of the app has any to speak of. Just get me x,y and z from the database and push it into a page. No caching, although we'll be adding memcached in the near future in an attempt to recover some speed ( at the cost of RAM ). Frankly I think a generic python application server similar to tomcat would do a world of good for python apps in general. Something similar to cherrypy... but this is beyond the responsibilities of the django community which have plenty great work left. I really wish I could talk more about this provide actual benchmarks and server info and code example... unfortunately, GOVERNMENT should pretty well some up why I can't and getting this licensed under NOSA takes longer than the little bit of code written to do this is really worth. Vance On 6/27/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > > > On 6/27/07, Vance Dubberly <[EMAIL PROTECTED]> wrote: > ... > > ball of red tape but let's just say django is ALOT more resource > intensive > > and ALOT slower. > > Have you done any profiling? I haven't compared such a port, but I'd > be surprised if performance is significantly (i.e. one order) > different without some optimization being missed. > > If you have, can you point to any parts of Django that we could improve? > > As presented, there's not much actionable. "Java is faster than > Python" is not news, but I doubt the language is the problem here. > > Thanks! > > > > -- To pretend, I actually do the thing: I have therefore only pretended to pretend. - Jacques Derrida --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django authorization of apache
Steven Armstrong wrote: > Robin Becker wrote on 06/28/07 16:13: >> I see from this documentation >> >> http://www.djangoproject.com/documentation/apache_auth/#configuring-apache >> >> that it is conceptually possible to configure apache authorization using >> django. >> >> However, we have recently decided to de-couple django from mod_python by >> using >> fastcgi. This is because we wish to allow our django apps to use which ever >> python might be appropriate and not restrict to the one for which we have >> compiled apache+mod_python. >> >> Is there any way to have mod_python stuck on Python-2.4 with the controlling >> django app use Python-2.5 and do configuration for apache. The only way I >> can >> think of is to create a stub project which runs the auth only. >> >> I know that theoretically we can advance the apache, but that implies >> re-installing wikis etc etc etc and when Python-2.6 comes out and the boss >> wants >> to use new feature X we'll go through the whole process again. >> >> Alternatively is there a way to do the reverse ie get django to use a >> database >> controlled by apache? > > You could directly access the database using something like > mod_auth_mysql or the like. But the way django stores passwords may be a > problem. yes it seems harder than setting up a dummy project. On the other hand our current scheme uses require group xxx and I cannot seem to get validation done that way. I have this in a .htaccess file AuthType basic AuthName "djauth test" Require valid-user Require group XXX SetEnv DJANGO_SETTINGS_MODULE djauth.settings PythonOption DJANGO_SETTINGS_MODULE djauth.settings PythonAuthenHandler django.contrib.auth.handlers.modpython I see the request for a user, but the validation seems to ignore the Require Group clause entirely. -- Robin Becker --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django is great, but where are the coders at
I'm a technical recruiter, but I also just love technology. I like to get involved with companies doing interesting things especially with open source. The problem is it's hard to find people that work with those technologies. I'm currently working with a cutting edge Internet Marketing and Web Development company in San Diego that is looking for 3 contract web developers (see skill set below). They are looking to have these developers start in July and work on contract for 1-2 months. 20-40 hours a week; flexible schedule; some off-site possible but have to be located in SD. They are also interested in permanent employees with these skills. If anyone is interested, knows where I can find people, or knows other resources I could tap please let me know. Thanks, Matthew Haver Technical Staffing Manager Kaizen Staffing - "Continuous Improvement" 858-866-2632 - Direct Line 800-691-3075 x2632 - Toll Free 775-330-2359 - Fax [EMAIL PROTECTED] www.kaizenstaffing.com www.payrolling.com www.linkedin.com/in/matthewhaveratkaizenstaffing Desired Skill Set: Python in Django frame work (this is the primary skill set) or CakePHP PostgreSQL or MySQL SQL Linux Subversion Data Caching Optimizing web apps for high traffic. If you are interested please email me a word formatted version of your resume. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: nasa site on django
No dynamically assembling the pages via django is faster than serving static files off disk with Apache. Vance On 6/27/07, KpoH <[EMAIL PROTECTED]> wrote: > > > I don't understand. Static files served by django? > > Vance Dubberly wrote: > > Moved http://opensource.arc.nasa.gov to django a couple of weeks ago. > > Thought ya'll might want to know that. > > > > Also thought you might want to know the site was running on > > Tomcat/Mysql and the performance difference is mind blowing. > > Unfortunately the actual server specs and benchmarks can't be released > > without going through a nasty ball of red tape but let's just say > > django is ALOT more resource intensive and ALOT slower. > > > > On the plus side it is faster than a similar PHP app ( with APC ) and > > faster than serving static files. > > > > -- > > To pretend, I actually do the thing: I have therefore only pretended > > to pretend. > > - Jacques Derrida > > -- > Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L. > http://www.asterisksupport.ru > http://www.asterisk-support.com > > > > > -- To pretend, I actually do the thing: I have therefore only pretended to pretend. - Jacques Derrida --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: nasa site on django
Kai, Very very untrue. RAM is much faster than Disk IO. Dynamically assembling a page from query results cached in database memory is far faster than going to disk. Caching the rendered page via memcached, squid, or even in a database table is so much faster than serving static disk bound files it'll make your router cry out for mercy. Vance On 6/27/07, Kai Kuehne <[EMAIL PROTECTED]> wrote: > > > Hi, > > > Vance Dubberly wrote: > > > On the plus side it is faster than a similar PHP app ( with APC ) and > > > faster than serving static files. > > Afaik, dynamic things _can't be_ faster than static things. > > Kai > > > > -- To pretend, I actually do the thing: I have therefore only pretended to pretend. - Jacques Derrida --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newbie Question - How do I get my burger and fries from BK and not Mickey D's?
I may not totally understand what you are suggesting here - I can use javascript to manipulate the data that's already on the page, but I want to filter the choices displayed to me using information that I have to get out of the database...will put js on that particular admin page do the trick? On Jun 24, 10:41 pm, Kent Johnson <[EMAIL PROTECTED]> wrote: > Wileywrote: > > Dirk, > > > Thanks for your comment! I simplified my use case for the sake of > > clarity, but in my actual application it does make sense to have > > Dishes and Restaurants to be many-to-many. Does anyone have any > > insight as to my original question? Can the choices of dish be > > narrowed to only dishes at a particular Restaurant somehow using the > > Admin class or other magic? > > I have done a lot of customization of the Admin interface with > JavaScript. Use the js attribute of the Admin nested class of your model > to include JavaScript in the change form. Then attach whatever behaviour > you want to the form elements. > > Personally I find jQuery very helpful with this but you can use a > different JS library or write it all yourself. > > Kent --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Customize change_list using a filter
If you want to use the admin page, you can add the following into your model class. class Admin: list_display('cars') list_filter = ('cars') If you want to create a custom page outside of admin then it is a little more difficult (for me at least :) ). I made a page like that last week. I can send you the code if you are interested. Best, Vincent ~ On 6/28/07 9:43 AM, "Diego" <[EMAIL PROTECTED]> wrote: > > Hi, I'm using the admin interface, I need use a change_list.html > filtered. > Example: > Show only Ford cars > Any ideas to do that?? > > Regards > > > > -- Vincent R. Nijs Assistant Professor of Marketing Kellogg School of Management, Northwestern University 2001 Sheridan Road, Evanston, IL 60208-2001 Phone: +1-847-491-4574 Fax: +1-847-491-2498 E-mail: [EMAIL PROTECTED] Skype: vincentnijs --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can't run Django. Getting error message about no module named _md5
Python 2.5 uses hashlib and no longer has a module "md5". There's at least 1 patch dealing with this for users and passwords: http://code.djangoproject.com/ticket/3604 Though the "_md5" doesn't seem right either. -Rob On Jun 27, 6:58 am, jeffself <[EMAIL PROTECTED]> wrote: > Just updated Django to latest version. I'm running it on a Mac Book > Pro with Python 2.5.1 from the MacPorts packaging system. When I run > 'python manage.py runserver', I get the following error: > > ImportError: No module named _md5 > > I have a feeling this may be more of a python problem than Django, but > I thought I'd ask around here. Maybe someone here has encountered > this. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Re-rendering same page
On 6/28/07, Doug B <[EMAIL PROTECTED]> wrote: > > Are you sure the request is actually being made, and not ignored by > the browser? If you do GETs to the same url with the same parameters If you do requests that have side effects, you shouldn't be using GET. Consider POST. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: nasa site on django
On 6/27/07, Vance Dubberly <[EMAIL PROTECTED]> wrote: > Moved http://opensource.arc.nasa.gov to django a couple of weeks ago. > Thought ya'll might want to know that. Congrats :) > Also thought you might want to know the site was running on Tomcat/Mysql and > the performance difference is mind blowing. Unfortunately the actual > server specs and benchmarks can't be released without going through a nasty > ball of red tape but let's just say django is ALOT more resource intensive > and ALOT slower. I (and many others, I'm sure) would love to help, but without details it's basically impossible. Tuning hardware for Java is a great deal different than tuning it for LAMPish stuff like Django. Like Jeremy, though, I'd suspect a software problem: most code ported from one language to another suffers the idioms of the old language. Python isn't Java, but if you've coding like it is you're gonna have issues. If you can/want to share any additional details, we can try to help you out. Jacob --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Re-rendering same page
Are you sure the request is actually being made, and not ignored by the browser? If you do GETs to the same url with the same parameters (your boolean I assume) the browser will simply ignore the request. I ran into that trying to do some ajax stuff, and ended up appending a timestamp number as an additional parameter to force the GET. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms, form.save(), and getting the object I just saved
If you are using the helper functions like form_for_model, form.save() should return the saved object. The helper functions build the save method for you based on the model definition. If you are doing custom forms, it's up to you to make the form.save() method to handle the form->model mappings, call save, and return the saved object. You could also skip form.save() and simply create the object from the form.clean_data dict in the view. When you call object.save() it will get an id. I prefer sticking that stuff in form.save(). --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newforms makes unicode String from a dictonary
I still have them as unicode strings in [5559] 2007/6/11, Malcolm Tredinnick <[EMAIL PROTECTED]>: > > > On Mon, 2007-06-11 at 11:39 +, Christian Schmidt wrote: > > I use at this time the ugly version with eval(). I really don't know > > how ugly it is. Can I have problems if there is python code or > > something else in the uploaded file? > > What is the best solution for me until this is fixed? > > With any luck, this should now be fixed in [5464]. > > There are still some things to sort with file upload fields in newforms, > but that's true on trunk as well as unicode. The above change just means > you can do > > data = request.POST.copy() > data.update(request.FILES) > > and the FILES dictionary won't be incorrectly converted to a string (it > will still be a dictionary, as expected). That fixed oldforms behaviour, > for a start. > > Regards, > Malcolm > > > > > > --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms, form.save(), and getting the object I just saved
Nevermind. I just needed to have foo = form.save(), and then I can access foo. On Jun 28, 8:37 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Using newforms, I do form.save(), and then need to get the object I > just saved. How can I do this? > > Here's the flow: > > User submits form. If valid, it's saved, and I need to take them to a > review page. At this point, the object has an "active" boolean set to > false. > > The review page needs a paypal form built, which is where I get into > needing the object (or at the very least, its ID). > > The paypal form will send them along for payment processing, passing > along a return URL, something like /object/id/ > > When it returns to that URL, I'll switch the active field to True. > > But as near as I can tell, to build the review page I'm going to need > to know the object I've saved. Complicating matters, if I try to do > anything other than ResponseRedirect after the save, I throw an error. > I know why, but in my case, with the status set to inactive, > duplicates aren't too much of a concern. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin for Table of Foreign Keys
I have a table that consists entirely of foreign keys. I'd like to display the User Id (and possibly retrieve and display the person's name from another table?) in the admin interface. The model is below. When I include the 'def __str__(self)' it displays the user id in the admin interface, but when I access the record I get an error "__str__ returned non-string (type Userid)". When I exclude the statement I can access the individual record by I get a generic "CYORegistrationRecord object" as the record description. Any help would be appreciated. Thanks, Jim class CYORegistrationRecord(models.Model): user_id = models.ForeignKey(Userid, raw_id_admin=True,) parish = models.ForeignKey(Parish, raw_id_admin=True,) school = models.ForeignKey(School, raw_id_admin=True,) cyo_name = models.ForeignKey(CYOName, raw_id_admin=True) grade = models.CharField(maxlength=15, choices=Grade_Choices) sport = models.ForeignKey(Activities, raw_id_admin=True,) cyo_year = models.CharField(maxlength=9) parental_participate = models.ManyToManyField(ParentHelp, raw_id_admin=True,) medical_considerations = models.TextField(maxlength=200) liability_waiver = models.BooleanField(default=False) affidavit = models.BooleanField(default=False) conduct = models.BooleanField(default=False) created_at = models.DateTimeField(default=datetime.now) updated_at = models.DateTimeField(default=datetime.now) def __repr__(self): return self.get_user_id().__repr__() def __str__(self): return self.user_id class Admin: pass class Meta: db_table = 'CYOreg' verbose_name = 'CYO Registration' --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Customize change_list using a filter
Hi, I'm using the admin interface, I need use a change_list.html filtered. Example: Show only Ford cars Any ideas to do that?? Regards --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
db backed dynamic forms
Hi all, Been reading this group for a while, decided to give an idea for dynamic forms a try after reading the article on dynamicmodels http://code.djangoproject.com/wiki/DynamicModels I cooked up a some models and a view see: http://statix.net/dynaform if one creates a form with some info and a field (type=CharField, maxlength=40) and views it http://somedomain.lan/forms/1, it will render the form At the moment Im not doing anything with the submitted data, but I'm thinking of emailing the output or inserting it in a database. I have no use for it, so i thought I'd share it, maybe anyone else can use it :) --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django authorization of apache
Robin Becker wrote on 06/28/07 16:13: > I see from this documentation > > http://www.djangoproject.com/documentation/apache_auth/#configuring-apache > > that it is conceptually possible to configure apache authorization using > django. > > However, we have recently decided to de-couple django from mod_python by > using > fastcgi. This is because we wish to allow our django apps to use which ever > python might be appropriate and not restrict to the one for which we have > compiled apache+mod_python. > > Is there any way to have mod_python stuck on Python-2.4 with the controlling > django app use Python-2.5 and do configuration for apache. The only way I can > think of is to create a stub project which runs the auth only. > > I know that theoretically we can advance the apache, but that implies > re-installing wikis etc etc etc and when Python-2.6 comes out and the boss > wants > to use new feature X we'll go through the whole process again. > > Alternatively is there a way to do the reverse ie get django to use a > database > controlled by apache? You could directly access the database using something like mod_auth_mysql or the like. But the way django stores passwords may be a 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 email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django authorization of apache
I see from this documentation http://www.djangoproject.com/documentation/apache_auth/#configuring-apache that it is conceptually possible to configure apache authorization using django. However, we have recently decided to de-couple django from mod_python by using fastcgi. This is because we wish to allow our django apps to use which ever python might be appropriate and not restrict to the one for which we have compiled apache+mod_python. Is there any way to have mod_python stuck on Python-2.4 with the controlling django app use Python-2.5 and do configuration for apache. The only way I can think of is to create a stub project which runs the auth only. I know that theoretically we can advance the apache, but that implies re-installing wikis etc etc etc and when Python-2.6 comes out and the boss wants to use new feature X we'll go through the whole process again. Alternatively is there a way to do the reverse ie get django to use a database controlled by apache? -- Robin Becker --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'retrieve': the missing permission?
2007/6/28, David Larlet <[EMAIL PROTECTED]>: > 2007/6/26, David Larlet <[EMAIL PROTECTED]>: > > 2007/6/22, Chris Brand <[EMAIL PROTECTED]>: > > > > > > > > I just wonder why this permission is not part of the default > > > > > permissions (like add, change and delete)? > > > > > > > > > > David > > > > > > > > > No more thoughts about that? I'm really surprised that it only happens > > > > to me, maybe I will be luckier on the users' mailing-list? > > > > > > Chapter 18 of the Django book > > > (http://www.djangobook.com/en/beta/chapter18/) > > > says this : > > > " For instance, although the admin is quite useful for reviewing data (see > > > above), it's not designed with that purpose as a goal: note the lack of a > > > "can view" permission (see Chapter 12). Django assumes that if people are > > > allowed to view content in the admin, they're also allowed to edit it." > > > > You're absolutely right, I miss that page. Thanks for the reminder. > > > > Eventually (for the record), if someone want to do the same without > breaking his django installation, just drop this management.py in one > of your app directory and syncdb. > Grrr, GMail didn't update attachments... try this more elegant version. David --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~--- """ Creates retrieve permissions for all installed apps that need permissions. """ from django.dispatch import dispatcher from django.db.models import get_models, signals from django.contrib.auth.management import _get_permission_codename def create_retrieve_permissions(app, created_models, verbosity): from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import Permission app_models = get_models(app) if not app_models: return for klass in app_models: ctype = ContentType.objects.get_for_model(klass) codename = _get_permission_codename('retrieve', klass._meta) name = 'Can %s %s' % ('retrieve', klass._meta.verbose_name) p, created = Permission.objects.get_or_create(codename=codename, content_type__pk=ctype.id, defaults={'name': name, 'content_type': ctype}) if created and verbosity >= 2: print "Adding permission '%s'" % p dispatcher.connect(create_retrieve_permissions, signal=signals.post_syncdb)
Re: 'retrieve': the missing permission?
2007/6/26, David Larlet <[EMAIL PROTECTED]>: > 2007/6/22, Chris Brand <[EMAIL PROTECTED]>: > > > > > > I just wonder why this permission is not part of the default > > > > permissions (like add, change and delete)? > > > > > > > > David > > > > > > > No more thoughts about that? I'm really surprised that it only happens > > > to me, maybe I will be luckier on the users' mailing-list? > > > > Chapter 18 of the Django book (http://www.djangobook.com/en/beta/chapter18/) > > says this : > > " For instance, although the admin is quite useful for reviewing data (see > > above), it's not designed with that purpose as a goal: note the lack of a > > "can view" permission (see Chapter 12). Django assumes that if people are > > allowed to view content in the admin, they're also allowed to edit it." > > You're absolutely right, I miss that page. Thanks for the reminder. > Eventually (for the record), if someone want to do the same without breaking his django installation, just drop this management.py in one of your app directory and syncdb. David --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~--- """ Creates retrieve permission for all installed apps that need permissions. """ from django.dispatch import dispatcher from django.db.models import get_models, signals from django.contrib.auth import models as auth_app from django.contrib.auth.management import _get_permission_codename def _get_all_permissions(opts): "Returns (codename, name) for all permissions in the given opts." perms = [] for action in ('retrieve',): perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name))) return perms def create_permissions(app, created_models, verbosity): from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import Permission app_models = get_models(app) if not app_models: return for klass in app_models: ctype = ContentType.objects.get_for_model(klass) for codename, name in _get_all_permissions(klass._meta): p, created = Permission.objects.get_or_create(codename=codename, content_type__pk=ctype.id, defaults={'name': name, 'content_type': ctype}) if created and verbosity >= 2: print "Adding permission '%s'" % p dispatcher.connect(create_permissions, signal=signals.post_syncdb)
newforms, form.save(), and getting the object I just saved
Using newforms, I do form.save(), and then need to get the object I just saved. How can I do this? Here's the flow: User submits form. If valid, it's saved, and I need to take them to a review page. At this point, the object has an "active" boolean set to false. The review page needs a paypal form built, which is where I get into needing the object (or at the very least, its ID). The paypal form will send them along for payment processing, passing along a return URL, something like /object/id/ When it returns to that URL, I'll switch the active field to True. But as near as I can tell, to build the review page I'm going to need to know the object I've saved. Complicating matters, if I try to do anything other than ResponseRedirect after the save, I throw an error. I know why, but in my case, with the status set to inactive, duplicates aren't too much of a concern. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: pydoc problem
On Jun 28, 12:31 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2007-06-27 at 18:58 -0700, dailer wrote: > > I have a models.py module that I thought I would test pydoc on. So I > > try. > > > $ python manage.py shell > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit > > (Intel)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > (InteractiveConsole) > > >>> from mysite.models import * > > >>> help(Merchant) > > Help on class Merchant in module mysite.models: > > > Merchant = > > Looks like this is the default result for Model subclasses. Possibly > related to the way we create them (using a metaclass). Feel free to work > out a patch in django/db/models/base.py (in the ModelBase class, > probably) if you want to fix this. It would probably be useful. > > Otherwise, might be worth opening a ticket in case somebody else is > looking for something to do. > > > but this isn't the doc string I have for this class at all and isn't > > what you normally get from pydoc. I try a few more of the classes with > > the same result. So I copy one of those classes to a new class in the > > same module (just adding the number 2 to the name) and it works > > perfectly for that class. Obviously something somewhere else is > > different but what? > > Given the complete lack of example code you've provided, we have no way > of telling. > > Regards, > Malcolm > > -- > Despite the cost of living, have you noticed how popular it > remains?http://www.pointy-stick.com/blog/ the only reason I didn't provide an example is that it seemed pointless given that you can copy the exact text of a class and change one character of the class name and that class works. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: limit)choices_to and OneToOne field affecting admin
Found it. In line 745 and 746 in main.py in django/contrib/admin/ views if self.opts.one_to_one_field: qs = qs.complex_filter(self.opts.one_to_one_field.rel.limit_choices_to) What was the thought behind this, and why wouldn't this be optional? On Jun 28, 8:52 am, Joe <[EMAIL PROTECTED]> wrote: > Hi, > > I have a model that has a OneToOneField to User and a limit_choices_to > parameter set: > > class Profile(models.model): > [---tab---] user = models.OneToOneField(User, > limit_choices_to={'is_staff':True}) > > When I use this is_staff parameter, I can only see staff users when I > log in to the Django admin and try to edit users by clicking on the > Users link. Why would a limit_choices_to parameter on another model > impact the User model administration? --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic menus using ul and li
A while back when I was trying to do a similar thing, someone mentioned using elementree to do this. I tried a bunch of other ways but in the end, elementree was the easiest way for me. If you'd like to see the template tag I created, you can see it here - http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/shop/templatetags/category_display.py Hopefully this will point you in the right direction. -Chris --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
limit)choices_to and OneToOne field affecting admin
Hi, I have a model that has a OneToOneField to User and a limit_choices_to parameter set: class Profile(models.model): [---tab---] user = models.OneToOneField(User, limit_choices_to={'is_staff':True}) When I use this is_staff parameter, I can only see staff users when I log in to the Django admin and try to edit users by clicking on the Users link. Why would a limit_choices_to parameter on another model impact the User model administration? --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
One-to-one relationship (model inheritance) or generic relations?
I'm still new to Django so bear with me ;) I have models for different types of venues (Bars, Clubs, etc). Because for example, I'd like to use one Rating model across all these venue Models I'd presumed that I'd need a parent Venue Model, using some kind of one-to-one relationship (until model inheritance is reintroduced), so that each venue had a unique primary key that could be related to the rating. However, apps such as comment and tagging get away with it. Is this through Generic Relations? I don't want to code myself into a corner, so when I start looking at features such as allowing users to search all venues would I be best with one parent model or will I be ok keeping them separate? The different types of venues have quite a number of different attributes btw which is why they are different models rather than simply categoried. Any clarification much appeciated. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Fixtures for datetime fields using auto_now
On 6/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I'm writing tests for an application, and I sort by update_time for > one model. Is it possible in my fixtures to set fixed times? Right > now, the update_time attribute is always almost "right now". If I try > to set it in my JSON fixtures file, that value is overridden when the > fixture is saved, and when I set it manually, I can't save because > then the update_time would be when I call save(), not what I manually > set. > > I'm using 0.96 Hi Vincent, This is a known problem, which is a variation on the theme of #4459. At present, there is no workaround for this; I'm hoping to look at this in the near future. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: gettatr() access to ManyToMany huuuge delay?
On 6/28/07, grassoalvaro <[EMAIL PROTECTED]> wrote: > > text: 1.149759 > name: 0.017819 > - > > Can someone explain me, why when i'm doing gettatr(test, "text") > (ManyToMany) i have so long delay? That is django (not database) > problem but i really don't know why. Anyone? Your first line of code retrieves a TestField object instance. This populates the value of the 'name' attribute (because it is simple table data), so 1 calls to getattr(test, 'name') is really just returning the same cached attribute value 1 times. There is only ever 1 call on the database. However, each call to getattr(test, 'text') requires a call on the database, performing a join on the M2M related table. This takes some time (or at least, much more time than a simple attribute lookup), and there is 1 calls on the database. The solution to optimizing this specific example is to do the getattr once, store the result, and use it multiple times. However, your example is a little artificial, so its difficult to tell the real problem that you are trying to optimize. As a side note, if your model used a ForeignKey, it would be possible to use select_related() to pre-cache related objects: http://www.djangoproject.com/documentation/db-api/#select-related However, this option isn't available to ManyToMany relations. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: gettatr() access to ManyToMany huuuge delay?
No, it doesn't depend on server. Like i said - this is django problem. On Jun 28, 1:37 am, l5x <[EMAIL PROTECTED]> wrote: > On Jun 27, 11:32 pm, grassoalvaro <[EMAIL PROTECTED]> wrote: > > > > > Here some code: > > - > > class TestField(models.Model): > > name = models.TextField() > > text = models.ManyToManyField(TextOption) > > class Meta: > > db_table = 'test' > > > test = TestField.objects.get() > > a = time.time() > > for i in range(0, 1): > > t = getattr(test, "text") > > print "text: %f"%(time.time()-a) > > a = time.time() > > for i in range(0, 1): > > t = getattr(test, "name") > > print "name: %f"%(time.time()-a) > > > text: 1.149759 > > name: 0.017819 > > - > > > Can someone explain me, why when i'm doing gettatr(test, "text") > > (ManyToMany) i have so long delay? That is django (not database) > > problem but i really don't know why. Anyone? > > Doesn't it depend on server ? --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using more than one database in the project
Hi There is a branch that supports multiple databases and I'm working on getting the merges I've made from trunk checked in at the moment... That's probably your best bet, watch this space! Ben On 28/06/07, AnaReis <[EMAIL PROTECTED]> wrote: > > > Hi! > As I said in previous posts I'm a newbie in these django stuff. > I'm creating a project that consists in a web based GUI for managing > some databases. This project has several modules. The user is > presented with a start page where it is possible to chose which > database to manage. > I have now finished working on one of the databases module and > everything is running smoothly. > I will now have to start working with another database but I have no > idea how to do this. The problem is, the server runs with a certain > settings.py file, in this settings file I have my database > configuration information. How can I use another database if the > settings file only has information about one database? > Another question I have is, the user will have to login before > entering the system. When using sessions with Django, there is a table > "django_session" that is created on the database that you are using. > My problem is, if the user has to login and after loggin the user can > access any of the databases, where should I store this table? It > doesn't make sense to make the user login again each time there is a > need to go manage a different database. > I'm kind of lost and a bit stuck here because I have no idea how to > deal with these two problems. > I read several other posts about this matter but none of them seemed > to help me. > > > > > -- Regards, Ben Ford [EMAIL PROTECTED] +628111880346 --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using more than one database in the project
Hi! As I said in previous posts I'm a newbie in these django stuff. I'm creating a project that consists in a web based GUI for managing some databases. This project has several modules. The user is presented with a start page where it is possible to chose which database to manage. I have now finished working on one of the databases module and everything is running smoothly. I will now have to start working with another database but I have no idea how to do this. The problem is, the server runs with a certain settings.py file, in this settings file I have my database configuration information. How can I use another database if the settings file only has information about one database? Another question I have is, the user will have to login before entering the system. When using sessions with Django, there is a table "django_session" that is created on the database that you are using. My problem is, if the user has to login and after loggin the user can access any of the databases, where should I store this table? It doesn't make sense to make the user login again each time there is a need to go manage a different database. I'm kind of lost and a bit stuck here because I have no idea how to deal with these two problems. I read several other posts about this matter but none of them seemed to help me. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newforms Attribute Errors
You tried, thanks! The errors I get come before any major piece of code. They come after some simple statements: OrderDetailForm = form_for_model(Order_Detail) f = OrderDetailForm() f.save() f.is_bound which means my 0.96-pre (not a typo :) ) version might not be up to the challenge of newforms. I will upgrade to the development version and see if the errors go away. FYI, the FloatField I used was a class I created, not provided by Django, therefore it could take max_digits and decimal_places. Quick question, what is the difference between form_for_model, forms.form_for_model, and forms.models.form_for_model? I have seen all 3 in use. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Dynamic menus using ul and li
What I need is a way to create nested menus using and with the data coming from a model. I need to be able to get the entire list: Home Some Category Page Even Deeper Another Deeper Page Another Page Some Other Page But also be able to pull a sub tree and tell it how deep to go: Page Another Page Here is a sample of the model for the data... class Page(models.Model): title = models.CharField(maxlength=200) slug = models.SlugField(prepopulate_from = ['name']) parent = models.ForeignKey('self', blank=True, null=True) content = models.TextField() active = models.BooleanField(default = True) show_in_menu = models.BooleanField(default = True) I have spent the past week or so trying to figure this out and just cant quite figure out how to do it... any help at all would be greatly appreciated. And for the record, Django ROCKS!! Eric --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Forms and formating error messages
On Jun 27, 9:41 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2007-06-27 at 02:26 -0700, AnaReis wrote: > > Hi again, > > This is getting very frustrating because I can't make this work... > > This is exactly what I wrote in the files: > > In future, please remember that when you send a message like this, a lot > of us are reading it through an e-mail interface, so include the > necessary context to help us understand the problem. I ended up having > to go back and read all your earlier messages in the thread to work out > what the problem is that you were having. People, including me, may not > always feel like spending that much time to answer a question, so please > help us to help you. > > If I understand correctly, you want to have control over error message > presentaiton. > > [... snip...] > > > [field.html] > >> > > > {{ field.label }}{% if > > field.field.required %}*{% endif %}: > label> > > > > > > {{ field }} > > {% if field.errors %}{{ field.errors }}{% endif %} > > So this is the problem. If you look at field classes (in > newforms.fields), you can see that the errors attribute is a > newforms.util.ErrorList class and the __str__ method for ErrorList is > the as_ul() method -- displaying results as an unordered list. > > If you want to control the presentation, you will need to iterate over > field.errors and write out the results one by one. Or you could write a > filter that applies to field.error and does this for you. Remember that > ErrorList is a subclass of Python's standard lists, so something like > (untested): > > {% if field.errors %} >{% for error in field.errors %} > {{ error }} >{% endfor %} > {% endif %} > > This particular example would just dump the strings with br tags between > them, but you can obviously do whatever you want there. > > Some experimentation will be required, but since you have full access to > the raw error strings, anything should be possible. > > Regards, > Malcolm > > -- > Works better when plugged in.http://www.pointy-stick.com/blog/ Hi, Sorry for that, I didn't know you received this by e-mail, I just come here kind of like a forum... Won't happen again. Thanks for your help, I managed to work this out by using the usual forms and not that TemplatedForm I was using before. In the template I just put: {%if field.errors%}{% for error in field.errors %}{{ error }}{%endfor%}{%endif%} This just prints the error as simple text exactly where I want it to appear. It was so simple after all... :) Thanks for your help and sorry for all the trouble. Ana --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with URL
On Jun 27, 9:42 pm, robo <[EMAIL PROTECTED]> wrote: > Yes, Alberto is right. > > Also, I ran into this problem a few days ago. Basically, after you > write your view processing like Alberto suggested, you need to do a > response redirect or HttpResponseRedirect and pass it "." (which is to > the same page the user was on). After I did that on my form, the user > gets sent back to the same page and the "." eliminates concatenating > another useradd string to the end of your url. > > Have fun. > > On Jun 27, 1:19 pm, Alberto Piai <[EMAIL PROTECTED]> wrote: > > > Hello, > > > On Jun 27, 10:55 am, AnaReis <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > I'm having a problem here and I don't really know how to solve it. > > > I have a form on a page, the add user page: > > > (r'^manager/operations/nlsciadc/users/adduser/$', add_user), #The > > > template is add_user.html > > > > When the user presses submit, the action on the form sends the user > > > to: > > > > > > the best practice is to use the same view to display (GET request) and > > process (POST request) the form. This is shown > > here:http://www.djangoproject.com/documentation/newforms/#simple-view-example > > > This way you redisplay the same page when the form is not valid, and > > redirect to another page upon successful form submission. > > > If something is not clear, feel free to ask again. > > > Bye, > > > Alberto Weee! I did it! Thanks guys :) Ana --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Password Logistics Help Needed
> The original poster suggested adding a field called password_md5 to a > model that is an extension of User. It was never indicated that such a > field already existed. Ah, my bad. I misinterpreted. --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Password Logistics Help Needed
On Thu, 2007-06-28 at 05:37 +, Bryan Veloso wrote: > Alright. I tried looking in the actual source for any mention of > password_md5... and it no longer exists. The original poster suggested adding a field called password_md5 to a model that is an extension of User. It was never indicated that such a field already existed. Regards, Malcolm -- Why can't you be a non-conformist like everyone else? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---