Re: Testing formset validation
I should also add that neither the formset nor the form report .errors or .non_form_errors() at all. On Oct 8, 6:15 pm, ses1984wrote: > I have a pretty simple form, defined below, that I am setting > according to some initial data, and no matter what I try, I can't seem > to get it to validate in a test. > > I have created some test data, which is an array with one dictionary > element, where the dictionary corresponds to the form. If I create a > singular from from the dictionary element, it is valid, but if I > create a formset from the list which contains only that very same > dictionary, it's not valid. > > ### > > class FormulaRow(forms.Form): > ingredient_number = forms.CharField(label="") > amount = forms.DecimalField(label="", max_digits=9, > decimal_places=5) > > ### > > >>> initial = [{'amount': '1000.000', 'ingredient_number': '100'}] > >>> initial_singular= initial[0] > >>> form = FormulaRow(initial_singular) > >>> form.is_valid() > True > >>> FormulaFormSet = formset_factory(FormulaRow) > >>> formset = FormulaFormSet(initial=initial) > >>> formset.is_valid() > > False -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
question about django url
In my application ,there is a url like this: """ xxx.com/xxx/s1-s2-s3-s4-s5/ """ 1: s1 .. s5 ,they are all numbers; 2: s1 must be there 3: the others like "-s2" can be zero to 4 how should I write this url??? any suggestion is welcome. thanks ~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
noob question about URLconf
I'm following the Django book but run into a pathing problem (I think) I did exactly what the book said, even copying and pasting the code as to make sure I didn't make a typo. so in the views.py I have from django.http import HttpResponse def hello(request): return HttpResponse("Hello world") and url I have from django.conf.urls.defaults import * from mysite.views import hello urlpatterns = patterns('', ('^hello/$', hello), ) I get the error "Unable to connect" what is wrong? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Project-wide tests
One thing you can do is to call your "out of django" app test process from one of your django app test modules. Roberto On Fri, Oct 8, 2010 at 11:00 PM, diogobaederwrote: > Hi there, > > I know that the testing facilities from Django read "test" modules > inside all the installed apps, but is there a way to include a test > from outside the apps, for example a "test" module located in the > project root? > > I'm trying to do this so that I can build an end-to-end test that > involves all the applications. > > Thanks! > > Diogo > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Testing formset validation
I have a pretty simple form, defined below, that I am setting according to some initial data, and no matter what I try, I can't seem to get it to validate in a test. I have created some test data, which is an array with one dictionary element, where the dictionary corresponds to the form. If I create a singular from from the dictionary element, it is valid, but if I create a formset from the list which contains only that very same dictionary, it's not valid. ### class FormulaRow(forms.Form): ingredient_number = forms.CharField(label="") amount = forms.DecimalField(label="", max_digits=9, decimal_places=5) ### >>> initial = [{'amount': '1000.000', 'ingredient_number': '100'}] >>> initial_singular= initial[0] >>> form = FormulaRow(initial_singular) >>> form.is_valid() True >>> FormulaFormSet = formset_factory(FormulaRow) >>> formset = FormulaFormSet(initial=initial) >>> formset.is_valid() False -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Iterating tree-like data structures with django
Hello all, Bruno was kind enough to list some of the techniques for working with trees. I'd like to throw out another technique you many want to look into if you are working with trees of unknown shape and need frequent inserts/ updates. I've been experimenting with it with some good results so far, although I don't have any code to share. Try searching for Vadim Tropashko's Nested Interval/Matrix Encoding technique. Toodle-l creecode -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
What's the best practice for Comet w/ Django?
I searched the list online and haven't seen any recent discussions about this, so I figured I'd check in. Last I heard, Orbited was the way to go, but it seems that both it and django-orbited haven't seen any development in quite a while. The developer of Orbited is working on something called Hookbox to supersede Comet. Specifically, our application deals with monetary payments, and I'd like the UI to update "live" as payments are added to the "pending balance" or moved from "pending balance" to "available balance." So, is anyone using a Comet implementation in production with Django? I'd rather use what the majority of the community is using (or moving toward). Thanks, Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: mod_wsgi + mod_php = segmentation fault
Hi I'm having the same problem. I'm using /mod_php5-5.2.9.so With that loaded my worker processes crash as soon as they are started and I get the segmentation fault in the logs. No mod_python. Did you fix this? Thanks Justin On Oct 3, 3:54 pm, Олег Корсакwrote: > Hello. I'm using apache Apache/2.2.16 (Unix) + mpm_worker on my ~amd64 > Gentoo Linux box. It has mod_php enabled and all my existing php > projects work fine (with mysql too). > > When I'm enabling mod_wsgi in apache config and trying to run simple > empty django project - I'm getting 500 Internal Server Error and > "Segmentation fault" in error_log. > > When disabling mod_php - it runs just ok. > Any ideas? I need them both :) > > Thanks > > signature.asc > < 1KViewDownload -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Project-wide tests
Hi there, I know that the testing facilities from Django read "test" modules inside all the installed apps, but is there a way to include a test from outside the apps, for example a "test" module located in the project root? I'm trying to do this so that I can build an end-to-end test that involves all the applications. Thanks! Diogo -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Admin Many-to-Many on a regular Form?
I really like the 'filter-horizontal' style widget used by Django Admin for things like specifying permissions for users/groups. I would like to create a form that uses this same widget to allow someone to select a group and then edit which users are in the group based on this widget. The catch for me is I need to do it through the standard part of my site, not the admin interface. A couple questions arise: Is there any way to use an ModelAdmin on a regular form? If not, is there another way to use that sort of widget? The tangential question would be, once the solution for the above is found, how do I populate the form? Django does not appear to make it easy to edit the "reverse" side of a Many-to-many relationship. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Admin Many-to-Many on a regular Form?
I really like the 'filter-horizontal' style widget used by Django Admin for things like specifying permissions for users/groups. I would like to create a form that uses this same widget to allow someone to select a group and then edit which users are in the group based on this widget. The catch for me is I need to do it through the standard part of my site, not the admin interface. A couple questions arise: Is there any way to use an ModelAdmin on a regular form? If not, is there another way to use that sort of widget? The tangential question would be, once the solution for the above is found, how do I populate the form? Django does not appear to make it easy to edit the "reverse" side of a Many-to-many relationship. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: possible model relations?
On Wed, Oct 6, 2010 at 9:20 PM, alecxwrote: > Hello, > I try to build a kind of call tracker app. The call intaker creates a > new item (main model) and makes some notes (subject, issue and which > printer nr, customer, technician,... all with modelfields) all in one > view. But I am struggling with the model relations and the form > saving. I cannot save anything to the db, thats because one related > object isnt already saved to the db. > I think the problem is the m2m relation between Servicetechnician and > Customer. Can someone please point me to the right direction? > > in http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ look for save_m2m() -- Marc -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Manually sorting items in a table - Doubly-Linked List vs sort_index
ah I see. But I'm a little confused. How are your users manipulating this list if not via a web page? are you saying you trying to create an API in your application for people to use on querysets and interact with the database table? The notion of lists & tables in the web space is a little ambiguous. On Oct 8, 7:05 am, Steven Sackswrote: > Sorry I accidentally repeated myself. > > List Delete closes gaps by setting item.prev = item.next and item.next > = item.prev. > > On Oct 8, 5:03 am, Steven Sacks wrote: > > > > > While I appreciate your response, your assumption is incorrect. > > However, I've found the solution and it's rather easy. > > > The List Delete function closes gaps by setting an item.prev = > > item.next and item.prev = item.next > > The List Insert function injects item(s) either at the end of the list > > (when the first item inserted's prev is the tail, and the tail's next > > is set to the first item inserted), or in the middle of the list > > (using similar logic). > > The List Move function simply calls List Delete to close the gaps, and > > List Insert with the new position. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-facebook
I chose django-facebook to allow site authentication via Facebook Connect because it seems to be alone amongst the various solutions in knowing how to smartly connect existing site accounts to FB logins rather than blindly creating new accounts (if you have users who sometimes log in the traditional way and other times via FB, they end up with two accounts in the system). All went well with implementation until I hit this issue, and it's a show-stopper: http://github.com/ryanmark/django-facebookconnect/issues/#issue/3 No response from the developer there, so asking here - has anyone hit this? How did you overcome? Is there another Facebook Connect app you prefer? Or a more recent fork of django-facebook that works better? Thanks, Scot -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Migrating Groups of Permissions
I've run afoul of this too, and would love to see a workable solution. On Oct 7, 1:21 pm, Dan Gentrywrote: > As I deploy my application into production, I haven't found a good way > to migrate the groups of permissions I have defined and tested in > development. In fact, due to my poor typing and reviewing, I missed > one in production and caused a small amount of concern with the users > until I figured it out. > > It seems that I can't just dump and load the data from the test DB, > since the permissions may not have the same ID. Any hints from the > community on how I can automate this to reduce the chance for error? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Serve static file from cdn
Really... As Daniel said, I can't see any problem... only refer your static into your templates like: Your javascript URL: http://commondatastorage.googleapis.com/static/media/node.js On template: (...) (...)
Re: Manually sorting items in a table - Doubly-Linked List vs sort_index
Sorry I accidentally repeated myself. List Delete closes gaps by setting item.prev = item.next and item.next = item.prev. On Oct 8, 5:03 am, Steven Sackswrote: > While I appreciate your response, your assumption is incorrect. > However, I've found the solution and it's rather easy. > > The List Delete function closes gaps by setting an item.prev = > item.next and item.prev = item.next > The List Insert function injects item(s) either at the end of the list > (when the first item inserted's prev is the tail, and the tail's next > is set to the first item inserted), or in the middle of the list > (using similar logic). > The List Move function simply calls List Delete to close the gaps, and > List Insert with the new position. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Manually sorting items in a table - Doubly-Linked List vs sort_index
While I appreciate your response, your assumption is incorrect. However, I've found the solution and it's rather easy. The List Delete function closes gaps by setting an item.prev = item.next and item.prev = item.next The List Insert function injects item(s) either at the end of the list (when the first item inserted's prev is the tail, and the tail's next is set to the first item inserted), or in the middle of the list (using similar logic). The List Move function simply calls List Delete to close the gaps, and List Insert with the new position. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Serve static file from cdn
On Oct 8, 9:37 am, Hudarwrote: > Hi, > > Just wondering how we could server static file if we have our files > hosted in cdn. > > I been trying several way, but nothings work. > > I have the files in let say ; > http://commondatastorage.googleapis.com/static/media/node.js > > As far as I know, all the example out there use static files reside in > the same server. Any help will be much appreciated. I'm having real trouble understanding what your confusion is. If your files are on an external URL, then you refer to that URL in your templates. What's the difficulty? -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Serve static file from cdn
Hi, Just wondering how we could server static file if we have our files hosted in cdn. I been trying several way, but nothings work. I have the files in let say ; http://commondatastorage.googleapis.com/static/media/node.js As far as I know, all the example out there use static files reside in the same server. Any help will be much appreciated. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ANN: Celery 2.1 stable released
Hey! Celery 2.1.0 was just uploaded to PyPI! This is a backward compatible release in the 2.x series, and is an recommended upgrade for all users. What is Celery? Celery is an open source asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well. The execution units, called tasks, are executed concurrently on one or more worker nodes. Tasks can execute asynchronously (in the background) or synchronously (wait until ready). For more information go to http://celeryproject.org Highlights * Periodic task schedule can now be stored in a database, and changes will be reflected at runtime (only supported by django-celery at the moment, but this can also be used in general) http://celeryq.org/docs/userguide/periodic-tasks.html#periodic-tasks * New web monitor using the Django Admin interface. Can also be used by non-Django users. http://celeryq.org/docs/userguide/monitoring.html#django-admin-monitor * Periodic tasks now supports arguments and keyword arguments. * celeryctl: A new command line utility to inspect and manage worker nodes. http://celeryq.org/docs/userguide/monitoring.html#celeryctl-management-utility * AMQP Backend: Now supports automatic expiration of results. * Task expiration: A date and time which after the task will be considered expired and will not be executed. * Lots of bugs fixed. * Lots of documentation improvements. Changes === The full list of changes are available in the changelogs: * celery: http://celeryq.org/docs/changelog.html * django-celery: http://celeryq.org/docs/django-celery/changelog.html Download * celery: http://pypi.python.org/pypi/celery/2.1.0 * django-celery: http://pypi.python.org/pypi/django-celery/2.1.0 -- {Ask Solem, +47 98435213 | twitter.com/asksol }. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django and legacy database
I have a legacy database and have user and password with plain-text or md5 encryption Now, I want an app or function, when the user signup, change or reset the password, the record of legacy databases will change synchronously. I would like to keep the existing account app, how can I do? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Iterating tree-like data structures with django
On 6 oct, 17:27, Paweł Romanwrote: > I have a model which has a tree-like structure (not exactly a FK on > self but we can assume that's the case). > > I want to visualise this tree using all records from the db. It seems > impossible to do with QuerySet, if I have say 100 records (100 nodes > in the tree) and I try building the tree recursively django will > execute a SELECT for each node so it will hit the db 100 times to > build the tree. (snip) > Am I missing something? Iterating tree-like data structures seems > something quite common problem and someone must have done it already > with django. Please not that it's in a no way a Django-specific problem, but a limitation of the relational model (or at least of it's most common implementation, ie SQL). The most obvious way to implement a tree in the relational model, wknown as "Adjacency list", is the use of a self-referential foreign key pointing on the parent record. It's easy to implement, easy to maintain, but as you noticed not really efficient when you want to build the whole tree or a branch of it. One of the known workaround is the "Modified Preorder Tree Transversal" (AKA "nested Set") pattern (google for more on this - there's a django implementation here http://code.google.com/p/django-mptt/), which is mostly optimized for reading deeply nested trees, but is not very efficient wrt/ insert/update. So if your hierarchy is 1/ deeply nested and 2/ read often, rarely updated, then it might be what your looking for. Another known solution is the "Materialized path" pattern, which is not as good as MPTT for reading and not as bad for inserts/updates. Here again, google is your friend. FWIW, there's also a django utility app that provides a generic implementation of these tree patterns with a same API: https://tabo.pe/projects/django-treebeard/docs/tip/ HTH -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: SUPPORTS_TRANSACTIONS Error while running tests
Hi Russ, thanks for the reply,,i resolved this error,, added DATABASES['xxx']['SUPPORTS_TRANSACTIONS'] = 'False' DATABASES['default']['SUPPORTS_TRANSACTIONS'] = 'False' in settings.py On Fri, Oct 8, 2010 at 11:49 AM, Russell Keith-Magee < russ...@keith-magee.com> wrote: > On Fri, Oct 8, 2010 at 1:34 PM, girish shabadimath >wrote: > > Hi all, > > i looked into the setup_databases() code, here it basically checks for > > MIRROR,,if db is a mirror ,then it simply points to it or else creates > test > > db,,,where dis SUPPORTS_TRANSACTIONS check is happening..? > > > > trace-out shows its present in testcases.py,,but how setup_database gets > > there..?,, > > > > im a newbie to django,,so don't mind if it sounds simple ... > > In django/db/backends/creation.py. It's part of the database backend > logic that defines how to create the test database. > > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Girish M S -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Calling method of a proxy-model in a template
Hi Daniel, Thanks for the hint, I've read through the documentation and I should be able to handle it despite the fact that I'm more of a "surface" than an "underground" programmer. Kindly Yours Marc On Sep 30, 5:19 pm, Daniel Rosemanwrote: > On Sep 30, 3:31 pm, mettwoch wrote: > > > Hi, > > > Let's say that I have aproxymodel of the User model that adds some > > methods. What would be an elegant way to access these methods from > > within a template in the same easy way I access the User attributes > > through {{ request.session.user.some_attribute }}. > > > Kindly Yours > > Marc > > Well, you don't access the user through request.session.user, but > simply through request.user. And if you have the auth context > processor installed, which you do by default, you can simply get it > via {{ user }}. > > So one answer is to define your own context processor to use in place > of the auth one, which returns an instance of yourproxyclass for the > user. > > Another possibility is to provide a custom request middleware which > replaces request.user with your version. This might be preferable, as > you now have access to the extra methods throughout your code, not > just in templates. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: SUPPORTS_TRANSACTIONS Error while running tests
On Fri, Oct 8, 2010 at 1:34 PM, girish shabadimathwrote: > Hi all, > i looked into the setup_databases() code, here it basically checks for > MIRROR,,if db is a mirror ,then it simply points to it or else creates test > db,,,where dis SUPPORTS_TRANSACTIONS check is happening..? > > trace-out shows its present in testcases.py,,but how setup_database gets > there..?,, > > im a newbie to django,,so don't mind if it sounds simple ... In django/db/backends/creation.py. It's part of the database backend logic that defines how to create the test database. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.