Non-Programmer Help: filter_insterface error?
Hello, I'm not a python programmer, this is the first time I've ever worked with a python app. I'm trying to install "Surftrackr" for my company and I have a problem. I have searched and can not find any clear answers. I have the installed the latest svn of Django. (I started out with the released tarball) This is the error I get: [EMAIL PROTECTED]:/usr/local/surftrackr# ./manage.py syncdb Traceback (most recent call last): File "./manage.py", line 11, in execute_manager(settings) File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 340, in execute_manager utility.execute() File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 221, in execute self.validate() File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "/usr/lib/python2.5/site-packages/django/core/management/ validation.py", line 28, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/usr/lib/python2.5/site-packages/django/db/models/loading.py", line 128, in get_app_errors self._populate() File "/usr/lib/python2.5/site-packages/django/db/models/loading.py", line 57, in _populate self.load_app(app_name, True) File "/usr/lib/python2.5/site-packages/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/surftrackr/../surftrackr/log/models.py", line 72, in class User(models.Model): File "/usr/local/surftrackr/../surftrackr/log/models.py", line 87, in User workstation = models.ManyToManyField(Workstation, null=True, blank=True, filter_interface=True) File "/usr/lib/python2.5/site-packages/django/db/models/fields/ related.py", line 759, in __init__ Field.__init__(self, **kwargs) TypeError: __init__() got an unexpected keyword argument 'filter_interface' Can someone please help me with this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Graphs
Sorry, I tried making them myself. NBut it looks horrible. I think you must make them as pie charts. Please ask the designer to do so Ramdas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~--- graphs.doc Description: MS-Word document
Re: How to get additional dynamic data into ModelChoiceField and ModelMultipleChoiceField?
Replying to myself :) I haven't found the solution yet but after reading a few posts in the group I think I have to try the "dynamic choices in a ChoiceField" approach and forget about the ModelChoiceField. There seems to be a few options on getting that done so I'll try tomorrow with a fresh brain and will let you know. In the meanwhile, if somebody has any idea please let me know. See ya! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to get additional dynamic data into ModelChoiceField and ModelMultipleChoiceField?
Hello, I have a Django app with two models: User and ChatRoom. Each user can be the owner of many chatrooms and can also link to his friends's chatrooms. There's is no authentication in this little app, the User model is just a custom model containing user ids. This is an app that will work with Facebook and the TOS doesn't allow storing user names, so I only can store user ids and then need to use the Facebook API (I'm using the very useful PyFacebook for that) for each user id to get the names on runtime. My question is about adding some dynamic data to the text presented in select lists and checkboxes generated by forms.ModelChoiceField and forms.ModelMultipleChoiceField, I provide more details (and a few more related questions) below. This is the ChatRoom model. class ChatRoom(models.Model): name = models.CharField(max_length=75) user = models.ForeignKey(User) def __unicode__(self): return self.name I have also created two forms, I'm simplifying parts of the code to make my point clear and focus just on what's causing me trouble: 1. The 'link' form, allows a user to link to a chatroom: class LinkedChatRoomForm(forms.Form): queryset = ChatRoom.objects.all() chatroom = forms.ModelChoiceField(label="Choose a chatroom to link to your profile", queryset=queryset) With this form the user sees a select box and can choose a chatroom to link to. The options in the select HTML are something like this: AC/DC fans Metallica fan club That's chatroom.id for the values and chatroom.name for the text shown to the user. Because each chatroom is owned by some user I'd like to include that user name in the list, so my HTML would be like: AC/DC fans (owned by Rick) Metallica fan club (owned by Andrew) Let's remember I just have user ids in my User model and need to call the Facebook API to get names for each user, so the question would be how do I 'inject' those names in the form field. 2. The 'unlink' form, allows a user to check chatrooms that he doesn't want to link to anymore: I have to mention I have another model to keep track of which chatrooms are linked to which users: class LinkedChatRoom(models.Model): chatroom = models.ForeignKey(ChatRoom) user = models.ForeignKey(User) I'm not sure why I didn't use models.ManyToManyField but this is working so far for all the other parts of my app and don't think is related to the problem I'm discussing here. Now the form: class MultipleLinkedChatRoomForm(forms.Form): user = get_current_user() # a function that returns the current user object queryset = ChatRoom.objects.filter(linkedchatroom__user=user) chatrooms = forms.ModelMultipleChoiceField( label='Check the chatrooms to unlink from your profile', queryset=queryset, widget=forms.CheckboxSelectMultiple, ) This produces HTML like this: AC/DC fans Metallica fan club My requirement is the same as in the 'link' form. I'd like to include the name of the user owning each chatroom, to produce this: AC/DC fans (owned by Rick) Metallica fan club (owned by Andrew) I'm not sure if I should subclass the form fields (I've been reviewing ModelMultipleChoiceField definition in django/forms/models.py) or if the magic should be in the querysets used for the form fields. As I already mentioned this should work with Facebook as I only have user ids in my database, so the querysets for these form fields have no way of knowing the user names until I've called the Facebook API. Maybe this would be way easier using forms.ChoiceField and forms.MultipleChoiceField (the simpler versions not requiring a queryset) but I've noticed that the choices in these fields don't get updated when the records on the database change. That's why I'm using the 'Model' versions of the fields. Or maybe I'm missing something pretty important here? Ok, if you've read until here you can clearly see I'm pretty confused of how to proceed so any ideas are welcome :) Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: RESTful API or SOAP in pre-magic
On Tue, Oct 14, 2008 at 10:39 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Thank you Malcolm for the feedback. > I would prefer to use REST. So write yourself a REST API. (in other words, the answers you get will be precisely as detailed as the questions you ask) -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: RESTful API or SOAP in pre-magic
Thank you Malcolm for the feedback. I would prefer to use REST. On Oct 14, 9:02 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-10-14 at 11:32 -0700, [EMAIL PROTECTED] wrote: > > Hello, > > I am trying to get REST or SOAP working in 0.91 pre-magic version of > > Django. The idea is to let a third-party vendor check via xmlrpc to > > see if a user is authorized on our system and get a username. I was > > planning on using the sessionid cookie as the query from the 3rd > > party. > > I need to stay on ver. 0.91. > > > Anybody have any suggestions on how to proceed? > > Your question is very vague. Basically the answer is "more or less the > same way you would with Django 1.0", although obviously some of the code > details will be different due to changs in the interim. But the design > is the same. > > You haven't even said whether you are aiming for a REST architecture or > a SOAP style. Since, they're more or less complete opposites your design > doesn't seem very well nailed down. > > So, in lieu of any actual specifics from you about what the actual > problem is, just approach this like any other project that needs to > request things from URLs. You set up particular URL patterns that are > the input avenues, they pass of the processing to views that do whatever > you want, which then return the appropriate data. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: No module named core
Thank alot! I'm obviously new to django and have been really eager to set this up on dreamhost but have been stuck with this for a while. Cheers! J On Oct 14, 4:31 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > My directory structure is: > > > projects/ > > django/ > > __init__.py > > trunk/ > > django/ > > __init__.py > > core/ > > __init__.py > > > and my PYTHONPATH is: > > > export PYTHONPATH=$HOME/projects:$HOME/projects/django/trunk:$HOME/ > > projects/flup/trunk:$PYTHONPATH > > The problem is that you have *two* django packages: I don't know why you > have an __init__.py in $HOME/projects/django, but that and your first > path element are combining to make Python think it's found Django at the > top level. If you delete or rename $HOME/projects/__init__.py you should > then be able to find core. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.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 -~--~~~~--~~--~--~---
use vObject for event calender application?
Has anybody had any experience using vObject (http:// vobject.skyhouseconsulting.com/). I want to try to create an event calendar application in django and all blogs/website suggest that I use this as part of the backend. Just want to make sure that I am going down the correct path. I haven't seen a prepackage event app yet, does one exist. If not, is this the best way to go. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: POST data delay
On Oct 15, 11:42 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-10-14 at 17:38 -0700, david wrote: > > Hi hope all is well. Please tell me if this is related to Django. > > > Using Django 1.0 with Apache 2.2.9. > > > Have a very simple form by writing to the Httpresponse directly. > > > r = HttpResponse() > > r.write('') > > r.write('First name: ') > > r.write('') > > r.write('') > > return r > > If you look at the source, you can see that all write() does is append > to the content of the class. So the net effect of the above code is the > same as constructing it all at once and returning. > > This is something else. There's no reason at all to suspect Django here, > since all Django's work is done before any content is returned. > > Regards, > Malcolm Thanks for the quick reply Malcolm. I don't doubt the code, as they are almost a straight copy from the example directory. I'll keep looking. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Populating form from existing model
I have a model called "myRegion" defined like so: class myRegion(models.Model): area = models.CharField(max_length=50, blank=False) state = models.CharField(max_length=2, blank=False) def __unicode__(self): return self.area + ", " + self.state What I would really like to do is have a form displayed on a page that simply has a drop-down box containing all of the "area" values. In a perfect world, the "--" blank option would not appear in the list. I've been successful in getting the form to appear properly when I'm accessing the myRegion as a ForeignKey through another model, but in this use case I can't do that. When the form POSTS, I plan on using the data to set a session key which would be used later on. After poring through the docs for a few hours, I can't figure out the syntax to generate the form. Is there anybody who would be willng to help? Thanks, Adam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: RESTful API or SOAP in pre-magic
On Tue, 2008-10-14 at 11:32 -0700, [EMAIL PROTECTED] wrote: > Hello, > I am trying to get REST or SOAP working in 0.91 pre-magic version of > Django. The idea is to let a third-party vendor check via xmlrpc to > see if a user is authorized on our system and get a username. I was > planning on using the sessionid cookie as the query from the 3rd > party. > I need to stay on ver. 0.91. > > Anybody have any suggestions on how to proceed? Your question is very vague. Basically the answer is "more or less the same way you would with Django 1.0", although obviously some of the code details will be different due to changs in the interim. But the design is the same. You haven't even said whether you are aiming for a REST architecture or a SOAP style. Since, they're more or less complete opposites your design doesn't seem very well nailed down. So, in lieu of any actual specifics from you about what the actual problem is, just approach this like any other project that needs to request things from URLs. You set up particular URL patterns that are the input avenues, they pass of the processing to views that do whatever you want, which then return the appropriate data. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: unable to get rid of app name via rewrite
On Tue, 2008-10-14 at 08:43 -0700, jwing wrote: > Hi all, I just moved to Django from Pylons. Django never ceases to > amaze me so far, but when I tried to deploy my app on apache > (fastcgi), I got the rewrite issue with no any corresponding solution > via Google, well, I can't find it at least :( > > I Got: > 1) several apps under project "demo" (app1, app2, etc); > > 2) domain http://app1.demo.com; > > 3) many reversed url addresses (by urlresolvers.reverse method) which > are being passed to templates via AJAX calls, in app1, say profile > page, the reversed url will be "/app1/profile" Since this part is entirely under your control (you completely control the URL configuration for your own applications), you can could this to not have the "app1" prefix. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 1.0 Transactions and Caching ...
On Tue, 2008-10-14 at 07:33 -0700, dbee wrote: > I'm upgrading my .97 app to 1.0 and I'm trying to figure out > transactions and caching ... > > In my app at present I have ... > > def event_editor(request): > > . > > return > > # Defeat caching for the event_editor > function event_editor = cache_control(no_cache=True)(event_editor) > > # The transacton autocommit for event_editor > event_editor = transaction.autocommit(event_editor) > > I'm reading the 1.0 docs and it seems to suggest that I use something > like this instead ... > > @transaction.autocommit > def event_editor(request): The two forms are identical. The "@..." syntax (decorator syntax) is just syntactic sugar for the first construction. It was only introduced in Python 2.4. Some people prefer using decorators in their code (putting the function modifiers up front), others prefer putting the modifiers at the end (or have a requirement to work with Python 2.3 so don't have the decorator syntax available). It's entirely your choice. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Data too long for column problem
On Tue, 2008-10-14 at 06:12 -0700, zjffdu wrote: > but I found that I can not even store one Chinese word into the column > with 100 bytes capacity. Since you've provided no example of what you're actually doing, or information about what database you're using, it's impossible for us to guess at what the problem might be. Django works correctly with all Unicode data, up to the limits of the database. Effectively, this means it works with all Unicode data you'll encounter in everyday life, including Chinese. So something is going wrong in your code. If you can provide a very simple example (a model with one field, for example) as well as say which database backend you're using and how you're trying to store the data, we might be able to help. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Data too long for column problem
On Tue, 2008-10-14 at 21:05 +0800, DULMANDAKH Sukhbaatar wrote: > chinese and some other complex or unicode characters takes more than > one byte to be stored. but as I know char(250) means 250 bytes or you > can store about 80 chinese chars if we assume 1 char takes 4 bytes. > then you need to change model, and manually alter table column. This isn't usually correct. Almost all databases, once the table encoding is set correctly (e.g. to UTF-8) use the length of a varchar column (which is what Django uses, not char, but the same applies to the former) to indicate the number of characters, not the number of bytes. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Once-only initialization of per-process resources following Django startup.
On Mon, 2008-10-13 at 19:18 -0700, Lifto wrote: > > Greetings Django Users, > > How do you control the initialization of your Django process? Do you > rely exclusively on Python's module-loading to initialize your > namespaces and reusable resource-connections? Since modules can be (and are) loaded multiple times, that won't work. > I would like to perform initialization of certain features in my > Django project exactly once when the Django process is started, after > Django has initialized. Is there a best practice for doing this? I am > having difficulties because I am relying on Python's module loading > system (top-level __init__.py file) to perform my initialization. I > feel it would be, among other conveniences, more explicit to specify > an initialization procedure than to depend on module loading. There's an open ticket to add support for functions that are called after settings have been imported by before anything further is executed. However, that still won't solve your "once and only once" problem, since each thread of execution (be it an actual thread or multiple processes) will do this. Similarly, there will be process restarts caused by the webserver (perfectly normal behaviour, too. Apache, amongst others, kills child processes every N requests to avoid any inadvertent memory leaks). > > I attempted to solve my issue by using Python globals to ensure my > initialization is idempotent, but it seems that Django (or just > manage.py?) munges with Python globals behind-the scenes. This is a very fuzzy statement and not particularly accurate as written Neither Python nor Django does anything special to globals. What do you actually mean? I suspect that you're simply seeing that modules aren't simply imported once, but without any idea of what you're trying to do, it's hard to say. If you want something to happen once, you have to use an external synchronisation mechanism so that all the execution processes can synchronise on the same thing. Lock files are a particularly good way to do this -- that's how your system manages to only start one each of various services, for example. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: POST data delay
On Tue, 2008-10-14 at 17:38 -0700, david wrote: > Hi hope all is well. Please tell me if this is related to Django. > > Using Django 1.0 with Apache 2.2.9. > > Have a very simple form by writing to the Httpresponse directly. > > > r = HttpResponse() > r.write('') > r.write('First name: ') > r.write('') > r.write('') > return r If you look at the source, you can see that all write() does is append to the content of the class. So the net effect of the above code is the same as constructing it all at once and returning. This is something else. There's no reason at all to suspect Django here, since all Django's work is done before any content is returned. 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 -~--~~~~--~~--~--~---
POST data delay
Hi hope all is well. Please tell me if this is related to Django. Using Django 1.0 with Apache 2.2.9. Have a very simple form by writing to the Httpresponse directly. r = HttpResponse() r.write('') r.write('First name: ') r.write('') r.write('') return r After the form is displayed on the browser, if I don't wait about 5 seconds before clicking the submit button, the POST content is lost. As in, when i try to write out the POST content, it doesn't write anything, whereas I can write out the current time, and the time changes as expected. Could this be to do with some configuration on 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-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: Making queries guide, incomplete code.
On Oct 14, 4:52 pm, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 14 oct, 23:25, KillaBee <[EMAIL PROTECTED]> > wrote: > > > > > On Oct 14, 4:17 pm, bruno desthuilliers > > > <[EMAIL PROTECTED]> wrote: > > > On 14 oct, 21:35, KillaBee <[EMAIL PROTECTED]> > > > wrote: > > > (snip) > > > > > No, it is very helpful, I know now that I have to learn all of python > > > > and I know now that ... means variable. > > > > No. It means learning a computer programming language - which in turn > > > means having the slightest clue about what a computer language is. > > > > > I changed because I put save() in my view, per my last post about how > > > > to save data to the db, and didn't not open a python console. > > > > I tried to enter those lines in the pyhton shell starting with the > > > > importing of my class time, but it said there was no module with that > > > > name. > > > > "from intranet.timesheets.models import time" and there is a models.py > > > > and a time class in it? do you think that it is not i my sitepath? > > > > I am still wanting to display data from the db, I was think that > > > > django had something to do it. > > > > So, after I enter those lines in my python shell, How do I put it in > > > > my view or page? > > > > Python's tutorial is here:http://docs.python.org/tutorial/ > > > > You'll also find some interesting informations > > > here:www.catb.org/~esr/faqs/smart-questions.html > > > > To make a long story short: > > > 1/ learn Python > > > 2/ learn to ask at least intelligible questions > > > 3/ then come back here. > > > > Until you have completed points 1/ and 2/, *no one* will be able to > > > help you here - and chances are no one will even bother reading your > > > posts no more. > > > > I don't like to look like the ugly guy in town, but seriously, these > > > are the friendliests and most helpful advises I can give you. > > > yep, until today I didn't know that Django was python, > > Is this a joke ??? > > fromhttp://www.djangoproject.com/ > > """ > Django is a high-level Python Web framework > """ > > Heck, it's the 5th (fith) sentence on Django's home page, and it in > big bold face. Not talking about the "quick overview" (a dozen > mentions of Python here), and let's not even mention the doc. Wait... > Did you even bother *reading* the doc ??? Check, I have read the lovely guide, and Didn't have to know real Python until now. I know that every body on here are super programmers, but I just want to know the steps to get this done. If I need to learn python so be it. But don't act like Python is always needed, the last things I need to do is show and filter with a calendar data picker.. If I can write to the DB i should be able to display in a simuler way. Django is a python help, now that that is out the way. So, I can't read and display like I wrote, save()? what does"news_list = New.objects.all().order_by('-date')"do, looks like it it gets all() the objects in new and order them by date? kinda like t=time(user=user, fedtime=fedtime, worked=worked, date=date ) then t.save() OK, alltime=time.objects.all() will not do it. Do I make QuerySets with python and not with Django? Do you know what the next step is? no, people don't respond but not because, I don't know python it is because, I don't go on and on and on about it, but I fixed today.thanks from django.contrib.auth import logout, login, authenticate def login(request): news_list = New.objects.all().order_by('- date') if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] user = auth.authenticate(username=username, password=password) if user is not None: if user.is_active: login(request,user) return HttpResponseRedirect('/') else: return render_to_response('registration.html', locals()) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: a bug about models EmailField
Thank you very much :) I just read the django-trunk original source, and compare it with django0.96 There's much different On Oct 14, 3:50 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > Wiadomość napisana w dniu 2008-10-14, o godz. 09:43, przez [EMAIL PROTECTED] > : > > > > > > > I meet a bug in django1.0 > > > class Reporter(models.Model): > >name = models.CharField(max_length=100) > >email = models.EmailField() > > >def __unicode__(self): > >return '%s : %s ' % (self.name, self.email) > > > r1 = Reporter() > > r1.name = 'edison' > > r1.email = 'x' > > r1.save() > > r1.id = 1 > > > Why it can be save ? > > there's not a valid email, > > Not a bug. Model-level validation does not exist in current Django. > Sorry. > > -- > We read Knuth so you don't have to. - Tim Peters > > Jarek Zgoda, R, Redefine > [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 -~--~~~~--~~--~--~---
DB record retrieval from every N minutes
I'd like to find an efficient method to retrieve a list of Django DB records (model has a DateTimeField `timestamp`) between datetime 'start' and datetime 'end' with a few conditions. First, we're looking for a record once every 'interval' minutes. Second, I only want a record if it's timestamp within 'fudge' minutes of the target time. Last, if such a record doesn't exist for an interval, put None in the list instead. For example: 'start' = 2008-10-01 00:00:00 'end' = 2008-10-01 12:00:00 'interval' = 60 minutes 'fudge' = 5 minutes I would expect to get thirteen items in a list (each either a record or None). The first record to save is the first record between 23:55:00 and 00:05:00. The second record to be saved would be the first record betwen 00:55:00 and 01:05:00. And so on. At the moment I have attacked this with a brute force approach by processing a QuerySet of all records between 'start' and 'end'. Here is the QuerySet: qs = Weather.objects.filter(timestamp__year=date.year, timestamp__month=date.month, timestamp__day=date.day).order_by('timestamp') Here is the processing code: def periodic_samples(qs, start, fudge, interval, periods): ''' Returns a list of arbitrary type records (containing attribute 'timestamp') from `qs`, one record for each target window during a total of 'periods' windows beginning at 'start'. `target` = `start` plus a (0 to `periods`) multiple of `interval`. A target window is defined as: `target`-`fudge` to `target` +`fudge`. The first record found in a target window is saved in the list and all other records in that window are ignored. If no record is found in the target window then None is placed in the list instead of a record. For instance if `start`=12:00, `fudge`=5 minutes, `interval`=30 minutes, and `periods`=2, record timestamps must fall in the ranges 11:55 - 12:05 and 12:25 - 12:35. Parameter types: `qs` = Queryset of records which have a "timestamp" field `start` = datetime.datetime `fudge` = datetime.timedelta `interval` = datetime.timedelta `periods` = integer ''' dataset = [] if len(qs): target = start end = start + (periods * interval) for rec in qs: if target >= end: break ts = rec.timestamp while ts > (target + fudge): dataset.append(None) target += interval if ts < (target - fudge): pass else: dataset.append(rec) target += interval # no more records, fill out the dataset with None values while target < end: dataset.append(None) target += interval return dataset Regardless of my finicky needs as outlined above, does anyone know of a method for efficiently extracting a bunch of records, say one record an hour, over some range of time? It seems awfully inefficient to look at each record in the queryset to find what I want. --- Graham Ullrich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: No module named core
[EMAIL PROTECTED] wrote: > My directory structure is: > > projects/ >django/ > __init__.py > trunk/ > django/ >__init__.py > core/ > __init__.py > > and my PYTHONPATH is: > > export PYTHONPATH=$HOME/projects:$HOME/projects/django/trunk:$HOME/ > projects/flup/trunk:$PYTHONPATH > The problem is that you have *two* django packages: I don't know why you have an __init__.py in $HOME/projects/django, but that and your first path element are combining to make Python think it's found Django at the top level. If you delete or rename $HOME/projects/__init__.py you should then be able to find core. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.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: No module named core
My directory structure is: projects/ django/ __init__.py trunk/ django/ __init__.py core/ __init__.py and my PYTHONPATH is: export PYTHONPATH=$HOME/projects:$HOME/projects/django/trunk:$HOME/ projects/flup/trunk:$PYTHONPATH Thanks, J On Oct 14, 12:15 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-10-14 at 00:10 -0700, [EMAIL PROTECTED] wrote: > > [...] > > > and here is the error: > > > $ django-admin.py > > Traceback (most recent call last): > > File "/home/username/projects/django/trunk/django/bin/django- > > admin.py", line 2, in ? > > from django.core import management > > ImportError: No module named core > > So either your copy of Django isn't complete, or your Python path is not > pointing to the right place. Look at the directories you've specified in > your Python path and make sure that one of them contains a subdirectory > setup that contains, in part: > > django/ > __init__.py > core/ > __init__.py > <... lots of other files ...> > <... lots of other files ...> > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: manage.py tab completion
[EMAIL PROTECTED] wrote: > Depending on your site's setup, there is a variety of extra manage.py > commands that could be available. Is it possible to set up tab > completion on these commands? for example: > > ./manage.py syn > => /manage.py syncdb > > If it is not currently supported, how hard would it be to include? > Would it use the readline library? > This is already implemented with a bash completion script. I'm not 100% sure where in svn it lives, but its there, and it works. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: HTTPS Service for Django
Harish wrote: > Hi Friends, > > I configured a django site using apache, which is running on Fedora 9. > Now I want to enable the > HTTPS (secured ) service on that site > > Any ideas on how to achieve this? > Configure apache to do SSL-- no special setup needed for Django. signature.asc Description: OpenPGP digital signature
Re: Template Tags in Text
On 14 oct, 23:06, Tim Sawyer <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to puzzle out the best way of achieving something, and I'd > appreciate some help. > > My website contains text writeups of events, and a gallery. I'd like to embed > some images from the gallery into the text writeups. The text is not in a > template, it's in the database and displayed using the textile filter: > > {% block body %} > > {{ Contest.date|date:"jS F Y" }} - {{ Contest.title }} > {{ Contest.report|textile }} > > {% endblock %} > > What's the best way to embed an image from my gallery into the Contest.report > variable? > > I'm looking to do something like: > > {% ShowImage 1 200 400 left %} > > where > - ShowImage is a template tag, > - 1 is the serial of the image to show, > - 200 is the height > - 400 is the width > - left is the align value so text wraps around it > > I can generate a thumbnail of the right size, and I can find the image > location from the database, but what's the best way of replacing this > template tag with the appropriate html? Can I write a filter which "runs" > template tags? Well... Django's template system works for any text format, so yes, you could takes that text, compiled it as a template, then render the template passing it the needed context. Since this might a bit heavy on processing, you may want to do cache the result in the database instead of recomputing the whole damn thing on each and every display... > Or should I be scanning the text for "{% ShowImage" and then > reading values until the next "%}" in a custom filter? Why reinvent the wheel ? Django's template system already has a parser. Now if you don't want to use the above solution, you could also use a more Textile-like syntax (to be invented...), then use a simple regexp in your filter to replace this syntax with the appropriate dynamically generated html snippet. My 2 cents... > Thoughts? > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: manage.py tab completion
On 14 oct, 21:30, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Depending on your site's setup, there is a variety of extra manage.py > commands that could be available. Is it possible to set up tab > completion on these commands? for example: > > ./manage.py syn > => /manage.py syncdb > > If it is not currently supported, how hard would it be to include? > Would it use the readline library? Not sure this answer you question, but: http://docs.djangoproject.com/en/dev/ref/django-admin/?from=olddocs#bash-completion --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Problems serving static files with Apache and mod_python
On 14 oct, 20:28, Javi <[EMAIL PROTECTED]> wrote: > Dear group, > > sorry for starting another thread on this issue. I've seen loads of > messages with similar but particular problems. > My system: > * apache2 (2.2.9-10) > * libapache2-mod-python (3.3.1-5) > * python-django (1.0-1) > > My project is located at: ~/Desktop/csl2-sdocente/src/candidateTool > and the app I'm trying to make work is called assessmentSystem, > obviously at ~/Desktop/csl2-sdocente/src/candidateTool/ > assessmentSystem. Just for the record : is there any reason you don't use the builtin development server ? > The static files are located at ~/Desktop/csl2-sdocente/src/ > django_media/ and match with the url 'r'^static/(?P.*)$' ??? You don't have to do url matching within django to serve static content - unless using the development server, that is. Did you try commenting out this line from your urls.py file ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Making queries guide, incomplete code.
On 14 oct, 23:25, KillaBee <[EMAIL PROTECTED]> wrote: > On Oct 14, 4:17 pm, bruno desthuilliers > > <[EMAIL PROTECTED]> wrote: > > On 14 oct, 21:35, KillaBee <[EMAIL PROTECTED]> > > wrote: > > (snip) > > > > No, it is very helpful, I know now that I have to learn all of python > > > and I know now that ... means variable. > > > No. It means learning a computer programming language - which in turn > > means having the slightest clue about what a computer language is. > > > > I changed because I put save() in my view, per my last post about how > > > to save data to the db, and didn't not open a python console. > > > I tried to enter those lines in the pyhton shell starting with the > > > importing of my class time, but it said there was no module with that > > > name. > > > "from intranet.timesheets.models import time" and there is a models.py > > > and a time class in it? do you think that it is not i my sitepath? > > > I am still wanting to display data from the db, I was think that > > > django had something to do it. > > > So, after I enter those lines in my python shell, How do I put it in > > > my view or page? > > > Python's tutorial is here:http://docs.python.org/tutorial/ > > > You'll also find some interesting informations > > here:www.catb.org/~esr/faqs/smart-questions.html > > > To make a long story short: > > 1/ learn Python > > 2/ learn to ask at least intelligible questions > > 3/ then come back here. > > > Until you have completed points 1/ and 2/, *no one* will be able to > > help you here - and chances are no one will even bother reading your > > posts no more. > > > I don't like to look like the ugly guy in town, but seriously, these > > are the friendliests and most helpful advises I can give you. > > yep, until today I didn't know that Django was python, Is this a joke ??? from http://www.djangoproject.com/ """ Django is a high-level Python Web framework """ Heck, it's the 5th (fith) sentence on Django's home page, and it in big bold face. Not talking about the "quick overview" (a dozen mentions of Python here), and let's not even mention the doc. Wait... Did you even bother *reading* the doc ??? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
manage.py tab completion
Depending on your site's setup, there is a variety of extra manage.py commands that could be available. Is it possible to set up tab completion on these commands? for example: ./manage.py syn => /manage.py syncdb If it is not currently supported, how hard would it be to include? Would it use the readline library? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Making queries guide, incomplete code.
On Oct 14, 4:17 pm, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 14 oct, 21:35, KillaBee <[EMAIL PROTECTED]> > wrote: > (snip) > > > No, it is very helpful, I know now that I have to learn all of python > > and I know now that ... means variable. > > No. It means learning a computer programming language - which in turn > means having the slightest clue about what a computer language is. > > > I changed because I put save() in my view, per my last post about how > > to save data to the db, and didn't not open a python console. > > I tried to enter those lines in the pyhton shell starting with the > > importing of my class time, but it said there was no module with that > > name. > > "from intranet.timesheets.models import time" and there is a models.py > > and a time class in it? do you think that it is not i my sitepath? > > I am still wanting to display data from the db, I was think that > > django had something to do it. > > So, after I enter those lines in my python shell, How do I put it in > > my view or page? > > Python's tutorial is here:http://docs.python.org/tutorial/ > > You'll also find some interesting informations > here:www.catb.org/~esr/faqs/smart-questions.html > > To make a long story short: > 1/ learn Python > 2/ learn to ask at least intelligible questions > 3/ then come back here. > > Until you have completed points 1/ and 2/, *no one* will be able to > help you here - and chances are no one will even bother reading your > posts no more. > > I don't like to look like the ugly guy in town, but seriously, these > are the friendliests and most helpful advises I can give you. yep, until today I didn't know that Django was python, thanks for being real. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: current user
On 14 oct, 22:18, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Tue, Oct 14, 2008 at 3:10 PM, gearheart <[EMAIL PROTECTED]> wrote: > >http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > > Sigh. > > I guess this is the part where I go edit that wiki page to point > people to the better solution? > > Yeah, I think this is the part where I go edit that wiki page. Lol ! (of course he did it) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Making queries guide, incomplete code.
On 14 oct, 21:35, KillaBee <[EMAIL PROTECTED]> wrote: (snip) > No, it is very helpful, I know now that I have to learn all of python > and I know now that ... means variable. No. It means learning a computer programming language - which in turn means having the slightest clue about what a computer language is. > I changed because I put save() in my view, per my last post about how > to save data to the db, and didn't not open a python console. > I tried to enter those lines in the pyhton shell starting with the > importing of my class time, but it said there was no module with that > name. > "from intranet.timesheets.models import time" and there is a models.py > and a time class in it? do you think that it is not i my sitepath? > I am still wanting to display data from the db, I was think that > django had something to do it. > So, after I enter those lines in my python shell, How do I put it in > my view or page? Python's tutorial is here: http://docs.python.org/tutorial/ You'll also find some interesting informations here: www.catb.org/~esr/faqs/smart-questions.html To make a long story short: 1/ learn Python 2/ learn to ask at least intelligible questions 3/ then come back here. Until you have completed points 1/ and 2/, *no one* will be able to help you here - and chances are no one will even bother reading your posts no more. I don't like to look like the ugly guy in town, but seriously, these are the friendliests and most helpful advises I can give 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Template Tags in Text
Hi, I'm trying to puzzle out the best way of achieving something, and I'd appreciate some help. My website contains text writeups of events, and a gallery. I'd like to embed some images from the gallery into the text writeups. The text is not in a template, it's in the database and displayed using the textile filter: {% block body %} {{ Contest.date|date:"jS F Y" }} - {{ Contest.title }} {{ Contest.report|textile }} {% endblock %} What's the best way to embed an image from my gallery into the Contest.report variable? I'm looking to do something like: {% ShowImage 1 200 400 left %} where - ShowImage is a template tag, - 1 is the serial of the image to show, - 200 is the height - 400 is the width - left is the align value so text wraps around it I can generate a thumbnail of the right size, and I can find the image location from the database, but what's the best way of replacing this template tag with the appropriate html? Can I write a filter which "runs" template tags? Or should I be scanning the text for "{% ShowImage" and then reading values until the next "%}" in a custom filter? Thoughts? Cheers, Tim. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: login problem, Django 1.0
On Oct 10, 12:02 pm, Robocop <[EMAIL PROTECTED]> wrote: > Unfortunately, that is the explanation. I really appreciate all the > help though; how disappointing that i didn't learn anything other than > not allowing anyone to touch my projects without me around. > > On Oct 10, 9:59 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > > On Fri, Oct 10, 2008 at 12:51 PM, Robocop <[EMAIL PROTECTED]> wrote: > > > > Bad news guys, someone deactivated my test user and didn't tell me. > > > I'm so sad. > > > Do you mean that is the explanation for why auth.login hasn't been working? > > Or is there still a problem that needs to be investigated? > > > Karen 1) I was looking at this because I am have a problem login in users and showing there auth info(show any data not from a form). my view looks just like yours, it is letting every thing in. 2) I saw the line: news_list = New.objects.all().order_by('- date') I need to do something like this usertime=time.objects.filter( user=User.username).filter(worked=null) time is my class in my models.py that has user and worked. what else do I have to do to get this to work? View http://dpaste.com/84442/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: modelForm
Alfredo Alessandrini wrote: > I don't understand where is the difference... indentation, so different code paths -- ()_() | That said, I didn't actually _test_ my patch. | + (o.o) | That's what users are for! | +---+ 'm m' | (Linus Torvalds) | O | (___) | raffaele at salmaso punto org | --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: modelForm
Alfredo Alessandrini wrote: > def setup_player(request): > if request.method == 'POST': > form = PlayerForm(request.POST) > if form.is_valid(): > form.save() > return HttpResponseRedirect(form_successfully) > else: > form = PlayerForm() > return render_to_response('player_form.html', {'form': form}) def setup_player(request): if request.method == 'POST': form = PlayerForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(form_successfully) else: form = PlayerForm() return render_to_response('player_form.html', {'form': form}) notice the last three lines the usual pattern is if POST: form = MyForm(POST) if form.is_valid(): return HttpResponseRedirect('all_ok.html') else: # no POST data form = MyForm() return render_to_response(..., {...}) -- ()_() | That said, I didn't actually _test_ my patch. | + (o.o) | That's what users are for! | +---+ 'm m' | (Linus Torvalds) | O | (___) | raffaele at salmaso punto org | --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: current user
thanks gearheart and james. i noticed a little blurb in the gearheart's link that points to a new way to do it (YAY!), instead of threadlocals. it worked beautifully, but i believe there's a typo in that... def save_model(self, request, form, change): i think should be: def save_model(self, request, obj, form, change): keith On Tue, Oct 14, 2008 at 4:20 PM, James Bennett <[EMAIL PROTECTED]>wrote: > > On Tue, Oct 14, 2008 at 3:17 PM, Keith Eberle <[EMAIL PROTECTED]> > wrote: > > ah yes, threadlocals... i was thinking maybe there was a newer way. > > > > its nice how you can override the queryset method of a ModelAdmin class > > because that gets passed a request. I was hoping there'd be some similar > > new functionality with the ModelForm class... > > You have access to the request in all of the ModelAdmin methods. That > includes: > > * The method which generates the form to use. > * The method which actually saves the object. > > Doing custom stuff in there is trivially easy. Try it out. > > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of > correct." > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: current user
On Tue, Oct 14, 2008 at 3:17 PM, Keith Eberle <[EMAIL PROTECTED]> wrote: > ah yes, threadlocals... i was thinking maybe there was a newer way. > > its nice how you can override the queryset method of a ModelAdmin class > because that gets passed a request. I was hoping there'd be some similar > new functionality with the ModelForm class... You have access to the request in all of the ModelAdmin methods. That includes: * The method which generates the form to use. * The method which actually saves the object. Doing custom stuff in there is trivially easy. Try it out. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: current user
On Tue, Oct 14, 2008 at 3:10 PM, gearheart <[EMAIL PROTECTED]> wrote: > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser Sigh. I guess this is the part where I go edit that wiki page to point people to the better solution? Yeah, I think this is the part where I go edit that wiki page. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: current user
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser lingrlongr wrote: > What's the best way to always set a User foreign key to the current > user using the admin site? For example: > > # models.py > class MyModel(models.Model): > my_data = models.CharField(max_length=50) > user = models.ForeignKey(User) > > When this was saved/updated in the admin, "user" should always equal > the person saving/updating the object. I'd also like for the user > field to not even show up... > > thx. > > keith --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: current user
ah yes, threadlocals... i was thinking maybe there was a newer way. its nice how you can override the queryset method of a ModelAdmin class because that gets passed a request. I was hoping there'd be some similar new functionality with the ModelForm class... thx keith On Tue, Oct 14, 2008 at 4:10 PM, gearheart <[EMAIL PROTECTED]> wrote: > > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > > lingrlongr wrote: > > What's the best way to always set a User foreign key to the current > > user using the admin site? For example: > > > > # models.py > > class MyModel(models.Model): > > my_data = models.CharField(max_length=50) > > user = models.ForeignKey(User) > > > > When this was saved/updated in the admin, "user" should always equal > > the person saving/updating the object. I'd also like for the user > > field to not even show up... > > > > thx. > > > > keith > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Making queries guide, incomplete code.
On Oct 14, 1:47 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Tue, Oct 14, 2008 at 1:52 PM, KillaBee < > > > > [EMAIL PROTECTED]> wrote: > > On Oct 14, 12:14 pm, KillaBee <[EMAIL PROTECTED]> > > wrote: > > > On Oct 14, 12:07 pm, Brian Neal <[EMAIL PROTECTED]> wrote: > > > > > On Oct 14, 11:35 am, KillaBee <[EMAIL PROTECTED]> > > > > wrote: > > > > > > I was reading the Making queries guide on the the website. > >http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-que... > > > > > It said: > > > > > > >>> Blog.objects > > > > > > >>> b = > > Blog(name='Foo', tagline='Bar') > > > > > >>> b.objects > > > > > > Traceback: > > > > > ... > > > > > AttributeError: "Manager isn't accessible via Blog instances." > > > > > > > > > > > What is this ... what is it, and why can't the page just say it. > > > > > Please no secrets. > > > > > > I to do this, in this view all the time. > > > > > > Blog.objects > > > > > t = time(user=user, fedtime=fedtime, worked=worked, date=date) > > > > > t.objects > > > > > time.objects.filter( user=username ).filter( PP=44 ) > > > > > I'm not really sure what you mean. The docs are showing you an example > > > > of interactive Python using the shell. You don't type the above into > > > > your program. You do know about Python's interactive shell, right? > > > > > The Blog.objects > > > > business is the shell printing out the __unicode__ representation of > > > > an object. > > > > I know about it, and saw those >>>. I didn't know I had to use it. > > > When do I use it? > > > OK now i am real confussed. I did the save() in my form that is the > > first part. Does any have a working example of how to filter() not > > python. > > If I have to use python to where does Django come in? > > Say what? I have no idea what you are asking. You started out with a > question about the docs in the area of making queries. Now you have jumped > to forms and save() -- entirely different topics, and are also asking how > not to write Python? Django is written in Python, your code using Django is > written in Python. Django provides many constructs and functions that allow > you to write much less Python than you would have to if you were going to > write your own database-driven web application from scratch, but you still > need to write some Python code. Which means you do have to have a working > grasp of the Python language in order to write a Django application. > > People on this list are going to have a hard time helping if you do not take > the time and make an effort to post quesitons that can be understood. "my > form that is the first part" refers to nothing in this previous conversation > so how can anyone be expected to respond sensibly? > > You also earlier ask for "please no secrets" in the documentation -- the > documentation isn't trying to hide anything. The project is open source so > there is nothing to hide. The excerpt you cite from the doc is simply > trying to point out that you can't use the 'objects' attribute on a variable > that is an instance of a model class instead of the model class itself. > This makes perfect sense so I'm having difficulty understanding what your > issue is with it. > > If you don't understand the distinction between an instance of a class and > the class itself then that is perhaps an indication that you need to develop > a better understanding of Python before you are going to be comfortable > writing Django application code. I'm sorry if that sounds unhelpful but > honestly it's the best advice I have at this point. > > Karen No, it is very helpful, I know now that I have to learn all of python and I know now that ... means variable. I changed because I put save() in my view, per my last post about how to save data to the db, and didn't not open a python console. I tried to enter those lines in the pyhton shell starting with the importing of my class time, but it said there was no module with that name. "from intranet.timesheets.models import time" and there is a models.py and a time class in it? do you think that it is not i my sitepath? I am still wanting to display data from the db, I was think that django had something to do it. So, after I enter those lines in my python shell, How do I put it in my view or page? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: password_reset
i must add it also doesn't print the newpassword in the email it sends. If you have a working password_reset template, please share with the community :) 2008/10/14 Alessandro <[EMAIL PROTECTED]>: > I want to let users reset their password, so I've used the password_reset > view. > I don't want to show my admin site to users, so I've overwritten the template > (r'^accounts/password_reset[/]*$', > 'django.contrib.auth.views.password_reset' ,{'template_name': > 'account/password_reset_form.html'}), > > In that way I have two errors: > 1) the template doesn't load the translation. but I've changed only > the first line to {% extends "index.html" %} , to use my index > template > 2) Errors are not shown as it happens if I leave {% extends > "admin/base_site" %} > > Is there any easy way to solve it? > > -- > Alessandro Ronchi > Skype: aronchi > http://www.alessandroronchi.net > > Rispetta l'ambiente: se non ti è necessario, non stampare questa mail > -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo Software e Sistemi Open Source Sede: Via Poggiali 2/bis, 47100 Forlì (FC) Tel.: +39 0543 798985 - Fax: +39 0543 579928 Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Problems serving static files with Apache and mod_python
Dear group, sorry for starting another thread on this issue. I've seen loads of messages with similar but particular problems. My system: * apache2 (2.2.9-10) * libapache2-mod-python (3.3.1-5) * python-django (1.0-1) My project is located at: ~/Desktop/csl2-sdocente/src/candidateTool and the app I'm trying to make work is called assessmentSystem, obviously at ~/Desktop/csl2-sdocente/src/candidateTool/ assessmentSystem. The static files are located at ~/Desktop/csl2-sdocente/src/ django_media/ and match with the url 'r'^static/(?P.*)$' I'd like to display the app at localhost, so my httpd.conf looks like: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE candidateTool.settings PythonOption django.root / PythonDebug On PythonPath "['/home/peris/Desktop/csl2-sdocente/src/', '/home/ peris/Desktop/csl3-sdocente/src/django_media'] + sys.path" Alias /static /home/peris/Desktop/csl3-sdocente/src/django_media Allow from all SetHandler None SetHandler None But there's no way I can't load the css and images files. Any idea? Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Making queries guide, incomplete code.
On Tue, Oct 14, 2008 at 1:52 PM, KillaBee < [EMAIL PROTECTED]> wrote: > On Oct 14, 12:14 pm, KillaBee <[EMAIL PROTECTED]> > wrote: > > On Oct 14, 12:07 pm, Brian Neal <[EMAIL PROTECTED]> wrote: > > > > > On Oct 14, 11:35 am, KillaBee <[EMAIL PROTECTED]> > > > wrote: > > > > > > I was reading the Making queries guide on the the website. > http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-que... > > > > It said: > > > > > > >>> Blog.objects > > > > > > >>> b = > Blog(name='Foo', tagline='Bar') > > > > >>> b.objects > > > > > > Traceback: > > > > ... > > > > AttributeError: "Manager isn't accessible via Blog instances." > > > > > > > > > > What is this ... what is it, and why can't the page just say it. > > > > Please no secrets. > > > > > > I to do this, in this view all the time. > > > > > > Blog.objects > > > > t = time(user=user, fedtime=fedtime, worked=worked, date=date) > > > > t.objects > > > > time.objects.filter( user=username ).filter( PP=44 ) > > > > > I'm not really sure what you mean. The docs are showing you an example > > > of interactive Python using the shell. You don't type the above into > > > your program. You do know about Python's interactive shell, right? > > > > > The Blog.objects > > > business is the shell printing out the __unicode__ representation of > > > an object. > > > > I know about it, and saw those >>>. I didn't know I had to use it. > > When do I use it? > > OK now i am real confussed. I did the save() in my form that is the > first part. Does any have a working example of how to filter() not > python. > If I have to use python to where does Django come in? > Say what? I have no idea what you are asking. You started out with a question about the docs in the area of making queries. Now you have jumped to forms and save() -- entirely different topics, and are also asking how not to write Python? Django is written in Python, your code using Django is written in Python. Django provides many constructs and functions that allow you to write much less Python than you would have to if you were going to write your own database-driven web application from scratch, but you still need to write some Python code. Which means you do have to have a working grasp of the Python language in order to write a Django application. People on this list are going to have a hard time helping if you do not take the time and make an effort to post quesitons that can be understood. "my form that is the first part" refers to nothing in this previous conversation so how can anyone be expected to respond sensibly? You also earlier ask for "please no secrets" in the documentation -- the documentation isn't trying to hide anything. The project is open source so there is nothing to hide. The excerpt you cite from the doc is simply trying to point out that you can't use the 'objects' attribute on a variable that is an instance of a model class instead of the model class itself. This makes perfect sense so I'm having difficulty understanding what your issue is with it. If you don't understand the distinction between an instance of a class and the class itself then that is perhaps an indication that you need to develop a better understanding of Python before you are going to be comfortable writing Django application code. I'm sorry if that sounds unhelpful but honestly it's the best advice I have at this point. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
current user
What's the best way to always set a User foreign key to the current user using the admin site? For example: # models.py class MyModel(models.Model): my_data = models.CharField(max_length=50) user = models.ForeignKey(User) When this was saved/updated in the admin, "user" should always equal the person saving/updating the object. I'd also like for the user field to not even show up... thx. keith --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
RESTful API or SOAP in pre-magic
Hello, I am trying to get REST or SOAP working in 0.91 pre-magic version of Django. The idea is to let a third-party vendor check via xmlrpc to see if a user is authorized on our system and get a username. I was planning on using the sessionid cookie as the query from the 3rd party. I need to stay on ver. 0.91. Anybody have any suggestions on how to proceed? Thanks, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: modelForm
On Tue, Oct 14, 2008 at 2:00 PM, Alfredo Alessandrini <[EMAIL PROTECTED]>wrote: > > I've a new error :-) : > > File "./mysite/views.py", line 26, in setup_player >return render_to_response('player_form.html', {'form': form}) > > UnboundLocalError: local variable 'form' referenced before assignment > That's a very clear error message. You are using the variable form before you have ever assigned it a value. Look at the code, and you should be able to figure out how to fix it. Perhaps the exact fix given earlier in this thread was not 100% correct; people aren't Python compilers and sometimes miss details when giving advice. There are also many many correct examples out there of how to write views that deal with forms, take a look at them and see how they differ from what you have. Really, you can figure this out yourself. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: modelForm
I've a new error :-) : File "./mysite/views.py", line 26, in setup_player return render_to_response('player_form.html', {'form': form}) UnboundLocalError: local variable 'form' referenced before assignment 2008/10/14 Daniel Roseman <[EMAIL PROTECTED]>: > > On Oct 14, 5:37 pm, "Alfredo Alessandrini" <[EMAIL PROTECTED]> > wrote: >> I've setup a form from a model: >> >> class PlayerForm(ModelForm): >> class Meta: >> model = Player >> >> I've setup a view function for save the data inserted in the form: >> >> def setup_player(request): >> if request.method == 'POST': >> form = PlayerForm(request.POST) >> if form.is_valid(): >> form.save() >> return HttpResponseRedirect(form_successfully) >> else: >> form = PlayerForm() >> return render_to_response('player_form.html', {'form': form}) >> >> But I've this error: >> >> ValueError: The view mysite.views.setup_player didn't return an >> HttpResponse object. >> >> why?? >> >> Thanks in advance, >> >> Alfredo > > The final line, return render_to_response, is indented so that it > comes inside the initial if request.method=='POST'. This means that if > it's not a POST - as it won't be when the user initial requests the > page - nothing is returned. > > The simple solution is to move that final line back four spaces, so it > is always executed. > -- > 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 -~--~~~~--~~--~--~---
Re: modelForm
On Oct 14, 5:37 pm, "Alfredo Alessandrini" <[EMAIL PROTECTED]> wrote: > I've setup a form from a model: > > class PlayerForm(ModelForm): > class Meta: > model = Player > > I've setup a view function for save the data inserted in the form: > > def setup_player(request): > if request.method == 'POST': > form = PlayerForm(request.POST) > if form.is_valid(): > form.save() > return HttpResponseRedirect(form_successfully) > else: > form = PlayerForm() > return render_to_response('player_form.html', {'form': form}) > > But I've this error: > > ValueError: The view mysite.views.setup_player didn't return an > HttpResponse object. > > why?? > > Thanks in advance, > > Alfredo The final line, return render_to_response, is indented so that it comes inside the initial if request.method=='POST'. This means that if it's not a POST - as it won't be when the user initial requests the page - nothing is returned. The simple solution is to move that final line back four spaces, so it is always executed. -- 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 -~--~~~~--~~--~--~---
Re: Making queries guide, incomplete code.
On Oct 14, 12:14 pm, KillaBee <[EMAIL PROTECTED]> wrote: > On Oct 14, 12:07 pm, Brian Neal <[EMAIL PROTECTED]> wrote: > > > On Oct 14, 11:35 am, KillaBee <[EMAIL PROTECTED]> > > wrote: > > > > I was reading the Making queries guide on the the > > > website.http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-que... > > > It said: > > > > >>> Blog.objects > > > > >>> b = Blog(name='Foo', > > > tagline='Bar') > > > >>> b.objects > > > > Traceback: > > > ... > > > AttributeError: "Manager isn't accessible via Blog instances." > > > > > > > What is this ... what is it, and why can't the page just say it. > > > Please no secrets. > > > > I to do this, in this view all the time. > > > > Blog.objects > > > t = time(user=user, fedtime=fedtime, worked=worked, date=date) > > > t.objects > > > time.objects.filter( user=username ).filter( PP=44 ) > > > I'm not really sure what you mean. The docs are showing you an example > > of interactive Python using the shell. You don't type the above into > > your program. You do know about Python's interactive shell, right? > > > The Blog.objects > > business is the shell printing out the __unicode__ representation of > > an object. > > I know about it, and saw those >>>. I didn't know I had to use it. > When do I use it? OK now i am real confussed. I did the save() in my form that is the first part. Does any have a working example of how to filter() not python. If I have to use python to where does Django come in? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
method to test for conditions on a per-field basis in a form
I have an application where I need to allow users of various levels access to the same data. For example, I want to render a form representing an employee profile to be displayed to the employee, his supervisor, and the manager. All the fields need to be visible to each of those different types of users, but only certain fields will be editable by each; ie, the supervisor needs to be able to update the pay grade of the employee, and the employee needs to be able to see his pay grade, while being able to edit other things. I've considered multiple approaches to accomplish what I need: 1) Add a method to the form class such as: # forms.py class ModelForm(ModelForm): def check_permission(self, user, field): # do test here if failed_test: return False return True class EmployeeForm(ModelForm): ... The idea here was to use something along the line of {% if form.check_permission user field %} within my template. Of course, templates can only use methods which have no arguments, so this approach quickly failed. 2) Add a method to each field after instantiating the form in the view: # views.py def employee_detail(request, name): ... def check_permission(self, user): # do test here if failed_test: return False return True form = EmployeeForm() for field in form: field.check_permission = check_permission ... Of course, this also runs into the problem where templates can't pass arguments to methods, but the idea was to use {% if field.check_permission user %}. A second issue with this approach is that the template doesn't "see" new attributes/methods added to the form fields in this fashion. So even if I modified this approach to somehow be able to find the user object without it being passed as an argument, I still can't use custom attributes/methods on form fields in the template for some reason. 3) Create custom form fields that derive from a common custom form field class which has the ability to be disabled at will through a simple argument-free method call. This is not feasible simply due to the sheer amount of coding that it would require for such seemingly simple functionality. The desire to display form fields in a disabled state based upon certain conditions has got to be a common issue, but I was unable to find anything helpful in extensive searches on google and on this list, so I am hopeful that someone will have a suggestion about what I can do. Probably I've missed something simple, as I tend to over-think my problems quite often. Thanks for any input. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: modelForm
from http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index - Using a form in a view The standard pattern for processing a form in a view looks like this: def contact(request): if request.method == 'POST': # If the form has been submitted... form = ContactForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process the data in form.cleaned_data # ... return HttpResponseRedirect('/thanks/') # Redirect after POST else: form = ContactForm() # An unbound form return render_to_response('contact.html', { 'form': form, }) -- I don't understand where is the difference... Alfredo 2008/10/14 Steve Holden <[EMAIL PROTECTED]>: > > Alfredo Alessandrini wrote: >> I've setup a form from a model: >> >> class PlayerForm(ModelForm): >> class Meta: >> model = Player >> >> I've setup a view function for save the data inserted in the form: >> >> def setup_player(request): >> if request.method == 'POST': >> form = PlayerForm(request.POST) >> if form.is_valid(): >> form.save() >> return HttpResponseRedirect(form_successfully) >> else: >> form = PlayerForm() >> return render_to_response('player_form.html', {'form': form}) >> >> But I've this error: >> >> ValueError: The view mysite.views.setup_player didn't return an >> HttpResponse object. >> >> why?? >> > Because you have no action when request.method != "POST", and so the > view is returning None. > > regards > Steve > -- > Steve Holden+1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.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 -~--~~~~--~~--~--~---
Forms and saving the image name
I'm currently developing a Django application that contains allows the user to take a photo using a webcam and save that on the local harddrive. The application won't be accessed remotely in will run from the localhost so there are no security concerns. The image can be saved using some flash code.I'm just wondering if anyone has any idea how I can access the image name and save that to my model when the user clicks on the ADD button. Should I break up the form into multiples so that in one step I capture bio-data and in the next I do the flash webcam capture and pass the last saved Id? Any ideas would be helpful --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Error Pages and Flatpages
Hi All, I am newer in Django Web Framework. I am very curious to know the following How to handle error pages and flat pages? Example : Error : 404 Error : Page not found. Ravi Hingarajiya --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Making queries guide, incomplete code.
On Oct 14, 12:07 pm, Brian Neal <[EMAIL PROTECTED]> wrote: > On Oct 14, 11:35 am, KillaBee <[EMAIL PROTECTED]> > wrote: > > > > > I was reading the Making queries guide on the the > > website.http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-que... > > It said: > > > >>> Blog.objects > > > >>> b = Blog(name='Foo', > > tagline='Bar') > > >>> b.objects > > > Traceback: > > ... > > AttributeError: "Manager isn't accessible via Blog instances." > > > > > What is this ... what is it, and why can't the page just say it. > > Please no secrets. > > > I to do this, in this view all the time. > > > Blog.objects > > t = time(user=user, fedtime=fedtime, worked=worked, date=date) > > t.objects > > time.objects.filter( user=username ).filter( PP=44 ) > > I'm not really sure what you mean. The docs are showing you an example > of interactive Python using the shell. You don't type the above into > your program. You do know about Python's interactive shell, right? > > The Blog.objects > business is the shell printing out the __unicode__ representation of > an object. I know about it, and saw those >>>. I didn't know I had to use it. When do I use it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Making queries guide, incomplete code.
On Oct 14, 11:35 am, KillaBee <[EMAIL PROTECTED]> wrote: > I was reading the Making queries guide on the the > website.http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-que... > It said: > > >>> Blog.objects > > >>> b = Blog(name='Foo', > tagline='Bar') > >>> b.objects > > Traceback: > ... > AttributeError: "Manager isn't accessible via Blog instances." > > > What is this ... what is it, and why can't the page just say it. > Please no secrets. > > I to do this, in this view all the time. > > Blog.objects > t = time(user=user, fedtime=fedtime, worked=worked, date=date) > t.objects > time.objects.filter( user=username ).filter( PP=44 ) I'm not really sure what you mean. The docs are showing you an example of interactive Python using the shell. You don't type the above into your program. You do know about Python's interactive shell, right? The Blog.objects business is the shell printing out the __unicode__ representation of an object. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: modelForm
Alfredo Alessandrini wrote: > I've setup a form from a model: > > class PlayerForm(ModelForm): > class Meta: > model = Player > > I've setup a view function for save the data inserted in the form: > > def setup_player(request): > if request.method == 'POST': > form = PlayerForm(request.POST) > if form.is_valid(): > form.save() > return HttpResponseRedirect(form_successfully) > else: > form = PlayerForm() > return render_to_response('player_form.html', {'form': form}) > > But I've this error: > > ValueError: The view mysite.views.setup_player didn't return an > HttpResponse object. > > why?? > Because you have no action when request.method != "POST", and so the view is returning None. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to pass a string to a custom filter?
Thanks; but I was not clear. I'll try to explain: the code is not intended to really create the breadcrumbs. The code tries to identify the problem. The problem is that the statement: parti=aurl.split('/') doesn't generate a list Moreover the statement: aurl.count('/') (with the supposed url that is "http://localhost/zsite/ancore/;) gives the value 0 (I expected 4) Worst, I used your suggestion and now the bc assignement line is bc= u' - %s - len=%d char= %s %s' % (parti[0],len(parti),aurl.count('/'),(isinstance(aurl, basestring))) and isinstance(aurl, basestring) id evaluated as True (so aurl is a string; but split('/') doesn't work) I don't know what to look for: I receive a string, the string contains '/', the string.split('/') doesn't generate the expected 5 elements. Obvoiusly, the same code pasted in the shell (python manage.py shell) works as expected. Any Hint? Thanks Mirto P.S. BTW the urls are different from development framework and production: * runserver: http://localhost:8000/ancore/ * apache: http://localhost/zsite/ancore/ bruno desthuilliers ha scritto: > On 14 oct, 16:34, Mirto Silvio Busico <[EMAIL PROTECTED]> wrote: > >> Hi all, >> I'm trying to pass a string to a custom tag to create custom breadcrumbs. >> >> I'm using as a base the snippet athttp://www.djangosnippets.org/snippets/656/ >> and using the documentation >> fromhttp://docs.djangoproject.com/en/dev/howto/custom-template-tags/ >> >> But it seems that I'm not able to pass the URL as a string. >> >> In ... zsite/ancore/templatetags/mytags.py (zsite is the django project >> directory) I have: >> == >> #!/usr/bin/python >> # encoding: utf-8 >> from django import template >> from django.utils.safestring import mark_safe >> from django.utils.translation import ugettext >> from django.template.defaultfilters import stringfilter >> from types import * >> >> register = template.Library() >> >> @register.filter(name='dovesono') >> @stringfilter >> def dovesono(aurl): >> >>bc = u'' >>parti=aurl.split('/') >> >>bc= u' - %s - len=%d char= %s %s' % >> (parti[0],len(parti),aurl.count('/'),(type(aurl) == StringTypes)) >> > > StringTypes is a tuple (, ). So you want : > type(aurl) in StringTypes > > which is better written: > isinstance(aurl, basestring) > > but anyway, given your example use case, this test is more than > probably more than useless... > > >>for i in range(len(parti)): >> bc=bc+' '+parti[i] >> > > The canonical way to iterate over a sequence is: > > for elt in sequence: > do_whatever_with(elt) > > but you don't need such a low-level construct here - just use > str.join(seq): > > bc = u' '.join(parti) > > Note that since request.path is an absolute path (iow with leading > slash), and may have a trailing one too, you may want to get rid of > both before splitting the request.path, ie: > > parti = aurl.strip('/').split('/') > > # code here > > >>return mark_safe(bc) >> == >> >> In the calling template I have: >> == >> {% block breadcrumbs %} >> {% load mytags %} >> >> {{ request.get_full_path|dovesono }} >> > > request.get_full_path will also gives you the querystring part if > there's one. I think you want request.path instead. > > >> >> {% endblock %} >> == >> >> and the generated html is: >> == >> >> >> - - len=1 char= 0 False >> >> >> == >> >> So (type(aurl) == StringTypes) is evaluated False >> >> What I'm doing wrong? >> What is the method to pass the actual url to a filter as a string? >> > > It is already one. The bug is elsewhere. > > HTH > > > > > > -- _ Busico Mirto Silvio Consulente ICT cell. 333 4562651 email [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: unable to open database file - sqlite3/apache problem - help?
Exact same problem, as well. I'm running Ubuntu 8.4 Hardy (server edition), but after running the apparmor_status command, I don't see any active [or even existent] AppArmor profiles that are activated onto httpd, Python, or any other relevant processes. It still didn't work after I disabled AppArmor either. I might try switching over to PostgreSQL, as that will probably resolve the problem (and I'll need to eventually anyway), but I'd like to figure out what's going on as well. Regards, Leaf On Oct 14, 10:44 am, Odie <[EMAIL PROTECTED]> wrote: > Hello, > > On Oct 11, 2:02 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > > > > On Fri, Oct 10, 2008 at 4:24 PM, shawn <[EMAIL PROTECTED]> wrote: > > > > Hey guys, > > > > So I want to be able to use mod_python and apache to host my django > > > project, but I'm running into a little problem. When I go to my URL, I > > > get this error: > > > > Exception Type: OperationalError at /admin/ > > > Exception Value: unable to open database file > > > > I'm using sqlite3 and apache, and I've been looking around the > > > interwebs and I know that this is a problem where apache can't write/ > > > read that particular file. This is what my apache configuration looks > > > like: > > > > # Location of project > > > > > > SetHandler python-program > > > PythonHandler django.core.handlers.modpython > > > SetEnv DJANGO_SETTINGS_MODULE rest.settings > > > PythonOption django.root /rest > > > PythonDebug On > > > PythonPath "['/home/djangoz/django_projects/'] + sys.path" > > > > > > > Now, I'll let you know what I've tried. I have tried changing the > > > permissions on the rest.db file itself, as well as the parent folder. > > > I tried changing the owners to the same one as apache (www-data). I've > > > tried making the permissions fully readable, executable, and > > > writeable, and it still doesn't seem to work. > > > > If I run the server with django using python manage runserver > > > 0.0.0.0:8080, I have no problem running the application. > > > > Does anyone have any suggestions? I can't seem to find a solution! > > > What OS are your running? Is it possibly one (SELinux-based ones come to > > mind) where permissions are not necessarily what control file access rights? > > I'm seeing the same problem and I'm running Ubuntu Intrepid which is > indeed > using apparmor. > > However, I'm struggling to find out how to relax apparmor's grip on > this issue > (assuming it's the one responsible for it which I've still not > demonstrated). So > any tips would be greatly welcomed! > > Cheers, > > Odie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
modelForm
I've setup a form from a model: class PlayerForm(ModelForm): class Meta: model = Player I've setup a view function for save the data inserted in the form: def setup_player(request): if request.method == 'POST': form = PlayerForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(form_successfully) else: form = PlayerForm() return render_to_response('player_form.html', {'form': form}) But I've this error: ValueError: The view mysite.views.setup_player didn't return an HttpResponse object. why?? Thanks in advance, Alfredo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Making queries guide, incomplete code.
I was reading the Making queries guide on the the website. http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-queries It said: >>> Blog.objects >>> b = Blog(name='Foo', tagline='Bar') >>> b.objects Traceback: ... AttributeError: "Manager isn't accessible via Blog instances." What is this ... what is it, and why can't the page just say it. Please no secrets. I to do this, in this view all the time. Blog.objects t = time(user=user, fedtime=fedtime, worked=worked, date=date) t.objects time.objects.filter( user=username ).filter( PP=44 ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: unable to get rid of app name via rewrite
jwing wrote: > Hi all, I just moved to Django from Pylons. Django never ceases to > amaze me so far, but when I tried to deploy my app on apache > (fastcgi), I got the rewrite issue with no any corresponding solution > via Google, well, I can't find it at least :( > > I Got: > 1) several apps under project "demo" (app1, app2, etc); > > 2) domain http://app1.demo.com; > > 3) many reversed url addresses (by urlresolvers.reverse method) which > are being passed to templates via AJAX calls, in app1, say profile > page, the reversed url will be "/app1/profile" > > 4) here is my VirtualHost settings > FastCGIExternalServer /home/host/app1/app1.fcgi -socket /home/host/ > app1/run/app1.socket > > ServerNameapp1.demo.com > DocumentRoot /home/host/app1 > Alias /media /home/host/app1/media > LogLevel warn > ErrorLog /home/host/app1/log/error.log > CustomLog /home/host/app1/log/access.log common > RewriteEngine On > RewriteRule ^/(media.*)$ /$1 [QSA,L,PT] > RewriteRule ^/js/(.*)$ /media/js/$1 [QSA,L,PT] > RewriteRule ^/css/(.*)$ /media/css/$1 [QSA,L,PT] > RewriteRule ^/img/(.*)$ /media/img/$1 [QSA,L,PT] > RewriteCond %{REQUEST_FILENAME} !-f > RewriteRule ^/(.*)$ /app1.fcgi/$1 [QSA,L] > > > > I wanna: get rid of "/app1", using http://app1.demo.com instead of > http://app1.demo.com/app1 > > Replacing "/app1.fcgi/$1" with "/app1.fcgi/app1$1" works partially, > but not for those reversed url addresses. Adding "SCRIPT_URL" rewrite > rule which mentioned by Django doc doesn't work for me either. Anyone > has ever met this before? > I suspect each site should be a separate project: this would avoid the app directory name being inserted at the top level as it is now. With a separate settings file for each site you can then use the sites subsystem the way it was intended if you want to share content. regards Steve regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.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 -~--~~~~--~~--~--~---
password_reset
I want to let users reset their password, so I've used the password_reset view. I don't want to show my admin site to users, so I've overwritten the template (r'^accounts/password_reset[/]*$', 'django.contrib.auth.views.password_reset' ,{'template_name': 'account/password_reset_form.html'}), In that way I have two errors: 1) the template doesn't load the translation. but I've changed only the first line to {% extends "index.html" %} , to use my index template 2) Errors are not shown as it happens if I leave {% extends "admin/base_site" %} Is there any easy way to solve it? -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to pass a string to a custom filter?
On 14 oct, 16:34, Mirto Silvio Busico <[EMAIL PROTECTED]> wrote: > Hi all, > I'm trying to pass a string to a custom tag to create custom breadcrumbs. > > I'm using as a base the snippet athttp://www.djangosnippets.org/snippets/656/ > and using the documentation > fromhttp://docs.djangoproject.com/en/dev/howto/custom-template-tags/ > > But it seems that I'm not able to pass the URL as a string. > > In ... zsite/ancore/templatetags/mytags.py (zsite is the django project > directory) I have: > == > #!/usr/bin/python > # encoding: utf-8 > from django import template > from django.utils.safestring import mark_safe > from django.utils.translation import ugettext > from django.template.defaultfilters import stringfilter > from types import * > > register = template.Library() > > @register.filter(name='dovesono') > @stringfilter > def dovesono(aurl): > >bc = u'' >parti=aurl.split('/') > >bc= u' - %s - len=%d char= %s %s' % > (parti[0],len(parti),aurl.count('/'),(type(aurl) == StringTypes)) StringTypes is a tuple (, ). So you want : type(aurl) in StringTypes which is better written: isinstance(aurl, basestring) but anyway, given your example use case, this test is more than probably more than useless... >for i in range(len(parti)): > bc=bc+' '+parti[i] The canonical way to iterate over a sequence is: for elt in sequence: do_whatever_with(elt) but you don't need such a low-level construct here - just use str.join(seq): bc = u' '.join(parti) Note that since request.path is an absolute path (iow with leading slash), and may have a trailing one too, you may want to get rid of both before splitting the request.path, ie: parti = aurl.strip('/').split('/') # code here >return mark_safe(bc) > == > > In the calling template I have: > == > {% block breadcrumbs %} > {% load mytags %} > > {{ request.get_full_path|dovesono }} request.get_full_path will also gives you the querystring part if there's one. I think you want request.path instead. > > {% endblock %} > == > > and the generated html is: > == > > > - - len=1 char= 0 False > > > == > > So (type(aurl) == StringTypes) is evaluated False > > What I'm doing wrong? > What is the method to pass the actual url to a filter as a string? It is already one. The bug is elsewhere. HTH --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
unable to get rid of app name via rewrite
Hi all, I just moved to Django from Pylons. Django never ceases to amaze me so far, but when I tried to deploy my app on apache (fastcgi), I got the rewrite issue with no any corresponding solution via Google, well, I can't find it at least :( I Got: 1) several apps under project "demo" (app1, app2, etc); 2) domain http://app1.demo.com; 3) many reversed url addresses (by urlresolvers.reverse method) which are being passed to templates via AJAX calls, in app1, say profile page, the reversed url will be "/app1/profile" 4) here is my VirtualHost settings FastCGIExternalServer /home/host/app1/app1.fcgi -socket /home/host/ app1/run/app1.socket ServerNameapp1.demo.com DocumentRoot /home/host/app1 Alias /media /home/host/app1/media LogLevel warn ErrorLog /home/host/app1/log/error.log CustomLog /home/host/app1/log/access.log common RewriteEngine On RewriteRule ^/(media.*)$ /$1 [QSA,L,PT] RewriteRule ^/js/(.*)$ /media/js/$1 [QSA,L,PT] RewriteRule ^/css/(.*)$ /media/css/$1 [QSA,L,PT] RewriteRule ^/img/(.*)$ /media/img/$1 [QSA,L,PT] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ /app1.fcgi/$1 [QSA,L] I wanna: get rid of "/app1", using http://app1.demo.com instead of http://app1.demo.com/app1 Replacing "/app1.fcgi/$1" with "/app1.fcgi/app1$1" works partially, but not for those reversed url addresses. Adding "SCRIPT_URL" rewrite rule which mentioned by Django doc doesn't work for me either. Anyone has ever met this before? Best regards --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: unable to open database file - sqlite3/apache problem - help?
Hello, On Oct 11, 2:02 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Fri, Oct 10, 2008 at 4:24 PM, shawn <[EMAIL PROTECTED]> wrote: > > > Hey guys, > > > So I want to be able to use mod_python and apache to host my django > > project, but I'm running into a little problem. When I go to my URL, I > > get this error: > > > Exception Type: OperationalError at /admin/ > > Exception Value: unable to open database file > > > I'm using sqlite3 and apache, and I've been looking around the > > interwebs and I know that this is a problem where apache can't write/ > > read that particular file. This is what my apache configuration looks > > like: > > > # Location of project > > > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE rest.settings > > PythonOption django.root /rest > > PythonDebug On > > PythonPath "['/home/djangoz/django_projects/'] + sys.path" > > > > > Now, I'll let you know what I've tried. I have tried changing the > > permissions on the rest.db file itself, as well as the parent folder. > > I tried changing the owners to the same one as apache (www-data). I've > > tried making the permissions fully readable, executable, and > > writeable, and it still doesn't seem to work. > > > If I run the server with django using python manage runserver > > 0.0.0.0:8080, I have no problem running the application. > > > Does anyone have any suggestions? I can't seem to find a solution! > > What OS are your running? Is it possibly one (SELinux-based ones come to > mind) where permissions are not necessarily what control file access rights? I'm seeing the same problem and I'm running Ubuntu Intrepid which is indeed using apparmor. However, I'm struggling to find out how to relax apparmor's grip on this issue (assuming it's the one responsible for it which I've still not demonstrated). So any tips would be greatly welcomed! Cheers, Odie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to pass a string to a custom filter?
Hi all, I'm trying to pass a string to a custom tag to create custom breadcrumbs. I'm using as a base the snippet at http://www.djangosnippets.org/snippets/656/ and using the documentation from http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ But it seems that I'm not able to pass the URL as a string. In ... zsite/ancore/templatetags/mytags.py (zsite is the django project directory) I have: == #!/usr/bin/python # encoding: utf-8 from django import template from django.utils.safestring import mark_safe from django.utils.translation import ugettext from django.template.defaultfilters import stringfilter from types import * register = template.Library() @register.filter(name='dovesono') @stringfilter def dovesono(aurl): bc = u'' parti=aurl.split('/') bc= u' - %s - len=%d char= %s %s' % (parti[0],len(parti),aurl.count('/'),(type(aurl) == StringTypes)) for i in range(len(parti)): bc=bc+' '+parti[i] return mark_safe(bc) == In the calling template I have: == {% block breadcrumbs %} {% load mytags %} {{ request.get_full_path|dovesono }} {% endblock %} == and the generated html is: == - - len=1 char= 0 False == So (type(aurl) == StringTypes) is evaluated False What I'm doing wrong? What is the method to pass the actual url to a filter as a string? Thanks Mirto -- _ Busico Mirto Silvio Consulente ICT cell. 333 4562651 email [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 -~--~~~~--~~--~--~---
1.0 Transactions and Caching ...
I'm upgrading my .97 app to 1.0 and I'm trying to figure out transactions and caching ... In my app at present I have ... def event_editor(request): . return # Defeat caching for the event_editor function event_editor = cache_control(no_cache=True)(event_editor) # The transacton autocommit for event_editor event_editor = transaction.autocommit(event_editor) I'm reading the 1.0 docs and it seems to suggest that I use something like this instead ... @transaction.autocommit def event_editor(request): I'm just wondering whether this is a compulsory django upgrade. I didn't see it anywhere in the backwards compatibility listings. Can I leave things the way they are and have it working still ? What about caching ? Will that still work also ... ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Search Module
Aruns, The two most popular I know of are... djangosearch: http://code.google.com/p/djangosearch/ and django-sphinx: http://code.google.com/p/django-sphinx/ I hope that helps. -Kevin On Oct 14, 6:36 am, aruns <[EMAIL PROTECTED]> wrote: > similar to django "userprofile" is there any other module which i can > plug in and use the search functionality in my site ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Update_object and file uploads
> Since both file uploading and file storage has changed a bit between > 0.96 and 1.0, it's not surprising that pre-existing code doesn't work > without porting. Thanks Malcolm. I've read the docs on the new file storage and feel fairly comfortable with it, generally speaking--at least all my other code is ported over to use it with no problems. But I'm not seeing how it works with update_object, which appears to be just ignoring the new file altogether. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Data too long for column problem
but I found that I can not even store one Chinese word into the column with 100 bytes capacity. On Oct 14, 9:05 pm, "DULMANDAKH Sukhbaatar" <[EMAIL PROTECTED]> wrote: > chinese and some other complex or unicode characters takes more than > one byte to be stored. but as I know char(250) means 250 bytes or you > can store about 80 chinese chars if we assume 1 char takes 4 bytes. > then you need to change model, and manually alter table column. > > -- > Regards > Dulmandakh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Data too long for column problem
chinese and some other complex or unicode characters takes more than one byte to be stored. but as I know char(250) means 250 bytes or you can store about 80 chinese chars if we assume 1 char takes 4 bytes. then you need to change model, and manually alter table column. -- Regards Dulmandakh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Data too long for column problem
I encountered a problem: "data too long for column problem" when I input Chinese character in admin site Is there any encoding problem? Anyone know the reason? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Formset - How to avoid required field errors in extra forms
Hello again. I tried this: AsignacionItemFormset = formset_factory(AsignacionItemForm, can_delete=True, extra=0) initial_data = [] for item in initialdataquery: initial_data.append({...}) # Now I append an extra item with the defaul initial data initial_data.append({'asignacion_id':1}) formset = AsignacionItemFormset(initial=initial_data) I still get the 'required field' error for the forms. What I want to do here is let the user use the extra form to append a new item using some default values but that should be optional. On Oct 14, 6:09 am, gearheart <[EMAIL PROTECTED]> wrote: > hi > form is being cleaned only if it's values are different from initial > values, so debug. > btw, > you can't do form.field['..'].initial = '..' > initial must be dictionary, not list > > V. > > On Oct 14, 12:34 am, Federico H <[EMAIL PROTECTED]> wrote: > > > Hi, > > I'm using a formset with hidden fields in the forms and other required > > fields. Those fields need to be initialized with some value. When I > > try to validate the formset I get "required field" errors for those > > other required fields. The formset apparently thinks that the > > extraform is half filled (because of the initial data for the hidden > > fields). > > How can I avoid that behavior? > > Let me give you an example (may not be completely right cause I'm > > extracting the relevant parts of the original code): > > > class ItemForm(forms.Form): > > asignacion_id = forms.IntegerField(label="ID de la asignación", > > required=True) > > gondola = forms.ModelChoiceField(Gondola.objects.all(), > > required=True, label="Góndola") > > def clean_gondola(self) > > # Some code that uses asignacion_id > > > def myView(request): > > AsignacionItemFormset = formset_factory(ItemForm) > > formset = AsignacionItemFormset(request.POST, request.FILES) > > formset.is_valid() # Returns false with "required field" errors > > for the extra form > > ... > > if not request.POST: > > formset = AsignacionItemFormset(initial=[{'asignacion_id':1, > > 'gondola':gon_id}]) > > for form in formset.forms: > > form.fields['asignacion_id'].initial = 1 # To make sure > > every asignacion_id is initialized to 1 (even the extra ones) > > > I hope someone can help me with these. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: allowing users to create and edit content types without editing model classes
webcomm wrote: > I've been playing with django in recent weeks and have been impressed, > but there is one publishing/programming problem I'm not sure how I > would handle with django. I'm thinking of a site where dozens of > different users need to frequently create and edit content types. > > I have in mind a site where several dozen privileged users can create/ > edit event types and then allow hundreds of other users to submit > events that conform to those event types. Event types would > essentially be models that are associated with a template. The > privileged users would be able to edit templates via the interface and > associate each of their event types with a different template. > > I'm not sure how this could work since the server needs to be > restarted each time a model is edited. This is my first time working > with a framework that requires an apache restart each time a model is > changed, and I haven't built a production django site, so I'm not sure > if it's really feasible to build a site where apache might need to be > restarted dozens of times each day. I'm not sure if this creates > extra overhead and don't know if the restarts are somehow visible to > site visitors... or might in some way interfere with the user > experience. > > It seems like it might be possible to store all the data for all > events (regardless of event type) in a single table. The table would > have an ID column, a field ID column and a value column. Meanwhile, > the table for event types would have one column with all the field > metadata for that event type. The field metadata column could store a > list of lists, with each list consisting of a field ID (to reference > the event data table), a field definition and a field label. > Something like that. Such an approach would seem to make it possible > to handle a lot of event types without ever editing the model classes > in a models.py file... no? > > I'm wondering if the design I've described above is already in use in > some publicly available module/app that I could look at... or if there > are problems with this type of design. Or if there are other > approaches to the problem I've described. > It sounds as though you are on the right track. Essentially your models need to be complex enough to describe all possible events that your users might want to create. This should avoid the need to restart the database, but you may well find that you need several different tables (in much the same way your database uses several internal tables to describe the structure of your application data). 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Formset - How to avoid required field errors in extra forms
Hi, I have been debugin. I understand that assigning initial values directly to each form in the formset is not the way. One question other though. How would you go if you had to change the queryset of a ModelChoiceField inside the view code? Now, I'm doing form.fields['gondola'].queryset = gondola_qs for each form inside the formset On Oct 14, 6:09 am, gearheart <[EMAIL PROTECTED]> wrote: > hi > form is being cleaned only if it's values are different from initial > values, so debug. > btw, > you can't do form.field['..'].initial = '..' > initial must be dictionary, not list --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Freelance Django / Web Developer - Hiring Now
Hi, My name is Ronaldo and I live in Brazil. I'm so interrested in this position. I have free 10-30 hours peer, but, as you can see, I'm not able to go to the office in USA "often". I have about 10 years of experience in Linux and about 2 years in Python (4 mounths in Django). These are the Django features I know best: * Pagination * Seng mail * Session I started learning Django for fun and now I really want to work with this technology. So, with all that said, can I apply to this position? If so I'll send you my resume. Thanks. Ronaldo. On Tue, Oct 14, 2008 at 5:00 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > We're a small web development company based in San Francisco, USA and > Zurich, Switzerland. > > In order to deal with our growing list of clients and to help move > ahead our own products, we are looking for a passionate web developer > with django/python knowledge. > The workload is between 10 and 30 hours per week and we have a rather > flexible schedule most of the time. > We're looking for a long-term relationship with the option to increase > the workload in the future. > > What is required for this position? > > Basic shell scripting & Linux sys admin > Javascript (jQuery and/or prototype.js) > XHTML knowledge, CSS knowledge > and of course Django / Python. > > > We like individuals who like to question our requirements (and the > ones of the client) and propose better or more efficient solutions. > > What are we offering you? > > Interesting and meaningful work for clients and our own products. > Make your own decisions on what technology to use and how to approach > things. > excellent compensation for outstanding and on-time work. > > You'll be able to work from home most of the time. However we'd like > you to come to our office, located centrally in San Francisco for > brainstorming, sprints and other fun stuff. > > Do you think you can offer added value to our team? If so, please send > us your application, including a Résumé and your online work > references (indicate what you contributed to the particular site) to > [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 -~--~~~~--~~--~--~---
Freelance Django / Web Developer - Hiring Now
We're a small web development company based in San Francisco, USA and Zurich, Switzerland. In order to deal with our growing list of clients and to help move ahead our own products, we are looking for a passionate web developer with django/python knowledge. The workload is between 10 and 30 hours per week and we have a rather flexible schedule most of the time. We're looking for a long-term relationship with the option to increase the workload in the future. What is required for this position? Basic shell scripting & Linux sys admin Javascript (jQuery and/or prototype.js) XHTML knowledge, CSS knowledge and of course Django / Python. We like individuals who like to question our requirements (and the ones of the client) and propose better or more efficient solutions. What are we offering you? Interesting and meaningful work for clients and our own products. Make your own decisions on what technology to use and how to approach things. excellent compensation for outstanding and on-time work. You'll be able to work from home most of the time. However we'd like you to come to our office, located centrally in San Francisco for brainstorming, sprints and other fun stuff. Do you think you can offer added value to our team? If so, please send us your application, including a Résumé and your online work references (indicate what you contributed to the particular site) to [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 -~--~~~~--~~--~--~---
Search Module
similar to django "userprofile" is there any other module which i can plug in and use the search functionality in my site ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: passing data with urls.py
>>http://docs.python.org/lib/re-syntax.html >> >> There are several good books and websites that will teach you the >> basics of regexps, and a quick search will bring back a number of >> results. > > Thank alot thats the best response I have had. Glad to help...though in a way, it's as much a Python or regexp question as a Django question. > What is: one or more times "+" mean? It looks at the "atom" (atom is the word used to describe "a thing"...a single character, a set of characters, or other group of expressions designated as a single unit) before it. A few examples, as well as a counterpoint with "*" ("zero or more times") and the "{X}"/"{X,Y}" ("exactly X repetitions" and "between X and Y repetitions") notation. An empty string would match "^a*$" because it contains "zero or more "a"s. The string "foo" would match "^fooa*" because it's "foo" followed by zero or more "a"s. (note that "a" is the atom because it's what immediately precedes the "*") However neither the empty string nor "foo" would match if the "*" was now a "+" because you would need at least *one* (or more) "a"s. The string "" would match both "a*" and "a+" because there are "zero or more" of the letter a. As a more complex example, you can use something other than a single letter as an atom: The pattern "^[aeiou]*$" will only match strings that are all vowels or are empty, while "^[^aeiou]*$" will only match strings that are all consonants or empty. Changing the "*" to a "+" requires that there be at least one vowel/consonant for a match, and thus would fail to match the empty string. Lastly, just as an example of the "{...}" repetition items, the pattern "^\d{4}$" would match exactly 4 digits, while "^\w{5,15}$" would match 5-15 "word" characters (as previously described as alphanumerics plus underscore). > How would I pass the whole date like 12/25/2008, I is freaking out > about the '/'? You have to be careful how you pass these strings, but you could match such a pattern with "\d{1,2}/\d{1,2}/\d{4}" which can be wrapped in a named capture: "(?P\d{1,2}/\d{1,2}/\d{4})" for a view that takes a parameter of "start_date" Just remember that when it gets passed to your view: 1) it's a string, not a date 2) it's a pretty loose date pattern, so it does match "99/42/9876" so you'd have to try converting it to a date and then respond accordingly (if it's valid, then yay. if it's bogus, let the user know to fix it) I'll reassert that you would do well to read a couple web-tutorials or pick up a book on regular expressions. They're a very powerful tool in the programmer's tool-belt. Hope this helps, -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ManyToMany and Foreignkey fields together (django-admin)
I am deveoping with django for a film web site. I need help with using ManyToMany and Foreignkey fields together and connected to eachother. That is when "Heores" is selected from the foreignkey field, I want the names of actors in "Heroes" to be posted (by ajax or postback) Can I do this with the existing django admin forms structure? or do you know of any simlar application code or tutorial? 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: Formset - How to avoid required field errors in extra forms
hi form is being cleaned only if it's values are different from initial values, so debug. btw, you can't do form.field['..'].initial = '..' initial must be dictionary, not list V. On Oct 14, 12:34 am, Federico H <[EMAIL PROTECTED]> wrote: > Hi, > I'm using a formset with hidden fields in the forms and other required > fields. Those fields need to be initialized with some value. When I > try to validate the formset I get "required field" errors for those > other required fields. The formset apparently thinks that the > extraform is half filled (because of the initial data for the hidden > fields). > How can I avoid that behavior? > Let me give you an example (may not be completely right cause I'm > extracting the relevant parts of the original code): > > class ItemForm(forms.Form): > asignacion_id = forms.IntegerField(label="ID de la asignación", > required=True) > gondola = forms.ModelChoiceField(Gondola.objects.all(), > required=True, label="Góndola") > def clean_gondola(self) > # Some code that uses asignacion_id > > def myView(request): > AsignacionItemFormset = formset_factory(ItemForm) > formset = AsignacionItemFormset(request.POST, request.FILES) > formset.is_valid() # Returns false with "required field" errors > for the extra form > ... > if not request.POST: > formset = AsignacionItemFormset(initial=[{'asignacion_id':1, > 'gondola':gon_id}]) > for form in formset.forms: > form.fields['asignacion_id'].initial = 1 # To make sure > every asignacion_id is initialized to 1 (even the extra ones) > > I hope someone can help me with these. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Issue with starting a process in middleware
I didn't mean to imply no one was going to look at it. I'm sure it will get fixed. It's strange that on the surface nothing appears to be getting blocked but deep down something is getting deadlocked somewhere. If there is anything I can try to get more info let me know. Regards Bob > > > On Tue, 2008-10-14 at 08:21 +0100, [EMAIL PROTECTED] wrote: >> I did Google around but obviously missed this. Having read it and >> followed >> the links it is definitely the same issue. I will try and investigate >> but >> I think bigger brains than mine have already given up so I may have to >> find a dirty work round. Thanks for pointing me in the right direction. > > I suspect it's going to turn out to be something simple in the end, but > I must admit I haven't had a chance to sit down and look at that ticket. > It's sufficiently uncommon that my times been going elsewhere and I've > been hoping somebody seeing the problem will be able to make the time > and have the motivation to work out the cause. We'll certainly fix it > when we get a chance, so don't give up hope or anything, but there have > been a few higher-impact bugs around that I know I've been spending my > available time on first. > > Regards, > Malcolm > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: HTTPS Service for Django
On Tue, 2008-10-14 at 00:19 -0700, Harish wrote: > Hi Friends, > > I configured a django site using apache, which is running on Fedora 9. > Now I want to enable the > HTTPS (secured ) service on that site > > Any ideas on how to achieve this? There's nothing Django specific about this. In fact, Django isn't involved at all. Just configure your webserver to accept HTTPS connections and you're done. That is documented in a number of places, including the Apache documentation, so that's a good place to look. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
On 13 Oct 2008, at 7:09 pm, Django users wrote: >> I am a newbie of django, and want to know which IDE is suit for >> django? >> >> thank your Textmate on OS X -- David Reynolds [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: separate users from django admin'able users
On Mon, 2008-10-13 at 19:39 -0700, tvaughan wrote: > let's say i'm building and on-line sudoku game. i want two types of > users. the first are those users that would play the game. and the > second are those that are built-in django users who would use the > django admin interface to mange the data model (create games). > > is the typical pattern to use the built-in django user model for the > first type of user described above? i'm a little weary of mixing the > two where the only thing that separates them is the is_superuser > field. i would expect two completely separate user tables with > separate permissions. I think you're worrying about the sky falling a bit too much here. What does "completely separate permissions" really mean? Probably no more than one of the classes of users has an extra bit of permission that allows them to use the admin interface (the extra permission is what makes it a different class of users). If you split them into separate tables, you're going to have tons of duplicated logic (introducing extra bugs). You'll also either needing to copy every using from the standard table to your extra table, or make every use who uses django admin have to create another (unprivileged) account just to play a game. Letting your admins also use the site would usually be considered a good thing. Django's user system is designed to handle privileged and unprivileged users. What problem are you actually worried about? 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 -~--~~~~--~~--~--~---
check if request.url is a known string
I have a menu with a class="active" to insert when a page is loaded. I am searching a way to put this class="active" when a page (flatpage, generic or custom view) is the same of the link. something like: {% ifequal request.url "/ricerca/" %} class="active" {% endif %} is it possible? and is it possible to do a ifcontains to get '/ricerca/' and '/ricerca/?search="text"' ? where can I get the request url? -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo Software e Sistemi Open Source Sede: Via Poggiali 2/bis, 47100 Forlì (FC) Tel.: +39 0543 798985 - Fax: +39 0543 579928 Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: a bug about models EmailField
Wiadomość napisana w dniu 2008-10-14, o godz. 09:43, przez [EMAIL PROTECTED] : > > I meet a bug in django1.0 > > class Reporter(models.Model): >name = models.CharField(max_length=100) >email = models.EmailField() > >def __unicode__(self): >return '%s : %s ' % (self.name, self.email) > > r1 = Reporter() > r1.name = 'edison' > r1.email = 'x' > r1.save() > r1.id = 1 > > Why it can be save ? > there's not a valid email, Not a bug. Model-level validation does not exist in current Django. Sorry. -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R, Redefine [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: Issue with starting a process in middleware
On Tue, 2008-10-14 at 08:21 +0100, [EMAIL PROTECTED] wrote: > I did Google around but obviously missed this. Having read it and followed > the links it is definitely the same issue. I will try and investigate but > I think bigger brains than mine have already given up so I may have to > find a dirty work round. Thanks for pointing me in the right direction. I suspect it's going to turn out to be something simple in the end, but I must admit I haven't had a chance to sit down and look at that ticket. It's sufficiently uncommon that my times been going elsewhere and I've been hoping somebody seeing the problem will be able to make the time and have the motivation to work out the cause. We'll certainly fix it when we get a chance, so don't give up hope or anything, but there have been a few higher-impact bugs around that I know I've been spending my available time on first. 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 -~--~~~~--~~--~--~---
a bug about models EmailField
I meet a bug in django1.0 class Reporter(models.Model): name = models.CharField(max_length=100) email = models.EmailField() def __unicode__(self): return '%s : %s ' % (self.name, self.email) r1 = Reporter() r1.name = 'edison' r1.email = 'x' r1.save() r1.id = 1 Why it can be save ? there's not a valid email, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
HTTPS Service for Django
Hi Friends, I configured a django site using apache, which is running on Fedora 9. Now I want to enable the HTTPS (secured ) service on that site Any ideas on how to achieve this? Thanks Harish Bhat --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Issue with starting a process in middleware
I did Google around but obviously missed this. Having read it and followed the links it is definitely the same issue. I will try and investigate but I think bigger brains than mine have already given up so I may have to find a dirty work round. Thanks for pointing me in the right direction. Bob > > > On Mon, 2008-10-13 at 21:53 +0100, Bob Cowdery wrote: >> Hi all >> >> Just starting out on Django. I have an app that needs a long running >> process. This is a python process that gets started from some code that >> I kick off from __init__ in a middleware class. Is there another way to >> do this? I just use subprocess.Popen() to start the other process. >> Everything returns fine, the process starts ok but my Django app hangs. >> It never finishes the download of some javascript files although the >> server thinks it sent them. If I don't start the other process or just >> let it exit after a short time my app comes back to life. I really don't >> understand what's going on. It's nothing the other app is doing as it >> happens with just an empty loop. Any ideas? > > You might be hitting bug #9286, which hasn't been diagnosed or solved as > yet. That assumes you're trying to start your other process as a daemon > (so what you're calling in Popen() should return immediately). > > Regards, > Malcolm > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: No module named core
On Tue, 2008-10-14 at 00:10 -0700, [EMAIL PROTECTED] wrote: [...] > and here is the error: > > $ django-admin.py > Traceback (most recent call last): > File "/home/username/projects/django/trunk/django/bin/django- > admin.py", line 2, in ? > from django.core import management > ImportError: No module named core So either your copy of Django isn't complete, or your Python path is not pointing to the right place. Look at the directories you've specified in your Python path and make sure that one of them contains a subdirectory setup that contains, in part: django/ __init__.py core/ __init__.py <... lots of other files ...> <... lots of other files ...> 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 -~--~~~~--~~--~--~---
No module named core
Hello, I attempted to setup django on dreamhost using Gordon Tillman's instructions a while ago but had problems and have been unable to resume the process. I left off with getting an ImportError and have not been able to figure it out. If anyone has resolved this problem or can help me out I would appreciate it. Here is my bash_profile: # ~/.bash_profile: executed by bash(1) for login shells. umask 002 PS1='[\h]$ ' export PATH=$HOME/bin:$HOME/projects/django/trunk/django/bin:$PATH export PYTHONPATH=$HOME/projects:$HOME/projects/django/trunk:$HOME/ projects/flup/trunk:$PYTHONPATH and here is the error: $ django-admin.py Traceback (most recent call last): File "/home/username/projects/django/trunk/django/bin/django- admin.py", line 2, in ? from django.core import management ImportError: No module named core Thanks, Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: fastCGI: always one server per site ?
> > I am afraid that single pool of fcgi resources is not currently possible for > > multiple django sites. Maybe it would be possible if someone wrote a > > specific script/wrapper for Django but, I guess, it would create more risks > > (think about thread safety) than benefits. > > It is only possible with mod_python/mod_wsgi because they use C API of > Python to create additional sub interpreters within same process. > There is no feature/module available to Python code to do the same > thing. It would be possible to create special C extension module that > allowed it but transferring request from context of sub interpreter > which accepting the request to another sub interpreter would be tricky > and you could run into lots of problems as a result of data sharing > between interpreters. Much clearer in my mind, thanks > > > > However, I read on a blog from Graham > > >http://www.technobabble.dk/2008/aug/25/django-mod-wsgi-perfect-match/ > > > > That there is a lot of shared libs between the various fcgi processes/ > > > servers, so it doesn't matter much to have unused processes/servers. > > Dynamically loadable shared libraries even though loaded by > independent process instances will be mapped only once by operating > system. In the larger scheme of things this doesn't help, as each > Django process may still have many tens of MBs of local process > private memory due to Python code caching and application data. It is > this latter memory usage which is the real problem. I see. Thanks. > Graham > > > > The issue being that, of course, I don't know in advance which site is > > > going to be inactive and that's likely to change from one day to the > > > other. Not to mention that changing the number of spare servers > > > manually isn't very high on the list of things I like to do on a daily > > > basis ;) > > > I meant that maxspare=NUMBER sets maximum number of free/idle processes. If > > the load grows new processes are spawned. When the load drops unneeded > > processes are killed. > > > Valts. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: fastCGI: always one server per site ?
On Tue, Oct 14, 2008 at 8:15 AM, Graham Dumpleton < [EMAIL PROTECTED]> wrote: > Dynamically loadable shared libraries even though loaded by > independent process instances will be mapped only once by operating > system. Thanks for the explanation. Valts. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Highlight current active page
Alex, As the docs state, you can place code in a {% block [name] %} and it gets overwritten when another template has that block defined. This is the base.html: http://paste.pocoo.org/show/87935/ This is a subnavigation with a different active 'tab' in the navigation bar called base_product.html: http://paste.pocoo.org/show/87936/ As you can see the second overwrites the navbar, and they both have the 'content' block. So when you have content in a sub page for the order 'tab', you define the actual content in another file that looks like this: http://paste.pocoo.org/show/87937/ And so the relation is: base.html > base_order.html > order_detail.html Resulting in this: http://paste.pocoo.org/show/87938/ Then in your CSS file you can give the active li a different color. Hope it helps! Regards, Gerard. Alex Rades wrote: > Hi Gerard, > sorry but I don't understand your setup. > Could you show us some sample code which does the actual navigation list? > > Thank you very much for your time > > On Tue, Sep 30, 2008 at 1:53 PM, Gerard Petersen <[EMAIL PROTECTED]> wrote: >> Hi All, >> >> I don't understand why it's needs to be so complicated. When using a >> 'double' template inheritance, e.g: base > base_products > product_add >> >> There's only one place where you have to maintain some navlist html/css >> code. This is where the 'active' attribute is maintained. So with multiple >> sections like: product, customer, invoices youre hierarchy looks like this: >> >> base.html >>base_product.html (extends base.html) >>product_add.html(extends base_product.html) >> >>base_customer.html >>etc ... >> >>base_invoice.html >>etc ... >> >> >> This comes straight from the docs: >> http://docs.djangoproject.com/en/dev/topics/templates/#id1 >> (See 'base_SECTIONNAME.html' about two screens down from there) >> >> I personally dont' see the needs for loops and extra code. Or is my app to >> simple ... :-) >> >> Regards, >> >> Gerard. >> >> Steven Armstrong wrote: >>> Alex Rades wrote on 09/30/08 09:03: Hi, what kind of pattern do you use to add a class attribute to the current page being viewed? I mean the usual: Home Products FAQ contact us I have this snipped of html defined in the base template and all pages inherit from it. Currently I'm using this templatetag: http://gnuvince.wordpress.com/2007/09/14/a-django-template-tag-for-the-current-active-page/ while it's very useful, I don't like it too much, so I'm asking you what is the best practice here. >>> I usually do that through a css switch on the body tag. >>> e.g. >>> >>> base template: - >>> >>> >>> Home >>> Products >>> FAQ >>> contact us >>> >>> >>> >>> >>> css: - >>> #section-home #nav-home a, >>> #section-products #nav-products a, >>> #section-faq #nav-faq a, >>> #section-contact #nav-contact a { >>>background-color: blue; >>> } >>> >>> >>> products template: - >>> {% block section %}products{% endblock %} >>> >>> >>> faq template: - >>> {% block section %}faq{% endblock %} >>> >>> >>> hth >>> Cheers >>> Steven >>> >> -- >> urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' } >> >> > > > -- urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Multiple relationships between multiple tables
On Mon, 2008-10-13 at 15:46 +0300, Necmettin Begiter wrote: > Hello all, > > I have, say, 8 tables: Persons, works, phones, emails, addresses, > eaddresses, articles, books. > > Each one may have relationship with another one, like so: > > A person may have more than one work, phone, email, address, eaddress, > article and book. > A phone, email, address, eaddress, .. may be related to more than one > persons. > > So, here is a sample model: > > class Relations(models.Model): > srctbl = models.CharField(max_length=2, choices=TBL_CHOICES) > srcidx = models.IntegerField() > tgttbl = models.CharField(max_length=2, choices=TBL_CHOICES) > tgtidx = models.IntegerField() > > But there's a *slight* problem here. Possible values for *idx fields > must change when *tbl are changed, like so: > > If I select Person for srctbl, srcidx must contain names of possible > persons; if I select Phone for srctbl, srcidx must contain possible > phone numbers. And this is the same for tgt* fields. I have been > looking around Django Docs and references for a while now, but > couldn't come with a solution. IntegerField()s must actually be like > ForeignKey(Person or Phone or Email or Address or eAddress) .. Any > ideas on how to achieve this? Use GenericRelations and GenericForeignKeys. They store a reference to the content type and object_id, so they emulate polymorphic database relations. That's just talking about the modelling at the database level, however. How you represent that to the user in forms is up to you. 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 -~--~~~~--~~--~--~---