Re: Your IDE of choice
what about kdevelop in linux? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin | Lookup via foreign key | Expected Behavior or Bug?
On Thu, Jan 8, 2009 at 12:28 AM, Glen Jarviswrote: > I'm not certain if this is a bug, or expected behavior. It certainly looks > like a Django bug to me. However, after looking at the same database for > hours on end, it could simply be a cross-eyed user error. > > In sort, the admin interface has the following search fields (I know this > won't scale very well and is cumbersome. Unfortunately, it's the fields my > customer wants to search; I also know that the first_service, > second_service, etc. models breaks 2nd normal form however, again, it is > my customer's preference =(). > > search_fields = ['contact_name', 'alternate_contact_name', > 'cross_reference', 'client_reference', 'info', > 'people_involved__first_name', 'people_involved__last_name', > 'people_involved__info', 'case_notes__notes', > 'first_service__service', 'second_service__service', > 'third_service__service', 'fourth_service__service', > 'first_subcontractor__subcontractor', > 'second_subcontractor__subcontractor', > 'third_subcontractor__subcontractor', > 'fourth_subcontractor__subcontractor' > ] > > > If you look at the following link, you'll see two 'cases': > > http://barbados.thepythonshoppe.com/forensic/admin/forensic_database/case/ > > userid: admin > password admin > > (this is a development instance for testing) > > If you notice in case 1, you'll notice that 'indigo' is a 'Person Involved' > first name set up for testing. However, it is not found during a search. In > summary, the following search fields work perfectly: > * 'contact_name' > * 'alternate_contact_name' > * 'cross_reference' > * 'client_reference' > * 'info' > > While the remainders do not. Either I am not properly using the syntax of > 'model, double underscore, field' to refer to the foreign model, I've made > another mistake (or am missing a key piece of information), or this is a > legitimate bug (i.e., foreign key lookups do not work). > > Any help you can give would be great. Then I would know that I need to go > read something to learn from a mistake, or I need to break this down into a > test case for a bug reproduction. > > I've tested this against the latest trunk with the same results. > > The admin.py file is attached. > > Thanks in advance, > I'd expect to get an error (I know I've gotten them) if the double-underscore syntax were incorrect or if you were specifying non-existent fields, etc. ForeignKey spanning search such as this does work -- I just tried adding some to my DB (using both forward and backwards relationships) and they worked correctly, even when more than five were listed in a single search_fields list. So I have no idea what is going wrong in your case. I'd try simplifying search fields to a single one that is not currently working. If you specify that one, does it work? If not, check the SQL generated by the admin (either turn on query logging at the database or use something like the debug toolbar) for clues as to why the search isn't working. If the one field does work, add fields one at at time until it breaks, and see what sort of clues you get then, and from the SQL generated then, etc. Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django too slow
On Thu, Jan 8, 2009 at 1:04 AM, Vickywrote: > > I using the django to generate xml and to fetch datas from database. > When i run it the response is too slow. it takes nearly 4sec to load > the page. So what can i do to make my program more efficient. Plse > tell me some things to avoid so that it becomes faster First thing you need to do is figure out where the slowness originates. Is it from DB access? XML generation? If it's from DB access, include the code you're using to fetch data. If XML generation, likewise. -- --- David Zhou da...@nodnod.net --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django too slow
I using the django to generate xml and to fetch datas from database. When i run it the response is too slow. it takes nearly 4sec to load the page. So what can i do to make my program more efficient. Plse tell me some things to avoid so that it becomes faster --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Setting Bound Fields Programmatically
On Wed, 2009-01-07 at 21:28 -0800, Keyton Weissinger wrote: > I have a form with the following fields (all required): > - first_name > - last_name > - site_id > > I'd like to use a template to display only the FIRST two items to the > user for him to fill out: > > > {{ form.first_name }} > {{ form.last_name }} > > > > Then when it gets posted back to me I'd like to set the site_id based > on a session variable or whatever like this (from my view): > > if request.method == 'POST': > my_data = {'site_id':1234} > my_data.update(request.POST) > form = form_class(data=my_data, files=request.FILES) > if form.is_valid(): > process form here... > > > My problem is that I cannot get the form to validate. It keeps telling > me that site_id is not set. On the surface, that look like it should work. Which makes me suspect some important detail has been lost in the simplification. What does the my_data dictionary look like just before you execute the "form = ..." line (print it out)? Also, how is form_class specified? Finally, what is the exact error Django gives you? Print out form._errors, for example. Maybe somewhere in there the answer will jump out. Admittedly, all the clues may already be there and I'm just missing the obvious, but I can't see it right now. On a related note, is there any particular reason you need to have site_id in the form class at all? Even if it's a model form, you could exclude it, and add it into the model object later, couldn't you? You might be going about this slightly backwards by trying to force in site_id when it's not something that actually needs to be validated or form-processed. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Setting Bound Fields Programmatically
On Thu, Jan 8, 2009 at 12:28 AM, Keyton Weissingerwrote: > > I have a form with the following fields (all required): > - first_name > - last_name > - site_id > > I'd like to use a template to display only the FIRST two items to the > user for him to fill out: > > > {{ form.first_name }} > {{ form.last_name }} > > > > Then when it gets posted back to me I'd like to set the site_id based > on a session variable or whatever like this (from my view): > >if request.method == 'POST': >my_data = {'site_id':1234} >my_data.update(request.POST) >form = form_class(data=my_data, files=request.FILES) >if form.is_valid(): > process form here... > > > My problem is that I cannot get the form to validate. It keeps telling > me that site_id is not set. > > How can I programmatically set this one form field's value and have > the user set the others without sending through a hidden field yada > yada. > > Please help! > Why do you have this field included in the form at all? Not only do you not want it to be required, but you do not even want to display it? So why it is there? Putting it there and then trying to fake out as though valid data had been posted for it just seems like a backwards approach to whatever real problem you are trying to solve. Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Setting Bound Fields Programmatically
I have a form with the following fields (all required): - first_name - last_name - site_id I'd like to use a template to display only the FIRST two items to the user for him to fill out: {{ form.first_name }} {{ form.last_name }} Then when it gets posted back to me I'd like to set the site_id based on a session variable or whatever like this (from my view): if request.method == 'POST': my_data = {'site_id':1234} my_data.update(request.POST) form = form_class(data=my_data, files=request.FILES) if form.is_valid(): process form here... My problem is that I cannot get the form to validate. It keeps telling me that site_id is not set. How can I programmatically set this one form field's value and have the user set the others without sending through a hidden field yada yada. Please help! Thank you. Keyton --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin | Lookup via foreign key | Expected Behavior or Bug?
I'm not certain if this is a bug, or expected behavior. It certainly looks like a Django bug to me. However, after looking at the same database for hours on end, it could simply be a cross-eyed user error.In sort, the admin interface has the following search fields (I know this won't scale very well and is cumbersome. Unfortunately, it's the fields my customer wants to search; I also know that the first_service, second_service, etc. models breaks 2nd normal form however, again, it is my customer's preference =( ). search_fields = ['contact_name', 'alternate_contact_name', 'cross_reference', 'client_reference', 'info', 'people_involved__first_name', 'people_involved__last_name', 'people_involved__info', 'case_notes__notes', 'first_service__service', 'second_service__service', 'third_service__service', 'fourth_service__service', 'first_subcontractor__subcontractor', 'second_subcontractor__subcontractor', 'third_subcontractor__subcontractor', 'fourth_subcontractor__subcontractor' ]If you look at the following link, you'll see two 'cases': http://barbados.thepythonshoppe.com/forensic/admin/forensic_database/case/userid: adminpassword admin(this is a development instance for testing)If you notice in case 1, you'll notice that 'indigo' is a 'Person Involved' first name set up for testing. However, it is not found during a search. In summary, the following search fields work perfectly:* 'contact_name'* 'alternate_contact_name'* 'cross_reference'* 'client_reference'* 'info'While the remainders do not. Either I am not properly using the syntax of 'model, double underscore, field' to refer to the foreign model, I've made another mistake (or am missing a key piece of information), or this is a legitimate bug (i.e., foreign key lookups do not work).Any help you can give would be great. Then I would know that I need to go read something to learn from a mistake, or I need to break this down into a test case for a bug reproduction.I've tested this against the latest trunk with the same results.The admin.py file is attached.Thanks in advance,Glen Jarvis --415-680-3964g...@glenjarvis.comhttp://www.glenjarvis.com"You must be the change you wish to see in the world." -M. Gandhi from django.contrib import admin from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin from myproject.forensic_database.models import Case, CaseNote, Company,\ Country, Function, PeopleInvolved, Service, Subcontractor, Tool forensic_admin = admin.AdminSite() # User Section # class UserAdmin(UserAdmin): fieldsets = ( ('Commonly Used', { 'fields': ['username', 'email', 'password', ('first_name', 'last_name'), ('is_active', 'is_staff', 'is_superuser'), 'user_permissions', ] } ), ) list_display = ('username', 'first_name', 'last_name', 'is_active', 'is_staff', 'is_superuser', 'last_login', ) list_display_links = ('username', 'first_name', 'last_name', 'is_active', 'is_staff', 'is_superuser', 'last_login', ) ordering = ('username', ) search_fields = ['username' ] # Case Section # class CaseNoteInline(admin.StackedInline): model=CaseNote fieldsets = ( ('Case Note', { 'fields': ('date','notes', 'initials',), 'classes': ('collapse',), }), ) extra=1 class PeopleInvolvedInline(admin.StackedInline): model=PeopleInvolved fieldsets = ( ('Person Involved', { 'fields': ('first_name','last_name', 'work_phone', 'mobile_phone', 'home_phone', 'email', 'info',), 'classes': ('collapse',), }), ) class CaseAdmin(admin.ModelAdmin): fieldsets = ( ('Case', { 'fields': (('case_number', 'company',), ('cross_reference', 'client_reference',), ('date_appointed', 'date_completed',), ('status', 'country',), ), }), ('Contact Details', { 'fields': (('contact_name', 'contact_work_phone', 'contact_mobile_phone', 'contact_home_phone', 'contact_email'), ), }), ('Alternate Contact Details', { 'fields': (('alternate_contact_name', 'alternate_contact_phone'),), 'classes': ('collapse',), }), ('Image', { 'fields': ('image',), 'classes': ('collapse',), 'description': 'Select image to upload. Click Save when finished.' }), ('Case Details', { 'fields': ('info', 'cost_analysis', 'report'), 'classes':
Re: Module Title
On Wed, 2009-01-07 at 20:34 -0800, Eric I.E. wrote: > I am trying to change the title of a module in the admin. I just need > to change the displayed name, easy enough for a field or a model but I > have not been able to figure out how to do it for an entire module. > Any pointers would be greatly appreciated. You can't really do that at the moment. You're talking about what we call the "application" name, and that's taken from the Python name. You could write a custom template for the admin interface that hard-codes what you're after. Copying the existing template and putting in an "if" template tag to test if the name's the one you want to override. So it's not necessarily impossible and I've seen it done, but you have to really want to do it. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Module Title
I am trying to change the title of a module in the admin. I just need to change the displayed name, easy enough for a field or a model but I have not been able to figure out how to do it for an entire module. Any pointers would be greatly 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-users@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: NewBie Question about ForeignKey relationships
Thanks for the pointer, I had read all around that. The short version is: maker.auto_set.all() There was was Dry(er) more elegant method to be found. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
Hey for gedit you should try my plug in http://github.com/vbabiy/gedit-openfiles/tree/master Vitaly Babiy On Wed, Jan 7, 2009 at 10:08 AM, don iliciswrote: > > > 2009/1/7 Kenneth Gonsalves > >> >> On Tuesday 06 Jan 2009 5:18:57 pm HB wrote: >> > What is your favorite IDE for coding Django projects? >> >> geany >> >> -- >> regards >> KG >> http://lawgon.livejournal.com >> >> >> me too > and also gedit / vim > > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: what type of data structure should I use?
Thanks for the link. I like that. I'm going to see if I can use it. I'd like to be able to do one query, then bring it into this plugin, sort it 3 or 4 different ways on the client side. I haven't really had any time today to look at it. But, I also thought about trying some kind of session object to hold the data. I could possibly use it to work with the jQuery plugin. On Jan 7, 7:40 pm, Ozan Onaywrote: > There's no need to keep selecting from the DB and refreshing the page. > You can re-sort the list client-side on AJAX response (with jQuery, > for instance). The tablesorter plugin (http://tablesorter.com/docs/) > is not exactly what you're looking for but will give you an idea of > how to sort client-side, if you're not sure. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't get_profile() create the profile object?
On Wed, 2009-01-07 at 22:50 -0200, Alvaro Mouriño wrote: > I find myself checking for the existence of the profile object for the > user everytime I call the get_profile function or making sure that it > gets created with every user. > > Is there a reason for this? Shouldn't the framework assure me that I > will get a profile whenever I call get_profile()? Even if it means > creating one? The function is called get_profile, not get_or_create_profile. Some people would like it to create automatically, others prefer it to be explicit. I'm in the latter camp: if a user should have a profile, I should create it properly when creating the user (e.g. using a signal), not have some magical transparency happen behind the curtain that hides the bug of me forgetting to do so. After all, if you're creating a profile, you might well need to initialise it in some particular default way. So now get_profile() needs to be like get_or_create() and accept a bunch of default arguments. Much more complicated. It's a moot point, though. Changing it would introduce the sort of backwards incompatibility we try to avoid. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: could not import settings error, FastCGI
Malcolm Tredinnick wrote: > On Tue, 2009-01-06 at 19:40 -0800, Bradley wrote: > >> I'm having a strange problem in that I can make any change that I want >> to the .fcgi file, short of deleting it and I get the same django >> error about seymourherald.settings not found. I can delete the entire >> contents of the file so all it has in it is #!/path/to/python and it >> still gives me this error message. How on earth is it still loading >> django? Error message looks like >> >> ImportError: Could not import settings 'seymourherald.settings' (Is it >> on sys.path? Does it have syntax errors?): No module named >> seymourherald.settings >> >> So I've been trying to troubleshoot why it can't find >> seymourherald.settings and I guess I've determined it doesn't have to >> do with my .fcgi file. I've checked and rechecked my PYTHONPATH, any >> other ideas? >> > > The obvious guess would be permission problems. You have different > access permissions to the webserver. Does the webserver (the user that > is executing the fastcgi script) have permission to read the file? And > the directories leading down to the file (the latter will need "execute" > permission set for the "other" section on Unix-like systems). > > Regards, > Malcolm > > Thanks for your help. I finally found the problem after hours of banging my head against the wall. It was simply the fastcgi script was always running. I have to kill the fastcgi script after making changes to the .fcgi file or else the changes will never take effect. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: could not import settings error, FastCGI
On Tue, 2009-01-06 at 19:40 -0800, Bradley wrote: > I'm having a strange problem in that I can make any change that I want > to the .fcgi file, short of deleting it and I get the same django > error about seymourherald.settings not found. I can delete the entire > contents of the file so all it has in it is #!/path/to/python and it > still gives me this error message. How on earth is it still loading > django? Error message looks like > > ImportError: Could not import settings 'seymourherald.settings' (Is it > on sys.path? Does it have syntax errors?): No module named > seymourherald.settings > > So I've been trying to troubleshoot why it can't find > seymourherald.settings and I guess I've determined it doesn't have to > do with my .fcgi file. I've checked and rechecked my PYTHONPATH, any > other ideas? The obvious guess would be permission problems. You have different access permissions to the webserver. Does the webserver (the user that is executing the fastcgi script) have permission to read the file? And the directories leading down to the file (the latter will need "execute" permission set for the "other" section on Unix-like systems). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Returning large files from a view
Ultimately what they really need is: View-03 wsgi.file_wrapper for large file serving from: http://code.djangoproject.com/wiki/Version1.1Features At least then it will be optimal for WSGI case. Graham On Jan 8, 10:42 am, bruno desthuillierswrote: > On 8 jan, 00:15, bruno desthuilliers > wrote: > > > > > On 7 jan, 23:37, David Lindquist wrote: > > > > I would like to return a binary file from a view, and so far I have > > > something like this: > > > > def my_file(request): > > > file_data = open("/path/to/file", "rb").read() > > > response = HttpResponse(file_data, mimetype="application/ > > > whatever") > > > response['Content-Disposition'] = 'attachment; filename=my_file' > > > return response > > > > Is there a better way to do this, especially for very large (> 10MB) > > > files? > > > Do you have any reason to serve these files thru django instead of > > letting your frontal web server handle them ?. > > (sorry, hit the send button to soon) > > Else, you could eventually just pass the file object itself to > HttpResponse: > > http://docs.djangoproject.com/en/dev/ref/request-response/#passing-it... > > ... but I don't know if you will gain that much from doing so (wild > guess: this probably depends on how you deploy your django instance). > Also, this may (or not) cause problem with ressource (the file) > deallocation (but this can eventually be solved using some 'lazy' > proxy instead of the file object itself). > > 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-users@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: Shouldn't blank=True imply null=True?
On Wed, 2009-01-07 at 21:46 +, tofer...@gmail.com wrote: > On 07.01-13:40, Jeff Anderson wrote: > [ ... ] > > > please troll somewhere else. > > > > > I wasn't trolling, thank you. I was genuinely interested in how this > > would look. > > my apologies, i mis-read your terse questioning. > > a 'blank' value is essentially undefined in database terms and may be > interpreted in various ways. Not, that's a NULL value. Blank has absolutely no technical meaning at the database level and certainly not any kind of ambiguous one. That's just confusing the issue. You're correct that Django uses it as a data-entry-level term meaning that the field was left blank, but wishing/hoping that it also substitutes as NULL isn't making things any clearer. As far as I'm concerned, this issue kind of died when somebody pointed out the binary field case. That's a minimally valid example of why the separation makes sense still. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "submit" and urls.py fail after moving site from runserver to Apache
On Wed, 2009-01-07 at 11:12 -0800, rabbi wrote: [...] > I have a submit input on one of my pages and when I run the site on > runserver it still works fine (I just tried it now) > However, when I run the exact same site on Apache the url that is > returned by "submit" is different, and this obviously causes the > pattern matching in urls.py to fail That's not correct. See below. > > Here is the html + template script that causes the problem > > {% if error_message %}{{ error_message }}{% > endif %} > > > {% for entry in entry_list %} > {{ > entry.eng_val }} label> > > {% endfor %} > > > > With runserver it returns the following when I press submit: > "http://127.0.0.1:8000/swenglish/test/submit/; > > With Apache it returns the followingwhen I press submit: > "http://localhost/swenglish/test/submit/?thank > +you=tack=mycket=han=roligt=hej+da=sno" I don't think this is the problem you think it is. URL pattern matching in Django doesn't look at the hostname portion of the URL or the query string (everything after the "?"). So those two URLs should look exactly the same to Django. When you have DEBUG=True in your settings file, do you really get the 404 screen saying it couldn't match any URL patterns? If so, what pattern does it say it was trying to match? It looks like something is going wrong in the runserver case, by the way. Your form is submitted using a GET action, which means the submitted URL should look like the second case (although the hostname portion might well be different). It's not clear why you're using GET and not POST there, by the way -- better to use normal form processing practice -- which means action="post", not action="get" -- when you're starting out so that the differences don't make things any harder than they already are. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Customizing form fields display
On Wed, 2009-01-07 at 10:38 -0800, sagi s wrote: > Can anyone suggest a way to customize model field display? Use auxillary functions. Model fields carry no implicit "display" concept with them, since they represent the data object, separate from the presentation. > > For example if I have a model called Course with fields n_girls and > n_students, > > if for a particular record n_girls = 4 and n_students = 10, I want to > display for n_girls: "40% (4)" instead of just "4". > > Obviously I can do this in the template but there are multiple fields > I want to customize and the lack of switch/elsif statement in the > templates would make for a deeply nested structure so I'd rather do it > upstream in the model. Write some model methods that return the appropriate string format of the given field. Or write some filters that accept a model object as the input value and format it appropriately. Using template filters for presentation changes always feels pretty natural to me. Model methods work, but, as noted above, my inclination is always to use models as the presentation-agnostic data object and set things up so that I can control presentation indepedently of the data itself. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: subquery has too many columns
On Wed, 2009-01-07 at 09:36 -0800, timc3 wrote: [...] > ProgrammingError: subquery has too many columns > > > It seems that this query is creating the problem: > > groupmembers = requestedgroup.group_members.exclude > (id__in=groupadmins) We'll need a bit more information here, since the devil's always in the details. At a minimum, what is the output of groupmembers.query.as_sql() There may be a problem with exclude and nested querysets. I just realised I haven't explicitly tested those. Also, which database are you using? There are lots of SQL variations between databases (for example, nested queries don't work with Oracle at the moment for an unusual reason that I'll fix later today). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: what type of data structure should I use?
There's no need to keep selecting from the DB and refreshing the page. You can re-sort the list client-side on AJAX response (with jQuery, for instance). The tablesorter plugin (http://tablesorter.com/docs/) is not exactly what you're looking for but will give you an idea of how to sort client-side, if you're not sure. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Specified key was too long; max key length is 767 bytes
On Wed, 2009-01-07 at 20:49 +0530, Rama wrote: > i have a model as below (please follow the red color lines) > > class NewsEntry(models.Model) : > url = models.URLField(max_length=1024,db_index=True) > title = models.CharField(max_length=1024) > > - > thereafter i ran > python manage.py syncdb > >i am getting the following error > Failed to install index for pystories.NewsEntry model: Specified > key was too long; max key length is 767 bytes That result is going to be database server specific and possibly also dependent upon whether you specified the table or database as accepting UTF-8 encoded strings or just plain ASCII. So which database are you using? [...] > But As per the requirement URL should be of length 1024 > so what did is ? > 1) kept the length to 1024 A URLfield is just a character field and since you also create a character field of the same length without an index and it worked, that would seem to rule out this possibility. > 2) Executed the following command on database > CREATE INDEX urlindex ON pystories_newsentry(url(255)); > > >Can i specify the same thing (i.e) creation of index on URL(255) > instead of 1024 in model class NewsEntry itself instead of going >to database and running the command (CREATE INDEX urlindex ON > pystories_newsentry(url(255));) ? No, you can't. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: NewBie Question about ForeignKey relationships
On Wed, Jan 7, 2009 at 8:26 PM, Mark Joneswrote: > > Ok, here is some simple code: > > class Maker(models.Model): >name = CharField(max_length=20) > > class Auto(models.Model): >name = CharField(max_length) >maker = ForeignKey(Maker) > > > maker = Maker.objects.get(pk=1) > > How do I get all the Autos made by this maker > > I don't see a maker.autos (railsish) > All I have been able to figure out for this is: > > Auto.objects.filter(maker=maker.id)# this works > Auto.objects.filter(maker=maker)# this works too > > Is that all there is, or is there some maker.autos abstraction that I > just don't see. The last method 2 methods both work, but it seems > awkward to use them given the fact that I have a Maker, and the > relationship between Maker and Auto is known in the models but via the > Manager interface requires restatement in (maker=maker.id) or > alternately (maker=maker) http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
NewBie Question about ForeignKey relationships
Ok, here is some simple code: class Maker(models.Model): name = CharField(max_length=20) class Auto(models.Model): name = CharField(max_length) maker = ForeignKey(Maker) maker = Maker.objects.get(pk=1) How do I get all the Autos made by this maker I don't see a maker.autos (railsish) All I have been able to figure out for this is: Auto.objects.filter(maker=maker.id)# this works Auto.objects.filter(maker=maker)# this works too Is that all there is, or is there some maker.autos abstraction that I just don't see. The last method 2 methods both work, but it seems awkward to use them given the fact that I have a Maker, and the relationship between Maker and Auto is known in the models but via the Manager interface requires restatement in (maker=maker.id) or alternately (maker=maker) --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Import models from CSV files?
heya, The sample code request was just me being lazy =). Hmm, so you think the csv parsing code should be in the upload processing? This would just be a form with two boxes for the user to select the .csv files, and an upload button. Better putting it here than in the model? In terms of processing, well, there's only a little bit. One of the files is a dump from a Lotus Notes view. It looks a little like this DateRegion Arrival TimeDurationSites For 2008-12-1 Australia 7:30 AM - 1.25 [HR] /SYD/225 G John Smith /GER/115 A Nolan Smith 7:30 AM - 1.25 [HR] /SYD/225 G Bob Smith 7:30 AM - 1.25 [HR] /SYD/225 G Joe Smith NZ 7:30 AM - 1.25 [HR] /SYD/225 G Jane Smith /SYD/ 7:30 AM - 1.0 [HR] /SYD/225 G Mary Smith 7:30 AM - 5.0 [HR] /SYD/225 G Brown Smith 2008-12-2 NZ 7:30 AM - 1.25 [HR] /SYD/225 G Jane Smith /SYD/ 7:30 AM - 1.25 [HR] /SYD/225 G Mary Smith 7:30 AM - 1.25 [HR] /SYD/225 G Brown Smith Firstly, there were dropdowns (e.g. for Date, and Region) - those date and regions apply to the rows below them - annoying, but easy to deal with. Also, the time is given as a start time and duration - I converted this into a start_time and end_time. Finally, the Sites and For columns can each contain multiple entries. After parsing, I'm storing it as a list of users, each with a list of access periods granted (containing the start_time, end_time and site - and a few other things). So you go through, and create entries for each user, for each of the sites, per line. Not too bad. Heck, I'll just post the code (I'm halfway through working on it - may not compile cleanly right now, but you get the idea). http://dl.getdropbox.com/u/281283/access_requests.py I guess the important thing is just the users being able to upload the .csv files themselves, and dealing with weirdness in the input. Cheers, Victor On Jan 8, 2:01 am, Keyton Weissingerwrote: > Hey Victor, > > I did the django-batchimport mentioned earlier. I think it will > address your need but is definitely aimed at XLS. However, it does > already handle duplicates (it will either update them or ignore them > based on setting). You can also specify a subset of model fields to > use to determine whether a given row represents a duplicate. This > allows for "batch update" too. > > If you get into it and have any problems, drop me a note. > > Keyton > > On Jan 6, 12:02 am, Victor Hooi wrote: > > > heya, > > > This question might seem a bit simple, but what's the best way to > > instantiate models from .csv files? > > > Essentially, I have two .csv files. One contains a list of people, and > > their access rights (one-to-many). The second .csv file contains a log > > of doorway access (just a bunch of sequential lines). I have a simple > > python script which imports these two .csv files, does some processing > > (the files are quite messy), creates user and access-entry objects, > > and produces a reconciliation with a list of exceptions (basically > > door entries which aren't in the list of user/access rights). Each > > user is just a dictionary, with their username as key, and a tuple of > > dictionary objects for their various access rights. > > > I would like a simple django project to import these logs, instantiate > > models, and then basically manage it via the in-built admin interface, > > hopefully saving a lot of time =). (will also need to deal with > > duplicates). Is there a smart way to go about doing this project, or > > any existing addons I can leverage off? > > > Thanks, > > Victor --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Shouldn't get_profile() create the profile object?
I find myself checking for the existence of the profile object for the user everytime I call the get_profile function or making sure that it gets created with every user. Is there a reason for this? Shouldn't the framework assure me that I will get a profile whenever I call get_profile()? Even if it means creating one? Thanks! -- AlvAro --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to impose a permission-based filter in admin?
Wow ... that article is so good, it needs to be part of the standard Django docs. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Returning large files from a view
On 8 jan, 00:15, bruno desthuillierswrote: > On 7 jan, 23:37, David Lindquist wrote: > > > I would like to return a binary file from a view, and so far I have > > something like this: > > > def my_file(request): > > file_data = open("/path/to/file", "rb").read() > > response = HttpResponse(file_data, mimetype="application/ > > whatever") > > response['Content-Disposition'] = 'attachment; filename=my_file' > > return response > > > Is there a better way to do this, especially for very large (> 10MB) > > files? > > Do you have any reason to serve these files thru django instead of > letting your frontal web server handle them ?. (sorry, hit the send button to soon) Else, you could eventually just pass the file object itself to HttpResponse: http://docs.djangoproject.com/en/dev/ref/request-response/#passing-iterators ... but I don't know if you will gain that much from doing so (wild guess: this probably depends on how you deploy your django instance). Also, this may (or not) cause problem with ressource (the file) deallocation (but this can eventually be solved using some 'lazy' proxy instead of the file object itself). 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-users@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: How to impose a permission-based filter in admin?
Karen officially rocks. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Returning large files from a view
On Jan 7, 2009, at 4:15 PM, bruno desthuilliers wrote: > > On 7 jan, 23:37, David Lindquistwrote: >> I would like to return a binary file from a view, and so far I have >> something like this: >> >> def my_file(request): >> file_data = open("/path/to/file", "rb").read() >> response = HttpResponse(file_data, mimetype="application/ >> whatever") >> response['Content-Disposition'] = 'attachment; filename=my_file' >> return response >> >> Is there a better way to do this, especially for very large (> 10MB) >> files? > > Do you have any reason to serve these files thru django instead of > letting your frontal web server handle them ?. The files do not reside under our site's document root, because my boss does not want them there (for reasons that aren't entirely clear to me). Also, we want to do some extra processing before the file is served, e.g. increment an integer representing the number of downloads. Thirdly, we want to be able to force the browser to download the file instead of displaying it (in the case of PDFs, for example). --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to impose a permission-based filter in admin?
On Wed, Jan 7, 2009 at 12:30 PM, ZebZigglewrote: > > Hi, > > I have two Model classes: > > class Opportunity(models.Model): >rep = models.ForeignKey(User) > ... > > class Deal(models.Model): >opportunity = models.ForeignKey(Opportunity) > ... > > > I want to limit the admin UI so that users can only see Opportunities > and the related Deals they own. If they attempt to go into the Deal > table directly, again, they should only see their Deals. > > To make it more interesting: Some users (that have a special > permission) should be able to see ALL Opportunities and Deals. > > How can I do this? > I'd start by reading this: http://www.b-list.org/weblog/2008/dec/24/admin/ Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Redirect parent from within iframe without losing session
I am getting a very similar problem when simply going between views (all within the same domain), so it may be nothing to do with iframes. I have put in a trace and can see that in some cases you enter the view with all session variables set and when the session is next saved all the variables have been cleared. On Jan 5, 10:57 pm, Berco Beutewrote: > This one still has me flabbergasted. It may be a browser restriction > (firefox 3), but there is no way I can have the iFrame redirect the > parent page to another page in the same domain (as the previous parent > page) without invalidating thesession. Is there maybe another common > solution for iFrames to give back control to the parent page? > > 2B > > On Jan 5, 10:43 am, Berco Beute wrote: > > > The iFrame is from a different domain, which is likely causing the > > problem. I can see that thesessionis lost since the logged in user > > is suddenly logged out. > > > 2B > > > On Jan 5, 1:15 am, Daniel Roseman > > wrote: > > > > Personally, I can't see how that redirect could be causing asession > > > to be 'lost'. As long as you stay within the same domain, yoursession > > > should remain valid. Are you sure that you are using 'localhost:8000' > > > as the original address as well as the redirected one? How are you > > > ascertaining that thesessionis being lost? > > > -- > > > 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-users@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 -~--~~~~--~~--~--~---
Returning large files from a view
I would like to return a binary file from a view, and so far I have something like this: def my_file(request): file_data = open("/path/to/file", "rb").read() response = HttpResponse(file_data, mimetype="application/ whatever") response['Content-Disposition'] = 'attachment; filename=my_file' return response Is there a better way to do this, especially for very large (> 10MB) files? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to impose a permission-based filter in admin?
Upon further research ... I'm suspecting I need to create a Manager and override get_query_set(), but since I don't have a request object, I can't get the currently logged in user. Is there a recommended approach to this for the dev stream? -Z --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
On 07.01-13:40, Jeff Anderson wrote: [ ... ] > > please troll somewhere else. > > > I wasn't trolling, thank you. I was genuinely interested in how this > would look. my apologies, i mis-read your terse questioning. a 'blank' value is essentially undefined in database terms and may be interpreted in various ways. in a mysql database (and other relational databases i know of) a 'blank integer' would generally be null. however the value could also trigger a database condition that would assign it a specific value which could in fact be defined as a custom data type or enumerated value. essentially, your question holds limitless answers, none of which you could actually 'see' (unless you wish to see an arbitary mnemonic or binary code). in django 'blank' does not define the data type, or even a property of the data it simply asserts that an empty (or blank) field submission should be considered valid, or more accurately, not be considered invalid within the admin interface. i think of this as a common override case in the standard validation code (which is most useful for a text field). --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Display of foreignkey relations
Hello everybody, I need your help. I have the following data model: class Contract (models.Model): : class Project (models.Model): :: contract= models.ForeignKey( "Contract") and would need to modify the administration interface that automatically generates Django, in order to view in edit page contract of admin the list for each of their projects. But I do not want to edit them in the contract. You should get something like: Contract 1 List of project Project A Project B I hope your answers. Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
Textmate with Python/Django bundles is very visually nice, but without code completion (and a few other tools) is just a pretty screen. Eclipse/PyDev would be nice, but it does seem to have a lot of little issues that are annoying. I have used IntelliJ for Java (and a couple of Rails projects) for the last few years and am looking into the Python/Django support for it. If they bring this up to speed then it should be the best IDE out there. On Jan 6, 3:48 am, HBwrote: > Hey, > What is your favorite IDE for coding Django projects? > Any ideas about PyDev and ActiveState Komodo IDE? > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using cache_page decorator with callable cllasses
On 7 jan, 20:13, "Elton Okada"wrote: > Hello, I wish to use a callable class to anwser this URL: > > urlpatterns = patterns('voduBBB.servicos.views', > (r'^participantes/$', ParticipanteView()), > ) > > It is OK. > > Now I wish to cache the result of ParticipanteView() using this > decorator: @cache_page(60) at the __call__ method of this class. > > But is fall in this error: > 'ParticipanteView' object has no attribute 'method' Posting the relevant code and the full traceback would have help... Without this, my only guess is that there's something wrong in your code that makes the decorator confusing your class __call__ method with the request object. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
On Wed, 2009-01-07 at 13:40 -0700, Jeff Anderson wrote: > tofer...@gmail.com wrote: > > ...I was genuinely interested in how this would look. One thing worth bearing in mind is that Django supports different database backends. Potentially, or ideally, it might even support non-SQL databases, like hierarchical databases, or XML-based databases. -- Lee --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Revise "search code" in Django Book
Hello, I am using the search code from the Django Book to search a publication table (model). The results are placed on the search.html page. I want to drill down and send more detail from the link that now surrounds each of the search results. I would like that detail information to go to another page search_detail.html. The ID from the first search is associated with each publication link and that ID should be able to retrieve the same information as the original search, but let me expand on the info for one publication on a new page. I need assistance on either revising the original search function in the view or fixing the search_detail function instead. The code is here: http://dpaste.com/106510/.Can anyone help? Thanks, Bob --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
tofer...@gmail.com wrote: > On 07.01-08:51, Jeff Anderson wrote: > >>> I agree with this. I use null=False, blank=True for some ImageFields >>> and integers. >>> >> I'm interested in how a blank integer looks in a MySQL database. Can you >> provide an example? >> > > please troll somewhere else. > I wasn't trolling, thank you. I was genuinely interested in how this would look. signature.asc Description: OpenPGP digital signature
Re: Traceback in the ``runserver`` console
Hi Russ, As I thank you for your quick reply I apologise for my lack thereof. These approaches seem well suited (and surprisingly clean) for achieving the desired functionality. I think it will make sense to suggest an improvement to the `--traceback` switch, perhaps making a patch if I have a brave moment sometime soon, and I appreciate the encouragement. Regards, Friðrik Már On Dec 27 2008, 1:14 pm, "Russell Keith-Magee"wrote: > On Sat, Dec 27, 2008 at 2:32 AM, Fridrik Mar Jonsson > wrote: > > > > > Hi Djangonians, > > > I recently had an instance where it would have been really convenient > > to see the error and a traceback in the ``runserver`` console instead > > of just a single line telling me that the request returned a 500 > > error. > > > In the event of blind debugging, where a 3rd party tool is performing > > a request that renders in an error, is there a Django mechanism or > > extension that allows you to catch any exceptions that occur during a > > page load and redirect them to the ``runserver`` console in addition > > to displaying them in the template? > > There are two options I can think of on an unmodified Django install. > > Firstly, write a middleware that implements process_exception(). This > middleware will get invoked whenever an exception is raised as part of > the view; the middleware method will be the exception as one of the > arguments. > > http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-... > > Secondly, write a listener for the got_request_exception signal. This > signal is fired whenever an exception other than 404, Permission > Denied, or SystemExit is raised. > > http://docs.djangoproject.com/en/dev/ref/signals/#django.core.signals... > > > For an optimistic moment I thought ``--traceback`` was a bit > > promising, but then it turned out that it doesn't really seem to do > > what I expected in the case of ``runserver``. I even considered > > switching to e-mail tracebacks but ended up writing a client to mimic > > the 3rd party tool's functionality instead. > > When I read this I went and had a look at the code, and it appears you > are correct. ``--traceback`` exists as a top-level command option, but > it doesn't appear to be exploited at all in runserver. This actually > surprised me - it seems like a reasonable suggestion for an > improvement. Feel free to open this as a ticket (and if you're really > adventurous, work on a patch :-) > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
On 07.01-08:51, Jeff Anderson wrote: > > I agree with this. I use null=False, blank=True for some ImageFields > > and integers. > I'm interested in how a blank integer looks in a MySQL database. Can you > provide an example? please troll somewhere else. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using cache_page decorator with callable cllasses
Hello, I wish to use a callable class to anwser this URL: urlpatterns = patterns('voduBBB.servicos.views', (r'^participantes/$', ParticipanteView()), ) It is OK. Now I wish to cache the result of ParticipanteView() using this decorator: @cache_page(60) at the __call__ method of this class. But is fall in this error: 'ParticipanteView' object has no attribute 'method' PS: I have already set the attribute method in this class: method = '' The error occurs no more, but nothig get cached. Any ideia? 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
"submit" and urls.py fail after moving site from runserver to Apache
Hi, I followed the django tutorial and got my site running on runserver + sqlite3 with no problems I then moved the site onto apache + mod_python and (after receiving some help from this group) managed to get the same site semi-running The admin page, home page, and a few others are working as they were with runserver... but I now have a strange problem with one of my pages I have a submit input on one of my pages and when I run the site on runserver it still works fine (I just tried it now) However, when I run the exact same site on Apache the url that is returned by "submit" is different, and this obviously causes the pattern matching in urls.py to fail Here is the html + template script that causes the problem {% if error_message %}{{ error_message }}{% endif %} {% for entry in entry_list %} {{ entry.eng_val }} {% endfor %} With runserver it returns the following when I press submit: "http://127.0.0.1:8000/swenglish/test/submit/; With Apache it returns the followingwhen I press submit: "http://localhost/swenglish/test/submit/?thank +you=tack=mycket=han=roligt=hej+da=sno" Any help would be greatly appreciated! Alex --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: lighttpd + django on windows
In fact, I think that the chapter describing the fastcgi deployment in the django doc is a little ... light :-) it gives only a description of a typical django.fcgi, and that's all. I have already deployed django sites with the following configs: - fastcgi ona hosting platform - apache/mod_python - standalone and there was no problem. With lighttpd, I thought (naively ?) that the deployement would be light and easy and I am just disappointed to note that it is not true. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
On Wed, Jan 7, 2009 at 12:48 PM, Jeff Andersonwrote: > Karen Tracey wrote: > > On Wed, Jan 7, 2009 at 10:51 AM, Jeff Anderson >wrote: > > > > > >> varikin wrote: > >> > >>> I agree with this. I use null=False, blank=True for some ImageFields > >>> and integers. > >>> > >> I'm interested in how a blank integer looks in a MySQL database. Can you > >> provide an example > > I believe the further description a bit later in the email covered this: > > > > In the case of an integer, I use it for order of the images. So if a > number > > > >> is given for an image, it is used, otherwise auto assign the order > number. > >> > > > > > > That is, blank is not actually stored in the DB but rather the lack of a > > user-provided value triggers creation of an auto-assigned value. > > > But that is code that could/should belong in the form/validation code. Could: probably, should: maybe, required to be: no. > The models define how things are to be setup and stored in the database > backend. > By that reasoning it sounds like blank should not be a model field parameter, since it only controls what is accepted in forms for the model, not what is stored in the database. > > A blank value in a webpage does not translate to a blank value in the > database, so blank=True is incorrect in this case, as an auto-assigned > value isn't actually blank, because a non-blank value will be stored in > the database. > blank simply controls whether the form field is required. It doesn't say anything about what's stored in the database, that's what null is for. They're decoupled, which allows for setting blank=True,null=False and substituting a non-blank auto-generated value at some point after form validation but before saving the model. It may not be an approach you prefer, but that does not make it incorrect. Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
Glad it was of use. Except for the script which I wrote myself, all the information came from either the following page or a link from that page: http://code.djangoproject.com/wiki/UsingVimWithDjango On Wed, 2009-01-07 at 19:32 +0100, Oscar Carlsson wrote: > Sweet! > > I've been looking (and I'm pretty sure it's not only me who's been > looking) for some good tutorial on how to do this. > > Luckily I use OS X at home, which probably means that I can use this > without any modification... :-D > > Thank you very much! > > Oscar > > On Wed, Jan 07, 2009 at 01:06:43PM +, Adam Stein wrote: > > > > I have omnicomplete working (haven't used it too much yet). I have this > > in my $HOME/.vimrc file: > > > > --.vimrc-- > > if has("autocmd") > > autocmd BufRead *.py set smartindent > > \ cinwords=if,elif,else,for,while,try,except,finally,def,class > > > > autocmd FileType python set omnifunc=pythoncomplete#Complete > > autocmd FileType javascript set > > omnifunc=javascriptcomplete#CompleteJS > > autocmd FileType html set omnifunc=htmlcomplete#CompleteTags > > autocmd FileType css set omnifunc=csscomplete#CompleteCSS > > endif > > > > " Allow to be used instead of like other IDE's do > > " for auto-completion > > inoremap > > --.vimrc-- > > > > All 'autocmd' lines should be single lines. > > > > Also, I have vim starting automatically importing the Django db. I have > > a little script (below) that will automatically find my settings.py file > > and start vim. I do this by starting at the location of the file on the > > vim command line and working upwards in the directory structure until I > > find it: > > > > --dvim-- > > #!/packages/bin/python > > > > """ > > Start vim for Django files > > """ > > > > import os > > import sys > > > > args = sys.argv > > > > # Get our starting directory to look for the settings file. If no > > # filename is given, start in the current directory > > if len(args) > 1: > > # If multiple filenames are given on the command line, we assume > > # the same Django settings apply to all > > dir = os.path.realpath(os.path.dirname(args[1])) > > else: > > dir = os.path.realpath(".") > > > > # Start looking for the settings file, going up one directory if we > > # don't find it until we hit the top of the filesystem > > > > while not os.path.exists(dir + "/settings.py"): > > if dir == "/": > > # We are as far as we can go and didn't find anything > > dir = None > > break > > > > # Go up one directory > > dir = os.path.dirname(dir) > > > > if dir != None: > > # Found the settings file > > os.putenv("PYTHONPATH", os.path.dirname(dir)) > > os.putenv("DJANGO_SETTINGS_MODULE", os.path.basename(dir) + > > ".settings") > > > > os.system("/packages/bin/vim '+python from django import db' " + \ > > " ".join(args[1:])) > > else: > > raise IOError("Django settings file not found") > > > > sys.exit(0) > > --dvim-- > > > > I'm sure some lines are probably getting wrapped. > > > > I only use Django on Unix/Linux so I'm guessing it would need some > > tweaking for Windows. > > > > On Wed, 2009-01-07 at 12:26 +0100, Oscar Carlsson wrote: > > > Have you been able to make omnicomplete work with Django? > > > I haven't been able to figure it out myself, and gave up after a few > > > tries. It would be really sweet to have, since vim otherwise is a really > > > good editor. > > > > > > Oscar > > > > > > On Wed, Jan 07, 2009 at 12:15:22PM +1930, Santiago wrote: > > > > > > > > i recently switched to screen + vim with omnicomplete for python and > > > > html... > > > > > > > > komodo edit its pretty good too > > > > > > > > 2009/1/7 martyn: > > > > > > > > > > Hi > > > > > > > > > > http://pyrox.utp.edu.co/ > > > > > > > > > > Regards > > > > > > > > > > Bye. > > > > > > > > > > On Jan 6, 9:34 am, roberto wrote: > > > > >> I tried them all (almost ... I think... at least the free ones). > > > > >> - Pyscripter is really nice but it is true, it is only for windows. > > > > >> (If it is developed with python it should be platform-independent, > > > > >> shouldn' be ?) (no support for sql queries I think) > > > > >> - Eclipse + PyDev (no good support for sql queries to relational db) > > > > >> - Ulipad (open source / excellent / very small / some issues with > > > > >> svn / no support for sql queries to db - django plugin to highlight > > > > >> templates, etc) > > > > >> - Netbeans (ex-NBPython) it is excellent (very good sql support - > > > > >> some > > > > >> issues with memory consume - I didn't get debugger work 100% with > > > > >> django) > > > > >> - Oracle jdeveloper. it is an excellent tool. Its support for python > > > > >> is still too new and I think that django support is still to come. > > > > >> - Eric4: screenshots are very beautiful bu I couldn't get to install > > > >
Customizing form fields display
Can anyone suggest a way to customize model field display? For example if I have a model called Course with fields n_girls and n_students, if for a particular record n_girls = 4 and n_students = 10, I want to display for n_girls: "40% (4)" instead of just "4". Obviously I can do this in the template but there are multiple fields I want to customize and the lack of switch/elsif statement in the templates would make for a deeply nested structure so I'd rather do it upstream in the model. Thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
Sweet! I've been looking (and I'm pretty sure it's not only me who's been looking) for some good tutorial on how to do this. Luckily I use OS X at home, which probably means that I can use this without any modification... :-D Thank you very much! Oscar On Wed, Jan 07, 2009 at 01:06:43PM +, Adam Stein wrote: > > I have omnicomplete working (haven't used it too much yet). I have this > in my $HOME/.vimrc file: > > --.vimrc-- > if has("autocmd") > autocmd BufRead *.py set smartindent > \ cinwords=if,elif,else,for,while,try,except,finally,def,class > > autocmd FileType python set omnifunc=pythoncomplete#Complete > autocmd FileType javascript set > omnifunc=javascriptcomplete#CompleteJS > autocmd FileType html set omnifunc=htmlcomplete#CompleteTags > autocmd FileType css set omnifunc=csscomplete#CompleteCSS > endif > > " Allow to be used instead of like other IDE's do > " for auto-completion > inoremap > --.vimrc-- > > All 'autocmd' lines should be single lines. > > Also, I have vim starting automatically importing the Django db. I have > a little script (below) that will automatically find my settings.py file > and start vim. I do this by starting at the location of the file on the > vim command line and working upwards in the directory structure until I > find it: > > --dvim-- > #!/packages/bin/python > > """ > Start vim for Django files > """ > > import os > import sys > > args = sys.argv > > # Get our starting directory to look for the settings file. If no > # filename is given, start in the current directory > if len(args) > 1: > # If multiple filenames are given on the command line, we assume > # the same Django settings apply to all > dir = os.path.realpath(os.path.dirname(args[1])) > else: > dir = os.path.realpath(".") > > # Start looking for the settings file, going up one directory if we > # don't find it until we hit the top of the filesystem > > while not os.path.exists(dir + "/settings.py"): > if dir == "/": > # We are as far as we can go and didn't find anything > dir = None > break > > # Go up one directory > dir = os.path.dirname(dir) > > if dir != None: > # Found the settings file > os.putenv("PYTHONPATH", os.path.dirname(dir)) > os.putenv("DJANGO_SETTINGS_MODULE", os.path.basename(dir) + > ".settings") > > os.system("/packages/bin/vim '+python from django import db' " + \ > " ".join(args[1:])) > else: > raise IOError("Django settings file not found") > > sys.exit(0) > --dvim-- > > I'm sure some lines are probably getting wrapped. > > I only use Django on Unix/Linux so I'm guessing it would need some > tweaking for Windows. > > On Wed, 2009-01-07 at 12:26 +0100, Oscar Carlsson wrote: > > Have you been able to make omnicomplete work with Django? > > I haven't been able to figure it out myself, and gave up after a few > > tries. It would be really sweet to have, since vim otherwise is a really > > good editor. > > > > Oscar > > > > On Wed, Jan 07, 2009 at 12:15:22PM +1930, Santiago wrote: > > > > > > i recently switched to screen + vim with omnicomplete for python and > > > html... > > > > > > komodo edit its pretty good too > > > > > > 2009/1/7 martyn: > > > > > > > > Hi > > > > > > > > http://pyrox.utp.edu.co/ > > > > > > > > Regards > > > > > > > > Bye. > > > > > > > > On Jan 6, 9:34 am, roberto wrote: > > > >> I tried them all (almost ... I think... at least the free ones). > > > >> - Pyscripter is really nice but it is true, it is only for windows. > > > >> (If it is developed with python it should be platform-independent, > > > >> shouldn' be ?) (no support for sql queries I think) > > > >> - Eclipse + PyDev (no good support for sql queries to relational db) > > > >> - Ulipad (open source / excellent / very small / some issues with > > > >> svn / no support for sql queries to db - django plugin to highlight > > > >> templates, etc) > > > >> - Netbeans (ex-NBPython) it is excellent (very good sql support - some > > > >> issues with memory consume - I didn't get debugger work 100% with > > > >> django) > > > >> - Oracle jdeveloper. it is an excellent tool. Its support for python > > > >> is still too new and I think that django support is still to come. > > > >> - Eric4: screenshots are very beautiful bu I couldn't get to install > > > >> it in my ubuntu box (too many precedences and too complicated for a > > > >> newbie like me). > > > >> > > > >> Have a great year 2009 everyone ! > > > >> > > > >> On Jan 6, 9:02 am, "Trivedi, Apaar" wrote: > > > >> > > > >> > I use Eclipse with PyDev and PyDev extensions. I really like it, > > > >> > but I > > > >> > prefer the eclipse sort of IDE's. > > > >> > > > >> > > > > >> > > > >> > From: django-users@googlegroups.com > > > >> >
Re: subquery has too many columns
And what is `groupadmins`? On Wed, Jan 7, 2009 at 8:36 PM, timc3wrote: > > I updated my django version to revision 9710 today and now I am > getting the following error message on screen: > > Caught an exception while rendering: subquery has too many columns > > This is the traceback: > > Original Traceback (most recent call last): > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/template/debug.py", line 71, in > render_node >result = node.render(context) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/template/debug.py", line 87, in render >output = force_unicode(self.filter_expression.resolve(context)) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/template/__init__.py", line 559, in > resolve >new_obj = func(obj, *arg_vals) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/template/defaultfilters.py", line 510, > in length >return len(value) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/db/models/query.py", line 160, in > __len__ >self._result_cache = list(self.iterator()) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/db/models/query.py", line 275, in > iterator >for row in self.query.results_iter(): > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/db/models/sql/query.py", line 203, in > results_iter >for rows in self.execute_sql(MULTI): > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/db/models/sql/query.py", line 1752, in > execute_sql >cursor.execute(sql, params) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/db/backends/util.py", line 19, in > execute >return self.cursor.execute(sql, params) > ProgrammingError: subquery has too many columns > > > It seems that this query is creating the problem: > > groupmembers = requestedgroup.group_members.exclude > (id__in=groupadmins) > > And the model looks like this: > > group_members = models.ManyToManyField(User, verbose_name="group > members", related_name="groupofumembers") > > > > And ideas? > > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
Karen Tracey wrote: > On Wed, Jan 7, 2009 at 10:51 AM, Jeff Anderson >wrote: > > >> varikin wrote: >> >>> I agree with this. I use null=False, blank=True for some ImageFields >>> and integers. >>> >> I'm interested in how a blank integer looks in a MySQL database. Can you >> provide an example > I believe the further description a bit later in the email covered this: > > In the case of an integer, I use it for order of the images. So if a number > >> is given for an image, it is used, otherwise auto assign the order number. >> > > > That is, blank is not actually stored in the DB but rather the lack of a > user-provided value triggers creation of an auto-assigned value. > But that is code that could/should belong in the form/validation code. The models define how things are to be setup and stored in the database backend. A blank value in a webpage does not translate to a blank value in the database, so blank=True is incorrect in this case, as an auto-assigned value isn't actually blank, because a non-blank value will be stored in the database. Jeff Anderson signature.asc Description: OpenPGP digital signature
subquery has too many columns
I updated my django version to revision 9710 today and now I am getting the following error message on screen: Caught an exception while rendering: subquery has too many columns This is the traceback: Original Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/template/debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/template/__init__.py", line 559, in resolve new_obj = func(obj, *arg_vals) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/template/defaultfilters.py", line 510, in length return len(value) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/db/models/query.py", line 160, in __len__ self._result_cache = list(self.iterator()) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/db/models/query.py", line 275, in iterator for row in self.query.results_iter(): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/db/models/sql/query.py", line 203, in results_iter for rows in self.execute_sql(MULTI): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/db/models/sql/query.py", line 1752, in execute_sql cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) ProgrammingError: subquery has too many columns It seems that this query is creating the problem: groupmembers = requestedgroup.group_members.exclude (id__in=groupadmins) And the model looks like this: group_members = models.ManyToManyField(User, verbose_name="group members", related_name="groupofumembers") And ideas? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using a model method in ModelAdmin fieldsets
Thanks Karen & Daniel, I think your overiding approach will work. Thank you. Implemented a work around. I added extra fields (that persist my method information) to my model that I update and save when I do a listing. Price I pay is an extra database update each time the model is getting listed. Will see how it influence performance. Thank you for your replies. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to impose a permission-based filter in admin?
Hi, I have two Model classes: class Opportunity(models.Model): rep = models.ForeignKey(User) ... class Deal(models.Model): opportunity = models.ForeignKey(Opportunity) ... I want to limit the admin UI so that users can only see Opportunities and the related Deals they own. If they attempt to go into the Deal table directly, again, they should only see their Deals. To make it more interesting: Some users (that have a special permission) should be able to see ALL Opportunities and Deals. How can I do this? Thx! -Z --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
Add to your list: * native 'scp'/'ftp' ability * Cross platform (Linux, MAC, WIN32) Bernard wrote: > I use Komodo IDE 5 everyday for every Python/Django/PHP/Drupal > projects at work and damn it works well. > > What I love about it: > > * Key bindings(shortcuts) for almost everything > * Simple subversion integration so I don't have to switch to another > window to commit something. > * Search & Replace , Regex toolkit > * Code Snippets. I have plenty of those for Django templates, HTML, > CSS, Python & PHP. > * http://code.google.com/p/django-komodo-kit/ for more django goodness > in Komodo Edit or IDE > > What I hate about it: > * a little slow to start but once it's fired, there's nothing stopping > it. > > what it looks like on my laptop : > http://www.picoodle.com/view.php?img=/3/1/6/f_komodoidem_51d0317.png=img37 > > On Jan 6, 6:48�am, HBwrote: > > Hey, > > What is your favorite IDE for coding Django projects? > > Any ideas about PyDev and ActiveState Komodo IDE? > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using a model method in ModelAdmin fieldsets
On Wed, Jan 7, 2009 at 11:45 AM, EagerToUnderstandwrote: > > What I try to achieve: > I have a couple of model methods that exposes real time information. > (Retrieved when method is called.) This is information I want to > display not only in the list_display, but also within the change view. > (Where the fieldsets come into play). > > Since the list_display option support methods call I was wondering how > I can expose this information within the change view without too much > changing the default code. I think the problem is that the change > view builds up a form from the model and method calls can not be > updated. The reason why not included in the form object ..and > therefor not visible to the fieldsets field? > > Still clear as mud? > The change view pretty much focuses on displaying in a form only what you can change in a model (non-editable fields are not displayed at all, for example). Since you can't edit/change something that is the result of a model method, I don't believe there are any hooks for showing these thing on the change page. If I were to try to do this (which I haven't, so no guarantees that this is even the right approach) I'd probably start by looking at overriding/extending the template used for the change view for that model: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: lighttpd + django on windows
On Wed, Jan 7, 2009 at 9:54 AM, Eric Simorrewrote: > > Does anybody know a tutorial about deploying django with lighttpd on > windows ? > > it does not work , and I don't find what to do > If nobody responds with a pointer to a tutorial, you might want to provide a few more details on what exactly you've done to set it up (versions, commands run, whatever) and what "does not work" looks like, exactly. I know nothing of this particular setup, but without such details you are not likely to get many helpful responses, even from people who have some experience trying the same setup you are attempting. Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
On Wed, Jan 7, 2009 at 10:51 AM, Jeff Andersonwrote: > varikin wrote: > > I agree with this. I use null=False, blank=True for some ImageFields > > and integers. > I'm interested in how a blank integer looks in a MySQL database. Can you > provide an example? > > I believe the further description a bit later in the email covered this: In the case of an integer, I use it for order of the images. So if a number > is given for an image, it is used, otherwise auto assign the order number. That is, blank is not actually stored in the DB but rather the lack of a user-provided value triggers creation of an auto-assigned value. Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Upcoming on-line Spanish translation sprint: Friday, Jan. 9, 2009
>From Friday, Jan. 9 to Sunday, Jan. 11, 2009 the Spanish Django community is going to hold an on-line translation sprint. The main purpose of this sprint is to translate the most important parts of the Django documentation into Spanish. After that the Spanish documentation will be available in the Spanish community site http://django.es and it will be merged into trunk when Jacob adds support for merging translated documentation: http://groups.google.com/group/django-developers/browse_thread/thread/a904a8e302d9e915 All details for translating any document into Spanish are described here: http://django.es/blog/traducir-la-documentacion-de-django-al-espanol/ Join us! :) Thank you. Regards, Antonio Melé --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using a model method in ModelAdmin fieldsets
What I try to achieve: I have a couple of model methods that exposes real time information. (Retrieved when method is called.) This is information I want to display not only in the list_display, but also within the change view. (Where the fieldsets come into play). Since the list_display option support methods call I was wondering how I can expose this information within the change view without too much changing the default code. I think the problem is that the change view builds up a form from the model and method calls can not be updated. The reason why not included in the form object ..and therefor not visible to the fieldsets field? Still clear as mud? On Jan 7, 5:48 pm, Daniel Rosemanwrote: > On Jan 7, 10:35 am, EagerToUnderstand wrote: > > > I am referencing a self defined model method in list_display option of > > ModelAdmin. I would like to do the same in the fiedsets option of > > ModelAdmin, but I get an error saying my method is missing from the > > form when the page is rendered. It seems to me I can only render > > model methods with list_display and not the fiedsets. > > > Any tips to get this working? > > Not at all sure what you're hoping to achieve here. Fieldsets are for > groups of fields on the model edit page. How does a model method fit > into this? Can you show us some code? > -- > 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-users@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 -~--~~~~--~~--~--~---
Adding link to Django book Search code
Hello, I would like to change the view so that the link retrieves more of the detailed information from the same model publication, but I haven't figured out how to change the view to respond either to a new search and/or to more detailed information about the item found. The link can go to a new page or refresh on the current search.html page. See http://dpaste.com/106410/ for the html and the view. The URL is: urlpatterns = patterns('mysite.fsafety.views.', (r'^$', 'index'), (r'^search/$', 'search'), ) Thank you for any help. Bob --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Drop down list not seeing newly added record
Thanks for your feedback. I will implement the changes that were suggested. -- Original message -- From: Daniel Roseman> > On Jan 7, 7:47 am, jeffhg58 wrote: > > I have a 2 forms. One to add a new author and then another form for > > Articles which has a drop down list to reference the authors. The > > behavior I am seeing is that when I add a new author and then go to > > the New Article form which references the author it does not display > > the new record. Also, I put in some print statements in the New > > Article form class and those statements are only executed when I go to > > my home page. > > > > Here are my code snippets > > > > def welcome(request): > > > > print 'in welcome' > > > > if request.GET: > > if request.GET.has_key( 'newarticle'): > > > > print 'going to new article' > > > > return HttpResponseRedirect( '/melsite/newarticle') > > if request.GET.has_key( 'newauthor'): > > print 'going to new author' > > > > return HttpResponseRedirect( '/melsite/newauthor') > > else: > > > > print 'retrieving articles' > > > > articles = Article.objects.filter > > (type_index__type='Poem').order_by('title') > > > > return render_to_response('stories/welcome.html', {'title': > > 'Poems', 'articles': articles}) > > > > def newarticle( request): > > > > print 'in new article request' > > from storyforms import NewArticle > > > > if request.method == 'POST': > > print 'in new article post' > > new_data = request.POST.copy() > > articleform = NewArticle(new_data) > > if form.is_valid(): > > form.save( new_data) > > articles = Article.objects.filter > > (type_index__type='Poem').order_by('title') > > > > return render_to_response('stories/welcome.html', > > {'title': 'Poems', 'articles': articles}) > > else: > > print 'in setting up new article' > > #from storyforms import NewArticle > > articleform = NewArticle() > > print 'after setting up new article' > > print 'rendering article' > > return render_to_response('stories/add_story.html', {'form': > > articleform}) > > > > class NewArticle( forms.Form): > > > > articletypelist=[] > > authorlist = [] > > > > print 'in new article class' > > > > articletypes = ArticleType.objects.all().order_by( 'type') > > articletypelist.append( selecttuple) > > for articletype in articletypes: > > choicestr = "choice%s" % str( articletype.id) > > typetuple = choicestr, articletype.type > > articletypelist.append( typetuple) > > authors = Author.objects.all().order_by( 'last_name') > > print 'authors in new article are ', authors > > authorlist.append( selecttuple) > > for author in authors: > > choicestr = "choice%s" % str( author.id) > > authorname = author.first_name + ' ' + author.last_name > > authortuple = choicestr, authorname > > authorlist.append( authortuple) > > > > ArticleType = forms.ChoiceField( choices=articletypelist) > > Author = forms.ChoiceField( choices=authorlist) > > Title = forms.CharField() > > Content = forms.CharField( widget=forms.Textarea) > > print 'end of new article def' > > > > Thanks, > > Jeff > > As Karen says, logic in the class declaration is only executed once, > when the form is first imported. Authorlist and articletypelist are > much better implemented as class methods on the relevant models: > > class Author(models.Model): > ... > @classmethod > def get_authorlist(cls): > return [('choice%s' % a.id, '%s %s' % (a.first_name, > a.last_name)) > for a in cls.objects.all().order_by('last_name')] > > Then in your view or template you can do Author.get_authorlist() to > return the up-to-date list. > > However, a much better solution is to use ModelChoiceField for the > Articletype and Author fields. These populate the list dynamically > from a queryset: > > class NewArticle(forms.Form): > ... > Author = forms.ModelChoiceField(queryset=Author.objects.order_by > ('last_name')) > > -- > 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-users@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: lighttpd + django on windows
Eric Simorre wrote: > it does not work , and I don't find what to do > Well, there's your problem. You should just make it work. :) signature.asc Description: OpenPGP digital signature
Re: Shouldn't blank=True imply null=True?
varikin wrote: > I agree with this. I use null=False, blank=True for some ImageFields > and integers. I'm interested in how a blank integer looks in a MySQL database. Can you provide an example? signature.asc Description: OpenPGP digital signature
Re: Using a model method in ModelAdmin fieldsets
On Jan 7, 10:35 am, EagerToUnderstandwrote: > I am referencing a self defined model method in list_display option of > ModelAdmin. I would like to do the same in the fiedsets option of > ModelAdmin, but I get an error saying my method is missing from the > form when the page is rendered. It seems to me I can only render > model methods with list_display and not the fiedsets. > > Any tips to get this working? Not at all sure what you're hoping to achieve here. Fieldsets are for groups of fields on the model edit page. How does a model method fit into this? Can you show us some code? -- 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-users@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: Drop down list not seeing newly added record
On Jan 7, 7:47 am, jeffhg58wrote: > I have a 2 forms. One to add a new author and then another form for > Articles which has a drop down list to reference the authors. The > behavior I am seeing is that when I add a new author and then go to > the New Article form which references the author it does not display > the new record. Also, I put in some print statements in the New > Article form class and those statements are only executed when I go to > my home page. > > Here are my code snippets > > def welcome(request): > > print 'in welcome' > > if request.GET: > if request.GET.has_key( 'newarticle'): > > print 'going to new article' > > return HttpResponseRedirect( '/melsite/newarticle') > if request.GET.has_key( 'newauthor'): > print 'going to new author' > > return HttpResponseRedirect( '/melsite/newauthor') > else: > > print 'retrieving articles' > > articles = Article.objects.filter > (type_index__type='Poem').order_by('title') > > return render_to_response('stories/welcome.html', {'title': > 'Poems', 'articles': articles}) > > def newarticle( request): > > print 'in new article request' > from storyforms import NewArticle > > if request.method == 'POST': > print 'in new article post' > new_data = request.POST.copy() > articleform = NewArticle(new_data) > if form.is_valid(): > form.save( new_data) > articles = Article.objects.filter > (type_index__type='Poem').order_by('title') > > return render_to_response('stories/welcome.html', > {'title': 'Poems', 'articles': articles}) > else: > print 'in setting up new article' > #from storyforms import NewArticle > articleform = NewArticle() > print 'after setting up new article' > print 'rendering article' > return render_to_response('stories/add_story.html', {'form': > articleform}) > > class NewArticle( forms.Form): > > articletypelist=[] > authorlist = [] > > print 'in new article class' > > articletypes = ArticleType.objects.all().order_by( 'type') > articletypelist.append( selecttuple) > for articletype in articletypes: > choicestr = "choice%s" % str( articletype.id) > typetuple = choicestr, articletype.type > articletypelist.append( typetuple) > authors = Author.objects.all().order_by( 'last_name') > print 'authors in new article are ', authors > authorlist.append( selecttuple) > for author in authors: > choicestr = "choice%s" % str( author.id) > authorname = author.first_name + ' ' + author.last_name > authortuple = choicestr, authorname > authorlist.append( authortuple) > > ArticleType = forms.ChoiceField( choices=articletypelist) > Author = forms.ChoiceField( choices=authorlist) > Title = forms.CharField() > Content = forms.CharField( widget=forms.Textarea) > print 'end of new article def' > > Thanks, > Jeff As Karen says, logic in the class declaration is only executed once, when the form is first imported. Authorlist and articletypelist are much better implemented as class methods on the relevant models: class Author(models.Model): ... @classmethod def get_authorlist(cls): return [('choice%s' % a.id, '%s %s' % (a.first_name, a.last_name)) for a in cls.objects.all().order_by('last_name')] Then in your view or template you can do Author.get_authorlist() to return the up-to-date list. However, a much better solution is to use ModelChoiceField for the Articletype and Author fields. These populate the list dynamically from a queryset: class NewArticle(forms.Form): ... Author = forms.ModelChoiceField(queryset=Author.objects.order_by ('last_name')) -- 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-users@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 -~--~~~~--~~--~--~---
Using a model method in ModelAdmin fieldsets
I am referencing a self defined model method in list_display option of ModelAdmin. I would like to do the same in the fiedsets option of ModelAdmin, but I get an error saying my method is missing from the form when the page is rendered. It seems to me I can only render model methods with list_display and not the fiedsets. Any tips to get this working? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
On Jan 7, 5:51 am, tofer...@gmail.com wrote: > On 07.01-09:47, Malcolm Tredinnick wrote: > [ ... ] > > > This thread is about whether blank=True, null=False (the fourth > > possibility) ever makes sense for non-text fields. > > answer is yes for any field type that accepts an empty string as having > a meaning. i currently use this for a couple of custom fields that > are autogenerated but can be set manually, if desired. it could also > happen for innumerate other reasons. > > or put more simply '-1' for me. > I agree with this. I use null=False, blank=True for some ImageFields and integers. In both cases, I am generated the this content for the database, but it is not entered. In the case of the ImageField, an image is uploaded (an original), then I generate a thumbnail, and a viewable (a standard sized image). Technically at this point I don't need blank=True here because users only upload the original image, but at some point I can allow them to upload an optional thumbnail and then use that if supplied or generate it if not. In the case of an integer, I use it for order of the images. So if a number is given for an image, it is used, otherwise auto assign the order number. I thought this was a common use case with Django. So that is a -1 for me. Thanks, John --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Specified key was too long; max key length is 767 bytes
i have a model as below (please follow the red color lines) class NewsEntry(models.Model) : url = models.URLField(max_length=1024,db_index=True) title = models.CharField(max_length=1024) - thereafter i ran python manage.py syncdb i am getting the following error Failed to install index for pystories.NewsEntry model: Specified key was too long; max key length is 767 bytes i understood that the problem is with max_length of the URL. if i change it 255 everthing was going on fine. But As per the requirement URL should be of length 1024 so what did is ? 1) kept the length to 1024 2) Executed the following command on database CREATE INDEX urlindex ON pystories_newsentry(url(255)); Can i specify the same thing (i.e) creation of index on URL(255) instead of 1024 in model class NewsEntry itself instead of going to database and running the command (CREATE INDEX urlindex ON pystories_newsentry(url(255));) ? --rama --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Drop down list not seeing newly added record
On Wed, Jan 7, 2009 at 7:47 AM, jeffhg58wrote: > > I have a 2 forms. One to add a new author and then another form for > Articles which has a drop down list to reference the authors. The > behavior I am seeing is that when I add a new author and then go to > the New Article form which references the author it does not display > the new record. Also, I put in some print statements in the New > Article form class and those statements are only executed when I go to > my home page. > Yes, the NewArticle form class is only loaded once, and then reused. This is standard Python behavior. If you need to depend on data that may change between the time the form class is loaded and a form instance is created, you need to put the logic that retrieves and uses that data into an __init__ function. The __init__ function will get called each time a NewArticle form instance is created, rather than just once when the NewArticle code is imported/loaded. Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django: creating formset is very slow
Hi, I was able to solve it. The issue was not with formsets, nor database. It was slow because request.POST was getting delayed - ranging from 3.5 seconds to 3+ minutes. I even tried having an assignment as follows: x = request.POST and even that was taking 3seconds to 3 minutes. On going through the depths of wsgi code (yay, opensource), I found the parsing is much slower in case on multipart messages - and I had my http content-type and encoding as multipart. Since having files was a rare thing in my code, I modified the code to encode as basic encoding unless files was present. Now, the same code - with 500 elements - take 0.7 seconds instead of the earlier 117 seconds. Open source is amazing. Regards K Jeff FW wrote: > Post the code for DataForm--I'll bet it's hitting the database a > number of times. That would be the only reason I can think of that it > would take that long. I just created a formset containing simple > forms, and it instantiated almost instantly--even with 2000 forms. > > -Jeff > > On Jan 6, 3:21�pm, "Kottiyath Nair"wrote: > > I tried with 500 forms instead of 25. Now the time is becoming appaling.--- > > 117 seconds. Second time it hung. > > > > 2009-01-07 01:42:13,812 INFO Start - 4.46984183744e-006 > > 2009-01-07 01:42:13,812 INFO Formset Class created- 0.000422958783868 > > 2009-01-07 01:44:11,703 INFO Created new formset- 117.90750668 > > 2009-01-07 01:44:17,203 INFO All forms done - 123.39991647 > > 2009-01-07 01:44:17,217 INFO Start - 123.416734808 > > 2009-01-07 01:44:17,217 INFO Formset Class created- 123.41704658 > > > > Regards > > K > > > > On 1/7/09, Kottiyath Nair wrote: > > > > > > > > > Hi all, > > > � �My web application sends a medium size data grid (20 elements). I was > > > using formsets for the same. > > > � �The issue I am facing is that the formset instantiation is very very > > > slow. I timed it and it is taking ~4-7 seconds for it to instantiate. > > > � �Is there someway the speed can be increased? > > > > > There are no files sent. I am planning to, later. > > > The code: > > > � � � � � � logging.info('Start - %s' %time.clock()) > > > � � � � � � DataFormSet = formset_factory(DataForm, extra=25) > > > � � � � � � logging.info('Formset Class created- %s' %time.clock()) > > > � � � � � � formset = DataFormSet(request.POST, request.FILES) > > > � � � � � � logging.info('Created new formset- %s'%time.clock()) > > > > > From my logs: > > > 2009-01-06 22:53:30,671 INFO Start - 0 > > > 2009-01-06 22:53:30,671 INFO Formset Class created- 0.000403403225829 > > > 2009-01-06 22:53:34,296 INFO Created new formset- 3.62182316468 > > > � or later > > > 2009-01-06 22:56:37,500 INFO Start - 186.836136716 > > > 2009-01-06 22:56:37,500 INFO Formset Class created- 186.836445135 > > > 2009-01-06 22:56:43,108 INFO Created new formset- 192.440754621 > > > > > � �Please note that I am running the whole thing under the django > > > development server in my laptop itself and not a 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
2009/1/7 Kenneth Gonsalves> > On Tuesday 06 Jan 2009 5:18:57 pm HB wrote: > > What is your favorite IDE for coding Django projects? > > geany > > -- > regards > KG > http://lawgon.livejournal.com > > > > me too and also gedit / vim --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Import models from CSV files?
Hey Victor, I did the django-batchimport mentioned earlier. I think it will address your need but is definitely aimed at XLS. However, it does already handle duplicates (it will either update them or ignore them based on setting). You can also specify a subset of model fields to use to determine whether a given row represents a duplicate. This allows for "batch update" too. If you get into it and have any problems, drop me a note. Keyton On Jan 6, 12:02 am, Victor Hooiwrote: > heya, > > This question might seem a bit simple, but what's the best way to > instantiate models from .csv files? > > Essentially, I have two .csv files. One contains a list of people, and > their access rights (one-to-many). The second .csv file contains a log > of doorway access (just a bunch of sequential lines). I have a simple > python script which imports these two .csv files, does some processing > (the files are quite messy), creates user and access-entry objects, > and produces a reconciliation with a list of exceptions (basically > door entries which aren't in the list of user/access rights). Each > user is just a dictionary, with their username as key, and a tuple of > dictionary objects for their various access rights. > > I would like a simple django project to import these logs, instantiate > models, and then basically manage it via the in-built admin interface, > hopefully saving a lot of time =). (will also need to deal with > duplicates). Is there a smart way to go about doing this project, or > any existing addons I can leverage off? > > Thanks, > Victor --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
this add-on does it : http://community.activestate.com/xpi/morekomodo On Jan 6, 3:19 pm, "Vitaly Babiy"wrote: > Bernard does komodo have a open files function (open file in project based > on file name search) like there is text mate or gedit with plugin > (gedit-openfiles). > > Vitaly Babiy > > On Tue, Jan 6, 2009 at 3:10 PM, Bernard wrote: > > > I use Komodo IDE 5 everyday for every Python/Django/PHP/Drupal > > projects at work and damn it works well. > > > What I love about it: > > > * Key bindings(shortcuts) for almost everything > > * Simple subversion integration so I don't have to switch to another > > window to commit something. > > * Search & Replace , Regex toolkit > > * Code Snippets. I have plenty of those for Django templates, HTML, > > CSS, Python & PHP. > > *http://code.google.com/p/django-komodo-kit/for more django goodness > > in Komodo Edit or IDE > > > What I hate about it: > > * a little slow to start but once it's fired, there's nothing stopping > > it. > > > what it looks like on my laptop : > > >http://www.picoodle.com/view.php?img=/3/1/6/f_komodoidem_51d0317.png;... > > > On Jan 6, 6:48 am, HB wrote: > > > Hey, > > > What is your favorite IDE for coding Django projects? > > > Any ideas about PyDev and ActiveState Komodo IDE? > > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
lighttpd + django on windows
Does anybody know a tutorial about deploying django with lighttpd on windows ? it does not work , and I don't find what to do Thanks, Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problems with locale of dates queryset
Hi! I'm trying to display a list of possible months in a queryset. I do so like this: premonths = MyModel.objects.dates('date_published', 'month') months = [m.strftime('%B') for m in premonths] The problem is that months get displayed in english instead of spanish, which is what I want. I have the following setting in my settings file, but it does not seem to do what I want: LANGUAGE_CODE = 'es-ES' I can indeed work out a solution doing something like this: premonths = MyModel.objects.dates('date_published', 'month') import locale locale.setlocale(locale.LC_TIME, "sp") months = [m.strftime('%B') for m in premonths] But I guess I'm missing something here... BTW, the problem of the wrong locale of dates is everywhere I use dates on my site, not only in this snippet. Regards, Stefan --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: I just tried GEdit and failed
Right now I use Gedit as my text editor(I don't use the terminal plugin, I just keep a seperate terminal up), that being said here are the plugins I use: * class browser * code comment * file browser pane * indent lines * Python indentation * smart spaces * snippets depending on what your looking for I believe that there is a current in development plugin to add auto completion. Alex On Jan 7, 8:40 am, Alexwrote: > I just tried GEdit on the basis of this thread to replace a very good > but slow Komodo. GEdit is not good, or should I say, the plugins that > let it be a python dev environment are not good. Perhaps I've > selected and incompatible set of plugins, because they started off > working somewhat decently, then syntax coloring was wrong for some > files as though it was detecting the wrong language and the class > browser turned blank, > > A lot of the plugins don't look like they've been touched in a few > years so maybe they're unmaintained. > > Could someone post a list of of GEdit plugins that create a good > django environment? > > Komodo Edit is very good except it's too slow. > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Process file after upload
On Jan 7, 2009, at 9:32 PM, dmishe wrote: > > Hey. > > I have FielField in my model for user to upload ZIP-archives. I want > to unpack that zip, place some files in some dirs and delete it just > after user uploaded it in admin. > > How can i do this? Model's save won't work because it gets called > everytime model is saved regardless of were the file uploaded again or > not. Custom storage/upload handler seems too complicated for this. A common way to check if an object is getting saved for the first time or not is to check if it has a pk. A newly created object won't have a pk until you call the super save() method, so you can put whatever operations you want to conduct inside an "if not obj.pk:" block. See if that does what you want... Eric > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
I just tried GEdit and failed
I just tried GEdit on the basis of this thread to replace a very good but slow Komodo. GEdit is not good, or should I say, the plugins that let it be a python dev environment are not good. Perhaps I've selected and incompatible set of plugins, because they started off working somewhat decently, then syntax coloring was wrong for some files as though it was detecting the wrong language and the class browser turned blank, A lot of the plugins don't look like they've been touched in a few years so maybe they're unmaintained. Could someone post a list of of GEdit plugins that create a good django environment? Komodo Edit is very good except it's too slow. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Process file after upload
On Jan 7, 7:32 am, dmishewrote: > Hey. > > I have FielField in my model for user to upload ZIP-archives. I want > to unpack that zip, place some files in some dirs and delete it just > after user uploaded it in admin. > > How can i do this? Model's save won't work because it gets called > everytime model is saved regardless of were the file uploaded again or > not. Custom storage/upload handler seems too complicated for this. Check out the save_model() method that you can override in your ModelAdmin class. You can add custom logic there. http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change Best, BN --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Process file after upload
Hey. I have FielField in my model for user to upload ZIP-archives. I want to unpack that zip, place some files in some dirs and delete it just after user uploaded it in admin. How can i do this? Model's save won't work because it gets called everytime model is saved regardless of were the file uploaded again or not. Custom storage/upload handler seems too complicated for 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Your IDE of choice
I have omnicomplete working (haven't used it too much yet). I have this in my $HOME/.vimrc file: --.vimrc-- if has("autocmd") autocmd BufRead *.py set smartindent \ cinwords=if,elif,else,for,while,try,except,finally,def,class autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType css set omnifunc=csscomplete#CompleteCSS endif " Allow to be used instead of like other IDE's do " for auto-completion inoremap --.vimrc-- All 'autocmd' lines should be single lines. Also, I have vim starting automatically importing the Django db. I have a little script (below) that will automatically find my settings.py file and start vim. I do this by starting at the location of the file on the vim command line and working upwards in the directory structure until I find it: --dvim-- #!/packages/bin/python """ Start vim for Django files """ import os import sys args = sys.argv # Get our starting directory to look for the settings file. If no # filename is given, start in the current directory if len(args) > 1: # If multiple filenames are given on the command line, we assume # the same Django settings apply to all dir = os.path.realpath(os.path.dirname(args[1])) else: dir = os.path.realpath(".") # Start looking for the settings file, going up one directory if we # don't find it until we hit the top of the filesystem while not os.path.exists(dir + "/settings.py"): if dir == "/": # We are as far as we can go and didn't find anything dir = None break # Go up one directory dir = os.path.dirname(dir) if dir != None: # Found the settings file os.putenv("PYTHONPATH", os.path.dirname(dir)) os.putenv("DJANGO_SETTINGS_MODULE", os.path.basename(dir) + ".settings") os.system("/packages/bin/vim '+python from django import db' " + \ " ".join(args[1:])) else: raise IOError("Django settings file not found") sys.exit(0) --dvim-- I'm sure some lines are probably getting wrapped. I only use Django on Unix/Linux so I'm guessing it would need some tweaking for Windows. On Wed, 2009-01-07 at 12:26 +0100, Oscar Carlsson wrote: > Have you been able to make omnicomplete work with Django? > I haven't been able to figure it out myself, and gave up after a few > tries. It would be really sweet to have, since vim otherwise is a really > good editor. > > Oscar > > On Wed, Jan 07, 2009 at 12:15:22PM +1930, Santiago wrote: > > > > i recently switched to screen + vim with omnicomplete for python and html... > > > > komodo edit its pretty good too > > > > 2009/1/7 martyn: > > > > > > Hi > > > > > > http://pyrox.utp.edu.co/ > > > > > > Regards > > > > > > Bye. > > > > > > On Jan 6, 9:34 am, roberto wrote: > > >> I tried them all (almost ... I think... at least the free ones). > > >> - Pyscripter is really nice but it is true, it is only for windows. > > >> (If it is developed with python it should be platform-independent, > > >> shouldn' be ?) (no support for sql queries I think) > > >> - Eclipse + PyDev (no good support for sql queries to relational db) > > >> - Ulipad (open source / excellent / very small / some issues with > > >> svn / no support for sql queries to db - django plugin to highlight > > >> templates, etc) > > >> - Netbeans (ex-NBPython) it is excellent (very good sql support - some > > >> issues with memory consume - I didn't get debugger work 100% with > > >> django) > > >> - Oracle jdeveloper. it is an excellent tool. Its support for python > > >> is still too new and I think that django support is still to come. > > >> - Eric4: screenshots are very beautiful bu I couldn't get to install > > >> it in my ubuntu box (too many precedences and too complicated for a > > >> newbie like me). > > >> > > >> Have a great year 2009 everyone ! > > >> > > >> On Jan 6, 9:02 am, "Trivedi, Apaar" wrote: > > >> > > >> > I use Eclipse with PyDev and PyDev extensions. I really like it, but I > > >> > prefer the eclipse sort of IDE's. > > >> > > >> > > > >> > > >> > From: django-users@googlegroups.com > > >> > [mailto:django-us...@googlegroups.com] On Behalf Of Damien Hou > > >> > Sent: Tuesday, January 06, 2009 8:43 AM > > >> > To: django-users@googlegroups.com > > >> > Subject: Re: Your IDE of choice > > >> > > >> > TextMate with Django and Django Templates bundles is pretty neat > > >> > > >> > On Tue, Jan 6, 2009 at 7:48 PM, HB wrote: > > >> > > >> > Hey, > > >> > What is your favorite IDE for coding Django projects? > > >> > Any ideas about PyDev and ActiveState Komodo IDE? > > >> > Thanks. > > >> > > >> > -- > > >> > Best Regards, > > >> > Damien > > > > > > > > > > > > > > -- Adam Stein @ Xerox Corporation
Re: How to populate a form field with a Select widget
Ahh yes, much more elegant. Thanks. On Jan 7, 11:32 am, bruno desthuillierswrote: > On 7 jan, 11:38, phoebebright wrote: > > > Finally got it working - and I'm sure there is a much clear way of > > doing it... > > > used_fuels= Car.objects.all().values('fuel_type').distinct() > > fuel_choices=[('Any','Any Fuel')] > > for f in used_fuels: > > for key,value in f.items(): > > fuel_choices.append((value,value)) > > fuels = forms.ChoiceField(choices=fuel_choices) > > used_fuels = Car.objects.values_list('fuel_type', flat=True).distinct > () > fuel_choices = [('Any', 'Any Fuel')] + [(item, item) for item in > used_fuels] > fuels = forms.ChoiceField(choices=fuel_choices) --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Drop down list not seeing newly added record
I have a 2 forms. One to add a new author and then another form for Articles which has a drop down list to reference the authors. The behavior I am seeing is that when I add a new author and then go to the New Article form which references the author it does not display the new record. Also, I put in some print statements in the New Article form class and those statements are only executed when I go to my home page. Here are my code snippets def welcome(request): print 'in welcome' if request.GET: if request.GET.has_key( 'newarticle'): print 'going to new article' return HttpResponseRedirect( '/melsite/newarticle') if request.GET.has_key( 'newauthor'): print 'going to new author' return HttpResponseRedirect( '/melsite/newauthor') else: print 'retrieving articles' articles = Article.objects.filter (type_index__type='Poem').order_by('title') return render_to_response('stories/welcome.html', {'title': 'Poems', 'articles': articles}) def newarticle( request): print 'in new article request' from storyforms import NewArticle if request.method == 'POST': print 'in new article post' new_data = request.POST.copy() articleform = NewArticle(new_data) if form.is_valid(): form.save( new_data) articles = Article.objects.filter (type_index__type='Poem').order_by('title') return render_to_response('stories/welcome.html', {'title': 'Poems', 'articles': articles}) else: print 'in setting up new article' #from storyforms import NewArticle articleform = NewArticle() print 'after setting up new article' print 'rendering article' return render_to_response('stories/add_story.html', {'form': articleform}) class NewArticle( forms.Form): articletypelist=[] authorlist = [] print 'in new article class' articletypes = ArticleType.objects.all().order_by( 'type') articletypelist.append( selecttuple) for articletype in articletypes: choicestr = "choice%s" % str( articletype.id) typetuple = choicestr, articletype.type articletypelist.append( typetuple) authors = Author.objects.all().order_by( 'last_name') print 'authors in new article are ', authors authorlist.append( selecttuple) for author in authors: choicestr = "choice%s" % str( author.id) authorname = author.first_name + ' ' + author.last_name authortuple = choicestr, authorname authorlist.append( authortuple) ArticleType = forms.ChoiceField( choices=articletypelist) Author = forms.ChoiceField( choices=authorlist) Title = forms.CharField() Content = forms.CharField( widget=forms.Textarea) print 'end of new article def' Thanks, Jeff --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Import models from CSV files?
On 06.01-16:55, Victor Hooi wrote: [ ... ] > Valts, thanks for the reply - that looks interesting, and is similar > in some ways to what I want - definitely going to check out the code. > Basically, I just wanted a simple file-upload form, for the user to > upload the two .CSV files. Then, there's quite a bit of processing to > do on the two files, currently in a small python script. > > My question was more along the lines of where should put all of the > logic? Should it be in the model itself, somewhere, and the file- > upload form just passes across the raw data from the .csv files? Where > would the file-handling stuff go? Is it easier to do it via raw SQL, > or via the django models? Any chance of sample code =)? no chance of sample code but i would put the code in the upload processing and simply instantiate objects with something like if request.method == 'POST' : while more_data() : x = myModel() ( x.a, x.b, x.c, x.n ) = read_tuple() x.save() obviously there's a lot more code required there but it should give an idea of one simple way to populate the DB from posted data. i believe valts also suggested doing it in batches (i.e. don't 'save()' every object) to improve the performance. personally, i wouldn't even use django for this, i'd just import the CSV into a database, perform my processing (i.e. eliminate duplicates, tidy the data, etc) and migrate the validated data to the django system for reporting or management or whatever. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shouldn't blank=True imply null=True?
On 07.01-09:47, Malcolm Tredinnick wrote: [ ... ] > This thread is about whether blank=True, null=False (the fourth > possibility) ever makes sense for non-text fields. answer is yes for any field type that accepts an empty string as having a meaning. i currently use this for a couple of custom fields that are autogenerated but can be set manually, if desired. it could also happen for innumerate other reasons. or put more simply '-1' for me. as i stated previously it seems unwise to speculate what may be needed, particularly because the current distinction is clear and valid, however, i would still be in favour of a change in conventions that will hide this issue/oddity from most implementations. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to populate a form field with a Select widget
On 7 jan, 11:38, phoebebrightwrote: > Finally got it working - and I'm sure there is a much clear way of > doing it... > > used_fuels= Car.objects.all().values('fuel_type').distinct() > fuel_choices=[('Any','Any Fuel')] > for f in used_fuels: > for key,value in f.items(): > fuel_choices.append((value,value)) > fuels = forms.ChoiceField(choices=fuel_choices) used_fuels = Car.objects.values_list('fuel_type', flat=True).distinct () fuel_choices = [('Any', 'Any Fuel')] + [(item, item) for item in used_fuels] fuels = forms.ChoiceField(choices=fuel_choices) --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django internal tests and url reverse lookup
Hi all, If I run manage.py test form my project, Django internal test are executed as well. If such a internal test uses a RequestContext, all template context processors defined in settings.TEMPLATE_CONTEXT_PROCESSORS are loaded by django.template.context.get_standard_processors(). If one of this (custom) template context processors uses "django.core.urlresolvers.reverse()" for a reverse URL matching, there will be no match for project specific URLs as this URL definitions aren't loaded for Django internal tests. How can this be fixed? Shouldn't load the test environment all the project URL definitions? Thanks and regards, /Aeby --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToMany problem
Hi Alex, On Jan 4, 12:27 pm, knightwrote: > Hi, > > I have the following problem: > I have models.py with the following class: > > class Section(Feed): > parent = models.ManyToManyField('self', blank=True, null=True) > depth = models.IntegerField(editable=False) > def save(self): > self.depth = 1 > if self.parent: > self.depth = self.parent.depth + 1 > return super(Section, self).save() > def __unicode__(self): > return "Section_%s" %(self.title) > Looks like the problem is trying to access the m2m property before the instance is saved for the 1st time - no id means ManyToMany relations will fail. In `save` you're trying to access `parent` (should be called `parents` IMO, plural) which is m2m and trigger the error. * You'll need to check if you have an id, if not, save it once to get it. After that, calculate and save again (blah). * You can't access `parent` like that, m2m behaves like a list, so you'll have to check members of that list - which is not clear how is going to be achieved. If different parents have different levels which one will you use ? * Another problem: If parent's level is changed, the children won't be updated, potential mess * Last thing: Treading this path might lead to recursion (item with parents which have the item in their parent, or up the tree, as well), you might wanna rethink this setup. > and admin.py with the following classes: > > class SectionInline(admin.TabularInline): > model = Section > extra = 2 > verbose_name_plural = "Sub Sections" > > class SectionAdmin(admin.ModelAdmin): > inlines = [ > SectionInline, ItemInline > ] > > When I try to save new Section from the admin page, I get the > following error: > > 'Section' instance needs to have a primary key value before a many-to- > many relationship can be used. > > There are 2 things that I don't understand: > > 1.) Why am I getting this error, if my ManyToMany relation is optional > 2.) I tried many things including defining id of the Section with > AutoField but still without luck. > > Does anyone have an idea what is my problem/mistake here? > > Thanks, Arshavski Alexander. Cheers -- Meir Kriheli --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to populate a form field with a Select widget
Finally got it working - and I'm sure there is a much clear way of doing it... used_fuels= Car.objects.all().values('fuel_type').distinct() fuel_choices=[('Any','Any Fuel')] for f in used_fuels: for key,value in f.items(): fuel_choices.append((value,value)) fuels = forms.ChoiceField(choices=fuel_choices) On Jan 3, 9:38 pm, phoebebrightwrote: > Following on from this example, I am trying to use values from a table > to populate a choicefield (and been at it for 2 days trying every > method I can find in google) > > Clearly from the output below, I am creating the wrong kind of data > type, but don't know how to change it: > > THIS VERSION WORKS:>>> CHOICES = ( ('P', 'Pending'), ('A', 'Active'), ('D', > 'Done')) > >>> print CHOICES > > (('P', 'Pending'), ('A', 'Active'), ('D', 'Done'))>>> fuel_type = > forms.ChoiceField(choices=CHOICES,widget=forms.Select ()) > >>> print fuel_type.choices > > [('P', 'Pending'), ('A', 'Active'), ('D', 'Done')] > > > > THIS VERSION DOES NOT: > (fails with Caught an exception while rendering: need more than 1 > value to unpack) > > >>> CHOICES = Car.objects.all().values('fuel_type','fuel_type').distinct() > >>> print CHOICES > > [{'fuel_type': u'Petrol'}, {'fuel_type': u'Diesel'}]>>> fuel_type = > forms.ChoiceField(choices=CHOICES,widget=forms.Select ()) > >>> print fuel_type.choices > > [{'fuel_type': u'Petrol'}, {'fuel_type': u'Diesel'}] > > Any help as to the best way of doing this would be great - I also need > to add 'Any Fuel' as the first option as this is for a search form. > > On Dec 29 2008, 11:10 am, Polat Tuzla wrote: > > > A formatting error occurred while I did my previous post. > > Please make sure that you notice the parentheses at the last line of > > the code snippet, which were actually meant to be at the end of the > > previous line. > > > Regards, > > Polat > > > On Dec 29, 1:03 pm, Polat Tuzla wrote: > > > > You can do it as follows: > > > > class MyForm: > > > CHOICES = ( ('P', 'Pending'), ('A', 'Active'), ('D', 'Done')) > > > status = forms.ChoiceField(choices=CHOICES,widget=forms.Select > > > ()) > > > > Regards, > > > Polat > > > > On Dec 29, 5:13 am, "Aaron Lee" wrote: > > > > > I would like to populate aformfield which uses aSelectwidget with > > > > choices in views.py. > > > > I understand I can pass the initial arg to theformbut I couldn't find > > > > the > > > > correct value to pass. > > > > > The choices is a list of tuple > > > > CHOICES = ( ('P', 'Pending'), ('A', 'Active'), ('D', 'Done')) > > > > > Any hints? > > > > > -Aaron > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newbie: Help to understand string handling
On 7 jan, 00:03, phoebebrightwrote: > Thanks for that clarification. I am finding that a lot of assumptions > are made in the documentation about previous knowledge. Indeed. It is assumed that the reader knows at least a couple things about the web, programming, HTML, and the HTTP protocol !-) > Maybe starting a collection of seemingly obvious statements would be > helpful for newbies: > - django is a module for python, so a basic knowledge of python is > required, Go to the project's home page. The first line of text contains the brand (and main menu). The fifth line - which is the first _effective_ content of the page - says : "Django is a high-level Python Web framework" I may be a bit biased here, but as far as I'm concerned, this is obvious enough. > - django includes a templating language that has a limited s/limited/extensible/ > set of > commands, so python code will not work there. Still on the project's home page: """ Template system Use Django's powerful, extensible and designer-friendly template language to separate design, content and Python code. """ Note that you have two strong hints there: 1/ python code 2/ separate If that's not enough, following the 'template language' link, you land on a documentation page that makes the whole point very clear: """ If you have a background in programming, or if you’re used to languages like PHP which mix programming code directly into HTML, you’ll want to bear in mind that the Django template system is not simply Python embedded into HTML. This is by design: the template system is meant to express presentation, not program logic. The Django template system provides tags which function similarly to some programming constructs – an if tag for boolean tests, a for tag for looping, etc. – but these are not simply executed as the corresponding Python code, and the template system will not execute arbitrary Python expressions """ (snip other already documented things). Now I don't mean there's no room for improvement, but what, you just can't stack everything on the home page, can you ?-) --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newbie: Help to understand string handling
On 6 jan, 22:46, phoebebrightwrote: > Thanks for your response. Do you think a working knowledge of python > is essential for django then? Obviously, yes !-) That's just like asking if a working knowledge of Java is essential for Strut, or if a working knowledge of PHP is essential for the Zend Framework, or if a working knowledge of Ruby is essential for Ruby On Rails (etc, insert your favorite language/web framework pair here...). --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Access records from two tables
On 7 jan, 08:02, Praveenwrote: > Models.py > > class Listing(models.Model): > name = models.CharField(max_length=20) > description = models.TextField(max_length = 100) > website = models.URLField() > category = models.ForeignKey(Category) > > class Category(models.Model): > category_code = models.CharField(max_length = 50, primary_key=True, > blank=False) > category_name = models.CharField(max_length = 50,) > def __unicode__(self): > return self.category_code > > i have cat_list.html which list all the category with name only as > link if some one wants to know more details he/she may click on that > link. > > urls.py > > (r'^category/category_view/$','mysite.library.views.categories'), > (r'^category/category_view/(?P\w+)/ > $','mysite.library.views.category_info'), > > views.py > > def categories(request): > result_category = Category.objects.all() > return render_to_response("cat_list.html", > {'result_category':result_category}) > > def category_info(request, category_code): > result_category = get_object_or_404(Category, pk = category_code) > ->result_listing = get_object_or_404(Listing, pk = id) > print result_category > return render_to_response("category_view.html", > {'result_category':result_category,'result_listing':result_listing}) > > see -->result_listing in category_info function. i want to display > some info of Listing tables of corresponding category_code. Then why don't you just use the reverse relationship ? related_listing_list = result_category.listing_set.all() which you can as well call directly from within the template, so you don't even need to code for it in the view... > when i use > > 1--> result_listing = get_object_or_404(Listing, pk = id) then i get > an error > id() takes exactly one argument (0 given) Indeed. id(obj) is a builtin python function that returns the OID of an object. Where do you thing this 'id' name came from ? > 2--> result_listing = get_object_or_404(Listing, pk = category_id) > then i am not getting the exact result cause Category(category_code) > is checking with Listing(id). You're getting the exact result you asked for : a listing instance which primary key has the value category_id. > i do not know how may i access corresponding records from two tables. That's explained in whole details in the online documentation. Go to djangoproject.com, click the "documentation" link, then follow the "models : accessing related objects" link. If i was one of Django's doc writer, I'd probably start to despair. Why spending so much _volunteer_ time writing a pretty good *and* well- organized documentation when no one seems to bother reading it ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: strip_tags in django admin issues
Alex - you are a legend. That's functioning perfectly. I've moved the import line to the start of the file, but other than that used your code and it's working a treat. Thanks for the swift help Alex, and also Karen: together you've clarified Django very clearly for me. On Jan 6, 6:01 pm, "Alex Koshelev"wrote: > Form class really doesn't have `strip_tags` method. I think you are > interested in `strip_tags` functon from `django.utils.html`(and your > comment says the same). So your method may look like this: > > def clean_title(self): > from django.utils.html importstrip_tags > title =strip_tags(self.cleaned_data["title"]) > return title > > On Tue, Jan 6, 2009 at 8:14 PM, ChrisL <1angryc...@googlemail.com> wrote: > > > Hi everyone, > > > Been bashing against this one for a while now and am keen for > > suggestions. I'm trying to apply custom validation to forms within > > Django's default admin. First up, I want to strip out all html from a > > Title field. Following the official documentation I have developed > > this: > > > > > > from django.contrib import admin > > from django import forms > > from django.utils.html importstrip_tags > > from queryclick.qc_news.models import * > > > #Custom Data Validation in the Admin Interface > > class MyArticleAdminForm(forms.ModelForm): > > class Meta: > > model = Article > > > def clean_title(self): > > #Remove all HTML, usingstrip_tags(import from > > django.utils.html > > title = self.strip_tags('title') > > #Always return cleaned data > > return self.cleaned_data["title"] > > > class ArticleAdmin(admin.ModelAdmin): > > list_display = ('title', 'client', 'submitted_date', 'edited_date', > > 'go_live_date') > > list_filter = ('client', 'submitted_date', 'edited_date', > > 'go_live_date') > > ordering = ('-submitted_date',) > > search_fields = ('title','client',) > > form = MyArticleAdminForm > > > admin.site.register(Copywriter) > > admin.site.register(Client) > > admin.site.register(Article, ArticleAdmin) > > > > > > But get an Attribute Error: 'ArticleForm' object has no attribute > > 'strip_tags' from line 13: > > > title = self.strip_tags('title') > > > Any and all suggestions warmly welcomed! --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Import models from CSV files?
Hello, If the file handling job is not too hard I would put the functionality in model. Actually it depends on complexity, use cases and taste. You can try writing the sample code by yourself :) -- Valts On Wed, Jan 7, 2009 at 02:55, Victor Hooiwrote: > > heya, > > Valts, thanks for the reply - that looks interesting, and is similar > in some ways to what I want - definitely going to check out the code. > Basically, I just wanted a simple file-upload form, for the user to > upload the two .CSV files. Then, there's quite a bit of processing to > do on the two files, currently in a small python script. > > My question was more along the lines of where should put all of the > logic? Should it be in the model itself, somewhere, and the file- > upload form just passes across the raw data from the .csv files? Where > would the file-handling stuff go? Is it easier to do it via raw SQL, > or via the django models? Any chance of sample code =)? > > Cheers, > Victor > > On Jan 6, 7:05 pm, "Valts Mazurs" wrote: > > Hello, > > > > Maybe this app could be helpful for you: > http://code.google.com/p/django-batchimport/ > > > > If you have to import lots of data I would suggest creating python script > > that reads the files and inserts the data in database either using Django > > ORM or plain SQL. In case of hundreds of thousands of rows I would commit > > the changes to database after number of inserts (e.g., 100) instead of > every > > insert. > > > > Best regards, > > -- > > Valts > > > > On Tue, Jan 6, 2009 at 07:02, Victor Hooi wrote: > > > > > heya, > > > > > This question might seem a bit simple, but what's the best way to > > > instantiate models from .csv files? > > > > > Essentially, I have two .csv files. One contains a list of people, and > > > their access rights (one-to-many). The second .csv file contains a log > > > of doorway access (just a bunch of sequential lines). I have a simple > > > python script which imports these two .csv files, does some processing > > > (the files are quite messy), creates user and access-entry objects, > > > and produces a reconciliation with a list of exceptions (basically > > > door entries which aren't in the list of user/access rights). Each > > > user is just a dictionary, with their username as key, and a tuple of > > > dictionary objects for their various access rights. > > > > > I would like a simple django project to import these logs, instantiate > > > models, and then basically manage it via the in-built admin interface, > > > hopefully saving a lot of time =). (will also need to deal with > > > duplicates). Is there a smart way to go about doing this project, or > > > any existing addons I can leverage off? > > > > > Thanks, > > > Victor > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: autodiscover not being called? why?
Check the output of: import sys print sys.modules['admin'] -- Valts On Tue, Jan 6, 2009 at 20:06, bongowrote: > > > > In your application directory, the one created by manage.py startapp, > same > > as where models.py is. > > Thanks. > > Thats what I thought I should put it. This is getting weirder though. > Even though I got autodiscover working it still couldn't find it. I > then decided to go with the manual method of subclassing the admin app > and manually wiring it in according to this blog. > > > http://oebfare.com/blog/2008/jul/20/newforms-admin-migration-and-screencast/ > > It still didn't work but now with an import name error. > > Its seems that when I renamed the module from admin.py to > adrem_admin.py it worked without an import error! > > This is crazy but it simply didn't like the module being called > admin.py!! What is going on? A naming conflict with something in my > python installation? I assume it was trying to load the site > attribute from another module called admin somewhere.. ouch! How can I > find out what it was really finding? > > This has been driving me crazy for days. I now have a manual > workaround but it means the autodiscover will never work for me.. I > need to eliminate the real problem if I am ever to use autodiscover. > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: wondering how to do something similar to save_model for inline.
Good call on the ModelAdmin spot. (user contacted me by email to see if I had a solution yet.) I got the formset.save() from here: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method saying: "If your formset contains a ManyToManyField, you'll also need to call formset.save_m2m() to ensure the many-to-many relationships are saved properly." Works now just had it in the wrong spot. thx! On Jan 6, 9:23 pm, "Karen Tracey"wrote: > On Tue, Jan 6, 2009 at 10:10 PM, Timboy wrote: > > > Still no solution to this. It has been confirmed by another user. Is > > it a bug? > > (Where was it confirmed by another user? I don't see that.) > > The doc list "save_formset" under "ModelAdmin methods" yet you seem to have > added it to your inline admin class. I also don't see any indication in the > traceback you posted that your custom method is being called, which leads me > to think where you have put it is not where it needs to be in order for it > to be called. > > (Also you changed formset.save_m2m() from the example in the docs to > formset.save(). I doubt that this change is correct.) > > Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---