ImageField woes
I want to expand on the ImageField functionality of django. Mainly, I want to check the dimensions of the image the user is uploading, and resize / crop where appropriate. I would also like to set compression amount, and perhaps even allow for watermarking. I know there are several libraries out there that do this, but I want to keep it as lightweight as possible, and haven't had much luck with sorl. It seems to me the best way to do this would be to create a custom field type, so I could do something like this in my model: image_tb = models.CustomImageField("Thumbnail Image", upload_to ='uploads/projects', size=(50, 50), compression="60", watermark="path/ to/watermark.png") Is this the best way to do something like this? I understand that you could also hijack the save method, but I might want to have more than one image field in each model meaning the sizes might vary. Can anyone point me towards any articles which will help me on my way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
What data structure to use, and how?
Hi all. I think django really rocks, but i have a question: I wrote a script in python that will get some values from servers and puts in them in a dictionary. The data is in the following format {'somehost': ['yes', '2'], 'remotehost': ['yes', '1'], 'localhost': ['yes', '1']} In python, i can then print the values as such: >>> print "Server: "+server+" Version: "+serverlist[server][1]+" >>> Reachable: "+serverlist[server][0] Server: somehost Version: 1 Reachable: no Server: remotehost Version: 2 Reachable: yes Server: localhost Version: 1 Reachable: yes In a django template however, this doesn't go far. The serverlist[server][0] type notation gives an error when used in a django template, so i tried this instead: {% block status_table %} {% for server in output_list %} {{ server }} {% for value in server %} {{ value }} {% endfor %} {% endfor %} {% endblock %} This prints each letter of the server name in different cell, which is not what i want. How can i retrieve the 'version' and 'reachable' values in the django template? Many thanks in advance. Jon --~--~-~--~~~---~--~~ 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: user object in login.html
Simply have an 'if logged in:' clause at the beginning of your login view definition that redirects to the /loggedin/ view if it matches. Of course this implies that you know some variable that will always match once someone is logged in. Most likely, django sets this already. If you cannot find one, you just set one yourself. I am new to django, only started learning it last week, so the solution may look a bit dirty in the eyes of seasoned django developers, but i am sure it will work. Have a look at the forms chapter, and read about the HttpResponseRedirect to see how to go about doing the redirect. HTH Jon. On May 19, 10:43 am, Rok wrote: > But what if "user" specify login URL in the browser? He gets login > form regardless if he is logged in or not. > > For example I have ( r'^login/$', login ) in urls.py and if I > requesthttp://localhost:8000/login/I get login form even though I am already > logged in; but I want to show some message that he/she is already > logged in. > > On 19 maj, 00:41, jon michaels wrote: > > > From the documentation it seems that it is not only possible, but > > required too.. > > > login_required() does the following: > > > * If the user isn't logged in, redirect to settings.LOGIN_URL > > (/accounts/login/ by default), passing the current absolute URL in the > > query string as next or the value of redirect_field_name. For example: > > /accounts/login/?next=/polls/3/. > > * If the user is logged in, execute the view normally. The view > > code is free to assume the user is logged in. > > [...] > > It's your responsibility to provide the login form in a template > > called registration/login.html by default. This template gets passed > > four template context variables:[...] > > > Source:http://docs.djangoproject.com/en/dev/topics/auth/ > > > If this doesn't answer your question, please be more specific about > > the context. > > > On Tue, May 19u, 2009 at 1:44 AM, Rok wrote: > > > > Hello. > > > > Is it possible to use user object in login.html when @login_required > > > is used? I want to display login fields only when user is ianonymous. > > > > Thank you. > > > > Kind regards, > > > > Rok --~--~-~--~~~---~--~~ 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: user object in login.html
Ah, and if you only want to display a message on the login page, that's possible too. In that case you don't use the redirect in the view, but use an if clause in your index.html template. Something like this: {% if logged_in %} You are logged in already. {% endif %} Jon. On May 20, 2:18 am, Jon wrote: > Simply have an 'if logged in:' clause at the beginning of your login > view definition that redirects to the /loggedin/ view if it matches. > > Of course this implies that you know some variable that will always > match once someone is logged in. > > Most likely, django sets this already. If you cannot find one, you > just set one yourself. > > I am new to django, only started learning it last week, so the > solution may look a bit dirty in the eyes of seasoned django > developers, but i am sure it will work. > > Have a look at the forms chapter, and read about the > HttpResponseRedirect to see how to go about doing the redirect. > > HTH > > Jon. > > On May 19, 10:43 am, Rok wrote: > > > But what if "user" specify login URL in the browser? He gets login > > form regardless if he is logged in or not. > > > For example I have ( r'^login/$', login ) in urls.py and if I > > requesthttp://localhost:8000/login/Iget login form even though I am already > > logged in; but I want to show some message that he/she is already > > logged in. > > > On 19 maj, 00:41, jon michaels wrote: > > > > From the documentation it seems that it is not only possible, but > > > required too.. > > > > login_required() does the following: > > > > * If the user isn't logged in, redirect to settings.LOGIN_URL > > > (/accounts/login/ by default), passing the current absolute URL in the > > > query string as next or the value of redirect_field_name. For example: > > > /accounts/login/?next=/polls/3/. > > > * If the user is logged in, execute the view normally. The view > > > code is free to assume the user is logged in. > > > [...] > > > It's your responsibility to provide the login form in a template > > > called registration/login.html by default. This template gets passed > > > four template context variables:[...] > > > > Source:http://docs.djangoproject.com/en/dev/topics/auth/ > > > > If this doesn't answer your question, please be more specific about > > > the context. > > > > On Tue, May 19u, 2009 at 1:44 AM, Rok wrote: > > > > > Hello. > > > > > Is it possible to use user object in login.html when @login_required > > > > is used? I want to display login fields only when user is ianonymous. > > > > > Thank you. > > > > > Kind regards, > > > > > Rok --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Finding a form field's widget type from the template
I'm trying to figure out how to determine a model form field's widget type from the template. I would like to loop through the fields as opposed to writing out each field explicitly in the template, but in order to loop through them, I need to know the widget type so I can do something special with certain types of form fields (checkboxes, for example). Is this possible? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Open source CMS (if based on Django better)
Right now i'm evaluating which technology learn to develope applications (web app). I'm thinking on CMS and lately in Flex (also pyjamas) or more interactive technologies, thinking in develope an application to monitoring remote systems through the Internet. I have to consider the most requested specifications for common applications and mix that with the experienced guy opinions as yours to make a decision on what mix of technologies git worth study hard for the future. Thanks for your ideas !! On May 7, 7:59 pm, Andy McKay wrote: > On 2010-05-05, at 12:52 PM, Jonatan.mv wrote: > > > What would be you recommended CMS?. Could you please give some reasons > > (pro and cons)?. > > Just to confuse things, don't forget you can pretty much use any non-Django > CMS as long as it can write to a relational database. All depends what you > want to do. > -- > Andy McKay, @andymckay > Django Consulting, Training and Support > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Model design graphically or UML
Hello, Trying to include some graph tool for managing and sharing data models visually. Testes mysql workbench, dia, graphivz and recently read some about argoUML.. ¿Do you know and recommend any visual tool for model design? Better if database independent 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Considering Django: How simple is customising django-admin?
1. Inlines http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects 2. Form media http://docs.djangoproject.com/en/dev/topics/forms/media/ 3. Your example does not require custom template overrides for the admin HTML, it is possible to simply include a function from your Model in 'list_display'. http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list ... In your example the function must return the HTML for the thumbnail image, and it must escape it and allow tags so that the HTML shows correctly in the admin. Example (from django-imagekit): >def admin_thumbnail_view(self): >if not self._imgfield: >return None >prop = getattr(self, self._ik.admin_thumbnail_spec, None) >if prop is None: >return 'An "%s" image spec has not been defined.' % \ > self._ik.admin_thumbnail_spec >else: >if hasattr(self, 'get_absolute_url'): >return u'' % \ >(escape(self.get_absolute_url()), escape(prop.url)) >else: >return u'' % \ >(escape(self._imgfield.url), escape(prop.url)) >admin_thumbnail_view.short_description = _('Thumbnail') >admin_thumbnail_view.allow_tags = True You would then include 'admin_thumbnail_view' in 'list_display' in your Model's admin. 4. As for the thumbnail question, you can look at 'sorl-thumbnail' or 'django-imagekit'. I use my own amalgamation of both, for their different features. As for the rest of the question, you can add onto the admin app all you want with your own views, templates, etc. by hijacking the URL routing in urls.py to look for '/admin/my-report-page' and route that to your own app. To integrate this into the admin you can simply edit the template for the main index, or use 'django-admin-tools' which gives you a much nicer way of adding onto the admin with your own dashboard links and modules. Or you may watch out for 'django- grappelli' to soon integrate 'django-admin-tools' into its already existing body of work, like their Navigation sidebar which lets you add your own links to the admin index, and Bookmarks which appear at the top of every admin page. (The latest work is still not quite usable but still very impressive) 5. I've pondered on both examples myself, but haven't really gone anywhere with those ideas, so I can't tell you for sure whether it's possible or not. But my bet's on it being possible, because in the first example you're simply filtering out child categories based on the parent category selection, so this would be doable completely with JS it seems. The second example seems doable as well, though I haven't tried it myself. On Apr 8, 6:15 am, UnclaimedBaggage wrote: > Hi folks, > > Long-time PHP/Zend user here who'd LOVE to switch to Python/Django for > webdev work. I've just spent a few hours snooping around Django and > really like what I see, but before I invest any real time in it I'd > really appreciate some advice on if (or how easily) a few things can > be done. My main concern is the flexibility of django-admin. I LOVE > the feature, but I'm a little concerned about flexibility. Any > suggestions on the following would be very appreciated: > > #1.) For usability's sake, I'd like to have foreign key models > embedded in the same admin form as the model they're referencing. For > example, if there's a "products" model with a one-to-many relationship > to "product options", I'd like to add "product options" from within > the "product" admin form. (Eg javascript adds another field each time > all existing "product option" fields are filled out...or something). > Anything that will help (or hurt) me in trying to add this sort of > functionality? Is this commonly done? > > #2.) Adding javascript to individual admin forms. Simple? > > #3.) Customising the HTML (not CSS) output of django-admin. For > example, putting a thumbnailed image next to each product in the > Admin-->Products table list. Simple? > > #4.) A lot of what I do is basic (but custom) e-commerce & CMS stuff. > Django's CMS potential looks very solid, although I'm wondering if > tacking on basic e-commerce features to django-admin could be a little > cumbersome. Features such as basic order reports/stats etc don't seem > to fit too freely into the django-admin approach. I'll also need to > auto-create thumbnails from model.ImageField inputs. Easily doable? > > #5.) 'Convenience' form fields in admin forms. For example, a select > box that lets you choose a parent category, which in turn presents a > 'child category' select box, etc...or tree-structured checkboxes. I'm > comfortable writing up the javascript, but from a quick inspection > django-admin didn't seem to like the inclusion of select fields that > weren't intended to interact with the model. Was this just my clumsy > newbieness or is this going to be a problem? > > Many thanks - hope to be one of
Re: Django and Caching Pages
boralyl wrote: > Jonathan, > > Thanks for your response. I first tested the site in firefox and > konqueror and had no problems. When using opera though I noticed it > wasn't requesting the page, as you had mentioned. The browser cache > was set to check every 5 hours on document requests. I changed it to > always and now I see the expected results. Instead of changing the browser preferences, you might also look at pages headers sent by your "webserver" from your views. Take a look at HTTP/1.1 headers : Expires-* headers and Etags too, for instance. They are here to handle this kind of problems. - Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Inherited models...
I wanted to share some fields and functionality in several tables without having to recode all of the field definitions in each table. Obviously, this is an inheritance problem. So I did what I figured was the logical thing: class MyModel (models.Model): date_created = models.DateTimeField(auto_now_add=True,blank=True) date_updated = models.DateTimeField(auto_now=True,blank=True) class Poll(MyModel): class Choice(MyModel): I ran manage.py syncdb and THREE tables were created: mysite_choice, mysite_poll and mysite_mymodel. It appears (although I haven't yet fully tested it) that as expected, the fields from MyModel are implicitly included in the other two tables (precisely what I wanted to happen!) I haven't explored all options, but it appears the two poll tables work correctly and have the extra fields in the database just as I wanted. The question then is can you SUPPRESS the creation of the "abstract class" table MyModel with some flag or option that I don't know about? My review of the django book revealed nothing but I am new to this and may have overlooked something. Having the table isn't an awful thing, I can drop it if I want or certainly just ignore it. However, it really shouldn't be created at all and the ideal thing would be to be able to declare an option for an abstract model class that would suppress the creation of any table for that class. Thanks! Jon Rosen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Inherited models...
Thank you! I read the doc and it looks like this is precisely what I want. I will look into updating to this latest release. Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Strange tutorial behavior...
I successfully ran the complete tutorial (using version 0.96.1) on my home machine over last weekend without incident. This week, I tried to bring up my new application at work and started getting some strange errors in the admin tool. So I went back and redid the tutorial (to see if I was doing anything different in my own app that I could understand) and I got the same weird errors (which is diffferent from what I got when I did this on my home machine - both are Windows XP, one is Home, one is Office, and the home machine is on Python 2.4 whereas the office machine is on Python 2.5 - those are the only differences). When I try to open the Polls table in the admin tool (which has the Date/Time), I get the following traceback: Django version 0.96.1, using settings 'mysite.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [17/Apr/2008 11:37:11] "GET /admin/ HTTP/1.1" 200 5199 [17/Apr/2008 11:37:16] "GET /admin/polls/choice/ HTTP/1.1" 200 1445 [17/Apr/2008 11:37:19] "GET /admin/polls/choice/add/ HTTP/1.1" 200 3014 [17/Apr/2008 11:37:19] "GET /admin/jsi18n/ HTTP/1.1" 200 801 [17/Apr/2008 11:37:29] "GET /admin/ HTTP/1.1" 200 5199 [17/Apr/2008 11:37:30] "GET /admin/polls/poll/ HTTP/1.1" 200 1435 [17/Apr/2008 11:37:32] "GET /admin/polls/poll/add/ HTTP/1.1" 200 2881 [17/Apr/2008 11:37:32] "GET /admin/jsi18n/ HTTP/1.1" 200 801 Traceback (most recent call last): File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 273, in run self.finish_response() File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 312, in finish_response self.write(data) File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 391, in write self.send_headers() File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 443, in send_headers self.send_preamble() File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 370, in send_preamble self._write('HTTP/%s %s\r\n' % (self.http_version,self.status)) File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 487, in _write self.stdout.write(data) File "C:\Python25\lib\socket.py", line 262, in write self.flush() File "C:\Python25\lib\socket.py", line 249, in flush self._sock.sendall(buffer) error: (10054, 'Connection reset by peer') Traceback (most recent call last): File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 273, in run self.finish_response() File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 312, in finish_response self.write(data) File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 391, in write self.send_headers() File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 443, in send_headers self.send_preamble() File "C:\Python25\Lib\site-packages\django\core\servers \basehttp.py", line 373, in send_preamble 'Date: %s\r\n' % time.asctime(time.gmtime(time.time())) File "C:\Python25\lib\socket.py", line 262, in write self.flush() File "C:\Python25\lib\socket.py", line 249, in flush self._sock.sendall(buffer) error: (10054, 'Connection reset by peer') The admin app still appears to work and I can put new entries into the table. I just keep getting these tracebacks anytime there is a date/ time in the view. This does not appear on the Choices screen which has no date in the tutorial, but if I add a date/time field, it starts to happen there. Of course, the traceback indicates that it is happening on the time.asctime() call. Is there something that changed in Python 2.5 that causes this? HELP :-( Jon Rosen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Strange tutorial behavior...
Sure! On Apr 17, 12:00 pm, "Eric Liu" <[EMAIL PROTECTED]> wrote: > Hi, > May be you can post your source code,then we can check it whether there are > some wongs with it. > I simply cut and paste from the tutorial, but here 'tis: === polls/models.py: === from django.db import models # Create your models here. from django.db import models class Poll(models.Model): question = models.CharField(maxlength=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question class Admin: pass class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(maxlength=200) votes = models.IntegerField() # ... def __str__(self): return self.choice class Admin: pass === polls/urls.py: === from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), ) === And that is it :-) Like I said, it was cut-and-paste from the standard tutorial so unless I screwed something up, I don't see why I am getting the weird error. Thanks! Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Strange tutorial behavior...
Both cases I am using MySQL 5.0. However, new info: this ONLY appears in IE. When I use Firefox, this doesn't happen. I think this may be an IE 6.0 problem. I am using IE 6.0 on this machine, but at home, i was using IE 7.0. Still, this seems really weird. Also, when I switch from http://localhost:8000/admin/ to http://127.0.0.1:8000/admin/, the second exception that was occurring above disappears (only the first remains). And when I switch to Firefox, no problems at all. Any ideas? Jon On Apr 17, 1:27 pm, "Hernan Olivera" <[EMAIL PROTECTED]> wrote: > Maybe something about your database settings. > You don't say what db are you using in each case. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Strange tutorial behavior...
Answering my own question here :-) It looks like this is related to the proxy server settings in IE. Home machine didn't use a proxy server - no problem on IE7 (and probably not a problem on IE6 either). On work machine, there is a proxy server in the settings and localhost isn't automatically exempted so this was going through the proxy server. When I added localhost to the sites that don't use the proxy server, it worked in IE6 (and IE7). Firefox apparently always exempts localhost (or at least by default) so that was probably why I saw the immediate difference between IE and FF So, problem appears to have been solved! Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Calling all Django / Python Developer
Hey all you Django Guru's! I'm a recruitment consultant working within the interactive sector in London. One of my clients has an excellent opportunity for an experienced Django / Python Developer. Suitable candidates ideally will have previously worked for a tier 1 type consumer internet company. Candidates must be experienced in Open Source, Django, AJAX etc etc. This individual should also be a talented front-end developer / designer and familiar of working with: XHTML, XSLT, CSS and Javascript. This is a fantastic team for individuals to work in a dynamic environment within a talented team. Excellent rewards are on offer to suitable individuals. Anyone interested should get in touch with me either by phone or e mail (0207 729 4771 / [EMAIL PROTECTED]) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django discarding MySQL results for "in" operator
Karen Tracey gmail.com> writes: > > > On Mon, Jan 5, 2009 at 3:37 PM, JonUK flinttechnology.co.uk> wrote: > > > > Apologies as this is a repost, but I'm completely stuck! > I'm using django 1.0.2 and the tagging app to retrieve a tag via a > database "in" query, and something is causing the query results to be > discarded. > In particular, this line of code from tagging.utils.get_tag_list() > executes: > return Tag.objects.filter(name__in=[force_unicode(tag) > for tag in tags]) > and at this point: > (Pdb) p tags > [u'sea'] > The thread of execution can be traced into the method > django.db.models.sql.query.execute_sql(self, result_type=MULTI), and > to this line of code: > cursor.execute(sql, params) > and over here: > > > c:\python26\lib\site-packages\django\db\models\sql\query.py(1735) > execute_sql() > -> cursor.execute(sql, params) > (Pdb) p sql > 'SELECT "tagging_tag"."id", "tagging_tag"."name" FROM "tagging_tag" > WHERE "tagging_tag"."name" IN (%s) ORDER BY "tagging_tag"."name" ASC' > (Pdb) p params > (u'sea',) > (Pdb) > If I audit what's submitted to MySQL via MySQL logging, it reports: > SELECT `tagging_tag`.`id`, `tagging_tag`.`name` FROM `tagging_tag` > WHERE `tagging_tag`.`name` IN ('sea') ORDER BY `tagging_tag`.`name` > ASC > which looks correct - however django returns an empty list. > If I execute the query interactively in MySQL, I get the expected > (correct) result: > ++--+ > | id | name | > ++--+ > | 28 | Sea | > ++--+ > 1 row in set (0.00 sec) > I suspect this is a configuration problem but have no idea where to > look - can anyone help? > > > I can't recreate with a similar (though without tagging, just doing a similar in query for one of my models) query on my MySQL DB/django app. The .filter(__in=[...]) returns case-insensitive results as expected. As you've traced it down to where the SQL executes, have you gone farther to determine if somehow that SQL query when issued by Django isn't returning any results while the one you issue in the mysql command does? It'd be pretty bizarre, but maybe the SQL is returning the same result but somehow it's getting lost before the .filter() is returning? The alternative seems to be that the same SQL query is returning different results, which seems equally bizarre. (There is no configuration option to change what collation is used for the query, which is all I could think would change the result as you have described -- Django always uses the default collation.)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+unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en > -~--~~~~--~~--~--~--- > Apologies for the long silence before responding. Although I do not recall if this was the precisely the issue (it was a long time ago), I did eventually hunt down an accepted bug in Mysql that makes the "in" clause unreliable, particularly when used in subqueries. The recommended workaround was to replace with joins, however my preferred solution was to use Postgres, which solved this problem and worked a treat. I appreciated your responses - so thank 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: Choosing a JS framework to go together with Django
The idea is to generate pure HTML views for non JS clients like search bots. If your view depends on AJAX calls, then it defies the purpose. I've been developing native mobile apps for the past year, so I get your argument about providing REST end points for your data. The point of my original post was to NOT do two different views; one for search bots and one for browsers. I agree that providing a REST interface is the "right" way to provide data for both browsers and mobile apps. To that end, the project I was suppose to work on, used tastypie. // Jon On 14/07/2013, at 15.16, Phang Mulianto wrote: > Hi , > > Why not using REST for serving your data to the Front End app, it can be from > mobile app or just web app with HTML + javascript. > > With that you don't need to worry about redo the template side in django and > in your front end js app. > With REST serving JSON, no template / html needed for the response. > > You can use Tastypie or Django rest framework which still using Django engine > . This way also your application server no need to rendering the HTML view in > every request from the first time. > > Any front end will be able to process the JSON with javascript. > > Regards, > > Mulianto > > > On Sun, Jul 14, 2013 at 8:18 PM, dotnetCarpenter > wrote: >> In the end, my project stalled due to lack of resources. We might pick it up >> but it's been abandoned for quite some time. I haven't had any django >> projects since. Hence, I can't make any recommendations. >> >> DjangoAjax looks promising but might lack the community support you expect. >> It is however based on jQuery and ASP.NET MVC, so if you can see past the M$ >> cruft, some guides etc are available. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/django-users. >> For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to a topic in the Google > Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/X_9qJJjiDfE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
'RegexURLResolver' object has no attribute 'default_args'
I am a newbie to Django, coming from PHP/Yii. I have gotten to the part 4 of the official Django tutorial but can't seem to get by this error. I have looked online and in this forum but cannot find anything on this specific error. Error: AttributeError at /polls/1/vote/ 'RegexURLResolver' object has no attribute 'default_args' Request Method: POST Request URL: http://127.0.0.1:8000/polls/1/vote/ Django Version: 1.8.4 Exception Type: AttributeError Exception Value: 'RegexURLResolver' object has no attribute 'default_args' View: def vote(request, question_id): question = get_object_or_404(Question, pk=question_id) try: selected_choice = question.choice_set.get(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): return render(request, 'polls/detail.html', { 'question': question, 'error_message': "You didn't select a choice.", }) else: selected_choice.votes += 1 selected_choice.save() return HttpResponseRedirect(reverse('polls:results', args=(question.id,))) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eaf2b01a-9a29-4b1e-867a-382291af54cd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django project beginner
I would recommend the Django Girls tutorial. It is very well written and easy to follow. I covers most of the components that you will need to get started with Django and is a good starting point. https://tutorial.djangogirls.org/en/ On Monday, December 26, 2016 at 6:39:25 AM UTC-5, imed chaabouni wrote: > > Hi everyone, > I'm about to make my first project with Django as an end-of-year project, > so, could you recommand me some exemple as a beginner ? > And if you've got some documentation that's would be great ( And yes I > already checked the doc of the official django website) > > Thanks, > Imed. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f8d7b6af-477a-4979-a8d0-d684b4162c04%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Master-Detail Form help needed
I have been struggling mightily with Master-Detail forms in Django. I have done a number of online tutorials but have yet to find a complete tutorial which completely explains models, views, templates, URL patterns related to master-detail forms. I use the Oracle toolsets where creating a master-detail form is just a matter of feeding the template your master table (model) and then selecting your detail table (model). It generates a basic form for you with CRUD controls. Similar to how the Django admin tool works. If someone could point me toward a good comprehensive book chapter or tutorial, I would be much appreciated. TIA. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c6d2-e561-409d-a356-724527431b66%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Foreign Key data not showing in formset
I have the following view with an inlineformset for two models: 1. Orders, the master / parent model 2. LineitemInfo, the detail / child model. FormSet LineFormSet = inlineformset_factory(Orders, LineitemInfo, can_delete=True, exclude = ('ordernotes',)) The edit order_edit view works fine for the master / parent form, but does not display the child records. I can add records to the child form and they will save, they do not display however when I select that record (I checked the database separately). def order_edit(request, pk): order = get_object_or_404(Orders, pk=pk) if request.method == "POST": form = OrderForm(request.POST, instance=order) if form.is_valid(): order = form.save(commit=False) lineitem_formset = LineFormSet(request.POST, instance=order) if lineitem_formset.is_valid(): order.save() lineitem_formset.save() return redirect('order_list') else: form = OrderForm(instance=order) lineitem_formset = LineFormSet(instance=Orders()) return render(request, "orders/order_edit.html", {"form": form, "lineitem_formset": lineitem_formset, }) I just get the empty fields on the child / detail form where the data should display. What am I missing? TIA -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/daa49199-da50-4be6-aa82-c28e84596580%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Foreign Key data not showing in formset
As much as I hate to answer my own questions, I was calling instance of an empty Order() model rather than the instance of the populated model. So: lineitem_formset = LineFormSet(instance=Orders()) should have been: lineitem_formset = LineFormSet(instance=order) On Wednesday, February 8, 2017 at 8:00:52 AM UTC-5, jon wrote: > > I have the following view with an inlineformset for two models: > >1. Orders, the master / parent model >2. LineitemInfo, the detail / child model. > > FormSet > > > LineFormSet = inlineformset_factory(Orders, LineitemInfo, > > can_delete=True, > > exclude = ('ordernotes',)) > > > > The edit order_edit view works fine for the master / parent form, but does > not display the child records. I can add records to the child form and they > will save, they do not display however when I select that record (I checked > the database separately). > > > def order_edit(request, pk): > > order = get_object_or_404(Orders, pk=pk) > > if request.method == "POST": > > form = OrderForm(request.POST, instance=order) > > if form.is_valid(): > > order = form.save(commit=False) > > lineitem_formset = LineFormSet(request.POST, instance=order) > > if lineitem_formset.is_valid(): > > order.save() > > lineitem_formset.save() > > return redirect('order_list') > > else: > > form = OrderForm(instance=order) > > lineitem_formset = LineFormSet(instance=Orders()) > > return render(request, "orders/order_edit.html", {"form": form, > "lineitem_formset": lineitem_formset, }) > > > > I just get the empty fields on the child / detail form where the data > should display. What am I missing? TIA > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/48bdb601-7636-4faa-9af9-b8c10a65c0cf%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Updating path and filename of ImageFieldFile
This code should work with Django 1.0 : from django.db import models from PIL import Image class Photo(models.Model): related_entry_id = models.ForeignKey(MyBlogEntryModel) # Use your model object photo = models.ImageField(upload_to="my_upload_path/") # Point to your upload directory (No leading slash will point to a subfolder of your media root) def __str__(self): return "%s" % (self.photo.name) def _save_FIELD_file(self, field, filename, raw_contents, save=True): filename = "%s_%s" % (self.related_entry_id, filename) super(Photo, self)._save_FIELD_file(field, filename, raw_contents, save) def save(self, size=(800, 800)): if not self.id and not self.photo: return super(Photo, self).save() filename = self.photo.path image = Image.open(filename) image.thumbnail(size, Image.ANTIALIAS) image.save(filename) On Oct 3, 5:43 pm, "Juanjo Conti" <[EMAIL PROTECTED]> wrote: > Matt, I'd like to resize an uploaded image, while uploading i think... > before it gets saved to the hard disk. How did you do it? In pre 1.0 > version I redefined _save_FIELD_file from my class. > > Thanks, > > 2008/8/14 mcordes <[EMAIL PROTECTED]>: > > > > > > > Thanks Andy, > > > Using the callable for upload_to is pretty interesting, but I don't > > think it's usable for my purposes because I want the image file's name > > to be XXX.png where XXX is the primary key for the model which, as the > > documentation warns, may not be set when the upload_to callable gets > > called. > > > I was previously doing this in the model's save method, but as I > > mentioned after the filestorage change it's not clear how to modify > > the path of an existing ImageFieldFile > > > As for my image processing it's pretty simple and consists of: > > > 1. resize image > > 2. changing format to png > > 3. applying relatively simple transformations on the image > > 4. then saving it in a different directory with a name based on the > > model's id, something like /path/i/want/.png > > > -Matt > > > On Aug 14, 12:18 am, "Andy Lei" <[EMAIL PROTECTED]> wrote: > >> If the only post processing you need to do is changing the filename, you > >> should pass a callable (like a function) as the upload_to parameter. > >> for example: > > >> def get_upload_path(instance, filename): > >> return '/path/you/want/' + instance.name > > >> class MyModel(models.Model): > > >> image = models.ImageField(upload_to=get_upload_path) > > >> Check out the documentation here: > > >>http://www.djangoproject.com/documentation/model-api/#filefield > > >> If you need to do other post processing, I think you want to take advantage > >> of the pre / post save signals, or override save method on your model. > >> Just > >> do the post processing in place though; i can't see a reason why you'd need > >> to save it twice. > > >> -Andy > > >> On Wed, Aug 13, 2008 at 10:22 PM, mcordes <[EMAIL PROTECTED]> wrote: > > >> > Hello, > > >> > When uploading files, I'd like to upload them to a temporary location > >> > and then after post processing move them to a different directory/ > >> > file. I had this working with the pre-filestorage code, but I'm not > >> > sure what the correct procedure should now be. > > >> > My model looks like this: > > >> > > class MyModel(models.Model): > >> > > image = models.ImageField(upload_to="images/tmp") > > >> > An uploaded file would then get stored here (relative to my media > >> > root): > > >> > > images/tmp/somefile.png > > >> > I'd like to be able to modify the associated MyModel instance so its > >> > image field now has a name of > > >> > > images/processed/XXX.png > > >> > I've tried using FieldFile.save as in > > >> > > myModelInstance.image.save('new/path/new.png', File(file('path to > >> > processed image file'))) > > >> > and this mostly seems to work, but it throws out the 'new/path' part > >> > of the name argument and my image ultimately gets stored here: > > >> > > images/tmp/new.png > > >> > rather than where I want it: 'images/processed/new.png'. > > >> > What am I missing? Am I attacking this all wrong? What are your > >> > suggestions? > > >> > -Matt > > -- > Juanjo Conti --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Does Django have a function that can be called by every view function ?
Another +1 for decorators. In fact, the example David S uses authentication and logins as an example of what he wants to do and its already handled as a decorator thus giving him a decent pattern to follow. David S, I'd suggest you look up the @login_required decorator and even look through the Django code to see how it's implemented. Don't be afraid of cruising through the code. As good as the documentation is, the code is also well organized and uses a lot of good pythonic idioms if you're new to the language. Jon. On Dec 1, 6:49 am, martyn <[EMAIL PROTECTED]> wrote: > David, > > +1 for decorator. > That let you use it or not in each view. > > On Dec 1, 9:30 am, David Shieh <[EMAIL PROTECTED]> wrote: > > > Thanks , David Zhou , I will find some information for decorator > > And also , I will surf for middleware . > > > Thank you very much , Malcolm. > > > On Dec 1, 3:55 pm, "David Zhou" <[EMAIL PROTECTED]> wrote: > > > > On Mon, Dec 1, 2008 at 2:23 AM, David Shieh <[EMAIL PROTECTED]> wrote: > > > > I dont' know whether this make any sense . > > > > Right now , I can't test it , but if django won't initiate the > > > > views.py as a class , this method will make no sense. > > > > Why not write a decorator? > > > > --- > > > David Zhou > > > [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Where are all the Django jobs?
Django is starting to gain more traction and I do believe we'll start to see a bit more of a hockey stick effect on it's adoption over the coming months. 1.0 being released last year and (at least part-wise) adoption by the Google AppEngine have both been great PR events for Django but I'd also argue that Django doesn't have it's Twitter or BaseCamp yet i.e. a killer application that grabs the mindshare of startup CTO and CEOs that seemingly make them choose Rails. At Thinktiv, while we're a professional services company thats officially platform agnostic, we've chosen Django as our in-house framework of choice for development. Django suits the majority of our customers applications very well (generally interesting presentations and visualization of structured data and media). Whenever we've had customers where we get to influence the framework used, we'll sell Django into the account. However, we've had customers comeback and want to build on Rails for the exact opposite reason from this thread: lack of people in the Austin area who know Python/Django to take on the maintenance work after we've done the initial application build. So it seems like we've got a bit of a chicken/egg problem. Our organization is going continue to evangelize Django in our community. The more that the Django-community sells its virtues in our various consulting gigs the more opportunity we'll get to use the framework we love. To further Malcolm's point above, be a good programmer first. Good programmers should be able to pick up (or already know) multiple platforms, frameworks, languages quickly. Being a first rate programmer who's technology agnostic will open up a huge number of opportunities where you'll get to be the person who influences what gets used in various situations. It's in those situations that you'll get to grab your favorite tool: Django. Jon Loyens Thinktiv, Inc. On Jan 11, 1:14 am, Malcolm Tredinnick wrote: > On Sat, 2009-01-10 at 15:38 -0700, David Lindquist wrote: > > First, I understand that the world economy is in a slump, and that > > the job market as a whole has not fared well of late. But even before > > the recent downturn, I noticed that there are precious few jobs in > > Django development (yes, I know about DjangoGigs.com). A simple > > keyword search on popular job boards shows that the number of Ruby on > > Rails jobs outnumber Django easily by a factor of 10 or 20. True, > > Rails has been around longer, but not by much (a year maybe?). > > > So my question to the group is: if Rails has been widely adopted in > > the enterprise, why hasn't Django? Do you think Django will catch on? > > Or do you think it will be more of a "boutique" framework? > > There are some slight problems with your methodology. Large companies > adopting something like Django aren't necessarily going to be posting to > djangogigs.com or places like that. They'll already have competent > programmers in-house to do the work. Or they'll hire through more > traditional channels. So it might well be that Django is more heavily > used in large organisations than Rails and all the Rails jobs you see > being advertised are because there are lots more gigs at the smaller > end. > > I have no evidence to support this either way, but it's always tough to > estimate "the number of people using X" by the job advertisements > without a lot more controlling of factors. > > It's probably a mistake to base your entire career for any period of > time on only doing Django work unless you have some long-term contract > or permanent position already lined up. But it's not a bad skill to have > in your bag of tools, since many other problems that contractors are > asked to solve can be solved using that particular skill. Keep in mind > that keyword searches only find offerings where the client/employer has > already picked the solution and is trying to backfill a lack of skills > and hoping desperately that adding more people or bringing in new people > won't make things worse than they are (hiring contractors is very > risky). There are many other positions where the hirer is in a position > of having a problem and after a solution. That's where the experienced, > all-around consultant can often add genuine value. > > Over the years, Python job advertisements have lagged behind other, > trendier areas. It's led to some perception problems, particularly when > trying to "sell" Python-based solutions to more conservative outfits. > But you can only hold one job at a time, so all you need is one job > opening in an area you can work in and you're fine. Do you want to be a > quali
Re: Quick question about switching to newforms-admin branch....
I assumed that trunk would be moving in the newforms-admin direction, so I've switched already. I would rather do it now than have to backport stuff later... Thanks! Jon Brisibn http://jbrisbin.com On Jul 15, 2008, at 3:50 PM, Dan wrote: > Should I start with the nfa branch or with trunk and update the code > when it is merged? Is there risks of breakage in nfa? Other issues? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: legacy site in php
Rather than the structure you suggest, it might be better to think about your exhibition projects not as django projects, but as django apps. Replace pyA and pyB with root/pyA and root/pyB (e.g. make your php directories a peer of the django root...conceptually, of course...you're Python files won't live physically next to your php files, or shouldn't anyway) and control all your django urls through your urls.py file. This would cut down on the duplication you'd probably end up with in the settings.py file, etc... I don't mix PHP with Python, but I do mix PHP with Java in the enterprise and there is, IMHO, no inherent conflict in mixing PHP with anything else. There is some duplication (and will be until you're using a single language), but you can generally keep that to a minimum by using an OO approach on both sides. It does create some internal strife in your mind, though, as you switch between worlds. Use the Force, though, and everything will magically turn out all right. ;) Thanks! Jon Brisibn http://jbrisbin.com On Jul 15, 2008, at 4:41 PM, garycannone wrote: > > I have what is a very naive question though I didn't find a close > enough post that answered what I think is a very general question. > > I work at a museum and inherited a site done in php (the coding is > very problematic but this is not the issue). I will overhaul the site > and would like to use Python and Django (I am being asked to make > small desktop apps and collective intelligence type interactions so I > would rather use a general purpose language across the board > suited for all needs). > > (I have used codeIgniter in php for other projects but the site I > inherited uses no php framework) > > Having never used django or mixed languages on a site, I wonder if > there's a way for me to maintain some of the folders I have on the > site while using the django framework? These are exhibition websites > in their own folders > > so I would like the following > > root(django) > |_ folder pyA (containg py files) .. I use the term "folder," but > know it is controller/view > |_ folder pyB (containg py files) > |_ folder a (containing php files).. Existing folder on site > |_ folder b (containing php files)..existing folder on site > > Mind you, I don't want to mix the languages at all in single files. > > I would prefer to use Python, yet would not be able to redo all the > smaller exhibition sites > > My question is, would there be an issue in setting up a structure like > above or should I face facts and realize that the site has to continue > with php in order to maintain everything integrated? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
accessing site settings in templates
I can't find a good answer to this in the Django docs: is there a good way to access site-specific settings from your templates without having to put them in context variables? I've got my media served by Apache and everything else by Django. In my templates, I've got an ugly hack to check for the existence of a "site_base_url" variable or default to localhost. This is a mess because I can't test it from my iPod without using a hostname, but I can't get context variables to the views I don't have control over (like login/logout, etc...), so my templates don't have the "site_base_url" for everything. Do I have to write some custom middleware that will add my global application settings to every request, then reference them through the RequestContext I'm passing in to render_to_response? Or is there some other feature of views I'm missing (I've read so much on Django lately, I'm starting to forget what I've read and what I haven't)? Thanks! Jon Brisibn http://jbrisbin.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
OpenID support in contrib.auth
I tried both OpenID integration packages I could find for Django and couldn't get either to integrate in what I felt like was a clean manner (or even get them to work!). I've resolved to simply write my own, stripped-down version of an Auth backend that uses OpenID (additionally storing the auth url in a user profile so I can indicate to the user under what OpenID they're signed in). Before I spend a couple days hacking on this, I was wondering if anyone else has tried (or succeeded) in integrating OpenID with Django trunk? I'm using newforms-admin and the latest egg of python-openid. Since I'm already using user profiles, my goal is to only impact my application by adding an auth handler for OpenID and mixing in the views for openid-begin and -complete. I don't want anything else scabbed on to enable OpenID integration. BTW- The ASL (python-openid's license) *is* compatible with BSD, right? Thanks! Jon Brisibn http://jbrisbin.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why 2 servers to serve dynamic and static content?
On Jul 17, 2008, at 10:43 AM, 3xM wrote: > >> And in deployment, how should this be? I mean, should I have 2 apache >> instances? or use another web server for static content or...? > > You can use the same Apache instance, running 2 different virtual > hosts: One for the Django site and the other for serving static files. > That will probably be sufficient in most cases. > That's fine if you're only concerned about separating images, css, and other media from Django. I'm using GWT in my Django app, though, and using any method other than Aliases or mod_rewrite won't work for me. In production, it'll be on a shared hosting provider, so I have to use rewrite rules running through an FCGI script and serve all other files and directories that actually exist through normal Apache. Thanks! Jon Brisibn http://jbrisbin.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: accessing site settings in templates
I was considering this option, but went with some custom middleware, which allows me to mix in some other things I was wanting to add to the context as well... Thanks for the suggestion! Jon Brisibn http://jbrisbin.com On Jul 17, 2008, at 4:16 PM, gordyt wrote: > > Jon I don't see why you couldn't make a custom template tag (see > http://tinyurl.com/2zlzf6). I made one to display the current > application revision and so to use it in a template is just this: > > {% revision %} > > --gordon > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: accessing site settings in templates
Sort of, but not really because I wanted something that worked even using the built-in views (the problem manifested when I started working with the login views). I didn't have a problem passing my settings into the templates for the views I created myself, but I didn't have access to the same arbitrary settings in the templates created for the built-in views. I had to use middleware to intercept the context and add the variables, even when using views I didn't write. It seemed like a fair amount of extra work just to make sure all my templates had a "media_base_url" variable! :) I've actually changed to using plain CGI (rather than manage.py runserver) in development so that I don't have to muck about with proxying the Django server and other such [*bleep*]...subtleties...to get a coherent environment where I can test in the GWT hosted mode browser, desktop Firefox, and the iPod Touch, all at the same time. Thanks! Jon Brisibn http://jbrisbin.com On Jul 17, 2008, at 6:45 PM, [EMAIL PROTECTED] wrote: > > Look at these sample code , is this you want ? > > from django.template import loader, RequestContext > def custom_proc(request): > "A context processor that provides 'app', 'user' and > 'ip_address'." > return { > 'app': 'My app', > 'user': request.user, > 'ip_address': request.META['REMOTE_ADDR'] > } > def view_1(request): > # ... > t = loader.get_template('template1.html') > c = RequestContext(request, {'message': 'I am view 1.'}, > processors=[custom_proc]) > return t.render(c) > > On Jul 18, 5:52 am, Jon Brisbin <[EMAIL PROTECTED]> wrote: >> I was considering this option, but went with some custom middleware, >> which allows me to mix in some other things I was wanting to add to >> the context as well... >> >> Thanks for the suggestion! >> >> Jon Brisibnhttp://jbrisbin.com >> >> On Jul 17, 2008, at 4:16 PM, gordyt wrote: >> >> >> >>> Jon I don't see why you couldn't make a custom template tag (see >>> http://tinyurl.com/2zlzf6). I made one to display the current >>> application revision and so to use it in a template is just this: >> >>> {% revision %} >> >>> --gordon > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: superuser has no rights with newforms admin
> Figured out what went wrong. You now have to register your models > with the admin app, which will give you access. > > If anyone else that is completely awful at Django is running into the > same problem let me know and I'll go in to more depth. Could you let me know what you did to fix this? My urls.py is very simple, and contains: -8<--- from django.conf.urls.defaults import * from django.contrib import admin from os import path admin.autodiscover() urlpatterns = patterns('', # Uncomment this for admin: ('^admin/(.*)', admin.site.root), # Index page. (r'^/?$', 'vmanager.frontend.views.index'), ) -8<--- My models.py file in my applicaion folder contains the following (I've snipped aprts of the model definition, as they're not relevant) -8<--- from django.db import models from django.contrib import admin class Person(models.Model): """This models a person machine""" (details omitted here) -8<--- I've tried alternating between using admin.autodiscover() in my urls.py, and manually registering my models using admin.site.register(Person), but I still get the permission error in the admin site. I've also tried flushing the database, but that doesn't seem to solve anything. FWIW, my user has is_superuser, is_staff and is_active all set to true in my database. The exact message I get in the admin site is "You don't have permission to edit anything". Any help would be much appreciated. --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: superuser has no rights with newforms admin
On Sun, Jul 20, 2008 at 2:01 AM, stryderjzw <[EMAIL PROTECTED]> wrote: > > Strange, I'm getting the message "You don't have permission to edit > anything." on the admin homepage. I've done admin.autodiscover() on > the project urls page, I've created admin.py files for my models and > registered the classes with admin.site.register(). Same here (having followed the earlier advice on the list). Is there any more useful information which I could post to help debug this? --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: superuser has no rights with newforms admin
>> > > I'm installing it from SVN and got "You don't have permission to edit >> > > anything", I made it work before, but now when I try to follow the >> > > book can't. Could you tell me what should I add to have full >> > > permissions? >> >> > I have no idea what is going on in cases where people have >> > admin.autodiscover() in their urls.py yet still get this "You don't have >> > permission to edit anything" message. I'd suggest you put a print >> > statement >> > in django/contrib/admin/__init__.py after the __import__ in autodiscover() >> > and verify that the auth app, at a minimum, is being found by >> > autodiscover(). If not put a print in before the import and ensure >> > adutodiscover() is really being called and attempting to import the admin >> > module for each installed app. Okay, I've spent a little time on this. There seem to be a few problems. First of all, I'm a little confused about where to use admin.site.register(). A few months ago I checked out the newforms-admin branch to try to get a head start, and I followed the instructions on this wiki page[1], which recommended importing django.contrib.admin at the top of models.py in a given app, then registering the models at the bottom of the same file. Of course, I realise that the documentation is in flux, but at the time, doing that worked. I've now moved that code into admin.py in my app folder. It looks something like this: -8<- from django.contrib import admin from myproj.people.models import Person class PersonAdmin(admin.ModelAdmin): pass admin.site.register(Person, PersonAdmin) -8<- However, when I *also* include admin.autodiscover() in my project-root urls.py, the following exception is raised: ImproperlyConfigured at /admin/ Error while importing URLconf 'myproj.urls': The model Person is already registered If I comment out the contents of my admin.py file, then that exception is not raised, and also if I comment out the call to admin.autodiscover(), the exception is not raised, however I cannot have both active at the same time. A little googling brought up ticket 6776 [2], which seems to have been closed, with the introduction of admin.autodiscover() as the resolution. I'm not entirely sure what is going on there. Regardless, I took Karen's advice, and modified the __init__.py in django.contrib.admin, and added a print statement to see which applications were being loaded. In my case, the output was this: django.contrib.auth django.contrib.contenttypes django.contrib.sessions django.contrib.sites django.contrib.admin myproj.people ... which looks reasonable to me (auth is being loaded before admin, which would suggest that the permissions would be available to the admin app), but I still see the same 'you don't have permission to edit anything' message in the admin application. Any help debugging this would be much appreciated - now that newforms-admin is in trunk, I can't justify continuing development without it, so I'd really like to solve this :-) --Jon [1] http://code.djangoproject.com/wiki/NewformsHOWTO [2] http://code.djangoproject.com/ticket/6776 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: superuser has no rights with newforms admin
> It sounds like your admin.py file has already been imported by something > else before the autodiscover() is called. Did you add an import of your > app's admin into your models.py? That shouldn't be necessary. Also make sure > you don't have an import for it in your __init__.py file; that was the > recommendation when I first migrated to newforms-admin but it led to > multiple registrations like this so was replaced by autodiscover(). You > should not have an explicit import of your app's admin anywhere; > autodiscover() is, I believe, the only thing that should be doing the import > thus ensuring registration is only run once. No, I don't. I should clarify that when I previously had newforms-admin working correctly, it was in a different project. The trouble that I'm having is with a project which I started after the newforms-admin merge. > Alternatively, you are sure you removed the registration calls from your > models.py file? Yep. > I'm pretty stumped by this myself. I can't recreate it (and actually right > now am away from home so unable to even try anything for several hours). > Maybe if you can figure out and solve what is causing the multiple > registration exception that will shed some light I've uploaded my complete project tree (it's fairly small, and I've included the sqlite database). The admin username and password is 'test'. It's available at: http://jonatkinson.co.uk/static/junk/myproj.zip FWIW, I'm using SVN trunk at revision 7951. I realise that asking anyone to download and run my project just to help me fix a problem is quite a presumptious request, but I live in hope :-) --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: superuser has no rights with newforms admin
> Does that mean it works for you as well if you update to latest? I only > knew nfa was not part of trunk at that point because I looked it up after > trying reverting to 7951 to test your environment. I found the > autodiscover() caused an exception because it didn't exist...so if you were > running 7951 it must have been a newforms-admin branch version? Not sure > why that wouldn't have worked but if it's fixed in latest it's probably not > worth tracking down. Yes, it does work for me. I had both the newforms-admin and an older trunk checked out on my machine, but it appears that I updated my nfa branch, and not my trunk, but then went ahead and installed my (old) trunk code. PEBKAC. Sorry for wasting your time, but thanks a lot for your help anyway, Karen. --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: superuser has no rights with newforms admin
> You can't really be using trunk 7951 -- that's from before newforms-admin > merge which was 7967?? Try updating to latest trunk? So I feel slightly ... foolish :-) --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
I posted a new template tag for forever-caching resources...
...at djangosnippets: http://www.djangosnippets.org/snippets/991/ I wanted to be able to use the forever-caching capability of Google Web Toolkit with my own resources, so I wrote this template tag to handle any resource. If the file you want cacheable is a JS or CSS file, it will (optionally) use YUI compressor to compress the file first. It creates a copy of your original file called "LONGMD5SUM.cache.(js| css|png|gif|etc...)". You have to set it up separately, but to get the effect of forever-caching, configure your webserver to cache resources conforming to that name. Different webservers do it differently, of course (I use lighttpd), so that's left as an exercise to the reader. In DEBUG mode, the minification and copying is turned off so you don't get a proliferation of files as you develop. I'm not entirely happy with the way I handle relative vs. absolute paths. It's hard to get a scheme that will work in cacheable and non- cacheable mode using the same pathname. I settled on setting DOCUMENT_ROOT in settings.py to my real document root (one step above MEDIA_ROOT) and using "/media/css/my.css" etc... in the "src" and "href" attributes in the template. I have to strip the leading "/" off to make os.path.join work right, but I have to put it *back* after I strip out DOCUMENT_ROOT and send it as a path to the browser. I think there's a better way to handle this and I'd be interested in hearing how to do that. I hope you find this useful. Comments are welcome! Thanks! Jon Brisbin http://jbrisbin.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
SuspiciousOperation exception on ImageField upload
Hello, I'm trying to work with a model which accepts a logo image upload via an ImageField. My a cut down version of my model is below: class Promoter(models.Model): name = models.CharField(max_length=100) logo = models.ImageField(upload_to="/images/promoters/%Y/%m/%d/") When I try to upload the logo via the built-in admin interface, I get the following error: SuspiciousOperation at /admin/promoters/promoter/add/ Attempted access to '/images/promoters/2008/08/19/kitten.jpg' denied. In settings.py, my MEDIA_ROOT is set to an accessible directory in my home folder: '/home/username/projectname/media/', and this folder has it's permissions set to 777. I'm currently using the ./manage.py webserver, which (I assume) runs as the same user which starts the process; this is the same user as owns the folder specified above. Any ideas what I'm doing wrong here? --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SuspiciousOperation exception on ImageField upload
Marty, That was the problem, thank you for you help. --Jon On Tue, Aug 19, 2008 at 2:13 PM, Marty Alchin <[EMAIL PROTECTED]> wrote: > > On Tue, Aug 19, 2008 at 8:47 AM, Jon Atkinson <[EMAIL PROTECTED]> wrote: >> I'm trying to work with a model which accepts a logo image upload via >> an ImageField. My a cut down version of my model is below: >> >> class Promoter(models.Model): >>name = models.CharField(max_length=100) >>logo = models.ImageField(upload_to="/images/promoters/%Y/%m/%d/") > > Drop the first slash in your path name. > >> When I try to upload the logo via the built-in admin interface, I get >> the following error: >> >> SuspiciousOperation at /admin/promoters/promoter/add/ >> Attempted access to '/images/promoters/2008/08/19/kitten.jpg' denied. >> >> In settings.py, my MEDIA_ROOT is set to an accessible directory in my >> home folder: '/home/username/projectname/media/', and this folder has >> it's permissions set to 777. > > But with that leading slash, you're trying to save to > /images/promotors/%Y/%m/%d/, not > /home/username/projectname/media/images/promotors/%Y/%m/%d/ like you > want. That path probably doesn't exist, and Django would need > unrestricted access to your system in order to create it for you. > Needless to say, not a good situation. > > That SuspiciousOperation is in place to help prevent Django from > trying to accidentally read or write from places on your filesystem it > shouldn't have access to. Just drop the first slash in the path name > (so it reads upload_to="images/promoters/%Y/%m/%d/") and you'll be all > set. > > -Gul > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using ETags with Django
Are any of you using ETags with Django? I'm wondering what the easiest solution for determining whether I need to send back a 304 is. I have last-modified timestamps on my models, so I could conceivably query those and match them against the If-Modified-Since header. It seems like I'd be doing two queries, though. Once for the latest timestamp and again for the real objects. The other alternative seems to be to create a model specifically for determining whether result sets have been dirtied or not. I'd have to make sure my update routines updated this object whenever a model got updated that would dirty a result set. Although new content will be added (hopefully) frequently, I'm not sure there will be that much changing once it's been added. I definitely want to reorder the list of content based on weighting a random ordering, so for some views it will be difficult to rely on ETags for caching. Since Django encourages the use of clean urls, though, it seems like I should be able to use ETags with my models, especially when getting the detail for a particular instance. How would I attack this in a reasonably clean (i.e. able to be reused with any views I want ETags for...but not *every* view) way? I'd like hear how others have solved this before I spend a lot of time hitting dead ends. Thanks! Jon Brisbin http://jbrisbin.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Composite Forms? Are widgets the right thing to use?
Hi all, I have a sight where I need to generate forms that are made up of two or three other forms. For example I have New User sign up form that accepts user information (user name, name, password), a shipping and a billing address (with the same usual field) and credit card info. Sometimes, I need a composite form with all of the above while sometimes I need a form with just a subset of the information. As an example, I'd like to define a series of forms like this: CreditCardForm - CardType = ChoiceField - CardNumber = CharField - CardExpiry = CharField AddressForm - StreetAddress = CharField - City = CharField - State = CharField NewUserForm - Username = CharField - Password = CharField - ShippingAddy = AddressForm - BillinAddy = AddressForm Is there a way to do this sort of thing with the Forms API? I had hope for FormSets but that's a more dynamic thing that I need which is really a Composite form pattern. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to use Django + Postgresql on leopard?
I do *all* my development on OS X Leopard! I just used the version in MacPorts. You have to compile psycopg2 against the same architecture as the server libraries (64 or 32-bit, depending on what you're on). I use a MacBook Pro and I had to add the 64-bit flags. I was going to post what I changed in the Makefile, but I've deleted it. I've used Cygwin a lot and I don't find it easier to use than the Mac at all. Of course, I would say that since I'm a die-hard Mac user. Are you using MacPorts? If so, there's a version in there that will compile fine. I use Postgres 8.3 and I had to make sure my CFLAGS and LDFLAGS were set such that /Library/PostgreSQL8 was found by psycopg's configure. It's called py25-psycopg2. Thanks! Jon Brisibn http://jbrisbin.com On Aug 23, 2008, at 1:08 PM, Theme Park Photo, LLC wrote: > > I have been unable to get Django + Postgres to run on Leopard. > > (Works fine on Windows and Linux. Personally, I find it much easier to > get most open source stuff to run on Windows or Windows+Cygwin than on > the Mac!) > > Anyway, the problem isn't Django, and it isn't Postgres. It's > psycopg2! I can't get it to build! And the "MacPorts" version that > everyone tells me to use is for Python 2.4, and I'm on Python 2.5. > > Has anyone gotten Django + Postgres + Python 2.5 + psycopg2 to run on > Leopard? Or should I just use the mac as a pretty box to browse the > web with? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Composite Forms? Are widgets the right thing to use?
Thanks guys! Using multiple forms + prefixes is exactly what I need! Would be nice if there was some global wrapper though so you could do validation amongst the forms but beggars can't be choosers. On Aug 23, 2:28 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Aug 23, 2:33 am, Jeff Anderson <[EMAIL PROTECTED]> wrote: > > > There is no reason that you couldn't include multiple forms in an HTML > > post operation. You just have to make sure that there won't end up being > > duplicate fields across forms. > > In fact, there isn't even any reason to worry about that: just use a > prefix when instantiating the > form.http://www.djangoproject.com/documentation/forms/#prefixes-for-forms > > -- > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Schema Evolution Choices?
Hi guys, I have a small project coming up that I think having some sort of schema evolution facilities will be handy on. I was wondering what the current and best project choices for schema evolution are? I was leaning towards django-evolution until I saw a post from Russell saying that he hadn't updated it to the 1.0 branch yet. Any options or opinions are appreciated. Thanks, Jon. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: OT: Google Chrome
I tried it on my Windows VM (still waiting on a Mac version) and it seemed quite fast. Since it's WebKit, I'm hoping it'll be as easy to develop for as Safari. I like that Gears is integrated, though I haven't yet used Gears in an app (it's on my list! :). I'm seriously considering using gears in my admin app for desktop browsers (the nature of the admin interface means you won't be doing much admin on the iPhone...mostly read-only). I think NPR was right about it, when they reported on it this afternoon: most people won't bother using anything other than IE because that's what's installed on their PC and it's what they know (we've standardized on Firefox at work and most people still use IE, though I've convinced some to switch). I can't begin to describe how much I HATE hacking what I write to work on IE. I think that's why I've gravitated to the iPhone. Closed platform or not, it's great to have some stability and predictability as a developer. I've never really had that before and it's kind of nice. Thanks! Jon Brisibn http://jbrisbin.com On Sep 2, 2008, at 6:41 PM, James Matthews wrote: > HI List, > > Today Google released chrome. I have been playing around with it a > little today. Besides for seeing some funny things (try https://www.gmail.com > Thanks reddit) It seems to be a very nice browser. I would like to > see where it's path is going to go. What are your thoughts? > > James > > -- > http://www.goldwatches.com/ > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Connecting to AS400
I don't think Django can natively use unixODBC as it's ORM backend, unfortunately. It would be great if it did! You could Django without the ORM, of course. To connect from a Win server (why would want to do that? ;), you could use ClientAccess. To connect from Linux, you could use IBM's Linux version of the ClientAccess drivers. All other unices would need the DB2 xpress install, configured to use unixODBC (which works, but to connect one DB2 server to another, you have to pay for the connectivity driver...it's kind of underhanded if you ask me when you can connect on other platforms, outside of the native DB2 driver for free). Or you could use the native Python functionality to use REST-based webservices (Apache/Tomcat come standard, though unconfigured on v5r4, which is what we're running). So there are several options, but not using the ORM, AFAIK. If I'm wrong about that, I'd love to hear it because I could use that as well! :) Thanks! Jon Brisibn http://jbrisbin.com On Sep 11, 2008, at 3:50 PM, Jason Sypolt wrote: > > Is it possible to connect to an as400 database using django > (preferably) or with python? I would like to build a product catalog > site using django and read in products and send orders to the as400. > > Note that the site itself will not be on an as400 system. Just > wondering if anyone has done this before and if so, can you point me > to some resources/libraries? Thanks! > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: troubles with mod_python on Leopard
I had quite a bit of trouble with Apache/mod_python on Leopard as well. I had to go back to using the default Apache 2 and stock python 2.5. I also had to rearrange things a bit in the path and ended up putting a symlink in /Library/Python/2.5/site-packges/django to ~/src/ django-trunk/django, which is found by Apache launched by launchd. From there, the basic mod_python directions seemed to work for me. I'm not using Apache any more, though, as I've moved to lighttpd. Thanks! Jon Brisibn http://jbrisbin.com On Sep 11, 2008, at 2:37 PM, [EMAIL PROTECTED] wrote: > > Hello, > > I'm trying to install Django with Mod_Python on Leopard. I've been > through the process on Linux and Windows several times without many > issues, but on Leopard I've come up against a wall and I don't know > what else to check. OS X is the os I have least experience with. > > I wanted to install the newest versions of Python and Apache instead > of using the versions that come with OS X. That went fine. I have > django checked, and symlinked from my site-packages directory. It runs > fine on the development server. If I type python at the terminal, I > can import Django without issue. Apache is running as well. > > I built Apache and Mod_python using the instructions here: > http://cavedoni.com/2005/django-osx > > I have Apache calling a test handler using configurations in > an .htaccess file, so something is right there. However, after > fighting with a "forbidden" message (and winning), I get the message > that I can't import django.core.handlers.modpython when I use the > configuration in the cavedoni.com tutorial. > > I had thought that perhaps Mod_python wasn't linked to the correct > version of Python, so I tried to build it again (first clearing the > configuration with distclear). But I'm getting the same problem > > I tried to add django to the Python Path using the PythonPath > declaration in my .htaccess file, but pointing it to the symlink and > actual code checkout gives me the same results. > > My path looks like this when output from my test mod_python handler: > > /Users/jdonato/Documents/code-checkouts/django-trunk/django > /Users/jdonato/Documents/code-checkouts/django-trunk > /Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5 > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat- > darwin > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat- > mac > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat- > mac/lib-scriptpackages > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib- > dynload > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- > packages > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- > packages/PIL > > Which is identical to what I see when I open python from the command > line and view sys.path, except here I have the two extra django > directories that I'm adding in the config. > > I saw this: > http://groups.google.com/group/django-users/browse_thread/thread/1cc6ad68d63cb61d?fwc=1 > but I tried changing my permissions and there's no change. > > My .htaccess file looks like this: > AddHandler python-program .py > PythonHandler mptest > PythonDebug On > PythonPath "['/Users/jdonato/Documents/code-checkouts/django-trunk/ > django', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django'] + sys.path" > > But note that I've tried similiar things in the main apache > configuration file. Right now, for testing purposes, I've removed > the .htaccess file, and changed my main conf file to: > > > AddHandler python-program .py > AllowOverride FileInfo > PythonHandler mptest > PythonDebug On > PythonPath "['/Users/jdonato/Documents/code-checkouts/django-trunk/ > django','/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django'] + sys.path" > > > In mptest, I try to import Django, but get:ImportError: No module > named django > > If any one has any ideas, I'm all out myself and would gladly try > anything. Thank you for reading this long post. > > Justin > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Deleting a Model with ForeignKey relationship where null=True in Admin causes IntegrityError
See the following set of models: class Mom(models.Model): name = models.CharField(max_length=80) def __unicode__(self): return self.name class Dad(models.Model): name = models.CharField(max_length=80) def __unicode__(self): return self.name class Child(models.Model): name = models.CharField(blank=True, max_length=100) mom = models.ForeignKey(Mom) dad = models.ForeignKey(Dad, null=True, blank=True) def __unicode__(self): return self.name In admin if you create a Child with a Mom and a Dad, and then attempt to delete the Mom, it works as expected (prompt to make sure you're okay deleting the children, click okay, Mom and Child objects are deleted). However, if you attempt to delete the, Dad, you'll get a prompt asking if it's okay to delete the Child but upon clicking Okay, you get an integrity error. I'm using MySQL and innoDB. Here's a link to the traceback: http://dpaste.com/83431/ Is this a bug I'm seeing or am I missing something in either my models or configuration? Or do I not understand how ForeignKeys where null=True are supposed to work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Deleting a Model with ForeignKey relationship where null=True in Admin causes IntegrityError
As a note... I've worked around this for the time being by setting cascade on delete explicitly in db. That said, I'd still like to know if this is a bug or if I'm doing something wrong with my models. Jon. On Oct 9, 11:28 am, Jon Loyens <[EMAIL PROTECTED]> wrote: > See the following set of models: > > class Mom(models.Model): > name = models.CharField(max_length=80) > > def __unicode__(self): > return self.name > > class Dad(models.Model): > name = models.CharField(max_length=80) > > def __unicode__(self): > return self.name > > class Child(models.Model): > name = models.CharField(blank=True, max_length=100) > mom = models.ForeignKey(Mom) > dad = models.ForeignKey(Dad, null=True, blank=True) > > def __unicode__(self): > return self.name > > In admin if you create a Child with a Mom and a Dad, and then attempt > to delete the Mom, it works as expected (prompt to make sure you're > okay deleting the children, click okay, Mom and Child objects are > deleted). However, if you attempt to delete the, Dad, you'll get a > prompt asking if it's okay to delete the Child but upon clicking Okay, > you get an integrity error. > > I'm using MySQL and innoDB. Here's a link to the traceback: > > http://dpaste.com/83431/ > > Is this a bug I'm seeing or am I missing something in either my models > or configuration? Or do I not understand how ForeignKeys where > null=True are supposed to work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Deleting a Model with ForeignKey relationship where null=True in Admin causes IntegrityError
I was looking for a ticket like that. Unfortunately I could see where either behavior is going to be controversial. If you set the foreign key back to null, some people will want it to be deleted. If you delete, some people will prefer it go back to null. Instead could there be an option on nullable foreign key fields? Default the behavior to the non-destructive setting and then allow people to override it if it should be destructive in their application? Of course, this would amount to introducing a new feature to the 1.0 branch which is probably not what you guys want to do. Maybe a 1.1 feature. I'll shut up now as this discussion clearly belongs in django-dev being discussed by people with more in-depth knowledge than myself ;) Thanks Malcolm. Jon. In the interim, for this project, I'll continue to explicitly set cascading deletes in the db. On Oct 9, 8:12 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-10-09 at 09:28 -0700, Jon Loyens wrote: > > [...] > > > Is this a bug I'm seeing or am I missing something in either my models > > or configuration? Or do I not understand how ForeignKeys where > > null=True are supposed to work? > > It's possibly a bug. There's a ticket open (#9308) about it. The only > question in my mind is which behaviour to use when deleting (delete > child or not), but raising an integrity error is a bug. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django 1.0.2 runfcgi fails to start on Windows
Hi, all. For various reasons, I prefer to use python 2.6 on my computer. Since mod_python and mod_wsgi won't work on Python 2.6, I have to use FCGI or switch to Python 2.5. I have flup installed without any problems. However, when I try to run this command: manage.py runfcgi method=threaded host=127.0.0.1 port=9000 Nothing happens. I get no status message or anything. If I then run this: manage.py runfcgi protocol=scgi method=threaded daemonize=false host=127.0.0.1 port=9000 I get "WSGIServer starting up", but nothing else happens, and I get server 500 errors from Apache. I know the flup library officially doesn't support Windows, and I also know that there are indications that fcgi simply won't work on Windows at all. But the Django site describes people getting it working on Windows machines. Could someone please help? I don't want to have to switch to Python 2.5 to be able to use mod_python. --~--~-~--~~~---~--~~ 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 1.0.2 runfcgi fails to start on Windows
There are no precompiled binaries for mod_wsgi with Python 2.6. In order to use it, I would have to download the source code for it and compile it against Python 2.6, which I don't think is doable in Windows without making some sort of special adjustments to the source code. On Jan 17, 2:16 pm, Daniel Roseman wrote: > On Jan 17, 6:44 pm, Jon Prater wrote: > > > > > Hi, all. > > For various reasons, I prefer to use python 2.6 on my computer. Since > > mod_python and mod_wsgi won't work on Python 2.6, I have to use FCGI > > or switch to Python 2.5. I have flup installed without any problems. > > However, when I try to run this command: > > manage.py runfcgi method=threaded host=127.0.0.1 port=9000 > > Nothing happens. I get no status message or anything. If I then run > > this: > > manage.py runfcgi protocol=scgi method=threaded daemonize=false > > host=127.0.0.1 port=9000 > > I get "WSGIServer starting up", but nothing else happens, and I get > > server 500 errors from Apache. > > I know the flup library officially doesn't support Windows, and I also > > know that there are indications that fcgi simply won't work on Windows > > at all. But the Django site describes people getting it working on > > Windows machines. Could someone please help? I don't want to have to > > switch to Python 2.5 to be able to use mod_python. > > I can't help with your fcgi problem, but what makes you think mod_wsgi > won't work with Python 2.6? > -- > 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: Django 1.0.2 runfcgi fails to start on Windows
I don't have one, but if mingw would do I know where I can get it. On Jan 17, 5:19 pm, Graham Dumpleton wrote: > On Jan 18, 6:31 am, Jon Prater wrote: > > > There are no precompiled binaries for mod_wsgi with Python 2.6. In > > order to use it, I would have to download the source code for it and > > compile it against Python 2.6, which I don't think is doable in > > Windows without making some sort of special adjustments to the source > > code. > > Wrong, should compile fine with Python 2.6. You just need the script > to do it. > > If you have a compiler more than happy to point you at the script. > Perhaps post to thread: > > http://groups.google.com/group/modwsgi/browse_frm/thread/4e0f5b50a9ac... > > which was my latest effort to get person who builds mod_wsgi binaries > to build one for Python 2.6. > > Graham > > > On Jan 17, 2:16 pm, Daniel Roseman > > wrote: > > > > On Jan 17, 6:44 pm, Jon Prater wrote: > > > > > Hi, all. > > > > For various reasons, I prefer to use python 2.6 on my computer. Since > > > > mod_python and mod_wsgi won't work on Python 2.6, I have to use FCGI > > > > or switch to Python 2.5. I have flup installed without any problems. > > > > However, when I try to run this command: > > > > manage.py runfcgi method=threaded host=127.0.0.1 port=9000 > > > > Nothing happens. I get no status message or anything. If I then run > > > > this: > > > > manage.py runfcgi protocol=scgi method=threaded daemonize=false > > > > host=127.0.0.1 port=9000 > > > > I get "WSGIServer starting up", but nothing else happens, and I get > > > > server 500 errors from Apache. > > > > I know the flup library officially doesn't support Windows, and I also > > > > know that there are indications that fcgi simply won't work on Windows > > > > at all. But the Django site describes people getting it working on > > > > Windows machines. Could someone please help? I don't want to have to > > > > switch to Python 2.5 to be able to use mod_python. > > > > I can't help with your fcgi problem, but what makes you think mod_wsgi > > > won't work with Python 2.6? > > > -- > > > 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: Displaying Data from Multiple Tables
Alex, would you mind posting your complete template at dpaste.org for us to look at? It might clarify how you're trying to do the output. Thanks, Jon. On Feb 2, 11:37 pm, Alexiski wrote: > > On Mon, 2009-02-02 at 21:21 -0800, Alexiski wrote: > > > Hi Malcolm, > > > > Thanks for your response, but I'm not quite sure how to iterate using > > > obj.query.all to get all the instances I'm after. > > > > Could you please provide a code snippet or direct me to a relevant > > > page? > > > Iteration in templates is done with the forloop template tag. You must > > already be using that to iteratate over all the copy instances. > > Correct I am using the {% for Copy in object_list %} tag. I access the > fields like so - {{ Copy.id }} {{ Copy.question }} > > In order to access the n Query objects per Copy object, do I nest {% > for Query in object_list %} and access using {{ Query.id }} > {{ Query.requirements }} ? > > 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: Displaying Data from Multiple Tables
Oops... I meant dpaste.com On Feb 3, 8:54 am, Jon Loyens wrote: > Alex, would you mind posting your complete template at dpaste.org for > us to look at? It might clarify how you're trying to do the output. > > Thanks, > > Jon. > > On Feb 2, 11:37 pm, Alexiski wrote: > > > > On Mon, 2009-02-02 at 21:21 -0800, Alexiski wrote: > > > > Hi Malcolm, > > > > > Thanks for your response, but I'm not quite sure how to iterate using > > > > obj.query.all to get all the instances I'm after. > > > > > Could you please provide a code snippet or direct me to a relevant > > > > page? > > > > Iteration in templates is done with the forloop template tag. You must > > > already be using that to iteratate over all the copy instances. > > > Correct I am using the {% for Copy in object_list %} tag. I access the > > fields like so - {{ Copy.id }} {{ Copy.question }} > > > In order to access the n Query objects per Copy object, do I nest {% > > for Query in object_list %} and access using {{ Query.id }} > > {{ Query.requirements }} ? > > > 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: [slightly offtopic] Which Python are people using on OSX?
On Thu, Feb 5, 2009 at 1:07 PM, cjl wrote: > 1. Use the stock Python, slightly outdated 2.5.1, with weird and > incomplete modules. > 2. Compile Python myself from source. > 3. Use MacPorts Python. Anyone know why the nearly all of Xorg gets > built as a dependency? > 4. Use the macpython .dmg > 5. Ssh into my linux box > 6. Install Linux on your MacBook Pro and have the environment you enjoy. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
extending admin change_form template
I'm a novice Python and Django programmer so please don't assume a lot of knowledge here. I'm trying to place a link on an admin change form to a label printing function. I'd like to pass the id of the current record to the function. If I hardwire it in (see below- record number = 920) it works. I can't figure out how to code this so the current record number is inserted by the program. Is there some sort of template variable that I can use for this? Or can you suggest a better approach? thanks , Jon {% extends "admin/change_form.html" %} {% load i18n %} {% block after_field_sets %} Print Labels {% endblock %} --~--~-~--~~~---~--~~ 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: extending admin change_form template
Thank you so much. Works like a charm. Print Labels -Jon On Wed, Mar 4, 2009 at 1:18 PM, AmanKow wrote: > > On Mar 3, 10:50 am, Jon Reck wrote: > > I'm a novice Python and Django programmer so please don't assume a lot of > > knowledge here. > > I'm trying to place a link on an admin change form to a label printing > > function. I'd like to pass the id of the current record to the function. > If > > I hardwire it in (see below- record number = 920) it works. I can't > figure > > out how to code this so the current record number is inserted by the > > program. Is there some sort of template variable that I can use for this? > Or > > can you suggest a better approach? > > > > thanks , Jon > > > > {% extends "admin/change_form.html" %} > > {% load i18n %} > > {% block after_field_sets %} > > Print Labels > > {% endblock %} > > I believe that the object id for the current object is passed in the > context in object_id. > > You can see it in use in the history link rendering in admin/ > change_form.html: > href="../../../r/{{ content_type_id }}/{{ object_id }}/" > > Wayne > --~--~-~--~~~---~--~~ 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: Very bad experience in Django...
> you'll see it doesn't say anything about the validation behavior being > dependent on the widget in use. So it doesn't matter what widget you use, > if you want to be able to validate False as a valid value, then you need to > include required=False in the form field definition. To be completely fair, the documentation says specifically: > Validates that the check box is *checked* (i.e. the value is True) if the > field has required=True. and > If you want to include a *checkbox* in your form that can be either *checked > or unchecked*, you must remember to pass in required=False when creating the > BooleanField. I can definitely understand how someone new to the framework, trying to use a custom widget to do HiddenFields (which is more arcane that it should be IMO, but that's off topic) and reading the BooleanField docs could get confused about using them _without a checkbox widget_. I'm going to open a ticket against the doc here and submit a first pass at a documentation patch. Confusion is worth fixing IMO. - Jon --~--~-~--~~~---~--~~ 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 Django other-than as web framework.
What do you get when you type 'python manage.py dbshell'? On Thu, Jul 2, 2009 at 10:25 AM, Harsha Reddy wrote: > > I using Django from past one week. > > On the Django web site, I read that it is a high-level python web > framework. Inspite of knowing this I am trying to use a Django > application both as a web application as well as a CLI client. > > To know if this works out, I created a Django project named "pyMyApp" > and added an application into it. > I updated the: > > settings.py to detect my application, > also models.py to create two tables. > > I have an other python file in the application which parses XML. This > python file makes use of objects defined in the models.py to store the > parsed values in those 2 tables. > > In the directory "../" where my "pyMyApp" resides, I created a file > index.py added the code to test the parser code. Runnning this file > yeilds: > > python index.py > Traceback (most recent call last): > File "index.py", line 3, in ? > from pyAPP.translator.translate import * > File "/usr/src/pySCAF/translator/translate.py", line 3, in ? > from pySCAF.translator.models import duo, scenario > File "/usr/src/pySCAF/../pySCAF/translator/models.py", line 1, in ? > from django.db import models > File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line > 10, in ? > if not settings.DATABASE_ENGINE: > File "/usr/lib/python2.4/site-packages/django/utils/functional.py", > line 269, in __getattr__ > self._setup() > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > line 38, in _setup > raise ImportError("Settings cannot be imported, because > environment variable %s is undefined." % ENVIRONMENT_VARIABLE) > ImportError: Settings cannot be imported, because environment variable > DJANGO_SETTINGS_MODULE is undefined. > > > By looking at the trace, I got a thought that "Django is designed to > be used as web framework" > if at all I want to use it both as cli and web apps, how to achieve > this in the case above? > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
A simple use for multidb... is this possible yet?
Hi everyone (particularly those working on multidb), I have a pretty simple use case that involves use of multidb support and I was wondering if the code base for multidb is far enough along to help me out on this. Basically, I have a legacy enterprise db that I've created working models for using inspectdb. The models work and are a big help in navigating and retrieving the data. What I need to do now is transform some of the data and then store the data in a new set of models in a different database. Of course I could just open another connection using mysqldb and just write raw sql but what would be great is if I could use the django ORM to manipulate the data from the first database and then store it in the second. My question is this: is there enough work done on multi-db already that maybe with maybe a little hack or two I could accomplish this? JL --~--~-~--~~~---~--~~ 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: Can i add initial admin user?
On Sat, Aug 1, 2009 at 10:38 AM, Mirat Can Bayrak wrote: > > i am playing a lot with my models in my project nowadays. On every change i > am deleting my > sqlite3 file and running syncdb again.. You don't need to delete your entire database; it might be worth checking out the management commands ./manage.py sqlreset and ./manage.py reset. These commands drop the tables for a single app and re-creates them, but will leave your auth tables intact, so you don't need to re-create your superuser. --Jon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Passing an object between views
I would like to use a form to collect a billing address, pass this address to a new form where I collect credit card info, and then pass the whole thing to the credit card processor. The only thing I want to save to the database is a shipping address. Is there a best practice for doing this? Below is pseudo-code for what I'm trying to do: def getAddress(request): if get: show form if post: validate form save if shipping address send to getCCInfo def getCCInfo(request, billingAddress): if get: show form if post: validate form send form results and billingAddress to cc processor redirect to success/fail Any help would be much appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Passing an object between views
And that's it? I guess I've always been afraid of the session due to working on web apps with non-traditional architecture (A web app built entirely in PL/SQL, for example). Thanks for the help. On Aug 2, 9:13 pm, Steve Schwarz wrote: > On Sun, Aug 2, 2009 at 6:58 PM, Jon Renaut wrote: > > > I would like to use a form to collect a billing address, pass this > > address to a new form where I collect credit card info, and then pass > > the whole thing to the credit card processor. The only thing I want > > to save to the database is a shipping address. Is there a best > > practice for doing this? > > Hi, > You might take a look at storing the information in the user's server-side > session when the first form is submitted and then accessing it from the > second > form:http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-htt... > Best Regards, > Steve --~--~-~--~~~---~--~~ 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 job in Manchester, UK
Hello, We're a 70% Django, 30% PHP shop in Manchester, in the UK. We're looking to recruit a Django developer in the near future. This might be of interest to some people on this list. Job description and application information: http://bit.ly/qlguI Cheers, --Jon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Emacs/yasnippet bundle for Django 1.0
Hello, I've been wanting a better set of Django snippets to use with yasnippet/Emacs for quite a while. I was at a bit of a loose end yesterday, so I decided to do something about this :-) I've based this set of snippets on Brian Kerr's excellent set of Django 1.0 snippets for Textmate[1]. They've available on github at: http://github.com/jonatkinson/yasnippet-djangotree/master ... and I've made the first release, a tarball is available here: http://cloud.github.com/downloads/jonatkinson/yasnippet-django/yasnippet-django-1.0.zip I hope someone finds this useful. Cheers, --Jon [1] http://bitbucket.org/bkerr/django-textmate-bundles/wiki/Home --~--~-~--~~~---~--~~ 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: Emacs/yasnippet bundle for Django 1.0
Hello, > http://github.com/jonatkinson/yasnippet-djangotree/master Somehow I managed to make a typo :-) The correct link to the github page is: http://github.com/jonatkinson/yasnippet-django/tree/master Cheers, --Jon --~--~-~--~~~---~--~~ 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 data structure to use, and how?
Works like a charm. Thanks a lot Alex, it saves me a lot of searching and trying. On Sun, May 17, 2009 at 2:37 AM, Alex Gaynor wrote: > > > On Sat, May 16, 2009 at 4:52 PM, Jon wrote: > >> >> >> Hi all. >> >> I think django really rocks, but i have a question: >> >> I wrote a script in python that will get some values from servers and >> puts in them in a dictionary. >> >> The data is in the following format >> {'somehost': ['yes', '2'], 'remotehost': ['yes', '1'], 'localhost': >> ['yes', '1']} >> >> In python, i can then print the values as such: >> >>> print "Server: "+server+" Version: "+serverlist[server][1]+" >> Reachable: "+serverlist[server][0] >> Server: somehost Version: 1 Reachable: no >> Server: remotehost Version: 2 Reachable: yes >> Server: localhost Version: 1 Reachable: yes >> >> In a django template however, this doesn't go far. >> >> The serverlist[server][0] type notation gives an error when used in a >> django template, so i tried this instead: >> >> {% block status_table %} >>{% for server in output_list %} >> >>{{ server }} >>{% for value in server %} >> {{ value }} > td> >>{% endfor %} >> >>{% endfor %} >> {% endblock %} >> >> This prints each letter of the server name in different cell, which is >> not what i want. >> How can i retrieve the 'version' and 'reachable' values in the django >> template? >> >> Many thanks in advance. >> >> Jon >> >> >> > You can do: > > {% for server, data in status_table.iteritems %} > {{ server }}: {{ data.0 }}, {{ data.1 }} > {% endfor %} > > Which prints as: > > somehost: yes, 2 > remotehost: yes, 1 > localhost: yes, 1 > > Alex > > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero > > > > > --~--~-~--~~~---~--~~ 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 save the data from a form to my db.
Hi all, I have the a from with the following validated data posted to itself (copied from the POST section on the error page): cru'008' description u'asdfs' file u'suus' I am trying to save it to the database. The variable names are the same as the column names in the database. How can i go about this? I tried various things with .save(), but that didn't work yet. I also tried doing it using cursor.execute (with only one value for a start) but that resulted in the error ''unicode' object has no attribute 'items''. I used this statement: cursor.execute("insert cr into editor.conffile values('%s')", cd['cr']) The following failed with "global name 'cr' is not defined" cursor.execute("insert cr into editor.conffile values('%s')", cr) Thanks in advance for your help! Jon. --~--~-~--~~~---~--~~ 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: user object in login.html
>From the documentation it seems that it is not only possible, but required too.. login_required() does the following: * If the user isn't logged in, redirect to settings.LOGIN_URL (/accounts/login/ by default), passing the current absolute URL in the query string as next or the value of redirect_field_name. For example: /accounts/login/?next=/polls/3/. * If the user is logged in, execute the view normally. The view code is free to assume the user is logged in. [...] It's your responsibility to provide the login form in a template called registration/login.html by default. This template gets passed four template context variables:[...] Source: http://docs.djangoproject.com/en/dev/topics/auth/ If this doesn't answer your question, please be more specific about the context. On Tue, May 19u, 2009 at 1:44 AM, Rok wrote: > > Hello. > > Is it possible to use user object in login.html when @login_required > is used? I want to display login fields only when user is ianonymous. > > Thank you. > > Kind regards, > > Rok > > > > --~--~-~--~~~---~--~~ 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 pass variables from a different file to via a view to a template?
Hi list, In an attempt to follow the DRY principle and keep environment specific variables separate from my application code, i decided to put a number of application specific variables in a different file. So i have a file like this: --- u...@host:~/program$ more appenv.py ## # app environment specific variables ## page_list = ('index','editor','upload') server_list = ('localhost','remotehost') --- This file will hold more variables, but for the sake of simplicity, i just show two here. In the beginning of my views.py i did an import: from app.appenv import page_list, server_list I have several views where the server_list tuple is used inside the view definition. That works fine. The page list, however, is only read by the template. I always pass locals() to the template and when defining server_list inside the view definition, that works fine; the template can access it. The following line however, doesn't work for me: return render_to_response('static', locals(), page_list) My question is twofold: 1) How do i add page_list to locals()? 2) What can i do if i don't want to pass locals(), but more than two arguments to render_to_response? --~--~-~--~~~---~--~~ 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 pass variables from a different file to via a view to a template?
Since nobody responded, i figured i should revisit the documentation. Here are the answers to my own questions: 1. To add a variable from an external file, i simply redefined the value page_list inside the view. That causes it to be included in the local context and added to locals(). In the appenv.py file i simply renamed page_list to pages and in the view i added 'page_list = pages'. 2. If i don't want to use locals(), i found that i should simply manually create a dictionary passing all values required. >From Chapter 7, Forms: For 1. "[..] locals(), which will include all variables defined at that point in the function’s execution.[..]" For 2. "[..] locals() incurs a small bit of overhead, because when you call it, Python has to create the dictionary dynamically. If you specify the context dictionary manually, you avoid this overhead." Django has great documentation. One remaining question for people who have vast experience creating reusable django applications, is if the appenv.py file is a good approach if my goal is to write django applications with reuse in mind. Thanks in advance for your response. On Mon, May 25, 2009 at 1:52 PM, jon michaels wrote: > Hi list, > > In an attempt to follow the DRY principle and keep environment > specific variables separate from my application code, i decided to put > a number of application specific variables in a different file. > > So i have a file like this: > > --- > u...@host:~/program$ more appenv.py > ## > # app environment specific variables > ## > > page_list = ('index','editor','upload') > server_list = ('localhost','remotehost') > --- > This file will hold more variables, but for the sake of simplicity, i > just show two here. > > In the beginning of my views.py i did an import: > from app.appenv import page_list, server_list > > I have several views where the server_list tuple is used inside the > view definition. > That works fine. > > The page list, however, is only read by the template. > > I always pass locals() to the template and when defining server_list > inside the view definition, that works fine; the template can access > it. The following line however, doesn't work for me: > return render_to_response('static', locals(), page_list) > > My question is twofold: > > 1) How do i add page_list to locals()? > 2) What can i do if i don't want to pass locals(), but more than two > arguments to render_to_response? > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Python 2.6.2 + Django 1.1 fails to install..
I have Python installed and working but when I try and install Django using: python setup.py install ..it chunters through a load of stuff and then fails: creating C:\Python26\Lib\site-packages\django\contrib\localflavor\sk copying build\lib\django\contrib\localflavor\sk\forms.py -> C: \Python26\Lib\site-packages\django\contrib\localflavor\sk copying build\lib\django\contrib\localflavor\sk\sk_districts.py -> C: \Python26\Lib\site-packages\django\contrib\localflavor\sk copying build\lib\django\contrib\localflavor\sk\sk_regions.py -> C: \Python26\Lib\site-packages\django\contrib\localflavor\sk copying build\lib\django\contrib\localflavor\sk\__ini creating C:\Python26\Lib\site-packages\django\contrib\localflavor\uk cerror: Invalid argument The docs say that Python 2.5 and later (but not 3.0) is supported so surely this should work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
syntax error what am i doing wrong???
SyntaxError at / ('invalid syntax', ('c:\\Users\\Vincent\\Documents\\django_bookmarks\ \..\\django_bookmarks\\bookmarks\\views.py', 15, 20, 'return Http Response(output)\n')) SCRIPT FROM VIEWS.PY from django.http import HttpResponse def main_page(request) : output = ''' %s %s%s ''' % ( 'Django Bookmarks', 'Welcome to Django Bookmarks', 'Where you can store and share bookmarks!' ) return HttpResponse(output) --~--~-~--~~~---~--~~ 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 job at the Alliance for Climate Protection
Hello, I'm looking for a Django programmer to work with me full-time at the Alliance for Climate Protection. If you're in DC, or want to be, check out the job posting below. Best, Jon Lesser Lead Developer, repo...@home - Web Developer @ Alliance for Climate Protection, repo...@home (Washington, DC) repo...@home is a new project of the Alliance for Climate Protection that aims to trigger a massive change in the energy efficiency of homes across the country. The project combines on the ground organizing with online components that leverage social connections and game mechanics. You’ll be part of an agile, two-person development team working within a project team consisting of field organizers, researchers, and a project leader. The ideal candidate will be excited about building websites and learning new skills and techniques. The project is in an early stage, so there is a lot of opportunity to influence the development technologies and potential for growth. Required experience: * 1-2 years of experience building standards-based web applications (We use Python and PHP) * Database design and optimization (We use MySQL) * Familiarity with source control (We use Subversion or Git) Extra credit: * Deploying applications to the cloud (e.g., EC2) * Facebook applications, Facebook Connect * Experience with frameworks like Django, Zend, or Code Igniter. * JavaScript libraries like jQuery * Recommendation engines * Understanding of key issues in scaling web applications * A passion for elegant software * Interest in energy, environmental, or climate change issues This is a full time position with excellent benefits in our beautiful new DC offices (901 E Street, NW). The salary range is $65,000 to $82,000. Candidates with less than one year of web development experience will be considered if they can demonstrate excellent potential through relevant coursework, independent projects, or prior experience. To apply, please send your resume to jon.les...@climateprotect.org. The Alliance is an Equal Opportunity Employer and does not discriminate on the basis of race, color, religion, sex, age, national origin, veteran status, marital status, sexual orientation, disability or any other category prohibited by local, state or federal law. This policy applies to all aspects of employment, including recruitment, placement, promotion, transfer, demotion, compensation, benefits, social and recreational activities and termination. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dynamic Form Widget [django admin]
Hi guys, This might be best explained by example... for the following model: class Setting(models.Model): data_type = models.CharField() value = models.TextField() I want Django's admin to display a different form widget for the "value" field depending on the input of "data_type". For example: if "data_type" was "date", then the value field would use a date widget instead of the TextField's default widget. My predicament is that ModelAdmin is defined as a class, and not instances. So I can't pass it a custom form since instances (i.e. "data_type" value) are needed to decide what field the form should have... Any help would be greatly appreciated! thanks, Jon -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Managing static content / basically handling images best practices
I solved this issue by making the FileField (or ImageField) save the files into an Apache (or other web server) served directory. Though obviously this has security implications so I only do this for the password protected admin. Hope that helps cheers, Jon On Jul 15, 12:33 am, reduxdj wrote: > I want to use ImageField for users to upload static content and I need > a little advice from a some django pros on how to do this in a dev > enviornment. I notice the disclaimer that django dev server should not > used to serve static content, or it shouldn't be. So... > > What's the best practice for this then? > Right now, I love the simplicity of the django dev webserver, should i > switch the devserver to nginx? > Does that have the ability to know when i make a change to a python > file without a server restart necessary? > Is there anything else I should know. > > Thanks so much, > Patrick -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Static files ...
Hello, First post to the group, and sorry it's on this common subject! I have tried to read every post on this and cannot seem to get it. I'm using Django 1.2.3, and therefore believe the instructions here apply: http://docs.djangoproject.com/en/1.2/howto/static-files/ My project is in folder 'MCOd' and I have created a folder 'static' under that into which I have placed my CSS files and images (images in another subfolder). To urls.py I have added: urlpatterns += patterns('', (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}), (r'^admin/', include(admin.site.urls)), ) To settings.py I have added: STATIC_DOC_ROOT = '/Users/jonno/django_projects/MCOd/static' This is what it says to do in the above referenced Django documentation. Nothing is mentioned about MEDIA_ROOT or MEDIA_URL, so I have left them intact (''). Many posts mention putting paths there, but not the Django doc. I didn't want to try the django-staticfiles packages as I understand this is folded into newer versions, so I'll deal with changes in an upgrade. I'm really only trying to add a little Django functionality to an existing static site, so dealing with my vast number of static files easily is crucial. Of course, my plan is to generate more of my site dynamically over time. I just can't get past this point! Thanks for any help -- Jon. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Template and Form Question
Folks, I would appreciate some help figuring out how to create a templated form scenario. The quick form of the question is either: How do I iterate over two form field list simultaneously in my template using {% for f in form %}, sort of like {% for f,g in form1,form2 %}? or How do I iterate over a list of strings and use that to select form fields in my template? Gory details of and failed attempts follow... I have a dynamically created form, attr_form, that derives its fields from a query and adds pairs of fields to the form roughly like this in my forms.py: def create_attribute_form(): class AttrForm(forms.Form): for every DB Attribute field, attr, on something: name = attr.name# Eg: "Volume" units = "%s-units" % name # Eg: "Volume-units" self.fields[name] = forms.FloatField() # Eg, "17.0" self.fields[units] = forms.ModelChoiceField(...) # Eg, "Liters" In my view, I trump up this form and hand it to my template in a context as "attr_form". I know this form gets to my template correctly because I can simply place {{ attr_form.as_p }} in it and all the fields are present. They are just not how I want them arranged. Specifically, I want to arrange them into a table like this: Attribute| Value | Units -|---|- Temperature |70 | C Volume |17 | Liters Which means I need to iterate over "Volume" and "Temperature" attribute names, and locate the "Volume" field and then the "Volume-units" field of my form in order to form one row of the table before going on to the next. If I just iterate over the attr_form straight up, I will see all the attributes, of course. So I kind of want to do this (not working) in my template: with: {{ attr_list }} == [ "Volume", "Temperature" ] {{ attr_form }} == The form instance with pairs of fields in it . {% for attr in attr_list %} {{attr}} {{attr_form.fields.$attr.}} {{attr_form.fields."$attr"-"units".}} {% endfor %} Naturally that $attr and constructing that $attr-"units" thing is totaly bogus. But even if I passed in a list of tuples with ("Volume", "Volume-units") in it and looped over that, I still can't use those for-loop-variables to index into the form's fields[] to get and print the fields! So another approach I tried was this: In my view, create a list of triplets with: ("Volume", , ) and pass that into the template as "attr_trio": . {% for a,v,u in attr_trio %} {{a}} {{v}} {{u}} {% endfor %} This *almost* works, but what I get is a table like: Volume object at 0x2768910> Temperature object at 0x2768050> That looks like the v and u parts are either un-instantiated, or being processed differently, or un-bound, or *something*... As another approach I've explored unsuccessfully so far, I've tried to create two forms: one with the Attribute fields and another with the corresponding Units fields. I can pass both those into the template, but now I need a way to iterate over the attr_form and units_form simultaneously so that I can grab a "Volume" and a "Volume-units" field for one row. I have the itertable list of ["Volume", "Temperature", ...] available, but I don't know how to use that iteration variable name to select the form field from the two forms: with: {{ attr_list }} == [ "Volume", "Temperature" ] {{ attr_form }} == The form instance with just Attribute fields {{ units_form }} == The form instance with corresponding Units fields . {% for a in attr_list %} {{a}} {{attr_form.a}} {{units_form.a}} {% endfor %} Even that glosses over the problem of having a form with two fields labeled with the same name. I'd really have to loop over a tuple of ("Volume", "Volume-units") like: {% for a,u in attrunit_list %} ... {{a}} {{attr_form.a}} {{units_form.u}} But none of that works either. OK. Any chance someone can point out the forehead-slapping obvious solution for me? Or point me in the right direction? Should I give up on doing this in the template and somehow render the whole form into a string in the view and pass that into the template to slap it down? Does that violate some large abstraction separation? :-) Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
[ANSWER] Re: Template and Form Question
> Folks, > > I would appreciate some help figuring out how to create a > templated form scenario. The quick form of the question is > either: > > How do I iterate over two form field list simultaneously > in my template using {% for f in form %}, sort of like > {% for f,g in form1,form2 %}? > or > How do I iterate over a list of strings and use that to > select form fields in my template? > > > Gory details of and failed attempts follow... So, for the record, I failed to get any form of proper template variable use or lookup to do what I needed. However, I was able to achieve success in my table construction using the following custom template filter as found here: http://diffract.me/2009/09/django-template-filter-show-list-of-objects-as-table-with-fixed-number-of-columns/ File: my_filter.py from django import template register = template.Library() def tablecols(data, cols): rows = [] row = [] index = 0 for user in data: row.append(user) index = index + 1 if index % cols == 0: rows.append(row) row = [] # Still stuff missing? if len(row) > 0: rows.append(row) return rows register.filter('tablecols', tablecols) and then in my template: {% load my_filters %} and: {% for row in attr_form|tablecols:2 %} {% for f in row %} {% if forloop.first %} {{ f.label }} {% endif %} {{f.errors}}{{f}} {% endfor %} {% endfor %} HTH, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
State of the Django MPTT Art?
Folks, I'd like to add a few MPTT manged data-sets to my projects so I am wondering what the current state of the MPTT art is. I'm using Danjgo 1.1.1 right now, and would like to slap down an MPTT manager in my project that is BSD-ish licensed, allows multiple, different sets of nodes, and hopefully comes with a good admin interface too! Googling shows both django-mptt and -treebeard, but are there good recommendations pro- or con- for either one? Or is there a better third choice out there now? Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting uploaded images to show
> 2010/2/13 holger : > > I am new to django and I am trying to get an image upload to work. > > > > My media url is > > MEDIA_URL =3D 'http://127.0.0.1:8000/media/' > > > > and my media_root is > > MEDIA_ROOT =3D os.path.join(PROJECT_ROOT, 'media') > > > > where project_root points to the root folder for the project > > > > So I want the images to be uploaded to http://127.0.0.1:8000/media/uploads/ > > > > I can see the images being uploaded to the directory but I can't > > access the file through the url in the template. > > > > What am I missing? > > > Do you have this code in urls.py? > > if settings.DEBUG: > urlpatterns +=3D patterns('', > (r'^media/(?P.*)$', > 'django.views.static.serve', {'document_root':'./media/'}), > ) > > In DEBUG mode you need such a code to serve static media. I also had difficulty even with the suggested d.v.static.serve as suggested above. I had to change the ADMIN_MEDIA_PREFIX in my settings.py to be different from MEDIA_ROOT as well. HTH, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
AJAX Autocompletion Field
Folks, For likely the umpteenth time, can someone recommend a good AJAX auto completion tutorial or example that I might use to crib-together a text-field selection that would otherwise be a very large drop-down selection field? My use case would be essentially like having a table full of say, recipie ingredients, and letting the user select which one to add into a recipe. I'd like to have the user simply start typing a few first characters and then let an autocompleter search for matches and present them to the user. The source of the matches would be a "Name" TextField in some model. What is the current Best Practice or even Good Advice? :-) Pros and cons for jQuery or extjs or something else? A good "How To" or a pointer to a write up? Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Slugify() and Clean form data Questions
Folks, Quick question or two: Is there a canonical definition or even a reference implementation of a slug = slugify(str) function somewhere? Yeah, I could go grep through the sources and maybe find one? And yes, I see: http://docs.djangoproject.com/en/dev/ref/models/fields/#slugfield But even that is a bit ambiguous as to the treatment of underscores. Naturally, I'm wanting to use a slug to identify some model instances based on some other model field. But it's not being entered via the Admin model, so I can't do the prepopulated_fileds[] trick either. Second question: Is there a standard clean_user_input() that accepts direct user input from a form text field and de-gunks it so that it is later acceptable to be re-emitted as HTML formatted data without worry of hacking issues? I am looking form something more clever than simply validating the user's input to conform to "is a number" or "is a text field" sorts of thing. I'm specifically looking for a function that strips out embedded scripting, SQL, HTML, etc hackery. Sure, I'd then like to use it to verify clean form input of course. Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slugify() and Clean form data Questions
> > > Is there a canonical definition or even a reference implementation > > of a slug =3D slugify(str) function somewhere? Yeah, I could go > > grep through the sources and maybe find one? And yes, I see: > >=20 > >http://docs.djangoproject.com/en/dev/ref/models/fields/#slugfield > >=20 > > But even that is a bit ambiguous as to the treatment of underscores. > > Could you clarify what you mean by "ambiguous as to the treatment of unders= > cores"? I don't see an ambiguity, so I wonder what I'm missing. Some places say underscores are valid, others say they removed: http://docs.djangoproject.com/en/dev/ref/templates/builtins/ slugify Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. > My understanding is that a slug is usable as a URL; that's really the synta= > x definition, and is why it is limited to "only letters, numbers, underscor= > es or hyphens." A slug is effectively an artifact of Django's birth in jour= > nalism-on-the-web, and an extraordinarily handy one. As such, it exists fo= > r practical reasons, rather than purity. Sure, I get that. It would be nice to use the same (or at least internally consistent) definition, of course. > I do indeed use the slugify() function for precisely that pattern. Exactly *which* slugify() function? Documentation reference? Import from line? > I override the model's save method, and populate the slug field prior > to allowing the save to proceed. I picked up that trick from some > other code somewhere; it isn't uncommon. Well, yeah. That's what I want to do too! :-) Any chance you can post a snippet for me? > HTH, Somewhat! Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slugify() and Clean form data Questions
> Some places say underscores are valid, others say they removed: > > http://docs.djangoproject.com/en/dev/ref/templates/builtins/ > > slugify > > Converts to lowercase, removes non-word characters > (alphanumerics and underscores) and converts spaces to > hyphens. Also strips leading and trailing whitespace. Wow. I just now re-read that differently. (alphanumerics and underscores) are what is _left_. Would this be clearer? Converts to lowercase, allows dashes and underscores, removes other non-alphanumeric characters, and converts spaces to hyphens. Also strips leading and trailing whitespace. Dunno. jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slugify() and Clean form data Questions
> > from django.template.defaultfilters import slugify > > Every filter you see listed in > http://docs.djangoproject.com/en/dev/ref/templates/builtins/ lives in > django.template.defaultfilters. Awesome! Thanks! And with that in hand, the only place I can find the string "django.template.defaultfilters" in the documentation is as a "Behind the Scenes" side-note to the "Custom Template Tags and Filters" page: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ Um, not exactly the obvious place to me. (How did you come to learn that this is where they were implemented?) And from a usability standpoint, I'm still going to have to go track down the sources to learn what that API signature actually looks like now. ... Except that I see a clear example given in http://gist.github.com/308068 now too! Most excellent! Thanks! jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slugify() and Clean form data Questions
> Folks, A few days ago I asked: > Is there a canonical definition or even a reference > implementation of a slug = slugify(str) function somewhere? Thanks for taking the time to answer that for me! We pretty much beat the answer into my thick skull: Use the slugify() function as per "from django.template.defaultfilters import slugify". What about my second question from earlier?: > Is there a standard clean_user_input() that accepts direct user > input from a form text field and de-gunks it so that it is later > acceptable to be re-emitted as HTML formatted data without worry > of hacking issues? I am looking form something more clever than > simply validating the user's input to conform to "is a number" or > "is a text field" sorts of thing. I'm specifically looking for a > function that strips out embedded scripting, SQL, HTML, etc hackery. > Sure, I'd then like to use it to verify clean form input of course. How do people ensure safe user input from their forms? Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slugify() and Clean form data Questions
> > Is there a reason why you can't use Form.is_valid()? It's pretty nice. > > http://docs.djangoproject.com/en/dev/ref/forms/api/#accessing-clean-data > > Example: > http://gist.github.com/311192 I get is_valid() and the notion of cleaned data. I *think*, though, that I am asking for something more robust. Will some_form.is_valid() will, say, remove (or identify) embedded SQL hacking attempts from a plain text field input? Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slugify() and Clean form data Questions
> > Hope this better answers your question, > Matt Matt, Indeed it does. Thank you! I guess a bit of the frustrating part of learning Django here is stumbling across the sites that explain how to do various tidbits of functionality, and then slide in some variant [*1*] of "But one would never do this on a production site." warning. I think to myself "But this is *exactly* the functionality I need." So, uh, what *should* I do differently then? Or, um, OK, so, why not take the next step in the write-up and tell me what the best practice is so I *can* "do this in a production setting." I read chapter 20. And when I was done, I had an inkling that Django escaped my user data when it went to HTML output. Good. And I read where "Django's API does this [escape SQL] for you". But what wasn't clear to me was how much *more* I really should do. How worried should I be? Should I write better form cleaning and validating functions? Should I write custom save() functions to search for SQL or script hacks? That sort of thing. And from the sounds of it, you are saying Django has taken large and likely sufficient steps already. Most excellent! And thank you! Thanks, jdl [*1*] Off hand examples: http://lethain.com/entry/2007/dec/01/using-jquery-django-autocomplete-fields/ http://lethain.com/entry/2008/sep/21/intro-to-unintrusive-javascript-with-django/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with views and urls
> Hello, > > I'm having a problem with views and url's. If I have a url called > "people" that has a callback to "index" works fine, but if I add a > url for parameters, let's say "people//" it does call the > index function, instead of the defined one. If I change it, for > example to "ppl//" it works fine. Any ideas? I leave here the > code. > urlpatterns = patterns('', > (r'^admin/', include(admin.site.urls)), > (r'^people/', 'IeA.gestion.views.index'), > (r'^people/(?P\d+)/$', 'IeA.gestion.views.detail'), > ) First match wins, right? A lacking $ in the first people rule will match with a trailing number as well. So I think you can solve yuour problem by either switching the order of the people patterns or add a trailing $ to the first rule: r'^people/$'. jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django advocacy in a commercial environment
Hello, Having just finished a couple of large projects in PHP4, our department (of 5 programmers) is looking to move to PHP5 - but me and another on the team have been pushing towards using Python/Django in future. While everyone sees the benefits of moving to Python (namespaces! enforced syntax! and more!), it would help us immensely if we could find some resources to wow the other programmers here. I was fortunate enough to attend Simon Willison's excellent talk at LUGRadio Live 2006, which really inspired me to start using Django, but short of inviting him here (and probably paying him), I'm not sure I could recreate that kind of convincing argument myself. Which leaves us with online resources, presentations, screencasts and suchlike. If anyone has any good resources which show off the power of Django (and by association, the benefits of PHP), then please share them with us. Thanks, --Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django advocacy in a commercial environment
Oops, a quick edit - that last sentence should of course read: ...'benefits *over* PHP'... --Jon On 7/19/07, Jon Atkinson <[EMAIL PROTECTED]> wrote: > Hello, > > Having just finished a couple of large projects in PHP4, our > department (of 5 programmers) is looking to move to PHP5 - but me and > another on the team have been pushing towards using Python/Django in > future. > > While everyone sees the benefits of moving to Python (namespaces! > enforced syntax! and more!), it would help us immensely if we could > find some resources to wow the other programmers here. > > I was fortunate enough to attend Simon Willison's excellent talk at > LUGRadio Live 2006, which really inspired me to start using Django, > but short of inviting him here (and probably paying him), I'm not sure > I could recreate that kind of convincing argument myself. Which leaves > us with online resources, presentations, screencasts and suchlike. > > If anyone has any good resources which show off the power of Django > (and by association, the benefits of PHP), then please share them with > us. > > Thanks, > > --Jon > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django advocacy in a commercial environment
Thanks for your reply, Rob. Personally, the reason we're looking to push Django is that our business needs very much match a statement Simon made in the talk I mentioned above: 'Web development on journalism deadlines' (that might not be entirely accurate). I was also considering putting together a report, but we all know the problems with code metrics - do we measure LoC, speed of development, or the very nebulous 'simplicity' concept which will be quite difficult to communicate to management. I don't mean to pry, but at your workplace have you had any difficulty hiring into Python/Django roles at your company (compared to PHP)? Do you get less applicants? A better quality of applicant? Cheers, --Jon On 7/19/07, Rob Hudson <[EMAIL PROTECTED]> wrote: > > On Jul 19, 1:19 am, "Jon Atkinson" <[EMAIL PROTECTED]> wrote: > > If anyone has any good resources which show off the power of Django > > (and by association, the benefits of PHP), then please share them with > > us. > > Where I work we migrated away from PHP to Django with great success > but it depends on your environment. > > For us the Django admin was a huge factor since we have teams entering > content and the default Django admin was way better than anything we > had going so far. > > There are some performance articles and blog posts, for example: > http://wiki.rubyonrails.org/rails/pages/Framework+Performance > > We benefitted from the Django workflow with its built-in web server. > > There's also the fact that Django is improving everyday which > translates into free new features or things that were hard to do are > easy now. For example, databrowse or djangosnippets. > > And we love Python and also love our jobs more because of the > switch. :) > > Those aren't really resources for you but depending on your in-house > requirements it's not hard to find resources online to help guide the > decision. When I had to convince my superiors of the choice, I wrote > a PDF document looking at the best choices in each language (Ruby, > PHP, Python) and Django won out for our particular needs. > > -Rob > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom primary key using Oracle 10g
Catriona, I have very little Oracle experience, but also no reason to think that setting a custom primary key would be different from any other database backend. The documentation is here: http://www.djangoproject.com/documentation/models/custom_pk/ The primary key is set by using 'primary_key=True' in the model. A simple model with a custom primary key: class Employee(models.Model): employee_code = models.CharField(max_length=10, primary_key=True) first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) I hope this helps. --Jon On 8/14/07, Catriona <[EMAIL PROTECTED]> wrote: > > Hello > > I am a beginning Django user and would appreciate help on the > following issue. > > How do I specify a custom primary key in my model when using Oracle > 10g > > I am using the lastest Django version from svn. > > Thanks for your help > > Catriona > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Questions regarding contrib.sitemaps
Hello, I'm trying to implement the a sitemap.xml file using the contrib.sitemaps framework. It's pretty simple to use, but the output I'm getting is not correct. My code in sitemaps.py is as follows. Notice I've used the optional location() method.: from django.contrib.sitemaps import Sitemap from jonatkinson.blog.models import Post class BlogSitemap(Sitemap): changefreq = "weekly" priority = 0.5 def items(self): return Post.objects.all() def lastmod(self, obj): return obj.date def location(self, obj): return "/blog/%s" % obj.slug And a snippet of the output I'm getting is: http://example.com/blog/ghetto-backup 2007-06-25 weekly 0.5 http://example.com/blog/removing-.svn-from-a-subversion-repository 2007-05-25 weekly 0.5 As you can see, the locations generated includes 'example.com', which is not correct. According to the documentation, the location method is supposed to "URL that doesn't include the protocol or domain"[1]. I'm guessing that the sitemaps framework is somehow tied to the sites framework. Has anyone else come across this issue before? Thanks, --Jon [1] http://www.djangoproject.com/documentation/sitemaps/#location --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Questions regarding contrib.sitemaps
On 8/14/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Tue, 2007-08-14 at 10:29 +0100, Jon Atkinson wrote: > [...] > > > As you can see, the locations generated includes 'example.com', which > > is not correct. According to the documentation, the location method is > > supposed to "URL that doesn't include the protocol or domain"[1]. I'm > > guessing that the sitemaps framework is somehow tied to the sites > > framework. > > Yes, it is. Edit the site information via the admin interface to display > the correct domain name and all will be well. > That worked perfectly. Thanks for your help, Malcolm. --Jon > -- > No one is listening until you make a mistake. > http://www.pointy-stick.com/blog/ > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---