Re: importing users from another db
I can answer for the settings part :) Make sure your project is in your PYTHONPATH environment variable and that DJANGO_SETTINGS_MODULE also exists as an environment variable. See http://www.djangoproject.com/documentation/settings/#designating-the-settings On Jul 8, 7:15 am, Carl Karsten <[EMAIL PROTECTED]> wrote: > Russell Keith-Magee wrote: > > On 7/8/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > >> Russell Keith-Magee wrote: > >>> Django users have many skills. Unfortunately, mind reading is > >>> generally not one of those skills :-) > > >> Yeah, I see what you mean. seemed obvious to me :) > > >> does django expose it's ORM so that I can do the above code (connect to > >> server, > >> execute query) and get results back that I can access using > >> object.fieldname > >> notation? (or a dict) > > > Well, depends what level you want to deal with it. > > > If you want Django to handle the full stack, then you will need to > > write a Django model that corresponds to the model you are trying to > > import. Usually not that difficult to do, but somewhat excessive > > effort for a temporary measure. > > Ok, not that big a deal. even with "inspectdb will help somewhat," it still > seems more trouble than it is worth. > > > Another alternative is to use the cursor to retrieve a row, then feed > > that row directly into the Django object of choice: > > > for row in cursor.fetchAll(): > >user = User(*row) > >user.save() > > > This assumes that the field names coming back from the cursor > > correspond to the field names in the object you are saving; if this > > isn't the case, you may need to do some dictionary munging on the *row > > part. > > Unfortunately, I need to do some mucking, including field names with spaces. > geez. > > > > >> This code just bothers me: > >>user = User.objects.create_user( member[5], member[4], member[6] ) > > > Why? It's just a manager shorthand for: > > > now = datetime.datetime.now() > > user = self.model(None, username, '', '', email.strip().lower(), > > 'placeholder', False, True, False, now, now) > > user.set_password(password) > > user.save() > > the User.objects.create_user() part is great. the member[5], member[4], > member[6] magic numbers bothers me. > > I was hoping for > user = User.objects.create_user( member.username, member.pw, > member.first_name ) > > > > >> Also, django.contrib.auth.models import User needs settings imported, and > >> import-users.py is in a util/ dir under the 'home dir' that holds > >> settings.py. > >> What is a good way to reference ../settings.py? > > > Something like: > > > from myproject import settings as myproject_settings > > like that, only completely different :) > > When I run my code (below) I get: > > self._target = Settings(settings_module) >File "/usr/lib/python2.5/site-packages/django/conf/__init__.py", line 83, > in > __init__ > raise EnvironmentError, "Could not import settings '%s' (Is it on > sys.path? > Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) > EnvironmentError: Could not import settings 'settings' (Is it on sys.path? > Does > it have syntax errors?): No module named settings > > I am assuming there are a few bad ways to solve this, and I am trying to > avoid them. > > also, (still someone on topic, given my vague subject) > Is the profile=... profile.save() look right? I'm not too sure what order the > new/new/save/save should be done in. > > Carl K > > # migrate.py > # migrates data from RidgeMoorJonas.Member to django.auth_user > # uses the django user api, > # mainly to create the password based on the current one. > > from django.contrib.auth.models import User > import MySQLdb > > con = MySQLdb.connect(user='u', passwd='v' db='src' ) > cur=con.cursor() > > # reset the tables > cur.execute("truncate auth_user") > cur.execute("truncate eventcal_event") > > # Create django Users > cSql=""" > select MemberNumber, Surname, `Given name`, >`Familiar Name`, `Email Address` >UserID, UserPassword, Telephone > from Member limit 1 > """ > cur.execute(cSql) > members = cur.fetchall() > for member in members: ># user = User.objects.create_user('john', '[EMAIL PROTECTED]', > 'johnpassword') >user = User.objects.create_user( member[5], member[4], member[6] ) >user.first_name=member[2] >user.last_name = member[1] >profile = UserProfile.objects.create(user=user) >profile.phone_number=member[7] >user.save() >profile.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: Database caching, querysets not evaluating?
And continuing this monologue :) ... the separate thread ofcourse didnt quite work as I intended. I see now that a new connection is created for each thread/polling I create. This brings me back to the original question... how can I force a query to evaluate? Or is there some alternative to solve my problem? On Jul 7, 3:08 am, ejot <[EMAIL PROTECTED]> wrote: > Hmm, Im guessing this might also have something to do with local() for > threads? > > Made my app work by using an extra and from my point of view > uneccesary worker thread that does the polling on the database.. . > anyone willing to offer some insight on this? I see people are trying > to do external (from django) applications but suggestions have been to > do cron jobs or use views in django to trigger an eventflow. These > things aren't always applicable tho, as in my case where i have to > keep a connection up on IRC while polling. > > On Jul 6, 4:50 pm,ejot<[EMAIL PROTECTED]> wrote: > > > Im really banging my head against a wall trying to get my threaded > > application to play nice with djangos ORM... > > > this is what my thread does for each iteration.. > > def run(self): > > while self.keepRunning: > > print repr(Topic.objects.get(id=1).content_set.order_by("- > > id")[0]) > > time.sleep(5) > > > Now, the docs say that a query should evaluate when calling repr(), > > but it doesnt... what i do is start up my thread and in the shell: > > > t = Topic.objects.get(id=1) > > eo = EntryObject(payload="Some random text") > > eo.save() > > e = Entry(content_object=eo, belongs_to=t) > > e.save() > > > Still, the thread reports that the last object in content_set created > > is the one that is evaluated or printed when the thread does its first > > iteration what's going on here? > > > What Im trying to accomplish is an application (just using Djangos > > ORM) that polls the database for new entries created, and based on > > that sends an message out on IRC. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
about django-admin settings
I try to use django-admin.py runserver --settings=mysite.settings in Windows shell(cmd.exe) it tells me that : raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) EnvironmentError: Could not import settings 'example.settings' (Is it on sys.pat h? Does it have syntax errors?): No module named example.settings I have put the project in in python search path in python shell through >>> import sys >>> sys.path.append('D:\\order\\newtest') >>> sys.path ['D:\\Python24\\Lib\\idlelib', 'C:\\WINDOWS\\system32\\python24.zip', 'D:\\Python24', 'D:\\Python24\\DLLs', 'D:\\Python24\\lib', 'D:\ \Python24\\lib\\plat-win', 'D:\\Python24\\lib\\lib-tk', 'D:\\Python24\ \lib\\site-packages', 'D:\\order\\newtest'] where newtest is the project why it does not work --~--~-~--~~~---~--~~ 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 books application i18n
Thanks...but in my case? I have thought to extends the "change_form.html" generic template. But how can I refer to a field of my data model? ( book name field for example) Thanks. Joseph Heck ha scritto: > I think most everything that you'd like to know is detailed out at > http://www.djangoproject.com/documentation/i18n/ > > -joe > > On 7/6/07, Gianluca <[EMAIL PROTECTED]> wrote: > > > > Hello, > > I'm following the Django tutorial about books application. How can I > > internationalize this application? > > For example, how can I internationalize a field name of insert book > > form? > > Thanks > > > > Gianluca > > > > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Djangonauts at EuroPython?
Hello fellow Django-users! Me and my colleague are attending to EuroPython conference (in Vilnius, Lithuania) tomorrow (9.-11.7.) and we were wondering if there are any other Django-users around. It would be great to arrange a Django-meetup or something. We arrived to Vilnius yesterday and are leaving on Friday evening. If the weather stays like this, I'm sure some company at the local bars (after the conference hours) wouldn't hurt =) Yours, Ville Säävuori http://www.unessa.net/en/hoyci/ --~--~-~--~~~---~--~~ 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: How to use Admin modules in my application
On 7/8/07, Doug B <[EMAIL PROTECTED]> wrote: > As tempting as the pretty admin interface > might be, I think you would be better off rolling your own form and > view for end users. Then you have complete control. Using the > form_for_* functions you could have the whole thing done in a few > minutes. Maybe you are right and this is the solution my current Python/Django knowledge seems to be sufficient for. But, this is 'quick and dirty' solution and I'm affraid I can't present it to my Boss without a risk I'd be fired and we can't interface out users/customers to such kind of interface in 21th century... > admin != user > Atleast that's my view. I don't agree in that point - from my perspective Django seems to be the system, which is used by admins only (admin == user), because admin's interface is pretty and much more user friendly comparing with techniques for building ordinary user interface described in documentation/tutorials, even if admins are used to talk to machines via text mode consoles :-O I'm going mad if it is true that there is a valuable piece of software, which is not possible to reuse in Django based applications. Please, is there any other solution than copy&paste functions from admin.main module and modify source code properly? Thanks, Angela --~--~-~--~~~---~--~~ 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: function to generate choices list
I think, the problem would be solved if you assigned a class overriding list instead of a preformed list to the choices. Check XFieldList for a living example: http://www.djangosnippets.org/snippets/51/ Regards, Aidas Bendoraitis aka Archatas On 7/6/07, David Reynolds <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to pre-populate a choices list for a CharField from some > folders on the file system, I was doing this by calling a function > within the models.py which assigned the list of folders to a variable > which was then used in the charfield. This all worked perfectly using > the development server, however, when deploying the site under > apache2/mod_python I find that this list only ever gets updated when > apache is restarted. I had vaguely thought of using a signal((pre| > post)-init) to create the list as a global variable, but that didn't > seem to work. > > Does anyone, please have any idea how I could do this? > > Thanks, > > Dave > > -- > David Reynolds > [EMAIL PROTECTED] > > > > --~--~-~--~~~---~--~~ 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: Database caching, querysets not evaluating?
You may want to take a look here: http://groups.google.com/group/django-users/browse_thread/thread/e4e1e0c017655ad/ On 7/8/07, ejot <[EMAIL PROTECTED]> wrote: > > And continuing this monologue :) ... the separate thread ofcourse > didnt quite work as I intended. I see now that a new connection is > created for each thread/polling I create. > > This brings me back to the original question... how can I force a > query to evaluate? Or is there some alternative to solve my problem? > > On Jul 7, 3:08 am, ejot <[EMAIL PROTECTED]> wrote: > > Hmm, Im guessing this might also have something to do with local() for > > threads? > > > > Made my app work by using an extra and from my point of view > > uneccesary worker thread that does the polling on the database.. . > > anyone willing to offer some insight on this? I see people are trying > > to do external (from django) applications but suggestions have been to > > do cron jobs or use views in django to trigger an eventflow. These > > things aren't always applicable tho, as in my case where i have to > > keep a connection up on IRC while polling. > > > > On Jul 6, 4:50 pm,ejot<[EMAIL PROTECTED]> wrote: > > > > > Im really banging my head against a wall trying to get my threaded > > > application to play nice with djangos ORM... > > > > > this is what my thread does for each iteration.. > > > def run(self): > > > while self.keepRunning: > > > print repr(Topic.objects.get(id=1).content_set.order_by("- > > > id")[0]) > > > time.sleep(5) > > > > > Now, the docs say that a query should evaluate when calling repr(), > > > but it doesnt... what i do is start up my thread and in the shell: > > > > > t = Topic.objects.get(id=1) > > > eo = EntryObject(payload="Some random text") > > > eo.save() > > > e = Entry(content_object=eo, belongs_to=t) > > > e.save() > > > > > Still, the thread reports that the last object in content_set created > > > is the one that is evaluated or printed when the thread does its first > > > iteration what's going on here? > > > > > What Im trying to accomplish is an application (just using Djangos > > > ORM) that polls the database for new entries created, and based on > > > that sends an message out on IRC. > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
generate choices list from database
In a similar vein to the OP, I'm trying to populate a choices list for a form (using newforms) from a database: nameChoices = Names.objects.filter(initials='AB') NameSelection.base_fields['names'].widget = widgets.Select(choices=nameChoices.Name) However, I am not having much succcess, I get this error: AttributeError at /names/ '_QuerySet' object has no attribute Name' Anyone have any ideas? thanks, Stu --~--~-~--~~~---~--~~ 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: Djangonauts at EuroPython?
On 7/8/07, Ville Säävuori <[EMAIL PROTECTED]> wrote: > We arrived to Vilnius yesterday and are leaving on Friday evening. If > the weather stays like this, I'm sure some company at the local bars > (after the conference hours) wouldn't hurt =) Simon Willison is keynoting, and he is an original contributor. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
arrays in templates
I have this working with some extra code in my view, but I would like to know how I could have done it in the template: # view.py from datetime import datetime, date # Week starts on Sunday c=calendar.Calendar(calendar.SUNDAY) # get all the dates that will be displayed, # including the tail and head of previous/next months. # (a list of weeks, each week is a list of 7 dates.) dates=c.monthdatescalendar(year, month) # array, ['Monday', 'Tuesday'.. 0 is Mon. daynamesarray=calendar.day_name # I can't figure out how to use the array in the template. # so I am building a list here. # Use the first week of the calandar, which is handy # because it makes sure the week starts on the weekday we want it to # (like Sunday) daynames= [ calendar.day_name[d.weekday()] for d in dates[0] ] {% for dayname in daynames %} {{ dayname }} {% endfor %} So what would the template code look like that uses daynamesarray and dates? Carl K --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
forms and designers
I'm a designer new to django and the templating system has been pretty easy to pick up. The area that I have a problem with is the form shortcuts - the auto-generation of html is a big pain and causes me a lot of headaches in terms of being able to manipulate the elements directly, not just in terms of creating a page initially but especially when modifying one. I know it makes the programmers jobs easier because of the built-in data validation but it's a the cost of my productivity, as I see it now. I just don't have the same level of control over the actual html compared to the rest of the templates. Can anyone share their tips on ongoing work with forms and designers? I asked a particularly well-known web designer on a django team how they deal with the issue and his answer in short is that they don't: he creates all the html by hand, including any form elements. Since I imagine that his programmers have the same data validation issues that the developers at my work do, I'm curious how they get around it. -- Al Abut -- web designer, crimefighter http://alabut.com -- --~--~-~--~~~---~--~~ 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: psycopg/psycopg2 - error at the loading
On Jul 6, 4:05 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Am Freitag, 6. Juli 2007 15:43 schrieb uxmal: > > > hello, > > I know it isn't directly related to django, but well my django depends > > on it... > > > yesterday I installed postgresql, mxBase, and psycopg 1.1 on openSUSE > > 10.2, > > and it worked fine until today (Django is really cool!). > > > using psycopg : > > Error loading psycopg module: libpq.so.5: cannot open shared object > > file: No such file or directory > > > > But after upgrading it mysteriously decided to stop working... > > What kind of upgrade? (SuSE, Django, Hardware, ...) > > Thomas I've made a SuSE upgrade > This is the shared library provided by the postgres or postgres-devel > RPM. > > It should be under /usr/lib or /usr/lib64. > > Starting the sql shell (psql) should fail, too. It works fine, looking like nothing have changed on the postgresql side When I reinstall psycopg 1 or 2 (properly configured with my lib path / usr/local/pgsql/lib/), it works (no error at the install of psycopg) but then it can't find this damn lib ! --- >>> import psycopg Traceback (most recent call last): File "", line 1, in ImportError: libpq.so.5: cannot open shared object file: No such file or directory --- >>> import psycopg2 Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.5/site-packages/psycopg2/__init__.py", line 60, in from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID ImportError: libpq.so.5: cannot open shared object file: No such file or directory --- I don't understand how it can have changed after a simple software upgrade... Is there a possibility to change the path to the lib somewhere after the install? (a conf file? ) 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 -~--~~~~--~~--~--~---
How can I achieve this intersection ?
I would like to do this in Django, using two lists that are QuerySet lists: mylist=mylistWHOM.intersection(mylistWHAT) When I do it in the Pythonic way above, the django parser complains with: 'QuerySet' object has no attribute 'intersection' This problem has been dogging me for a few days now and I have tried almost everything. Thanks heaps! -Nat --~--~-~--~~~---~--~~ 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 designers
Maybe it will be useful: http://groups.google.com/group/django-users/browse_thread/thread/a60038f4d0777391/a94a8e1dff4865db#a94a8e1dff4865db --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Parent / Child Categories and QuerySet filters
This question may have been asked a thousand times, but I'm not sure how to use the Parent/Child category database model given here: http://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic I have a model Item with category as a ForeignKey. I'd like to loop through all top level categories and then print all items in that category or its child categories. Here's what I've got for a view: def catalog(request): # Find top level categories dict = {'categories':{}} cats = Category.objects.all().filter(parent__isnull=True) for cat in cats: dict['categories'][str(cat)] = cat.getFullItemSet() return render_to_response('catalog.html', dict) And then in the Category model, I've added a function that merges all the QuerySets from its child objects: def getFullItemSet(self): items = list(self.item_set.all()) for child in self.child_set.all(): items.extend(child.getFullItemSet()) return items This works, but it seems sloppy, and inefficient since it requires database hits. Can anyone suggest a better way of doing this? I'll be looking into using Q objects to filter through Item.objects.all() list in the meantime. Thanks, Dan --~--~-~--~~~---~--~~ 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: MySQL Got packet bigger than 'max_allowed_packet'
Hello I wrote a test case using mysldb with direct python calls and using the django model classes to insert various sized binary data into a blob field. First I changed the value of max_allowed_packets in my.cnf to prove/disprove that mysqldb/django are using it. Conclusion they do use my.cnf and setting it to 1k will always cause the error. So I set it to 32M and tried loading the large data. Both the mysqldb direct call and django model class routes fail at some point between 10M and 25M with the max packet error. Seems like a bug in mysqldb as the same mysql insert works up to 30M. I'm going to see if there is a later version to try. Thanks for the help Owen On Jul 4, 4:27 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Thanks Martn and Carl. > > > I would really like to avoid having to re design the architecture of > > the application at this stage (its a case of the requirements changing > > after roll out), althougth thanks for the comments re serving large > > data volumes. > > I have made the adjustments suggested > > inhttp://dev.mysql.com/doc/refman/4.1/en/packet-too-large.html > > prior to making these loading the insert directly into mysql failed, > > afterwards it suceeded but the insert through django still fails hence > > my question - Does django ignore the max_allowed_packet setting in > > my.cnf? > > if so how can it be increased so that django uses it? > > django uses python's mysqldb module, which uses mysql's client library. > > My guess is the my.conf you edited is not the one being used. > > I would write a little 5 line .py that just connects and inserts a 5m wad of > data. my guess is it will fail. > > I tried to track down exactly where the .conf file got read, and ran out of > time. But I did see that you can specify it as part of the connection: > > 89 read_default_file > 90 file from which default client values are read > > http://mysql-python.svn.sourceforge.net/viewvc/mysql-python/trunk/MyS... > > I rushed this post and just psoted what I had so far, so let me know if you > need > more details. > > Carl K --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Deleting Object/
I am new to Django and getting started with the Poll example. 1 ) While in the Shell if type "Poll.objects.a() " I get the result [, ] Why am I getting 2 poll objects and what command can I use to delete one. 2) I can view the Admin screen but I am still unable to view the poll app. I've added a new class (see below) to mysite/polls/models.py but the Admin screen remains unchanged. class Poll(models.Model): # ... class Admin: pass Any help would be appreciated TheOrb --~--~-~--~~~---~--~~ 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: Djangonauts at EuroPython?
> Simon Willison is keynoting, and he is an original contributor. I was going to mention that besides Simon (but thought it was too obvious :) We had a fun evening with some Danish friends from #django channel today. Hopefully we see more django-people -- including Simon -- tomorrow! :) Yours, - VS --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
problem with session persistence
I am building an online test taking type of application and I am having an issue with one of my session variables... The code looks something like this: (A lot removed for brevity) The first time around I do the following to initialize the list: question = Question.objects.order_by('?')[0]# Get a random question request.session['question_list'] = [int(question.id),] Then on the second pass, I do the following: questions_asked = request.session['question_list'] question = Question.objects.order_by('?')[0]# Get a random question request.session['question_list'] = questions_asked.append(int(question.id)) Now this partially works. The first page of my test asks how many questions you want and then once that is entered, it takes you to the first question. My debugging output shows that I do indeed have a list with the current question's ID in it. I answer the question, it takes me to page 2. Now my debugging information shows I have two ids in my list, the first question and this second question. Now, when I answer this second question, I get: AttributeError at /flight/test/ 'NoneType' object has no attribute 'append' Here is the traceback info: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "/var/www/localhost/django/flight_school/knowledge_test/views.py" in take_test 42. request.session['question_list'] = questions_asked.append(int(question.id)) AttributeError at /flight/test/ 'NoneType' object has no attribute 'append' If I change the line that appends it to the following: try: request.session['question_list'] = questions_asked.append(int(question.id)) except AttributeError: request.session['question_list'] = [question.id,] Again, the first two are ok, the third shows the request.session['question_list'] contains 'None' The next question show the previous question and the current question. Then none, then previous question and the current question, etc This is with the 0.96 version. Am I doing something wrong? Should I try to upgrade to the svn version? I am using this with apache/ mod_python but the same thing happens with the development 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: Djangonauts at EuroPython?
I don't participate in the EuroPython this year, but have fun in the capital of my native country :) Regards, Aidas Bendoraitis aka Archatas (from Berlin, Germany) On 7/8/07, Ville Säävuori <[EMAIL PROTECTED]> wrote: > > > Simon Willison is keynoting, and he is an original contributor. > > I was going to mention that besides Simon (but thought it was too > obvious :) > > We had a fun evening with some Danish friends from #django channel > today. Hopefully we see more django-people -- including Simon -- > tomorrow! :) > > Yours, > > - VS > > > > > --~--~-~--~~~---~--~~ 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: about django-admin settings
HELP! --~--~-~--~~~---~--~~ 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: about django-admin settings
Set the environment variable PYTHONPATH to the parent directory of the mysite. That should help you. Regards, Aidas Bendoraitis aka Archatas On 7/9/07, jujian <[EMAIL PROTECTED]> wrote: > > HELP! > > > > > --~--~-~--~~~---~--~~ 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: Virtual Hosts, Django, SetEnv and settings.py - random behaviour.
Strange - only one thing was equal for switched requests - PID. Interpreter, host type, os.environ, hostname etc proper for VirtualHost. Anyway, I switched to FastCgi (stil considering mod_wsgi and scgi) and problem disappeared. Cheers, On 4 Lip, 03:30, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > Correct. The whole problem is effectively the result of a race > condition on setting os.environ the first time just before Django > settings file is imported. Normally the requests should be getting > handled in the same Python subinterpreter though and thus os.environ > would be different for each subinterpreter, but that ServerAlias > overlaps with the name of the other VirtualHost must be causing Apache > to handle the request under the context of the wrong VirtualHost. > > One way of confirming which Python subinterpreter is being used, is to > do: > > from mod_python import apache > > and send back the value of: > > apache.interpreter > > in a web page so you can see what it is. > > You might also display the value of: > > apache.main_server.server_hostname > apache.main_server.names > apache.main_server.wild_names > > These show the value of ServerName and ServerAlias. > > Graham > > On Jul 4, 12:53 am, bluszcz <[EMAIL PROTECTED]> wrote: > > > I've just found one thing - this happen if two users send two request > > at once - one for admin.coke, second for *.coke. This happen when > > apache handling these requests by one process (i set PID logging..) > > > On 3 Lip, 13:41, bluszcz <[EMAIL PROTECTED]> wrote: > > > > Thanks Graham for the fast reply. Unfortunately, I cannot list the > > > sites directly - too much of them (about 100), and generally I have to > > > handle all except of 'admin' one :( > > > > On 3 Lip, 13:07, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > > > > > On Jul 3, 8:40 pm, bluszcz <[EMAIL PROTECTED]> wrote: > > > > > > Hello people - I wrote earlier this mail on django devs but Adrian and > > > > > Graham pointed me, that I should write here. > > > > > > I am using Apache 2.0 and mod python 3.3,1 on Ubuntu Dapper x86_64. I > > > > > found a strange behavior during SetEnv directive. But let's start from > > > > > the > > > > > beginning. I have two virtual hosts, one admin and one application, > > > > > both of them works on the same settings file: > > > > > > > > > > >ServerName admin.bluszcz.coke > > > > >PythonDebug On > > > > >SetHandler python-program > > > > >PythonHandler django.core.handlers.modpython > > > > >PythonPath "sys.path + ['/home/bluszcz/coke/app']" > > > > >SetEnv DJANGO_SETTINGS_MODULE pepsi.settings > > > > >SetEnv HOME /home/bluszcz > > > > >PythonInterpreter Admin > > > > >SetEnv ADMINOS True > > > > > > > > > > > > > > > > >ServerName bluszcz.coke > > > > >ServerAlias *.bluszcz.coke > > > > > Try listing your site aliases explicitly rather than using a wildcard. > > > > Maybe the problem is that because the wildcard can match the name of > > > > your other virtual host, ie., admin.bluszcz.coke, that which one > > > > Apache sends the request to may be a bit random. > > > > > >PythonDebug On > > > > >SetHandler python-program > > > > >PythonHandler django.core.handlers.modpython > > > > >PythonPath "sys.path + ['/home/bluszcz/coke/app']" > > > > >SetEnv DJANGO_SETTINGS_MODULE pepsi.settings > > > > > Do you mean coke.settings here. > > > > > >SetEnv HOME /home/bluszcz > > > > >PythonInterpreter Coke > > > > >SetEnv ADMINOS False > > > > > > > > > > > Graham pointed me also, that SetEnv doesn't work with > > > > > os.environmodpythonprocessess (as in themodpythonFAQ is wrote), but > > > > > djangomodpythonhandler has workaround for this. > > > > > > Both applications in checks in theirs settings.py > > > > > os.environ('ADMINOS') and set some variables depending on it. > > > > > Unfortunately, sometimes - it is very difficult to reproduce and > > > > > undetermistic - the second one (bluszcz.coke) get value (ADMINOS) from > > > > > VirtualHost Admin. I set PythonInterpreter (IMVHO) propertly. Any one > > > > > has idea what is happening? > > > > > > Any help would be appreciat. > > > > > > Cheers, --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Update Admin Screen view
1) I can view the Admin screen but I am still unable to view the poll app. I've added a new class (see below) to mysite/polls/models.py but the Admin screen remains unchanged. class Poll(models.Model): # ... class Admin: pass 2 ) While in the Shell if type "Poll.objects.a() " I get the result [, ] Why am I getting 2 poll objects and what command can I use to delete one. Any help would be appreciated Rod --~--~-~--~~~---~--~~ 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: How can I achieve this intersection ?
On Jul 9, 5:17 am, queezy <[EMAIL PROTECTED]> wrote: > I would like to do this in Django, using two lists that are QuerySet lists: > > mylist=mylistWHOM.intersection(mylistWHAT) > > When I do it in the Pythonic way above, the django parser complains with: > 'QuerySet' object has no attribute 'intersection' Of course it complains, QuerySets (or lists) don't have a function called intersection. You can't just make up a name and expect it to do what you want. mylistWHOM.invite_them_to_my_party() won't work either. try something like: whom = set(mylistWHOM) what = set(mylistWHAT) mylist = whom & what # or whom.intersection(what), same thing. --~--~-~--~~~---~--~~ 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: Update Admin Screen view
On Jul 9, 12:19 pm, Rod <[EMAIL PROTECTED]> wrote: > 1) I can view the Admin screen but I am still unable to view the poll > app. > > I've added a new class (see below) to mysite/polls/models.py but > the Admin screen remains unchanged. > > class Poll(models.Model): > # ... > class Admin: > pass That's the correct way to do it. Try restarting the development server? Usually it handles rebuilding it automatically but sometimes if you have saved a model with an error in it, it drops that model until you restart the server. > > 2 ) While in the Shell if type "Poll.objects.a() " I get the result > [, ] > > Why am I getting 2 poll objects and what command can I use to > delete one. Read the api documentation. But basically: polls = Poll.objects.all() poll = polls[0] poll.delete() --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
dump an object
For quickly displaying an object on a page (in particular from a generic view), is there something that is slightly better than {{object}} ? Something between that and the admin look/feel. The goal is to show someone what data will be displayed ins a some what sane way during development, and make it pretty some other day. This might be what I want, but I cant tell: http://code.djangoproject.com/wiki/CookBookShortcutsPageDecoratorSimple Carl K --~--~-~--~~~---~--~~ 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: dump an object
On 7/8/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > Something between that and the admin look/feel. The goal is to show someone > what data will be displayed ins a some what sane way during development, and > make it pretty some other day. Maybe you want databrowse? http://www.djangoproject.com/documentation/databrowse/ > This might be what I want, but I cant tell: > http://code.djangoproject.com/wiki/CookBookShortcutsPageDecoratorSimple Err, why not try it out? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Query Object and comparing only partial TimeField Value
What I want to do is get post between 9:00AM-5:00PM on any day. I just want to compare Hour part of "created_at" field. If the hour is between 9-5, can be any day, get the matching records. Pseudo Django Python Code: Post.objects.get( Q(created_at = (9:00AM - 5:00PM))) Is this possible? --~--~-~--~~~---~--~~ 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: generate choices list from database
On 7/8/07, Stu <[EMAIL PROTECTED]> wrote: > > In a similar vein to the OP, I'm trying to populate a choices list for > a form (using newforms) from a database: > > nameChoices = Names.objects.filter(initials='AB') > NameSelection.base_fields['names'].widget = > widgets.Select(choices=nameChoices.Name) > > However, I am not having much succcess, I get this error: > AttributeError at /names/ > '_QuerySet' object has no attribute Name' > > Anyone have any ideas? Keep in mind that Django doesn't contain any magic syntax parsers - it's just Python code. If what you type doesn't make sense as raw Python, it won't work in Django, either. So - does nameChoices have an attribute called Name? No - nameChoices is a list of objects. Each object in the list might have an attribute called name, but that's not the same thing. To get this example to work, you will need to do a list comprehension to convert the list of objects into a list of names: widgets.Select(choices=[obj.Name for obj in nameChoices]) You will also need to keep in mind the time at which that comprehension will be evaluated. Depending on how you define and use your form, you may find that the choices list isn't as dynamic as you would like. This may be due to the queryset getting evaluated at time of definition, rather than at time of use. If it is evaluated at time of definition, it won't get re-evaluated each time you use it, so the choices list won't be updated if names are added or removed from the list. You may find it necessary to define a function that returns the list, and use that function in the 'choices' definition. 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: Deleting Object/
On 7/9/07, TheOrb <[EMAIL PROTECTED]> wrote: > > I am new to Django and getting started with the Poll example. > > 1 ) While in the Shell if type "Poll.objects.a() " I get the result > [, ] > > Why am I getting 2 poll objects and what command can I use to > delete one. Well - you are getting two poll objects because... there are two poll objects in the database. To delete one, you need to select a single object, and call delete() on it. There are many ways you could do this - which one is correct will depend on which data you want to keep. However, here are some examples of ways to select and delete objects: Poll.objects.all()[0].delete() # Delete the first object in the result set Poll.objects.get(pk=1).delete() # Delete the object with primary key of 1 Poll.objects.get(name='Foobar').delete() # Delete the object with a name of 'Foobar' > 2) I can view the Admin screen but I am still unable to view the poll > app. > I've added a new class (see below) to mysite/polls/models.py but > the Admin screen remains unchanged. > > class Poll(models.Model): > # ... > class Admin: > pass > > Any help would be appreciated The most obvious reason for this is that mysite.polls isn't in your INSTALLED_APPS list. The second reason would be that the web server hasn't loaded the change to the Poll model. If you are using mod_python, you will need to restart apache; if you are using the development server, try restarting the server. 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 -~--~~~~--~~--~--~---
newforms-admin: defaults and radio select
Hi folks, I'm doing my best to convert over to the newforms-admin model. There are three things that used to be model kwargs that I'm having difficulty converting over: default values and radio_admin.. Any tips? Do I have to tie these things into formfield_for_dbfield() in the Options class? Cheers, Allen --~--~-~--~~~---~--~~ 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: Query Object and comparing only partial TimeField Value
> What I want to do is get post between 9:00AM-5:00PM on any day. I > just want to compare Hour part of "created_at" field. If the hour is > between 9-5, can be any day, get the matching records. > > Pseudo Django Python Code: > > Post.objects.get( Q(created_at = (9:00AM - 5:00PM))) > > Is this possible? Yes, it's possible. First off, you'd /generally/ want to likely use .filter() instead of .get() as .get() is designed for getting a single existing row. The .filter() function returns zero-or-more rows which is likely what you want. However in *this* case, because Django doesn't have an __hour pseudo-property for the filter clause like it has a pseudo-year/month/day property as described at http://www.djangoproject.com/documentation/db-api/#year there's no abstracted way to do it that will work across all the DB backends. You can, however, use the .extra() call to pass an additional WHERE clause to your query object. This would take the form something like Post.objects.extra(where=""" hour(app_post.created_at) BETWEEN 9 AND 5+12 """) However, the syntax varies based on your SQL backend. The above should work for MySQL. For sqlite, it would be something like strftime('%y', app_post.created_at) BETWEEN 9 AND 5+12 whereas for PostgreSQL, you would want Extract(hour FROM app_post.created_at) BETWEEN 9 AND 5+12 I'm not 100% positive on the Sqlite variant, as I'm not sure how smart it is about dealing with strings vs. integers (it's a little overhelpful in converting, so you might need a cast()/convert() sort of call to push it to an integer before comparing) -tim --~--~-~--~~~---~--~~ 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 designers
A reply by John Shaffer posted on django-developers (didn't realize it was for "developing django" not "developing with django"): "We use this in Satchmo: Discounts Discount code {{ form.discount }} {% if form.discount.errors %}*** {{ form.discount.errors|join:", " }}{% endif %} Does that give you enough control?" No, that's exactly the type of problem I'm having, with the {{ form.discount }} shortcut rather than it being an or element. The only control that offers me as a designer is knowing that the id in this case would be "id_discount" as a matter of convention and that's it - I can't stick a class on it or add any other attributes, like onFocus or an initial value or all the other range of stuff I'd be able to monkey with if it was a plain old html element rather than something auto-generated. Does using a newform shortcut make things that much easier from a programmatic standpoint? Or to ask the opposite, is using and elements in a template make things that much harder for things like data validation? --~--~-~--~~~---~--~~ 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 designers
Ix5 - thanks for the link, being able to tack classes into the form elements as they're being autogenerated would help but that method looks like a pretty convoluted way to just tack on some presentation- related info, no? Compared to if that element was plain html, that's the standard I'm holding it to. What would be rad is if I could work with the django tags as if they were html, so for example: {{ form.whatever class="red small" onFocus="someJavascriptFunction" }} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
installation issues
I am having trouble installing Django on Mac OSX 10.4.10. Any help would be 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-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 designers
On 7/8/07, Al Abut <[EMAIL PROTECTED]> wrote: > Does using a newform shortcut make things that much easier from a > programmatic standpoint? Or to ask the opposite, is using and > elements in a template make things that much harder for > things like data validation? All that the shortcut does is give you less to type. It doesn't affect validation at all. As long as you have a form element with the same name, validation will work fine. All you need to write is . The validators will work just as well. --~--~-~--~~~---~--~~ 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 designers
I use jQuery as a base for my JS, so it becomes pretty simple to attach the events. I personally don't like putting JS into the HTML element inline, though, so I'm bias. But I basically just add a script element to my form page: $(function() { $('input#id_whatever').focus(someJavascriptFunction); }); As for classes, I've taken to applying them to a div surrounding my input elements. So I have something like: {{ form.whatever.label }} {{ form.whatever }} The CSS isn't much longer... form .red input { color: red; } Nathan Ostgard On Jul 8, 8:04 pm, Al Abut <[EMAIL PROTECTED]> wrote: > Ix5 - thanks for the link, being able to tack classes into the form > elements as they're being autogenerated would help but that method > looks like a pretty convoluted way to just tack on some presentation- > related info, no? Compared to if that element was plain html, that's > the standard I'm holding it to. > > What would be rad is if I could work with the django tags as if they > were html, so for example: > > {{ form.whatever class="red small" onFocus="someJavascriptFunction" }} --~--~-~--~~~---~--~~ 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 designers
> All that the shortcut does is give you less to type. It doesn't affect > validation at all. As long as you have a form element with the same > name, validation will work fine. Ok, thanks John, I'm calling out the developers at work and pointing them to 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: forms and designers
On 7/8/07, Al Abut <[EMAIL PROTECTED]> wrote: > Does using a newform shortcut make things that much easier from a > programmatic standpoint? Or to ask the opposite, is using and > elements in a template make things that much harder for > things like data validation? Well, the thing to remember is that you're not just displaying an empty input element -- it's fairly common, due to the data validation step, to have to go back and show the form again with values filled in. Which raises the question of how you take the in the original form and turn it into after the validation step -- if you're just writing raw HTML form elements you have no way of being able to fill in input, or indicate selected elements, or handle pre-populated data... that's why the {{ form.fieldname }} shortcut exists. -- "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: forms and designers
Nathan, thanks for those tips and that looks like a smart way to attach js triggers and classes for css. What about all the other stuff I could do to an html element though, like specify its initial value? Or do I draw the line there as a designer and say that's on the programmer's plate? James, thanks for the clarification about the exact utility of using the form shortcuts. So would I be correct in saying that if you don't need to programmatically manipulate the values of a form element, then you can stick to plain html form elements instead? Not that I don't care about highlighting errors after the validation step - one method we've been using is to modify the text of the associated and give it a class="error" for me to style up with red text and hazard icons and whatnot. --~--~-~--~~~---~--~~ 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: How can I achieve this intersection ?
Um, I know that you can't make up names and expect them to magically do what you wish. My question was simply how to do the straight Pythonic function in a Django manner. Thanks. - Original Message - From: "SmileyChris" <[EMAIL PROTECTED]> To: "Django users" Sent: Sunday, July 08, 2007 7:24 PM Subject: Re: How can I achieve this intersection ? > > On Jul 9, 5:17 am, queezy <[EMAIL PROTECTED]> wrote: >> I would like to do this in Django, using two lists that are QuerySet >> lists: >> >> mylist=mylistWHOM.intersection(mylistWHAT) >> >> When I do it in the Pythonic way above, the django parser complains with: >> 'QuerySet' object has no attribute 'intersection' > > Of course it complains, QuerySets (or lists) don't have a function > called intersection. You can't just make up a name and expect it to do > what you want. > mylistWHOM.invite_them_to_my_party() won't work either. > > try something like: > > whom = set(mylistWHOM) > what = set(mylistWHAT) > mylist = whom & what # or whom.intersection(what), same thing. > > > > --~--~-~--~~~---~--~~ 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 designers
Ok, so here's what I get when I pinged this discussion to the two python guys I work with: basically, you want to be able to redisplay the data the user entered on a form when you return the page with errors. And that the newform shortcuts are the only way to do that. If that's the case, then fair enough, I'll just have to deal with the existing setup. --~--~-~--~~~---~--~~ 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: How to execute an external application from View
Just wanted to add a "me too!" +1, any help would really be appreciated. I've already tried every variation of os.spawn, and the new subprocess module: subprocess.Popen([cmd, arg1, arg2, ... , argN]) That's supposed to be similar to os.P_NOWAIT, and it does behave similarly. It sits and waits for the process to exit, and then it refuses to redirect. My view has the following pseudo-code shape. view1(request): args=['arg1'] os.spawnv(os.P_NOWAIT, executable, (decorated-executable,) + tuple(args)) return HttpResponseRedirect('http://www.yahoo.com') This view never redirects properly, and no error messages pop up. If I replace the os.P_NOWAIT, with a os.P_WAIT ... then the view redirects properly only after the process has completed as expected. If anyone out there has any ideas at all as to why this is please share. Even if you don't know of a work around, just knowing why this happens would be really handy. Thanks, Ray --~--~-~--~~~---~--~~ 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: dump an object
Jeremy Dunck wrote: > On 7/8/07, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Something between that and the admin look/feel. The goal is to show someone >> what data will be displayed ins a some what sane way during development, and >> make it pretty some other day. > > Maybe you want databrowse? > http://www.djangoproject.com/documentation/databrowse/ Right look, wrong source. My {{object}} is the results of a calendar display with a bunch of these: http://dell29:8000/eventcal/detail/600/ I need the detail for Event 600 to be dumped. I can almost do it with; http://dell29:8000/databrowse/eventcal/event/objects/600/ But that circumvents the view and {% extends "main.html" %} and the plan to hear "yes, that is the right data, lets make it look pretty" and have some clue what attributes object has, just by looking at the 'raw' version rendered in the browser. > >> This might be what I want, but I cant tell: >> http://code.djangoproject.com/wiki/CookBookShortcutsPageDecoratorSimple > > Err, why not try it out? I mean I am not sure how to make it work with 'object' the generic view hands off. Carl K --~--~-~--~~~---~--~~ 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 designers
On 7/8/07, James Bennett <[EMAIL PROTECTED]> wrote: > Well, the thing to remember is that you're not just displaying an > empty input element -- it's fairly common, due to the data validation > step, to have to go back and show the form again with values filled > in. Right, so use: It gets really messy with default values, though. Hopefully Nathan's tips are enough for you, Al. If not, have your programmers make a templatetag or filter: {{ form.fieldname|add_field_attrs:"class='cls'" }} def add_field_attrs: [make a dict out of attrs] return form.fieldname.as_widget(form.fieldname.field.widget, attrs) A templatetag is better, but I outlined a filter because I'm tired. The proper templatetag would let you keep all the standard functionality but still give you the power to add any attribute that you want. --~--~-~--~~~---~--~~ 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-admin: defaults and radio select
Hi Allen, I'm no Django expert (in fact, I just started learning a month ago), but I'm happy to share what I have discovered so far. >From what I can tell, the only way to override the default widget or field for a model's database field is to subclass the Options class and override the kwargs['widget'] for the field. For more info, check out my earlier post: http://groups.google.com/group/django-users/browse_thread/thread/bebad28c9701b4d0/180dd29380fbece9?hl=en#180dd29380fbece9 But there's a complication in the case of the radio widget. I could be mistaken, but I was unable to get it to work with newforms-admin. I had to create my own subclassed radio widget and use that instead. (The problem was that the radio widget was returning a "radio field renderer" object, not the actual code as a unicode string.) If you're interested in the details, I can post my solution tomorrow when I'm at the office. But if anyone with more intimate knowledge of newforms-admin has a better solution, I do hope he'll chime in. Cheers, Leif On Jul 8, 7:38 pm, _ <[EMAIL PROTECTED]> wrote: > Hi folks, > > I'm doing my best to convert over to the newforms-admin model. There > are three things that used to be model kwargs that I'm having > difficulty converting over: default values and radio_admin.. Any tips? > Do I > have to tie these things into formfield_for_dbfield() in the Options > class? > > Cheers, > > Allen --~--~-~--~~~---~--~~ 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: installation issues
On 7/9/07, surfwizz <[EMAIL PROTECTED]> wrote: > > I am having trouble installing Django on Mac OSX 10.4.10. Any help > would be welcome. Thanks! Django works fine on MacOSX - I'm developing on OSX right now. If you want help, you're going to need to ask a specific question. What part of the installation is causing you difficulty? What have you done? what hasn't worked as you expected? 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: dump an object
On 7/8/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > Right look, wrong source. My {{object}} is the results of a calendar display > with a bunch of these: http://dell29:8000/eventcal/detail/600/ I seriously doubt "dell29:8000" is resolvable for me. :) > But that circumvents the view and {% extends "main.html" %} and the plan to > hear > "yes, that is the right data, lets make it look pretty" and have some clue > what > attributes object has, just by looking at the 'raw' version rendered in the > browser. Sorry, I don't follow. :-/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Can textarea attributes (rows, cols) be specified for django admin interface
Hi all, Is it possible to specify HTML attributes (rows, cols) for textarea (TextField) widgets that appear in django's admin interface? If so, some pointers would be great. Thanks, Shankar --~--~-~--~~~---~--~~ 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: Checkout with Tortoise SVN
Hallo, and thank you all very much. I will ask my administrator and tell you if it worked. Thanks On 6 Jul., 23:06, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have seen this error before. > > It is usually because your proxy doesn't support the PROPFIND > command. Ask your administrator to upgrade the proxy (usually squid) > to a version that supports this, or to reconfigure the proxy to allow > this HTTP method. > > On Jul 6, 5:21 am, tsc <[EMAIL PROTECTED]> wrote: > > > Sorry, but I've forgotten to set the proxy server in Tortoise. Now it > > worked a little better. But other repositories work witout the proxy > > settings too, hmm strange. > > Now I get another error: > > REPORT request failed on '/svn/!svn/vcc/default' > > REPORT of '/svn/!svn/vcc/default': 400 Bad Request (http:// > > code.djangoproject.com) --~--~-~--~~~---~--~~ 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: How to execute an external application from View
Den 9. jul. 2007 kl. 06.40 skrev RayLeyva: > > If anyone out there has any ideas at all as to why this is please > share. Even if you don't know of a work around, just knowing why this > happens would be really handy. A working workaround: If javascript is an option, have a look at this: http:// developer.yahoo.com/yui/examples/container/panelwait/1.html Just call the view and then when your external application returns, the view returns the exit status and the popup closes. I use it to import data and generating thumbnails, etc. It works great. :-) -- Knut Ivar Nesheim --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---