Re: South trunk with Django trunk? (wierd error)
2010/2/20 Norbert Wójtowicz : > Howdy, > Just started a new project with Django trunk (have been using Django 1.1 > lately, so please bare with me). > After I got a basic setup going I installed the latest release of south, but > that bombed spectacularly with database errors in settings.py. ... > I'd really appreciate any guidance or divine intervention. The best guidance I can offer is to ask your question in the right place. While Django-users might be able to answer your question, your odds are much higher on the South-dedicated mailing list [1]. [1] http://groups.google.com/group/south-users Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
deleting all cookies and sessions for my domain
Hello, I want to wrap the django.contrib.auth.views.logout so that it also deletes all the cookies for my domain, this is my wrapped logout method. def grupsal_logout(request, **kwargs): from django.contrib.auth.views import logout from django.core.urlresolvers import reverse response = logout(request, next_page=reverse('myapp.views.index_view')) response.delete_cookie('user_location') return response It doesn't seem to work. How can I achieve this ? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
I cannot see the raw SQL queries Django is running?
I am running on my dev machine, working with Django 1.1, Python 2.5.2, Mysql 5.0. My settings.py file has DEBUG = True I have done this: $ cd project-dir $ python manage.py shell >>> from django.db import connection >>> connection.queries All that happens is I get a [] result, and am back to the Python prompt (>>>). No queries, as shown here: http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running are ever displayed, as I browse Admin, edit records etc. What else do I need to do? Thanks Derek -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: I cannot see the raw SQL queries Django is running?
On Feb 20, 11:37 am, Derek wrote: > I am running on my dev machine, working with Django 1.1, Python 2.5.2, Mysql > 5.0. > > My settings.py file has DEBUG = True > > I have done this: > > $ cd project-dir > $ python manage.py shell > > >>> from django.db import connection > >>> connection.queries > > All that happens is I get a [] result, and am back to the Python prompt > (>>>). > > No queries, as shown > here:http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-ra... > > are ever displayed, as I browse Admin, edit records etc. > > What else do I need to do? > > Thanks > Derek connection.queries only shows the queries executed in the current process - so if you call some ORM functions in your shell, you will see the SQL there. You won't see the queries from your server process in the shell. If you do want to see the queries the server is running, your best bet is to install the Django debug toolbar: http://github.com/robhudson/django-debug-toolbar -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: simple, input from user and database earch result
What do you mean by : > > The have the view that the form posts back to put the result of the search > > in the generated HTML for the result. What is the name of view, in which folder. My question was: > > 1> 2 > > > On line 1 user put a word > > On line 2 user start search in database > > I would like to get the result of the search printed back in the same > > field on the line 1. >From the examples of Django the search result is printed below on the webpage, but not in the same field where search was performed. if you could paste code of any example it would be grate. gintare On 17 Vas, 18:10, Malcolm Box wrote: > On Wed, Feb 17, 2010 at 3:12 PM, gintare wrote: > > > One more simple question: > > > Is it possible that area which is used for data submission also can be > > updated from python script. > > It's not clear what you mean by this. The python (Django) script isn't > running in the webbrowser, so it can't update the webbrowser unless the > browser makes a HTTP request and then renders the response. > > > 1 > 2 > > > On line 1 user put a word > > On line 2 user start search in database > > I would like to get the result of the search printed back in the same > > field on the line 1. > > > The have the view that the form posts back to put the result of the search > > in the generated HTML for the result. > > 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Making a User Registration form
It's really not that difficult. You can just override the save() method and create the Profile there. class RegistrationForm(forms.ModelForm): class Meta: model = User def save(self): user = super(RegistrationForm, self).save() profile = Profile.objects.create(user=user) char.save() return user On Feb 19, 10:22 pm, Wiiboy wrote: > That doesn't look like it helps a whole lot actually. I don't see > where I can create a registration form including my custom profile > model. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Making a User Registration form
Sorry... char.save() should read profile.save() On Feb 20, 9:05 am, Tim Shaffer wrote: > It's really not that difficult. You can just override the save() > method and create the Profile there. > > class RegistrationForm(forms.ModelForm): > > class Meta: > model = User > > def save(self): > user = super(RegistrationForm, self).save() > profile = Profile.objects.create(user=user) > char.save() > return user > > On Feb 19, 10:22 pm, Wiiboy wrote: > > > > > That doesn't look like it helps a whole lot actually. I don't see > > where I can create a registration form including my custom profile > > model. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: anybody tried web2py and gone back to Django?
On Sat, Feb 20, 2010 at 11:56 AM, Russell Keith-Magee wrote: > Yes, I are > free to choose whatever license you want for your own code, but the > terms of the GPL mean that your own choice of license on your own > project *may* affect whether or not I can distribute Web2py along with > my code. Let's try that sentence again, this time without the pronoun dance: Yes, I am free to choose whatever license I want for my own code, but the terms of the GPL mean that my choice of license on my own project *may* affect whether I can distribute Web2Py along with my code. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
one form, many submits
Hi all, I have a view that iterates over a queryset to produce a list of items. I have added a checkbox next to each item (from within the template) and have multiple 'submit' buttons that will do different things with the items selected. For example, one button will delete all the items selected. My question is how can I detect which of the submit buttons has been pressed? Is there some property of 'request' that I can access that will tell my view which action to peform on the selected items? The only likely property I can see is QUERY_STRING, but I cannot seem to come up with any info on what this is or how to set it. Any thoughts would be greatly appreciated. Thanks, Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Making a User Registration form
Wait, but do profile fields get displayed as part of the form? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Making a User Registration form
On Feb 20, 2010, at 10:11 AM, Wiiboy wrote: > Wait, but do profile fields get displayed as part of the form? This is Django. It can do whatever you want it to. Django-registration was specifically written to be reusable so that, for example, templates can be overridden with your own. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passenger 57 - a Django query problem
Lol..c'mon Bruno, we just resolved this. Stop attacking Emily. You admitted in your email to me that you could be, in your own words, an "asshole" sometimes, that your words were "uselessly harsh", and that Emily was right. Why come onto the thread and attack her again? I declare this matter closed: let's all behave like mature grown-ups. This is not a primary school lunch break where we must eat each other's peanut butter sandwiches and push the girls around. Now, hug and make up before you sit in the corner.. [?] On Fri, Feb 19, 2010 at 10:51 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > On 18 fév, 12:16, Emily Rodgers > wrote: > (snip) > > I think he stopped helping when he started using phrases like 'crystal > > ball' and 'wild-guess programming'. They are hostile responses. > > > > Emily, if you manage to stick to your wishfull words for the next ten > years without even a single possibly "hostile" answer, then you'll > prove you're a better human being than I'm - needless to say, I whish > you'll succeed. In the meantime, please reserve your judgments, or > you're going to fail right from the start... > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. <<35D.gif>>
Re: Making a User Registration form
> Wait, but do profile fields get displayed as part of the form? Just add them to RegistrationForm and they will. Or create another form class for Profile, and use the fields from that to populate the Profile... {{ reg_form.as_p }} {{ profile_form.as_p }} On Feb 20, 10:22 am, Shawn Milochik wrote: > On Feb 20, 2010, at 10:11 AM, Wiiboy wrote: > > > Wait, but do profile fields get displayed as part of the form? > > This is Django. It can do whatever you want it to. > > Django-registration was specifically written to be reusable so that, for > example, templates can be overridden with your own. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: one form, many submits
On Sat, Feb 20, 2010 at 06:42:11AM -0800, Tom wrote: > Hi all, > > I have a view that iterates over a queryset to produce a list of > items. I have added a checkbox next to each item (from within the > template) and have multiple 'submit' buttons that will do different > things with the items selected. For example, one button will delete > all the items selected. > > My question is how can I detect which of the submit buttons has been > pressed? Is there some property of 'request' that I can access that > will tell my view which action to peform on the selected items? > That is more a html thing than a django thing. Non-stone-age browsers will pass the particular submit button used for a form with multiple submits - and only that button - as only that button is "successful" (IIRC old IE used to do some wierd/dumb thing involving the name and/or value but I've largely suppressed the memory...) http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 (aside: You'll also still come across some ancient html tutorials claiming forms are allowed exactly one submit button, that is untrue) http://www.w3.org/TR/html401/interact/forms.html#submit-button i.e. given a POSTed form with two submit buttons Check request.POST.get('cancel') to see if cancel was clicked, and request.POST.get('accept') to see if accept was clicked. (remember someone curious can nonetheless construct a post request with both accept and cancel just to see if your server logic falls over in exploitable fashion) While django doesn't actually handle input type=submit for you, there are "SubmitField" snippets floating about. They may have advantages (e.g. form prefix handling, could in theory refuse to validate if more than one SubmitField of the form was successful from a malicious client, and maybe supply workarounds for that IE annoyance I only vaguely recollect), but may be overkill - you could e.g. just pass a "submit" dictionary down to the template, with a key and value to use as the name of various submit buttons (just to avoid hardcoding in the template) i.e. the above becomes (assuming you've stuck the submit dictionary on the form): -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passing parameters from child models
Hi Bruno, Thanks for you candor. Yeah. I appreciate I'm not that that great at the moment. By having the usertype id would therefore make the usertype specific attributes much easier to access, such as showing the usertype name in the templates. So if my usertype model is this: class UserType(models.Model): id = models.CharField(max_length=3, primary_key=True) name = models.CharField(max_length=30) def __unicode__(self): return u'%s' % (self.name) I just have to use this (using a userprofile this time): {{ user.get_profile.usertype }} ... rather than this... if hasattr('user','teacher'): current_type = "Teacher" elif hasattr('user','student'): current_type = "Student" elif . everytime I want to find out what type of user I am dealing with. Anyway. Cheers for the code. ALJ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Making a User Registration form
Ok, I think that'll work. I'll try 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slugify() and Clean form data Questions
> Folks, A few days ago I asked: > Is there a canonical definition or even a reference > implementation of a slug = slugify(str) function somewhere? Thanks for taking the time to answer that for me! We pretty much beat the answer into my thick skull: Use the slugify() function as per "from django.template.defaultfilters import slugify". What about my second question from earlier?: > Is there a standard clean_user_input() that accepts direct user > input from a form text field and de-gunks it so that it is later > acceptable to be re-emitted as HTML formatted data without worry > of hacking issues? I am looking form something more clever than > simply validating the user's input to conform to "is a number" or > "is a text field" sorts of thing. I'm specifically looking for a > function that strips out embedded scripting, SQL, HTML, etc hackery. > Sure, I'd then like to use it to verify clean form input of course. How do people ensure safe user input from their forms? Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: one form, many submits
David, thanks for that. I ended up going for the simple HTML method because, as you guessed, the SubmitField idea was a bit unwieldy for my needs. Thanks for your help! Tom On 20 Feb, 15:37, David De La Harpe Golden wrote: > On Sat, Feb 20, 2010 at 06:42:11AM -0800, Tom wrote: > > Hi all, > > > I have a view that iterates over a queryset to produce a list of > > items. I have added a checkbox next to each item (from within the > > template) and have multiple 'submit' buttons that will do different > > things with the items selected. For example, one button will delete > > all the items selected. > > > My question is how can I detect which of the submit buttons has been > > pressed? Is there some property of 'request' that I can access that > > will tell my view which action to peform on the selected items? > > That is more a html thing than a django thing. > > Non-stone-age browsers will pass the particular submit button used > for a form with multiple submits - and only that button - as only > that button is "successful" (IIRC old IE used to do some wierd/dumb > thing involving the name and/or value but I've largely suppressed the > memory...) > > http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 > > (aside: You'll also still come across some ancient html tutorials claiming > forms are allowed exactly one submit button, that is > untrue)http://www.w3.org/TR/html401/interact/forms.html#submit-button > > i.e. given a POSTed form with two submit buttons > > > > > Check request.POST.get('cancel') to see if cancel was clicked, > and request.POST.get('accept') to see if accept was clicked. > > (remember someone curious can nonetheless construct a post request > with both accept and cancel just to see if your server logic > falls over in exploitable fashion) > > While django doesn't actually handle input type=submit for you, > there are "SubmitField" snippets floating about. They may have advantages > (e.g. form prefix handling, could in theory refuse to validate > if more than one SubmitField of the form was successful from a > malicious client, and maybe supply workarounds for that IE annoyance > I only vaguely recollect), but may be overkill - you could e.g. just > pass a "submit" dictionary down to the template, with a key and value > to use as the name of various submit buttons (just to avoid > hardcoding in the template) i.e. the above becomes (assuming you've > stuck the submit dictionary on the form): > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passenger 57 - a Django query problem
I wonder what Atamert the peacemaker has to say now, since the person to whose defense he came admitted he was wrong. Amazing to note that Atamert noticed my directness to Bruno, but did not notice how nasty Bruno was to other respondents (namely Emily and Derek). What have you to say, o' wise Atamert? On Thu, Feb 18, 2010 at 11:25 AM, Atamert Ölçgen wrote: > Hi Sithembewena, > > > On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote: > > Emily provided an answer according to what she understood from the OP. No > > harm in doing that, at least not worse than no attempt at giving a > > solution.. > > > > I think that people who have a problem with posts, even vague ones, > should > > stay away from them - let those that would try to help, to do so > > unhindered.. > > > > We have no interest in your personal coding style: attempt to help, or > stay > > away. > Bruno is trying to help in his own way. Let's not be unkind to each other > like > that. > > Also, please use your e-mail app's **draft** feature and send your reply > when > it's **done**. > > > -- > Saygılarımla, > Atamert Ölçgen > > -+- > --+ > +++ > > www.muhuk.com > mu...@jabber.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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
mouse events and view.py
How correctly define syntax for the event in templates? I want that all text in the text area would be send to the python function "search2" after i paste text or click mouse. After making changes the text has to be pasted back to the same form. Is it possible with python or i need java script? Bellow is view.py and diction.html which do not work, i.e. line: " print "search2", search2, query " do not print in terminal words which i pasted to the text area. ##diction.html ##views.py def search2(request): query = request.GET.get('Lpasted', '') print "search2", search2, query t=get_template(Tdiction.html) html=t.render( Context({'Lpasted':sentenc}) ) return HttpResponse(html) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: one form, many submits
You could also go with a column called "Execute" and a checkbox for the actions you want to execute and then a single submit button that grabs all the checked actions. But I think the other way is probably more intuitive. -Tim On Sat, Feb 20, 2010 at 10:45 AM, Tom wrote: > David, thanks for that. I ended up going for the simple HTML method > because, as you guessed, the SubmitField idea was a bit unwieldy for > my needs. > > Thanks for your help! > > Tom > > On 20 Feb, 15:37, David De La Harpe Golden > wrote: > > On Sat, Feb 20, 2010 at 06:42:11AM -0800, Tom wrote: > > > Hi all, > > > > > I have a view that iterates over a queryset to produce a list of > > > items. I have added a checkbox next to each item (from within the > > > template) and have multiple 'submit' buttons that will do different > > > things with the items selected. For example, one button will delete > > > all the items selected. > > > > > My question is how can I detect which of the submit buttons has been > > > pressed? Is there some property of 'request' that I can access that > > > will tell my view which action to peform on the selected items? > > > > That is more a html thing than a django thing. > > > > Non-stone-age browsers will pass the particular submit button used > > for a form with multiple submits - and only that button - as only > > that button is "successful" (IIRC old IE used to do some wierd/dumb > > thing involving the name and/or value but I've largely suppressed the > > memory...) > > > > http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 > > > > (aside: You'll also still come across some ancient html tutorials > claiming > > forms are allowed exactly one submit button, that is untrue) > http://www.w3.org/TR/html401/interact/forms.html#submit-button > > > > i.e. given a POSTed form with two submit buttons > > > > > > > > > > Check request.POST.get('cancel') to see if cancel was clicked, > > and request.POST.get('accept') to see if accept was clicked. > > > > (remember someone curious can nonetheless construct a post request > > with both accept and cancel just to see if your server logic > > falls over in exploitable fashion) > > > > While django doesn't actually handle input type=submit for you, > > there are "SubmitField" snippets floating about. They may have advantages > > (e.g. form prefix handling, could in theory refuse to validate > > if more than one SubmitField of the form was successful from a > > malicious client, and maybe supply workarounds for that IE annoyance > > I only vaguely recollect), but may be overkill - you could e.g. just > > pass a "submit" dictionary down to the template, with a key and value > > to use as the name of various submit buttons (just to avoid > > hardcoding in the template) i.e. the above becomes (assuming you've > > stuck the submit dictionary on the form): > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passenger 57 - a Django query problem
So, Atamert, Bruno admitted he was wrong. What have you to say?? It's strange that you noticed i was direct with him,but you did not seem to notice how harsh he was to Emily and Derek?? Anyways, peace.. On Thu, Feb 18, 2010 at 11:25 AM, Atamert Ölçgen wrote: > Hi Sithembewena, > > > On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote: > > Emily provided an answer according to what she understood from the OP. No > > harm in doing that, at least not worse than no attempt at giving a > > solution.. > > > > I think that people who have a problem with posts, even vague ones, > should > > stay away from them - let those that would try to help, to do so > > unhindered.. > > > > We have no interest in your personal coding style: attempt to help, or > stay > > away. > Bruno is trying to help in his own way. Let's not be unkind to each other > like > that. > > Also, please use your e-mail app's **draft** feature and send your reply > when > it's **done**. > > > -- > Saygılarımla, > Atamert Ölçgen > > -+- > --+ > +++ > > www.muhuk.com > mu...@jabber.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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: what is the name of your super class?
This is strange. When I duplicate your code, thanos, I get an error that says: AttributeError: SubClass instance has no attribute '__bases__' What's different about my setup? I'm running Python 2.5.3 -Tim On Fri, Feb 19, 2010 at 6:43 PM, thanos wrote: > How about: > > >>> class MySuperClass: pass > ... > >>> class MySubClass(MySuperClass): pass > ... > >>> c = MySubClass > >>> > >>> c.__bases__[0].__name__ > 'MySuperClass' > >>> > > What I always ask develoeprs hwo join my team is "Please read the > Language Reference!" Its a great read, I'm not joking and your answer > is there some where under Data Model. > > > Thanos > > > > > > On Feb 19, 5:51 pm, Joel Stransky wrote: > > Bit of a python question here. > > Say I have a class named MySuperClass and an extension of that class > called > > MySubClass. When referring to MySubClass (the class, not an instance of > it), > > how would I retrieve the class name of its super class. > > > > For instance if I had: > > c = MySubClass > > > > I'd like to know if there is a method that would work to the effect of: > > b = superclassname(c) > > which would return MySuperClass > > > > Thanks. > > > > -- > > --Joel Stransky > > stranskydesign.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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: mouse events and view.py
El 20/02/10 19:11, gintare escribió: > Is it possible with python or i need java script? You need javascript. -- Gonzalo Delgado -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Regression
What are best practices to regress django views? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passenger 57 - a Django query problem
On Sun, Feb 21, 2010 at 4:11 AM, Sithembewena Lloyd Dube wrote: > I wonder what Atamert the peacemaker has to say now, since the person to > whose defense he came admitted he was wrong. Amazing to note that Atamert > noticed my directness to Bruno, but did not notice how nasty Bruno was to > other respondents (namely Emily and Derek). > > What have you to say, o' wise Atamert? Ok, I'm stepping in here. Emily is right - this sort of tone is *exactly* what we don't want on Django users. Django-users has historically been a very friendly place. I don't want that to change. Bruno; Lloyd; Atamert - at this point, I don't care who started it. When you wrestle in mud, everyone gets dirty - even the bystanders. So Stop. Now. If you want to have some petty name calling argument, take it somewhere else. If you persist in posting to django-users with anything other than helpful responses to the original question, I will start banning accounts. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Treat two fields as one in a queryset
Given a model like: class Item(models.Model): title = models.CharField(max_length=140) created_date = models.DateTimeField(default=datetime.datetime.now) completed = models.BooleanField(default=False) completed_date = models.DateTimeField(blank=True,null=True) ... I want to create a queryset that retrieves the last 30 Items that were either created OR completed most recently. In other words, the created_date and the completed_date fields need to be treated as if they were a single date field on the model, so that the returned items would be chronological by either date (completed_date would only be considered for items where completed=True) I've tried both: .order_by('-completed_date','-created_date')[:30] and .order_by('-completed_date').order_by('-created_date')[:30] but neither of these are quite right. Not sure what the right approach to this should be. Suggestions? Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: photos
2010/2/21 : > Photos > > bisou > Ariel > > > > -- > Infomed - Red de Salud de Cuba > http://www.sld.cu/ > > > -- > > Este mensaje le ha llegado mediante el servicio de correo electronico que > ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema > Nacional de Salud. La persona que envia este correo asume el compromiso de > usar el servicio a tales fines y cumplir con las regulaciones establecidas > > Infomed: http://www.sld.cu/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > Interesting thing is, the guy on the photo has "django colours" t-shirt :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: what if I need to use two objects to get a third object in my templates?
Hm. Looks like the with tag would help with this, as it accepts filtered values: {% with person|get_obj:col|gt:too_large as val_too_large %} {% if val_too_large %} ... {% endif %} {% endwith %} On Feb 19, 10:55 am, Daniel Wong wrote: > Thanks, Roseman. I was hoping I wouldn't have to resort to custom > filters or tags, because it obfuscates template code that should be > really simple. Also, I don't think filters can be applied to this > slightly modified example: > > {% for person in people %} > > {% for col in columns %} > too_large %} class="too-large"{% endif > %}> > {{ person.get(col) }} > > {% endfor %} > {% endfor %} > > I know Django templates were intentionally designed to disallow > passing arguments to methods; therefore, I'm assuming there must be a > clean way of implementing this example that I'm just not aware of. > > On Feb 19, 12:27 am, Daniel Roseman wrote: > > > On Feb 19, 8:04 am, Daniel Wong wrote: > > > > Seems like there's no good way to do this, because you can't call > > > methods that take > 0 arguments. > > > > Here's an example of the sort of thing I'm trying to do. Imagine > > > you're trying to create a spreadsheet like view: > > > > {% for person in people %} > > > > > > {% for col in columns %} > > > {{ person.get(col) }} > > > {% endfor %} > > > {% endfor %} > > > > Seems like you'd have to use custom tags to achieve this, but that > > > seems way too complicated for something so simple. Is there a better > > > way? > > > Writing a custom filter for this is the correct way - and it's a three- > > line job: > > > @register.filter > > def get_obj(obj, value): > > return obj.get(value) > > > -- > > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django CMS
Hi, I'm learning Python (coming from Perl) and I discovered Django this weekend! What I'd like to do is to have a Django based CMS system! I notice here http://code.djangoproject.com/wiki/CMSAppsComparison that I have a choice ;-) I'd like to import, my stories from Geeklog, the stories are in MySQL and I'd simply like to convert them so that the stories, links etc (as much as possible) is available in the new Django based CMS. Does anyone have any experience with Django based CMS that they would recommend and especially if I could import the stories from Geeklog ? Thanks very much for any help. Regards, Jerry -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subclassing + Renaming
Hi there, I've some basic models like PERSON, GROUP and ROLE: class PERSON (models.Model): first = models.CharField ('first name', max_length=256) last = models.CharField ('last name', max_length=256) class GROUP (models.Model): name = models.CharField (max_length=256) members = models.ManyToManyField (PERSON, blank=True, null=True, through='ROLE') class ROLE (models.Model): person = models.ForeignKey (PERSON) group = models.ForeignKey (GROUP) Now based on those three models above I'd like to create the following models: class ORGANIZATION (GROUP): """ An ORGANIZATION is a GROUP of PERSONs, and therefore I'd like to *rename* (or at least create a 'second' name for) GROUP.members to GROUP.people. """ people = GROUP.members class COMPANY (ORGANIZATION): class Meta: verbose_name_plural = 'companies' incorporation = models.CharField (max_length=16) class EMPLOYEE (ROLE): """ An EMPLOYEE is a ROLE a PERSON takes without a GROUP of PERSONs, e.g. a COMPANY. There I'd like to *rename* ROLE.group to the more specific class' member EMPLOYEE.company. Sine company = ROLE.group.organization.company does not work (be - cause apparently this *casting* down the hierarchy requires an object instance, I did the casting inside the constructor .. """ def __init__ (self, *args, **kwargs): super (EMPLOYEE, self).__init__ (*args, **kwargs) self.company = self.group.organization.company profession = models.CharField (max_length=256) Now, my question is: Are these approaches above somehow *correct* or maybe even *recommended* ? Is there a better solution? I wish there would be something like: class EMPLOYEE (ROLE): company = @rename (ROLE.group.organization.company) profession = models.CharField (max_length=256) where *after* the *true* renaming the original name *group* is not available anymore .. I read somewhere that this is not possible and it just worms me this imposiblity .. :.'( -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passenger 57 - a Django query problem
I've always found both the Django and Python communities to be among the friendliest and most helpful. Please be kind to one another and respectful of everyones comments. We are here to support one another in our efforts to better our django skills and to better the community and project as a whole. Let's not start bickering amongst ourselves... Best, Steven Elliott Sent from my iPhone On Feb 20, 2010, at 7:19 PM, Russell Keith-Magee wrote: On Sun, Feb 21, 2010 at 4:11 AM, Sithembewena Lloyd Dube wrote: I wonder what Atamert the peacemaker has to say now, since the person to whose defense he came admitted he was wrong. Amazing to note that Atamert noticed my directness to Bruno, but did not notice how nasty Bruno was to other respondents (namely Emily and Derek). What have you to say, o' wise Atamert? Ok, I'm stepping in here. Emily is right - this sort of tone is *exactly* what we don't want on Django users. Django-users has historically been a very friendly place. I don't want that to change. Bruno; Lloyd; Atamert - at this point, I don't care who started it. When you wrestle in mud, everyone gets dirty - even the bystanders. So Stop. Now. If you want to have some petty name calling argument, take it somewhere else. If you persist in posting to django-users with anything other than helpful responses to the original question, I will start banning accounts. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/django-users?hl=en . -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django CMS
I used the same comparison you did, and I ended up going with Django-CMS. I like it a lot. As for importing the content, that should be pretty easy. Once you see how Django-CMS works you'll just need to make a simple HTML template and then transfer the data from your old database into the appropriate places. However, if you only just discovered Django this weekend, I think there will be a learning curve you need to overcome before trying to understand Django-CMS (or any other large reusable Django app). I recommend reading "The Definitive Guide to Django," and supplementing it with questions on this list. In that order -- if you ask questions here before doing the reading yourself you'll just end up dependent on others and they'll lose interest in doing your work for you. Welcome to Django! I did Perl before Python as well, and now Python is my favorite language, by far. Also, as has been noted many times before, if you're not that comfortable with Python, a lot of your questions about how to do something 'in Django' is really how to do it in Python. Django is Python. I hope my rambling is helpful. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Treat two fields as one in a queryset
I think you'll have to sort the list yourself by creating a calculated field, since you're only returning a small number, I don't see this as a big issue. So, get the records back that you want via the ORM, and then copy them over to a list. HTH John On Feb 20, 6:26 pm, shacker wrote: > Given a model like: > > class Item(models.Model): > title = models.CharField(max_length=140) > created_date = > models.DateTimeField(default=datetime.datetime.now) > completed = models.BooleanField(default=False) > completed_date = models.DateTimeField(blank=True,null=True) > ... > > I want to create a queryset that retrieves the last 30 Items that were > either created OR completed most recently. In other words, the > created_date and the completed_date fields need to be treated as if > they were a single date field on the model, so that the returned items > would be chronological by either date (completed_date would only be > considered for items where completed=True) > > I've tried both: > > .order_by('-completed_date','-created_date')[:30] > > and > > .order_by('-completed_date').order_by('-created_date')[:30] > > but neither of these are quite right. Not sure what the right approach > to this should be. Suggestions? Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Treat two fields as one in a queryset
If you know how to do it in SQL, just make your own manager. http://docs.djangoproject.com/en/1.1/topics/db/managers/ Yay for Django! Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Load template tags if installed?
On Jan 29, 5:07 am, trójkąt wrote: > And do you have any solution for something like this: > > {% ifloaded my_app %} > {% tag_from_my_app %} > {% endifloaded %} Sorry for the delay--Google didn't notify me of your reply. I never thought about that one... ;) Fortunately I don't have a need at the moment, because I'm stumped on how I would go about implementing it. -A -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django CMS
+1 On Sat, Feb 20, 2010 at 9:38 PM, Shawn Milochik wrote: > I used the same comparison you did, and I ended up going with Django-CMS. I > like it a lot. > > As for importing the content, that should be pretty easy. Once you see how > Django-CMS works you'll just need to make a simple HTML template and then > transfer the data from your old database into the appropriate places. > > However, if you only just discovered Django this weekend, I think there > will be a learning curve you need to overcome before trying to understand > Django-CMS (or any other large reusable Django app). I recommend reading > "The Definitive Guide to Django," and supplementing it with questions on > this list. In that order -- if you ask questions here before doing the > reading yourself you'll just end up dependent on others and they'll lose > interest in doing your work for you. > > Welcome to Django! I did Perl before Python as well, and now Python is my > favorite language, by far. Also, as has been noted many times before, if > you're not that comfortable with Python, a lot of your questions about how > to do something 'in Django' is really how to do it in Python. Django is > Python. I hope my rambling is helpful. > > Shawn > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.