Re: Shift a QuerySet?
Good point, that's actually kind of embarassing. I don't actually expect to be able to use that syntax but I thought it would be constructive. Let me try again: I have a QuerySet of PlaylistAggregation objects. Each PlaylistAggregation object is related to one Playlist object. I want to change my QuerySet to select only the related Playlist objects. An analogous operation would be: playlist_aggregates = PlaylistAggregation.objects.order_by('-count') playlists = [p.playlist for p in playlist_aggregates] But there are some significant downsides for doing that...namely, the playlist_aggregates QuerySet is evaluated (if I want to paginate the results, use generic views, etc. it becomes much harder). Thanks for your help, Eric On Jul 24, 10:09 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > This may sound like a strange inquiry, but is there any way using > > Django's ORM to "shift" a queryset? To explain my question, I'll > > provide an example. > ... > > Now, I want to "shift" my queryset to be a queryset of JUST the > > related playlist objects: > > playlists = playlist_aggregates.shift(playlist) > > This example doesn't explain anything - it just shows the syntax you > expect to be able to use. What exactly is "shifting"? What behaviour > do you expect "shift" to implement? > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
unbound method get_profile()
Hey all, I feel like I may be missing a small thing, but here it is. from django.shortcuts import render_to_response from django.template import RequestContext from django.contrib import auth def profile(request): template_name = 'user_profile.html' obj_list = User.get_profile() return render_to_response(template_name, locals(), context_instance=RequestContext(request)) Simple enough. But when I try to render the page, I get: unbound method get_profile() must be called with User instance as first argument (got nothing instead) I have AUTH_PROFILE_MODULE set correctly, and I can pass normal user data through to the page fine. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shift a QuerySet?
Thanks! All of your workarounds involving filter didn't work, erroring with "Cannot resolve keyword 'song_aggregation' into field", which makes sense since I really wanted to go the other way around, I think. Anyways, after some munging with 'extra', as per your suggestion, I got it working! Thanks again, Eric On Jul 24, 10:36 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > An analogous operation would be: > > playlist_aggregates = PlaylistAggregation.objects.order_by('-count') > > playlists = [p.playlist for p in playlist_aggregates] > > The query itself looks like it's just a query over Playlist objects > where all the query terms relate to Playlist_aggregate, e.g., > > Playlist.objects.filter(playlist_aggregation__count=3) > > The ordering issue is a little more difficult. Ideally, it sounds like > you want to be able to write: > > Playlist.objects.all().order_by('playlist_aggregation.count') > > but the query syntax doesn't currently support this; order_by isn't > taken into account when the joins are determined. This is part of a > task that Malcolm is currently looking at. > > In the interim, there are a few workarounds. In the end, the argument > to order_by is just the SQL name of the attribute; it just happens > that for attributes on a model, the SQL name matches the attribute > name. However, you can use this to cheat a bit. If you substitute the > SQL name for the joined column, you can order by joined attribute - as > long as the related table is actually joined in the SQL query. > > A normal Playlist.objects.all() query won't join Playlist_aggregation > - so you'll need to fake it. Either add a meaningless filter, like > filter(playlist_aggregation__count__gte=0) (which will join the table, > but not reject any rows), or use the 'extra' clause to manually add > the join required. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Shift a QuerySet?
Oops, that should read "Cannot resolve keyword 'playlist_aggreation' into field", even though I am messing with song aggregations and playlist aggregations :) On Jul 24, 11:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Thanks! > > All of your workarounds involving filter didn't work, erroring with > "Cannot resolve keyword 'song_aggregation' into field", which makes > sense since I really wanted to go the other way around, I think. > > Anyways, after some munging with 'extra', as per your suggestion, I > got it working! > > Thanks again, > Eric > > On Jul 24, 10:36 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> > wrote: > > > On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > An analogous operation would be: > > > playlist_aggregates = PlaylistAggregation.objects.order_by('-count') > > > playlists = [p.playlist for p in playlist_aggregates] > > > The query itself looks like it's just a query over Playlist objects > > where all the query terms relate to Playlist_aggregate, e.g., > > > Playlist.objects.filter(playlist_aggregation__count=3) > > > The ordering issue is a little more difficult. Ideally, it sounds like > > you want to be able to write: > > > Playlist.objects.all().order_by('playlist_aggregation.count') > > > but the query syntax doesn't currently support this; order_by isn't > > taken into account when the joins are determined. This is part of a > > task that Malcolm is currently looking at. > > > In the interim, there are a few workarounds. In the end, the argument > > to order_by is just the SQL name of the attribute; it just happens > > that for attributes on a model, the SQL name matches the attribute > > name. However, you can use this to cheat a bit. If you substitute the > > SQL name for the joined column, you can order by joined attribute - as > > long as the related table is actually joined in the SQL query. > > > A normal Playlist.objects.all() query won't join Playlist_aggregation > > - so you'll need to fake it. Either add a meaningless filter, like > > filter(playlist_aggregation__count__gte=0) (which will join the table, > > but not reject any rows), or use the 'extra' clause to manually add > > the join required. > > > Yours, > > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A convenient way to include images in a blog entry
I said to hell with it and put all the related images in a slideshow alongside the entry. On Jul 25, 11:05 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote: > Hi Patrick, > > On 7/25/07, Patrick <[EMAIL PROTECTED]> wrote: > > > What I did in one of my projects is to use a JS editor (at this point I > > opted for WYM Editor), which has a function to insert image tags if you > > give it a URL. I think that is the most-widely used approach. > > I don't like such editors, so this isn't an option. > > > In my project, I also have a photo gallery app, which members can use to > > upload and organise their photos. They can grab a thumbnail image > > location using their browser context menu and paste it (or I could > > provide the whole img tag with a 'src', 'title' attributes wrapped in an > > anchor tag pointing to that page, I haven't decided on it yet.). > > > The photos are not related to a blog post entry, as they could also > > include photos from other sites, if they wanted. > > This is exactly the point where I stuck. Actual there is no need > for a relation between Entry and Image because in the template > filter-solution you can refer to every image via $image[id] no matter > if its related or not. I just wanted a list in the Entry admin page > so the user can see the available images and the corresponding ids. > This looks like: > > 1: blog_entry_images\343566.jpg > 2: blog_entry_images\36767jhjg.jpg > > If there were a possibility to show up such a list without having > a relation, this would solve my problem. > > (In the version a posted above, I have a problem. I try to explain: > If you select image A from the list and insert "$image0" this works > great. But after saving if you select image B an use "$image0" to > refer to it, it will still include image A instead of image B.) > > > The problem is that if the image is not available anymore, I have no way > > of checking it and it won't show in the post. > > I don't understand the problem, sorry. If the image isn't available, you > cannot show it. :) > > > The way you designed it ensures that the image(s) remain with the post, > > so to speak, but how do you decide how to display them within the post > > body text? > > I'm still not sure whether to use the templatetag-solution or the replace- > some-weird-placehoders-before-saving solution. In the latter I just include > them via markdown (which is applied after replacing $imageX with the > actual image path). > > Thanks for your answer! > Kai --~--~-~--~----~----~---~--~~ You received this message because you are subscribed to the Google 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: Confusion over CRUD generic views and newforms
Hello, {{ form.as_ul }} or {{ form.as_table }}, etc, should work for this purpose. Hope that helps, Eric Matt wrote: > Hello group, > > I'm reasonably new to Django andconfused over how to implement generic > views for CRUD operations, specifically with respect to newforms. I'm > using 0.96 for the time being, but I'm happy to upgrade to the > development version if required. > > What I'm trying to acheive is an automatic way of rendering a form to > create/update etc. a model. I know this is possible because the admin > site does it! > > I understand how the URLconf part of things work, but I'm not sure > what to put in the template to actually render the form. > > For completeness, my URLconf contains this line: > > > (r'^job/new/$', create_object, {'model': Job, 'template_name': > > 'newjob.html'}), > > and my (very simplistic) template contains this: > > > {% block content %} > > Fill in this form: > > {{form}} > > {% endblock %} > > I had hoped that some magic would turn {{form}} into an HTML rendered > form, but all it does it output the __str__ method of FormWrapper. > > If I use {{form.field}}, then the field is correctly rendered in the > HTML - but it seems stupidly repetitive to have to manually rebuild > forms in the template using {{form.field}} for every field. So my > first question is: how can this be done automatically? > > Secondly, am I shooting myself in the foot here by using elements of > oldforms which will be canned in the next stable release? And if so, > are there any resources out there on how to do this the 'right' way? > > Many thanks indeed, > Matt. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Forms for complex model hierarchies
Speaking about newforms, of course. Sorry. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Forms for complex model hierarchies
Thanks for the quick response! That will help me out. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: There's got to be a better way
I'm probably doing something wrong in my template now, but that version is only returning one event per region, and the order is backwards. I tried .order_by('-start_date'), but it didn't appear to make any difference. On Jul 26, 3:12 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > few minor questions: > > missing ) > > [(region, future_events.filter(club__region=region) for region in regions] > > > guessing the missing ) goes here: > > [(region, future_events.filter(club__region=region)) for region in regions] > > Yup...must have been my poor transcription from brain to email. > Sorry for the confusion. It's building a list of tuples where > the first item is the region and the second is the list of events > in that region. > > > What happens if there are no events in one of the regions? > > > Does that cause a hit to the DB for each region? > > In its current state, yes, it does cause a DB hit for each > region, data or no data. Yes, Baxter, filter() is lazy, but it's > instantiated in the view when called upon, so it is actually > evaluated even when blank. > > To avoid this, an alternative might be something like > >future_events = Event.object.filter( > start_date__gte=now).select_related( > ).order_by('start_date') > >events = {} # or SortedDict if order matters >for event in future_events: # one DB hit here > region = event.club.region > ev_list = events.get(region, []) > ev_list.append(event) > events[region] = ev_list >return render_to_response(..., { > 'events': events, # this might need to > # be events.iteritems() or something > # like that > ...}) > > This version should only hit the DB once for all the event data > and also sort the data before it ever gets to you, so you > (Baxter) can avoid the dictsort in your template. > > -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: There's got to be a better way
On Jul 26, 4:17 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > AssertionError: {'Southeast': [], > > 'Northeast': > > [], 'Pacific': [ > show>], > > 'Southwest': []} > > [aside: please use edited-down inline posting conventions rather > than top-posting to make the conversation easier to follow] > > I'm not sure if just using "region" is being considered a unique > item (or being overly unique). Try changing this line: > > region = event.club.region > > to > > region = str(event.club.region) > > or > > region = event.club.region.name > > or something that is string. For debugging purposes, you can > also adjust the code to look something like > > events = {} # or SortedDict if order matters > + new_lists = 0 > + appended_lists = 0 > for event in future_events: # one DB hit here > - region = event.club.region > + region = str(event.club.region) > +if region in events: > + appended_lists += 1 > +else: > + new_lists += 1 > ev_list = events.get(region, []) > ev_list.append(event) > events[region] = ev_list > + assert False, '%i created, %i updated, %i total' % ( > + new_lists, appended_lists, len(future_events)) > > This should give an idea as to how many regions are added to the > dictionary, and how many resultant lists should have been updated > (the two tallies should sum to the len() of the future_events). > You can try it with and without the "region = > str(event.club.region)" change and see if they're different. > > -tim Interesting... as long as select_related was on there, it only picked up 4 events. Remove it, and it gets all 13. Weird. It wasn't anything to do with region, which isn't another table, it's just a field under Club with choices (since they'll basically never change) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: There's got to be a better way
Thanks, Tim. I got tripped up by a punctuation, and only half understood what you were doing, but it put me on the track. Here's what I ended up with: future_events = Event.objects.filter(start_date__gte=now) regions = ( 'Pacific', 'Rocky Mountain', ) events = [] for region in regions: events.append((region, future_events.filter(club__region=region))) return render_to_response('clubs/events.html', {'events': events}) Then in the template, I have a simple check to see if there's anything there: {% for region in events %} {% ifnotequal region.1.count 0 %} {{ region.0 }} region {% for event in region.1|dictsort:"start_date" %} blah blah blah {% endfor %} {% endifnotequal%} {% endfor %} Carl, I may be mistaken, but I think filter is lazy? On Jul 26, 2:45 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: > Tim Chase wrote: > >> In my view, I have: > >> future_events = Event.objects.filter(start_date__gte=now) > >> pacific_events = future_events.filter(club__region='Pacific') > >> rocky_mountain_events = future_events.filter(club__region='Rocky > >> Mountain') > >> southwest_events = future_events.filter(club__region='Southwest') > >> midwest_events = future_events.filter(club__region='Midwest') > >> central_events = future_events.filter(club__region='Central') > >> northeast_events = > >> future_events.filter(club__region='Northeast') > >> southeast_events = > >> future_events.filter(club__region='Southeast') > > >> return render_to_response('clubs/events.html', {' > >> 'pacific_events': pacific_events, > >> 'rocky_mountain_events':rocky_mountain_events, > >> 'southwest_events':southwest_events, > >> 'midwest_events':midwest_events, > >> 'central_events':central_events, > >> 'northeast_events':northeast_events, > >> 'southeast_events':southeast_events, > >> }) > > >> And then in the view, I spit out: > >> {% if pacific_events %} > >> do stuff > >> {% endif %} > > >> For each event type, ad nauseum. > > > Sounds like you want to do something like > > > future_events = Event.objects.filter(start_date__gte=now) > > regions = ( > > 'Pacific', > > 'Midwest', > > # ... or load from your Region table > > ) > > return render_to-response('clubs/events.html'), {'events': [ > > (region, future_events.filter(club__region=region) > > for region in regions > > ]) > > 'other_context_field': whatever, > > }) > > > and then in your template, you'd have something like > > >{% for region in events %} > > Happenings in the {{ region.0 }} region > > > >{% for event in region.1 %} > > {{ event.description }} > >{% endfor %} > > > >{% endfor %} > > > Hope this helps, > > > -tim > > tim, > > I have a similar task, and this looks like what I need to do. > > few minor questions: > missing ) > [(region, future_events.filter(club__region=region) for region in regions] > > guessing the missing ) goes here: > [(region, future_events.filter(club__region=region)) for region in regions] > > What happens if there are no events in one of the regions? > > Does that cause a hit to the DB for each region? > > Carl K --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: There's got to be a better way
AssertionError: {'Southeast': [], 'Northeast': [], 'Pacific': [], 'Southwest': []} On Jul 26, 3:45 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > >>future_events = Event.object.filter( > >> start_date__gte=now).select_related( > >> ).order_by('start_date') > > >>events = {} # or SortedDict if order matters > >>for event in future_events: # one DB hit here > >> region = event.club.region > >> ev_list = events.get(region, []) > >> ev_list.append(event) > >> events[region] = ev_list > >>return render_to_response(..., { > >> 'events': events, # this might need to > >> # be events.iteritems() or something > >> # like that > >> ...}) > > > I'm probably doing something wrong in my template now, but that > > version is only returning one event per region, and the order is > > backwards. I tried .order_by('-start_date'), but it didn't appear to > > make any difference. > > (fixed top-posting) > > Not having your models, I've only been guessing at them which may > be causing problems. > > Before the "return render_to_response(...)" line, you might want > to try adding one of the following > >assert False, repr(events) >assert False, repr(events.items()) > > to see what comes back. > > -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: Confusion over CRUD generic views and newforms
On Jul 26, 4:50 pm, Matt <[EMAIL PROTECTED]> wrote: > Hi Etienne, > > I read that {{ form.as_table }} was the default value for {{ form }} > as well, but when I insert {{ form }} into my template I get something > out which looks like the output of a __str__ method - a list of > dictionaries and values. > > I'm running Python 2.5 on Ubuntu Feisty. I'll put together a test on a > Windows box later today and see if I still have the same problems. > > Can you confirm that the CRUD generic views are compatible with > newforms? I haven't seen any examples of how to do it, but I'm having > a hard time believing that this core functionality hasn't been > implemented (or even patched) for newforms yet. The CRUD generic views are using oldforms AFAIK. > Thanks, > Matt. > > On Jul 26, 12:19 am, "Etienne Robillard" <[EMAIL PROTECTED]> > wrote: > > > I think the default value for {{ form }} is {{ form.as_table }}, so > > perhaps it is safe to just use the default {{ form }} within a > > table element: > > > > > > > {{ form }} > > > > > > > As for this error, it looks like the server didnt finished serving a request > > and crashed. Maybe upgrading Python and a couple of python modules > > should help. > > > Regards, > > Etienne > > > On 7/25/07, Matt <[EMAIL PROTECTED]> wrote: > > > > Eric, > > > > It seems I jumped to conclusions too quickly. I'm finding that > > > {{ form.as_table }}, {{ form.as_ul }} and {{ form.as_p }} cause the > > > server to error. The page is still served, but the following is in the > > > terminal where the development server is running: > > > > Traceback (most recent call last): > > > File "/usr/lib/python2.5/site-packages/django/core/servers/ > > > basehttp.py", line 279, in run > > > self.finish_response() > > > File "/usr/lib/python2.5/site-packages/django/core/servers/ > > > basehttp.py", line 318, in finish_response > > > self.write(data) > > > File "/usr/lib/python2.5/site-packages/django/core/servers/ > > > basehttp.py", line 397, in write > > > self.send_headers() > > > File "/usr/lib/python2.5/site-packages/django/core/servers/ > > > basehttp.py", line 449, in send_headers > > > self.send_preamble() > > > File "/usr/lib/python2.5/site-packages/django/core/servers/ > > > basehttp.py", line 379, in send_preamble > > > 'Date: %s\r\n' % (formatdate()[:26] + "GMT") > > > File "socket.py", line 262, in write > > > self.flush() > > > File "socket.py", line 249, in flush > > > self._sock.sendall(buffer) > > > error: (32, 'Broken pipe') > > > > This is occurring with the SVN version of Django. Have you seen this > > > before? > > > > Thanks, > > > Matt.- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: problem with session persistence
What about setting session variable to None, then setting it back to a new list object with the questions in it, just to see if it's a problem with it not realizing that the list has been modified? I don't think this is the best solution either, but would be a good test to see if it's just not realizing that the variable has changed, and possibly another workaround if it works. On Jul 26, 1:09 pm, flynnguy <[EMAIL PROTECTED]> wrote: > Thanks for responding, I should have mentioned previously that I did > try putting 'SESSION_SAVE_EVERY_REQUEST=True' in my settings file but > that didn't work. Now that I read your e-mail, I also tried setting > request.session.modified = True right after my append but that didn't > work either. > > I meant to reply to the list a while ago to tell my work around but I > forgot, I guess now is as good a time as any... > > I ended up just using a string that I concatenate the new values to in > a comma separated list: > request.session['questions_asked'] += ','+str(question.id) > (obviously you would have to initialize it for the first question) > > Then to convert that string to an actual list I do the following: > for item in csv.reader([request.session['questions_asked']]): > question_list = item > > I tried doing just: csv.reader([request.session['questions_asked']]) > [0] but it's not a real list and in the interpreter, I get: TypeError: > unsubscriptable object. So if anyone knows of a cleaner, more pythonic > way, I'm all ears. (Because I'm guessing it's not very pythonic) > > So that's how I'm getting around it for now, I'd love to hear anyone > else's thoughts on the subject. > -Chris > > On Jul 26, 12:23 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > You might want to try adding: > > request.session.modified = True ( or modify your settings file to save > > every request by setting the SESSION_SAVE_EVERY_REQUEST to True ) > > > Because from this note from DjangoSessiondocs: > > #Sessionis modified. > > request.session['foo'] = {} > > > # Gotcha:Sessionis NOT modified, because this alters > > # request.session['foo'] instead of request.session. > > request.session['foo']['bar'] = 'baz' > > > On Jul 9, 10:50 am, flynnguy <[EMAIL PROTECTED]> wrote: > > > > Ok, I upgraded to the development version of django and that didn't > > > help. I then started to try and trim out the code so it was of a more > > > manageable size to post here. It's still rather large but if it helps > > > anyone visualize what I'm talking about, here it is: > > > > ## test_indexs.html > > > Take the Test > > > > > > > > > {{ form }} > > > > > > > > > > > > > ## take_tests.html > > > {{ questions_asked }} > > > > {% if score_page %} > > > {{ num }} > > > Your score is: {{ score|floatformat:2 }}% > > > ({{ num_correct }}/{{ total }}) > > > > > > {% else %} > > > > {{ question.id }} {{ question.question }} > > > > > > > > > > > > {% for answer in answers %} > > > > > value="{{ answer.1 }}" /> > > > {% endfor %} > > > > > > > > > {% endif %} > > > > ## views.py > > > def sessiontest(request): > > > if 'questionlist' inrequest.session: > > > questions_asked =request.session['questionlist'] > > > if request.method == "POST": > > > ifrequest.session.get('num_questions',False): # If there > > > is a GET var called num_questions > > > ifrequest.session['current_question'] > > > <request.session['num_questions']: > > >request.session['current_question'] += 1 > > > question = Question.objects.order_by('?')[0]# Get > > > a random question > > >request.session['previous_question'] = question > > > answers = list(enumerate([question.correct_answer, > > > question.other_answer_1, question.other_answer_2])) > > > shuffle(answers) > > > try: > > >request.session['questionlist'] = > > > questions_asked.append(int(question.id)) > > > except AttributeError: > > >request.session['questionlist'] = > > > [(int(question.id)),] > > > > return render_to_response('take_tests.html', > > > {'current_num':request.session
Re: problem with session persistence
You might want to try adding: request.session.modified = True ( or modify your settings file to save every request by setting the SESSION_SAVE_EVERY_REQUEST to True ) Because from this note from Django Session docs: # Session is modified. request.session['foo'] = {} # Gotcha: Session is NOT modified, because this alters # request.session['foo'] instead of request.session. request.session['foo']['bar'] = 'baz' On Jul 9, 10:50 am, flynnguy <[EMAIL PROTECTED]> wrote: > Ok, I upgraded to the development version of django and that didn't > help. I then started to try and trim out the code so it was of a more > manageable size to post here. It's still rather large but if it helps > anyone visualize what I'm talking about, here it is: > > ## test_indexs.html > Take the Test > > > {{ form }} > > > > > ## take_tests.html > {{ questions_asked }} > > {% if score_page %} > {{ num }} > Your score is: {{ score|floatformat:2 }}% > ({{ num_correct }}/{{ total }}) > > {% else %} > > {{ question.id }} {{ question.question }} > > > > {% for answer in answers %} > value="{{ answer.1 }}" /> > {% endfor %} > > > {% endif %} > > ## views.py > def sessiontest(request): > if 'questionlist' inrequest.session: > questions_asked =request.session['questionlist'] > if request.method == "POST": > ifrequest.session.get('num_questions',False): # If there > is a GET var called num_questions > ifrequest.session['current_question'] > <request.session['num_questions']: >request.session['current_question'] += 1 > question = Question.objects.order_by('?')[0]# Get > a random question >request.session['previous_question'] = question > answers = list(enumerate([question.correct_answer, > question.other_answer_1, question.other_answer_2])) > shuffle(answers) > try: >request.session['questionlist'] = > questions_asked.append(int(question.id)) > except AttributeError: >request.session['questionlist'] = > [(int(question.id)),] > > return render_to_response('take_tests.html', > {'current_num':request.session['current_question'], \ > > 'num':request.session['num_questions'], \ > > 'question':question, \ > > 'first_page':False, \ > > 'questions_asked':questions_asked, \ > > 'answers': answers}) > else: > score = (float(request.session['num_correct'])/ > float(request.session['num_questions']))*100 > return render_to_response('take_tests.html', > {'correct':request.session['num_correct'], \ > > 'total':request.session['num_questions'], \ > > 'score':score, \ > > 'score_page':True, \ > > 'num_correct':request.session['num_correct'] }) > else: # No num_questions var set... show/process form > form = TestForm(request.POST) > if form.is_valid(): > num_questions = > form.cleaned_data['number_of_questions'] >request.session['num_questions'] = num_questions >request.session['current_question'] = 1 >request.session['num_correct'] = 0 > question = Question.objects.order_by('?')[0]# Get > a random question >request.session['previous_question'] = question > answers = list(enumerate([question.correct_answer, > question.other_answer_1, question.other_answer_2])) > shuffle(answers) >request.session['previous_answers'] = answers >request.session['questionlist'] = [int(question.id),] > #topics = request.POST['topics'] > return render_to_response('take_tests.html', > {'current_num':request.session['current_question'], \ > > 'num':num_questions, \ > > 'first_page':True, \ > > 'questions_asked':request.session['questionlist'], \ > > 'question':question, 'answers': answers,}) > else: > # Remove num_questions session key in case it is hanging > around > try: > delrequest.session['num_questions'] > except KeyError: > pass > form = TestForm() > return render_to_response('test_indexs.html', {'form':form}) > > ## End Code ### > > If there is a problem storing lists in the session variables, then I > can look at some other method. I just thought this would be the best > solution. Also it works some of the time, just not all of the time. I > don't understand why it's getting set to 'None'. > -Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Authentication with remember me like option
Read http://code.djangoproject.com/wiki/CookBookDualSessionMiddleware --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 for complex model hierarchies
Hi group, I have a rather complex hierarchy of models. Say, I have a model A. A has a 1:N relation to model B, which itself has a 1:N relation to model C. What I want is a single web page, on which an instance of A and all its related B and C instances can be edited. What is the best way to achieve this? I am not sure wether it is worth the effort of coding something generic like a deepform function. What are your experiences? Regards, -Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problem with session persistence
I just realized that if the above was the case, you probably wouldn't be getting the NoneType error, but the original list with one element. Did you check your session contents to make sure the data was in actually in there? If the new item was there in the session, perhaps it was your if statement? Did you try request.session.get('questionlist') instead of if 'questionlist' in request.session. I would think either would work, but that is worth a shot as well. On Jul 26, 1:28 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > What about settingsessionvariable to None, then setting it back to a > new list object with the questions in it, just to see if it's aproblemwith it > not realizing that the list has been modified? > > I don't think this is the best solution either, but would be a good > test to see if it's just not realizing that the variable has changed, > and possibly another workaround if it works. > > On Jul 26, 1:09 pm, flynnguy <[EMAIL PROTECTED]> wrote: > > > Thanks for responding, I should have mentioned previously that I did > > try putting 'SESSION_SAVE_EVERY_REQUEST=True' in my settings file but > > that didn't work. Now that I read your e-mail, I also tried setting > > request.session.modified = True right after my append but that didn't > > work either. > > > I meant to reply to the list a while ago to tell my work around but I > > forgot, I guess now is as good a time as any... > > > I ended up just using a string that I concatenate the new values to in > > a comma separated list: > > request.session['questions_asked'] += ','+str(question.id) > > (obviously you would have to initialize it for the first question) > > > Then to convert that string to an actual list I do the following: > > for item in csv.reader([request.session['questions_asked']]): > > question_list = item > > > I tried doing just: csv.reader([request.session['questions_asked']]) > > [0] but it's not a real list and in the interpreter, I get: TypeError: > > unsubscriptable object. So if anyone knows of a cleaner, more pythonic > > way, I'm all ears. (Because I'm guessing it's not very pythonic) > > > So that's how I'm getting around it for now, I'd love to hear anyone > > else's thoughts on the subject. > > -Chris > > > On Jul 26, 12:23 pm, "[EMAIL PROTECTED]" > > > <[EMAIL PROTECTED]> wrote: > > > You might want to try adding: > > > request.session.modified = True ( or modify your settings file to save > > > every request by setting the SESSION_SAVE_EVERY_REQUEST to True ) > > > > Because from this note from DjangoSessiondocs: > > > #Sessionis modified. > > > request.session['foo'] = {} > > > > # Gotcha:Sessionis NOT modified, because this alters > > > # request.session['foo'] instead of request.session. > > > request.session['foo']['bar'] = 'baz' > > > > On Jul 9, 10:50 am, flynnguy <[EMAIL PROTECTED]> wrote: > > > > > Ok, I upgraded to the development version of django and that didn't > > > > help. I then started to try and trim out the code so it was of a more > > > > manageable size to post here. It's still rather large but if it helps > > > > anyone visualize what I'm talking about, here it is: > > > > > ## test_indexs.html > > > > Take the Test > > > > > > > > > > > > {{ form }} > > > > > > > > > > > > > > > > > ## take_tests.html > > > > {{ questions_asked }} > > > > > {% if score_page %} > > > > {{ num }} > > > > Your score is: {{ score|floatformat:2 }}% > > > > ({{ num_correct }}/{{ total }}) > > > > > > > > {% else %} > > > > > {{ question.id }} {{ question.question }} > > > > > > > > > > > > > > > > {% for answer in answers %} > > > > > > > value="{{ answer.1 }}" /> > > > > {% endfor %} > > > > > > > > > > > > {% endif %} > > > > > ## views.py > > > > def sessiontest(request): > > > > if 'questionlist' inrequest.session: > > > > questions_asked =request.session['questionlist'] > > > > if request.method == "POST": > > > > ifrequest.session.get('num_questions',False): # If there > > > > is a GET var called num_questions > > > > ifrequest.session['current_question'] > &
Re: There's got to be a better way
> > I second the weirdness. I'd try tossing an > > assert False, len(future_events) > > immediately after the > > future_events = Event.objects.select_related().filter(...) > > statement to see what Django thinks it's bringing back for future > events. > > > It wasn't anything to do with region, which isn't another table, it's > > just a field under Club with choices (since they'll basically never > > change) > > ah...helpful to know. So from what I've discerned from your > models, you have something like > > class Club(Model): > REGIONS = ( > ('NE', 'NorthEast'), > ('PAC', 'Pacific'), > #... > ) > region = CharField(..., choices=Club.REGIONS) > name = CharField(...) > > class Event(Model): > club = ForeignKey(Club) # FK or M2M? > start_date = DateField(...) > > Anything important I'm missing here? > > I'm not sure why it's not behaving properly with the > select_related, as that should allow you to pull back the whole > bunch in one query (as opposed to performing a query for each event). > > -tim Yup, that's more or less it. event.club is a FK. Definitely odd, but when I put the select related in, it only finds 4 future events instead of the 13. WIthout it, I'm fine. I can't figure out where or why it decided to quit at 4, but I'm not sure in this case it really matters. Since region isn't another table, I'm not sure what I'd gain by select_related (which admittedly, I don't completely understand). But hey, it's working, and it's MILES better than what I had. Thanks for all your help! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to pick a template based on the request object?
Just out of curiosity...why not use the same templates, and switch the css file you are referencing for a different look? On Jul 26, 1:53 pm, "Stefan Matthias Aust" <[EMAIL PROTECTED]> wrote: > I'm searching for the best way to "theme" an application. I'd like to > pick a template based on the request object. That's easy as long as I > implement the views using something similar to the utility function > render_and_response() which knows to add a template folder to the > template name based on the request object. > > However, I'd like to also "theme" templates of contributed modules. I > looked into creating a custom template loader but I think, that > doesn't work because the loader cannot access the request object. > > Is it possible to create a generic solution that requires no code > changes in contributed modules? > > -- > Stefan Matthias Aust // Truth until paradox --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
There's got to be a better way
I'm sure you all will immediately see what I'm doing, and how I could be doing it better. I'm sure I need to create my own dict or something, but I'm not sure how I'd do so, or (more importantly), how I'd work with in the template. In my view, I have: future_events = Event.objects.filter(start_date__gte=now) pacific_events = future_events.filter(club__region='Pacific') rocky_mountain_events = future_events.filter(club__region='Rocky Mountain') southwest_events = future_events.filter(club__region='Southwest') midwest_events = future_events.filter(club__region='Midwest') central_events = future_events.filter(club__region='Central') northeast_events = future_events.filter(club__region='Northeast') southeast_events = future_events.filter(club__region='Southeast') return render_to_response('clubs/events.html', {' 'pacific_events': pacific_events, 'rocky_mountain_events':rocky_mountain_events, 'southwest_events':southwest_events, 'midwest_events':midwest_events, 'central_events':central_events, 'northeast_events':northeast_events, 'southeast_events':southeast_events, }) And then in the view, I spit out: {% if pacific_events %} do stuff {% endif %} For each event type, ad nauseum. It works, but I know I'm being stupid here and thoroughly violating the DRY principle. Could someone show me the light? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
filter by if object exists
I just know this is a dumb question, and I've seen this done somewhere, but what I'm after is something like GpUser.objects.filter('image'=True) To only get the Gpuser objects that actually have an image, rather than all of them. Can someone point me in the right direction? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Can Django call cscript.exe to run vbscripts
On Jul 27, 2:35 pm, braveheart <[EMAIL PROTECTED]> wrote: > script process the input and forwards the output result to django; the > result is stored in a database or displayed on the page. Have the vbscript write to the same database django reads from or just output to a logfile that django knows where to find. Lorenzo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: filter by if object exists
Thanks. I knew it was simple, and I'd seen it before, but couldn't remember or find it. On Jul 27, 9:33 am, "Jonathan Buchanan" <[EMAIL PROTECTED]> wrote: > > I just know this is a dumb question, and I've seen this done > > somewhere, but what I'm after is something like > > > GpUser.objects.filter('image'=True) > > > To only get the Gpuser objects that actually have an image, rather > > than all of them. Can someone point me in the right direction? > > GpUser.objects.filter(image__isnull=False) > > Seehttp://www.djangoproject.com/documentation/db-api/#isnull > > Jonathan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Is cloning Facebook in Django feasible?
Is it possible to develop a Facebook functional clone in Django? What parts of it are provided out of the box? Any third-party contributions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is cloning Facebook in Django feasible?
a localised version would make sense in a country where people mostly don't speak English On 27 июл, 19:55, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Is it possible to develop a Facebook functional clone in Django? What > > parts of it are provided out of the box? Any third-party contributions? > > This is like going to a company that sells construction equipment and > saying "is it possible to build a copy of the Empire State Building > with your tools?" ;) > > Yes, it's possible. But it's going to be a lot of work, it's going to > take a lot of time and there's already an Empire State Building that > people know and love, so people are left asking exactly what it is > that the cloning project would accomplish... > > -- > "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: Is cloning Facebook in Django feasible?
A localised version would make sense in a country where most people don't speak English On 27 июл, 19:55, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Is it possible to develop a Facebook functional clone in Django? What > > parts of it are provided out of the box? Any third-party contributions? > > This is like going to a company that sells construction equipment and > saying "is it possible to build a copy of the Empire State Building > with your tools?" ;) > > Yes, it's possible. But it's going to be a lot of work, it's going to > take a lot of time and there's already an Empire State Building that > people know and love, so people are left asking exactly what it is > that the cloning project would accomplish... > > -- > "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: There's got to be a better way
> > Creating a template tag [1] might be a good idea here, especially if > you will be displaying a list of events on any other pages. > > In your view, you would have: > > future_events = > Event.objects.filter(start_date__gte=now).sort_by('start_date') > return render_to_response('clubs/events.html', {'events': > future_events}) > > And in the template, you would have: > > {% show_events events "Pacific" %} > {% show_events events "Central" %} > ... > > Or take out some more duplication: > > view: > > future_events = > Event.objects.filter(start_date__gte=now).sort_by('start_date') > regions = ["Pacific", "Central", ... ] > return render_to_response('clubs/events.html', { > 'events': future_events, > 'regions': regions}) > > template: > > {% for region in regions %} > {% show_events events region %} > {% endfor %} > > Now, you can do what you want with your newly created show_events > template tag. You could make the region optional, for example, and > display all events in the passed QuerySet if no region is specified. > > Also, if you aren't doing anything more in your view than passing the > couple of context variables to the template, you could even get rid of > your view entirely by using the direct_to_template generic view [2] > instead. > > [1]http://www.djangoproject.com/documentation/templates_python/#writing-... > [2]http://www.djangoproject.com/documentation/generic_views/#django-view... > > Gary Thanks Gary, but it's just one page, and a fairly specialized one... although I left it out of the above code, there's also a form to submit events, and the template creates calendars for them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
friends table adding choices from the same database
i'm working on an app that has a table called friends whose model looks like this: class Friend(models.Model): user = models.ForeignKey(User) friend = models.CharField(maxlength=100) status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES) def __str__(self): return self.friend user is the user that added the friend, while friend SHOULD be the id of the user that has been added. Both fields use the user table. I cant use the same foreign key for both, this would be an error. Ideally i would want a drop down box with all the username for the friend field. I thought about using choices, but cant seem to create a tuple that is dynamically populated from the username field in the user table. Any ideas how i could go about this? P.S is this a recursive relationship? i dont think so but hopefully some DB guru can shed some light. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Looping through my POST data?
I'm not sure if I'm following what your saying...but this is what I think you want to do: if request.method == 'POST': pads = request.session.get('pad', []) for pad in pads: if request.POST[pad.id] <> '---': # the select name should be the pad id based on your template code # do something here ... because it wasn't --- On Jul 27, 5:54 pm, Greg <[EMAIL PROTECTED]> wrote: > I'm trying to loop through my POST data. However I am having > difficulties. I think my 'for' statement might be wrong. Below is my > function and template code > > View function > > def addpad(request): > if request.method == 'POST': > pads = request.session.get('pad', []) > i = 0 > b = 1 > for a in request.POST: > if a != '---': > opad = RugPad.objects.get(id=b) > s = opad.size > p = opad.price > pads.append({'size': s, 'price': p}) > request.session['pad'] = pads > i = i + 1 > b = b + 1 > return render_to_response('addpad.html', {'spad': > request.session['pad']}) > > / Template File > > {% for a in pad %} > > > >--- >1 >2 >3 >4 >5 >{{ a.size }} -- ${{ a.price }} > > > {% endfor %} > > // > > Notice how my 'for' statement is listed as ' for a in request.POST: > '. However, when i do a 'assert False, a' it always returns the value > '1'. I need to get the value of each select statement. Such as (---, > 1,2,3,4,5). > > Is that 'for' statement returning me the value of each select > statement? > > 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 -~--~~~~--~~--~--~---
Generating charts with ReportLab
I had the need to generate a few different types of charts using ReportLab. The wiki only had a sample of a Horizontal Bar Chart, so I've added a new sample on how to produce a Line Chart... http://code.djangoproject.com/wiki/Charts If anyone is interested in a sample for a Pie or Scatter chart, let me know, and I can add samples of these as well. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
shoppingkicks.com Shop nike air jordan air force 1 dunk sb bape sta shoes on sale only $75
Nike Shoes Air Force I Air Jordan 1-10 Air Jordan 11-22 Nike Dunk SB Nike Dunk SB For Women Air Max Series Nike Shox R4 Nike For women Adidas Shoes Adi Color Adidas Campus Adidas Stam Smith Adidas Country Adidas 35 Super Star Adidas For Women Other Brand Shoes BAPE STA BAPE STA For Women Timberland Gucci Prada Ice Cream Dsquared2 Jeans Red Monkey Bathing Ape Evisu Jeans Item No: bape-7w Color: view photo Price: US$ 73.99 Item No: bape-6w Color: view photo Price: US$ 73.99 Item No: bape-5w Color: view photo Price: US$ 73.99 Item No: bape-4w Color: view photo Price: US$ 73.99 Item No: bape-3w Color: view photo Price: US$ 73.99 Item No: bape-2w Color: view photo Price: US$ 73.99 Item No: bape-1w Color: view photo Price: US$ 73.99 Item No: AF-new20 Color: view photo Price: US$ 83.99 Item No: AF-new19 Color: view photo Price: US$ 81.99 Item No: AF-new18 Color: view photo Price: US$ 82.99 Item No: AF-new17 Color: view photo Price: US$ 81.99 Item No: AF-new16 Color: view photo Price: US$ 83.99 Item No: AF-new15 Color: view photo Price: US$ 82.99 Item No: AF-new14 Color: view photo Price: US$ 82.99 Item No: AF-new13 Color: view photo Price: US$ 82.99 Shoppingkicks.com shop. Shoppingkicks shop Nike Air force one (AF1), Nike Dunk SB, Air Jordan I-XXI, Air Max95, Air Max97, Air Max2003, Air Max2004, Air Max 360, TN, R4, NZ. Adidas, A Bathing APE, GUCCI, Timberland shoes. Name Brand jeans such as Evisu, Red Monkey, BAPE, True Religion, Rock & Republic and Seven. Branded fashions included Polo, Bape T-Shirt. Branded sportswear included Jordans, Nike, Adidas etc. We offer high quality stuff with best wholesale price. Good credit & best services, shipping in time, smooth delivery are guaranteed! We hope to make a long term cooperation with customers all over the world. Attention please: All prices listed are retail prices,and ALL prices listed at the website include the shipping charge. Don't hesitate to contact us for wholesale details. Please note : Your tracking numbers will not appear at the USPS website until your item has reached US grounds. So when you received your tracking numbers give it three days before checking at the USPS website. If you cannot find your record there, try to check after a day or two. Please be reminded that tracking numbers will be emailed to you once your order has been shipped. Thank you - Shoppingkicks.com Admin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Looping through my POST data?
Greg... I'm curious as to why you're iterating over the entire request.POST when you could just use the id of each pad that you've previously passed to your template to retrieve it from the request.POST dict, as that is what you've named your select statements with? While iterating through all of the request.POST key/value pairs works, if you choose to later add any other inputs to your screen that aren't drop downs for your CarpetPads, you'll have to add special code for each of them so that your code won't attempt to add a RugPad for those key/value pairs. Just wanted to point that out, in case you might need to do that later. Carole On Jul 28, 9:15 am, Greg <[EMAIL PROTECTED]> wrote: > Nathan, > Thanks for your help...I got it working. This is what I used: > > if values != list("0"): > > Is that what you were recommending? Because I couldn't convert a list > (values) to a int. Since values was a list I decided to convert my > int to a list and that worked. Can you tell me what the u stands for > when i do a 'assert False, values': It returns a [u'0']. Why doesn't > it just return a ['0']? Also, it there anyway that I can convert the > 'values' variable to a int so that I can do a comparison without > converting the 0 to a list? > > Thanks > > On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > To illustrate with the Python shell: > > > >>> 0 == "0" > > False > > >>> 0 == int("0") > > > True > > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > > > > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > > > AssertionError at /rugs/cart/addpad/ > > > > [u'0'] > > > > > Does that mean that the value is 0? below is my view function and > > > > template code: > > > > That little 'u' in front of the '0' means unicode so the value is the > > > unicode string "0" not the number zero. Very different as far as > > > Python is concerned. You may be used to other scripting languages > > > that auto-convert. Python is not one of them. > > > > try: > > > num = int(values) > > > if num == 0: > > > deal_with_zero() > > > else: > > > deal_with_number(num) > > > except ValueError: > > > # hmm, values is a string, not a number > > > deal_with_a_string(values) > > > > Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Looping through my POST data?
Right... because, unless I'm misunderstanding your code... you're creating a select drop down for each of your RugPad entires with the RugPad id. So you know that the request.POST is going to have entries for each id... But..I think it should be this: opads = RugPad.objects.all() for a in opads: if request.POST[a.id] != 0: opad = RugPad.objects.get(id=a) s = opad.size p = opad.price pads.append({'size': s, 'price': p}) So now you'd be iterating through each of your rug pads, and checking to see if the corresponding drop down had a non-zero value selected, instead of iterating all of the request.POST keys. This way you can have other items in your form if needed. On Jul 28, 10:58 am, Greg <[EMAIL PROTECTED]> wrote: > Carole, > So your saying that I should do: > > opad = RugPad.objects.all() > for a in opad.id > if request[a] != 0 > .#add to session > > On Jul 28, 8:43 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Greg... I'm curious as to why you're iterating over the entire > > request.POST when you could just use the id of each pad that you've > > previously passed to your template to retrieve it from the > > request.POST dict, as that is what you've named your select statements > > with? > > > While iterating through all of the request.POST key/value pairs works, > > if you choose to later add any other inputs to your screen that aren't > > drop downs for your CarpetPads, you'll have to add special code for > > each of them so that your code won't attempt to add a RugPad for those > > key/value pairs. Just wanted to point that out, in case you might > > need to do that later. > > > Carole > > > On Jul 28, 9:15 am, Greg <[EMAIL PROTECTED]> wrote: > > > > Nathan, > > > Thanks for your help...I got it working. This is what I used: > > > > if values != list("0"): > > > > Is that what you were recommending? Because I couldn't convert a list > > > (values) to a int. Since values was a list I decided to convert my > > > int to a list and that worked. Can you tell me what the u stands for > > > when i do a 'assert False, values': It returns a [u'0']. Why doesn't > > > it just return a ['0']? Also, it there anyway that I can convert the > > > 'values' variable to a int so that I can do a comparison without > > > converting the 0 to a list? > > > > Thanks > > > > On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > > > To illustrate with the Python shell: > > > > > >>> 0 == "0" > > > > False > > > > >>> 0 == int("0") > > > > > True > > > > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > > > > > > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > > > > > AssertionError at /rugs/cart/addpad/ > > > > > > [u'0'] > > > > > > > Does that mean that the value is 0? below is my view function and > > > > > > template code: > > > > > > That little 'u' in front of the '0' means unicode so the value is the > > > > > unicode string "0" not the number zero. Very different as far as > > > > > Python is concerned. You may be used to other scripting languages > > > > > that auto-convert. Python is not one of them. > > > > > > try: > > > > > num = int(values) > > > > > if num == 0: > > > > > deal_with_zero() > > > > > else: > > > > > deal_with_number(num) > > > > > except ValueError: > > > > > # hmm, values is a string, not a number > > > > > deal_with_a_string(values) > > > > Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to associate a view with a template?
Why not have a base template that contains the menu variable ( I put mine in a session variable accessible to the templates named menu ), then have all of your other templates extend from that template? In base.html: your header code {% block menu %} {{ menu }} {% endblock%} {% block content %}{% endblock %} Then in your other templates: {% extends "base.html" %} {% block content %} content for your html specific page here {% endblock %} On Jul 28, 1:13 pm, Eloff <[EMAIL PROTECTED]> wrote: > I've got a nav.html template that does the menu on every page. The > only trouble is I have to store the menu items in a global variable > and pass it to the page template in every view. Is there any way to > make a view for the nav.html template (which is included in all the > page templates)? I imagine it could be done with SSI but I don't want > to go that route unless I have no other option. > > Thanks, > -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to associate a view with a template?
Yeah I was going to post a sample if that's what he said next :) Here is another sample in addition to the link above .. on how to pass the menu code via context processors: In your settings.py file ... Find the line that says (there may be more in there depending on your setup): TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.request",) Change it to something like this: TEMPLATE_CONTEXT_PROCESSORS = ('yourproject.yourapp.somepythonfile.menu',"django.core.context_processors.request",) Then under in your python code create a menu function which corresponds to the above: def menu(request): return {'menu': "some html code for the menu"} Then when calling up each of your views add (context_instance=RequestContext(request)) when calling render_to_response: return render_to_response('somefile.html', {'someothervariableyouyoumightwant':value},context_instance=RequestContext(request)) Now you can access this via {{ menu }} in any of your templates. On Jul 28, 2:26 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > I could be wrong, but I think the problem he's having is having to > specify the menu variable in the context for every view, not the > template end of it... > > To fix that, you will want to check out context > processors:http://www.djangoproject.com/documentation/templates_python/#subclass... > > On Jul 28, 10:30 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Why not have a base template that contains the menu variable ( I put > > mine in a session variable accessible to the templates named menu ), > > then have all of your other templates extend from that template? > > > In base.html: > > > your header code > > > > {% block menu %} > > {{ menu }} > > {% endblock%} > > > {% block content %}{% endblock %} > > > > > Then in your other templates: > > {% extends "base.html" %} > > > {% block content %} > > content for your html specific page here > > {% endblock %} > > > On Jul 28, 1:13 pm, Eloff <[EMAIL PROTECTED]> wrote: > > > > I've got a nav.html template that does the menu on every page. The > > > only trouble is I have to store the menu items in a global variable > > > and pass it to the page template in every view. Is there any way to > > > make a view for the nav.html template (which is included in all the > > > page templates)? I imagine it could be done with SSI but I don't want > > > to go that route unless I have no other option. > > > > Thanks, > > > -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ubuntu 6.06 deployment issues
Sorry to re-awaken this thread, but it seems that people are still having issues with this PYTHONPATH info. In an attempt to get this sorted out, I've attached a patch to #4296 that adds a bit more info. Can anyone add any more info to what I've got? Thanks, Simon G #4296 - http://code.djangoproject.com/ticket/4296 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: friends table adding choices from the same database
If the Friend is really a user...wouldn't something like this work: class Friends(models.Model): parent_user = models.ForeignKey(User, related_name="user") friend_user = models.ForeignKey(User,related_name="friends") Then for the parent_user's friends...you'd do something like: parent_users_friends = parentuser.friends_set.all() to bring back a listing of all of his friends. On Jul 27, 8:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > i'm working on an app that has a table called friends whose model > looks like this: > > class Friend(models.Model): > user = models.ForeignKey(User) > friend = models.CharField(maxlength=100) > status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES) > > def __str__(self): > return self.friend > > user is the user that added the friend, while friend SHOULD be the id > of the user that has been added. Both fields use the user table. I > cant use the same foreign key for both, this would be an error. > Ideally i would want a drop down box with all the username for the > friend field. I thought about using choices, but cant seem to create > a tuple that is dynamically populated from the username field in the > user table. > > Any ideas how i could go about this? > > P.S is this a recursive relationship? i dont think so but hopefully > some DB guru can shed some light. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: friends table adding choices from the same database
THANK YOU! i just got home, will try this to see if this works... i'm new to django so thanks for the help, i'll look up what related_name works, but it looks good. Israel On Jul 29, 9:41 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > If the Friend is really a user...wouldn't something like this work: > > class Friends(models.Model): > parent_user = models.ForeignKey(User, related_name="user") > friend_user = models.ForeignKey(User,related_name="friends") > > Then for the parent_user's friends...you'd do something like: > parent_users_friends = parentuser.friends_set.all() to bring back > a listing of all of his friends. > > On Jul 27, 8:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > i'm working on an app that has a table called friends whose model > > looks like this: > > > class Friend(models.Model): > > user = models.ForeignKey(User) > > friend = models.CharField(maxlength=100) > > status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES) > > > def __str__(self): > > return self.friend > > > user is the user that added the friend, while friend SHOULD be the id > > of the user that has been added. Both fields use the user table. I > > cant use the same foreign key for both, this would be an error. > > Ideally i would want a drop down box with all the username for the > > friend field. I thought about using choices, but cant seem to create > > a tuple that is dynamically populated from the username field in the > > user table. > > > Any ideas how i could go about this? > > > P.S is this a recursive relationship? i dont think so but hopefully > > some DB guru can shed some light. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 do I echo template variables?
I'm coming from CakePHP and I would typically set a variable for use in my view with a call to findAll. Since there is a lot of data in the array, I typically do something like: This way, I can find out what data is available in the view and figure out how much I can scale back the recursion. Is there any equivalent in Python/Django? I've searched and didn't come up with anything. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Generating charts with ReportLab
Hey Ben...thanks...I'll check that out. We'll most likely continue to use ReportLab for our project, as we are using the graphs in some reports we are going to export to PDF... but looks like an interesting read :) I'll also add the other two samples to the wiki this week... Carole On Jul 30, 4:29 am, "Ben Ford" <[EMAIL PROTECTED]> wrote: > Hey Carole, > A guy called Toby has put something together using R and rpy that does > graphs... I haven't been able to make it work as yet, but he's keen to move > on with it, and wants some testers and some help! > Check > out:http://groups.google.com/group/django-users/browse_thread/thread/43ea... > > or just have a look through your gmail for *Re: Graphs and django.* > (The search string "contrib namespace r" worked for me.) > Ben > > On 30/07/07, David Reynolds <[EMAIL PROTECTED] > wrote: > > > > > > > On 28 Jul 2007, at 4:34 am, [EMAIL PROTECTED] wrote: > > > > I had the need to generate a few different types of charts using > > > ReportLab. The wiki only had a sample of a Horizontal Bar Chart, so > > > I've added a new sample on how to produce a Line Chart... > > >http://code.djangoproject.com/wiki/Charts > > > > If anyone is interested in a sample for a Pie or Scatter chart, let me > > > know, and I can add samples of these as well. > > > I would say, go ahead and add them, as I'm sure many people will find > > them useful at some point. > > > Thanks, > > > David > > > -- > > David Reynolds > > [EMAIL PROTECTED] > > -- > Regards, > Ben Ford > [EMAIL PROTECTED] > +628111880346 --~--~-~--~~~---~--~----~ You received this message because you are subscribed to the Google 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: PopUp instead of Select widget (newforms)
Oops..pardon the typo... #1 shold say "Display a div" On Jul 30, 1:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I am not using new forms... but I'm assuming you would make this a > text field... with a link next to it that says something like 'view > existing entries' > > Then when a user clicks that, you could do one of the following: > > 1. Display a ldiv with a list of all entries, and make it so that when > the user scrolls through the list and clicks on one, it closes the > div, and sets the text in the entry box ( if you need the ID of what > is selected... you could do this in an invisible form field ). > > 2. Display a search box, then post a form submit back to the same > page, with parameters set so that it comes back with matching results > displayed, each as a link to hide the div and set form variables as > described above. > > 3. Display a search box, and use AJAX to pull back the matching > results, with a list displaying matching results, each as a link to > hide the div and set form variables as described above. > > On Jul 30, 11:12 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I want to use a popUp instead of an select widget, since > > there will be too many entries (>10.000). It would be better > > to use a PopUp with a search form. Has anyone done something like > > this? > > > I search some example code to learn from. > > > Thomas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: PopUp instead of Select widget (newforms)
I am not using new forms... but I'm assuming you would make this a text field... with a link next to it that says something like 'view existing entries' Then when a user clicks that, you could do one of the following: 1. Display a ldiv with a list of all entries, and make it so that when the user scrolls through the list and clicks on one, it closes the div, and sets the text in the entry box ( if you need the ID of what is selected... you could do this in an invisible form field ). 2. Display a search box, then post a form submit back to the same page, with parameters set so that it comes back with matching results displayed, each as a link to hide the div and set form variables as described above. 3. Display a search box, and use AJAX to pull back the matching results, with a list displaying matching results, each as a link to hide the div and set form variables as described above. On Jul 30, 11:12 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Hi, > > I want to use a popUp instead of an select widget, since > there will be too many entries (>10.000). It would be better > to use a PopUp with a search form. Has anyone done something like > this? > > I search some example code to learn from. > > Thomas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Newforms and GET Requests for Search Result Pagination?
Greetings, Is it not possible to use Newforms with GET requests? I'm trying to figure out how to paginate results from a search form, and I'm passing GET values to the pagination view, instantiating an instance of the Form object with request.GET as an argument (instead of the typical request.POST). I can't find any mention of GET support in the documentation, is this something that will eventually be added or has it been decided against? Also, does anyone know of any very clean way to paginate search results? I really can't believe there's no way to do this with generic views, it's a common thing to have to do. It's no good if you lose your search query every time you change pages :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newforms and GET Requests for Search Result Pagination?
I completely forgot to run is_valid() on the receiving view, so cleaned_data wasn't being populated. This was the problem. Thanks! On Jul 30, 4:00 pm, RajeshD <[EMAIL PROTECTED]> wrote: > > Is it not possible to use Newforms with GET requests? > > It is. You can pass it any "dictionary-like" object instance as its > submitted data (request.GET and request.POST are both dictionary-like > objects.) > > > I'm trying to > > figure out how to paginate results from a search form, and I'm passing > > GET values to the pagination view, instantiating an instance of the > > Form object with request.GET as an argument (instead of the typical > > request.POST). I can't find any mention of GET support in the > > documentation, is this something that will eventually be added or has > > it been decided against? > > It should work as you have it. Are you seeing a problem with this? > > > Also, does anyone know of any very clean way to paginate search > > results? > > Are your search results simply a query set? > > Generic Views do provide pagination support. See the "paginate_by" > argument:http://www.djangoproject.com/documentation/generic_views/#django-view... > > If you need custom pagination in your own views > see:http://www.djangoproject.com/documentation/models/pagination/ > > > I really can't believe there's no way to do this with generic > > views, it's a common thing to have to do. It's no good if you lose > > your search query every time you change pages :) > > Well, that depends. Is your search result going to potentially return > thousands of hits? Are dozens of users going to be able to perform > different searches at the same time? > > If so, it's no good for the application to hang on to the search > results. Consider many users launching searches and never going to > page #2. The cached querysets will have to linger on wasting away > precious server resources. In other words, it would be a scalability > issue. > > If your search results are limited to say a few pages or if > scalability is not a problem or if the search query is very complex > and time-consuming to perform, you could turn your queryset into a > list and cache it (using Django's caching framework) and then feed it > to your view from the cache if found. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Traversing Deep Model Objects in template...
I'm using the Books, Publishers, Authors example from the documentation (Django Book) and I'm trying to figure out how to get related data in a list. For example, I want to print a list of books and a list of authors for each book in my template. What do I have to do to make the code below function? view.py ... def index(request): books = Book.objects.all().select_related()[:3] return render_to_response('books/index.html', {'books':books,}) ... template.py ... {% for book in books %} {{ book.title }} {% for author in book.authors %} {{ author }} {% endfor %} {% endfor %} ... 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: Traversing Deep Model Objects in template...
Is this the *best* way to accomplish this? It seems like the author DB query per book isn't very efficient (where it might sense to do a JOIN) Also, if I was doing any more "levels" things would get very complicated and bloated. view.py: ... def index(request): data = Book.objects.all().values('id','title',) books = [] for b in data: book = Book.objects.all().get(id=b['id']) authors = book.authors.all().values('first_name','last_name',) books.append({ 'id': b['id'], 'title':b['title'], 'authors':authors, }) return render_to_response('books/index.html', {'books':books,}) ... template.html: ... {% for book in books %} {{ book.title }} {% for author in book.authors %} {{ author.first_name }} {{ author.last_name }} {% endfor %} {% endfor %} ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Dojo LayoutContainer and ContentPane as application frame?
Hello Group, I tried to setup a kind of frame architecture with the dojo layout container widget. The idea is to load the menu (fisheye widget menu) only once and let the django page itself load asynchronously into a ContentPane. A dojo menu widget loads an url in the content pane like this: function load_app(id){ var docPane = dojo.widget.byId("docpane"); if (id == 6) { docPane.setUrl("/projects/"); } } Projects is an application of my site. The main urls.py includes the url of the projects application: (r'^projects/', include('mugdisite.apps.projects.urls')), The project app urls.py has the following: . info_dict = { 'queryset': Project.objects.all(), } urlpatterns = patterns('', (r'^$', 'django.views.generic.list_detail.object_list', dict(info_dict, paginate_by=10)), ... The urlpatterns work ok when I enter localhost:8000/projects directly. However, in the dojo ContentPane the result is "Error loading '/ projects/' (200 OK)". When I modify the main urls.py to direct to a HTML template directly, the inclusion works (r'^projects/', 'django.views.generic.simple.direct_to_template', {'template': 'projects-entry.html'}), Do you think it is somehow possible to trick the dojo widget which expects a HTML file, I think? I am using the django trunk version and dojo 0.4. Would be happy for any help. Dennis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
AttributeError: 'module' object has no attribute
Hello, I keep getting this error and I can't seem to track where it is coming from. I am working with django-0.91. I had a calendar app that was installed but I commented calendar out in my installed apps and commented it out in the urlpatterns. So there should be no reason why this is trying to load this module. Could the error be coming from somewhere else. I entionally placed errors in the settings.py and urls.py file to see if it would trip up on that and it doesn't even make it to that point. I am stumped and don't know where else it could be erroring out at. AttributeError: 'module' object has no attribute 'calendar' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Dojo LayoutContainer and ContentPane as application frame?
ok the solution was dojo.io.bind({ url: "/projects/", load: function(type, data, evt){ docPane.setContent(data); }, mimetype: "text/html" }); sorry ... On 31 Jul., 22:37, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hello Group, > > I tried to setup a kind of frame architecture with the dojo layout > container widget. > The idea is to load the menu (fisheye widget menu) only once and let > the django page itself load asynchronously into a ContentPane. > A dojo menu widget loads an url in the content pane like this: > > function load_app(id){ > var docPane = dojo.widget.byId("docpane"); > if (id == 6) { > docPane.setUrl("/projects/"); > } > } > > Projects is an application of my site. The main urls.py includes the > url of the projects application: > (r'^projects/', include('mugdisite.apps.projects.urls')), > > The project app urls.py has the following: > . > info_dict = { > 'queryset': Project.objects.all(),} > > urlpatterns = patterns('', > (r'^$', 'django.views.generic.list_detail.object_list', > dict(info_dict, paginate_by=10)), > ... > > The urlpatterns work ok when I enter localhost:8000/projects directly. > > However, in the dojo ContentPane the result is "Error loading '/ > projects/' (200 OK)". > > When I modify the main urls.py to direct to a HTML template directly, > the inclusion works > (r'^projects/', 'django.views.generic.simple.direct_to_template', > {'template': 'projects-entry.html'}), > > Do you think it is somehow possible to trick the dojo widget which > expects a HTML file, I think? > I am using the django trunk version and dojo 0.4. > > Would be happy for any help. > > Dennis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Flickr / Django
Bret, Your model and sync script looks exactly like what I was starting to write!! Heck yeah! Anyway, I have everything set up but I keep getting this error and I'm not 100% sure why Traceback (most recent call last): File "flickr/flickrupdate.py", line 7, in from models import Photo File "/home2/spyderfcs/webapps/django/bradmcgonigle/flickr/ models.py", line 1, in from django.db import models File "/home2/spyderfcs/lib/python2.5/django/db/__init__.py", line 7, in if not settings.DATABASE_ENGINE: File "/home2/spyderfcs/lib/python2.5/django/conf/__init__.py", line 28, in __getattr__ self._import_settings() File "/home2/spyderfcs/lib/python2.5/django/conf/__init__.py", line 53, in _import_settings raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined. On Jun 29, 5:06 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Here's a model and syncronization script I > wrote:http://www.djangosnippets.org/snippets/299/ > > BW > > On May 25, 3:14 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > Hi everyone, > > > I'm trying to write a view that displays a selection from someFlickr > > groups on a page. > > > I'm unsure where to begin... > > > I've read this: > > >http://code.djangoproject.com/wiki/FlickrIntegration > > > But unsure whether to use FlickrClient or FlickrApi > > >http://beej.us/flickr/flickrapi/ > > >http://micampe.it/projects/flickrclient > > > Any help in pointing me in the right direction would be greatly > > appreciated! 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 -~--~~~~--~~--~--~---
Making get_or_create (or equivalent) atomic on MySQL
Hi, I'm trying to atomically check if a certain field in the db exists and create it otherwise. I naively started using get_or_create but it seems like that function does not try to do things atomically at all. My database is MySQL and my table type is InnoDB. I installed the select_for_update patch and was calling select_for_update().get_or_create(): Tag.objects.select_for_update().get_or_create(name = tagName) This gave me a deadlock when run from multiple threads. I also tried select_for_update().get() with a try except on DoesNotExist and then calling create separately: try: Tag.objects.select_for_update().get(name = tagName) except Tag.DoesNotExist: Tag.objects.create(name = tagName) I still get a deadlock. It appears that MySQL does not create the exclusive lock on the row in Tag because it does not exist yet. Is there a good way (simple or not) of performing this operation (get_or_create) atomically, even if it is MySQL specific. I appreciate any help! Thanks, Can Sar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Including view in a template
In the view.py code that you have calling your frontpage_template.html, you should put your code to query the database and generate your user list and articles. You would then pass these to your html template via: return render_to_response('frontpage_template.html', {'list_users':list_users,'latest_articles':latest_articles}) On Aug 1, 2:34 pm, sagi s <[EMAIL PROTECTED]> wrote: > I am trying to find a way to include a view in a template. The view > generates an html snippet based on a DB query + another template. In > pseudocode what I am trying to achieve is: > > frontpage_template.html: > {{% include header.html %}} > {{% load /views/list_users %}} > {{% load /views/latest_articles %}} > ... > > I tried loading a template instead and have that template issue an > Ajax Updater request to a view upon loading but it seems like an > overkill. > > Any suggestions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Including view in a template
Another option is to use AJAX to populate the "building block" areas. e.g. (Using JQuery) $(document).ready(function() { $('#block1').load('/views/list_users'); $('#block2').load('/views/latest_articles'); }); ... ... -Eric Florenzano On Aug 1, 11:34 am, sagi s <[EMAIL PROTECTED]> wrote: > I am trying to find a way to include a view in a template. The view > generates an html snippet based on a DB query + another template. In > pseudocode what I am trying to achieve is: > > frontpage_template.html: > {{% include header.html %}} > {{% load /views/list_users %}} > {{% load /views/latest_articles %}} > ... > > I tried loading a template instead and have that template issue an > Ajax Updater request to a view upon loading but it seems like an > overkill. > > Any suggestions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Compare column entries in database query
Hi everybody! I want to find all entries in a database where two specific fields are equal: mytable.objects.filter(column_a='column_b') But this gives me no results at all. I now managed to get it done with a .extra(), but I was wondering if this is the only possible solution. All examples in the documentation work with static values for comparison and there are no further details about the right hand side of the query. Thanks for reading! Thomas. P.S.: Here's the query which get's the work done: mytable.objects.extra(where=['column_a=column_b']) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Job Fair F/OSS project
I'm looking for some volunteers for a new open source project. At the Institute of Design (http://www.id.iit.edu ), our next project is a system for the management of our job fair (http://www.id.iit.edu/ recruitID/ ) The systems goal is to allow students and employers to enter their availability for interviews and have the system designate times and rooms for each to meet for interviews. The system includes much more than just this of course, but that is the main goal. We decided that this application is generic enough that it should be made into an F/ OSS project. So far the system will be built on Django and uses (hopefully) Prototype.js I've only really been using Django for a month now so anyone with real experience would be appreciated. The project is on the ground floor and some basic wire frames and a few other preliminary designs. I'm personally located in Chicago and West Virginia (about half of my time spent in each place), though you are welcome to help out from anywhere around the world! If you're interested, reply to this message, or contact me at cezar AT id.iit.edu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Queryset of instances bound to particular ForeignKey
In model B.. if you say modela = models.ForeignKey(ModelA) You could also say b.modela_set.all() On Aug 2, 8:18 pm, Lucky B <[EMAIL PROTECTED]> wrote: > If I gather correctly you want to see every ModelA that's bound to a > particular ModelB b? > > ModelA.objects.filter(modelBs=b) > > That gives you what you want. > > On Aug 2, 7:20 pm, Benjamin Goldenberg <[EMAIL PROTECTED]> wrote: > > > Hi everyone, > > I asked about this earlier today on IRC and no one knew of a way to do > > it. Basically I have a model, let's call it ModelA with a ForeignKey > > to an instance of ModelB. I would like QuerySet of all instances of > > ModelB that are bound to that particular ForeignKey. Does anyone have > > any idea of how to construct such a query? > > > Thanks, > > Benjamin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 handle forms with more than submit button
Something like this... function submitFunctionA() { document.getElementById('myform').action = "someurl"; document.getElementById('myform').submit() } function submitFunctionB() { document.getElementById('myform').action = "someotherurl"; document.getElementById('myform').submit() } . . some form fields . . First Save Button . . some other stuff... Second Save Button On Aug 2, 10:36 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi > > > create different URLs (and thus different views) for the different > > buttons and then redirect to wherever you want to go. > > How do I create a different URL for different buttons but under one > form? > > Thanks > james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 handle forms with more than submit button
Oh... forgot the semicolons after .submit(); but you get the picture On Aug 2, 11:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Something like this... > > > function submitFunctionA() > { >document.getElementById('myform').action = "someurl"; >document.getElementById('myform').submit() > > } > > function submitFunctionB() > { >document.getElementById('myform').action = "someotherurl"; >document.getElementById('myform').submit()} > > > > . > . > some form fields > . > . > First Save Button > . > . > some other stuff... > Second Save Button > > > On Aug 2, 10:36 pm, james_027 <[EMAIL PROTECTED]> wrote: > > > hi > > > > create different URLs (and thus different views) for the different > > > buttons and then redirect to wherever you want to go. > > > How do I create a different URL for different buttons but under one > > form? > > > Thanks > > james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 handle forms with more than submit button
Well... that's how I've been doing it anyway :) On Aug 2, 11:15 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > On Aug 3, 11:12 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Oh... forgot the semicolons after .submit(); but you get the picture > > thanks carole, yes I the picture. so its about javascript not > django ... > > cheers, > james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: get object qs with certain generic relation
On Aug 3, 12:54 pm, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > hello all, > > I have a generic relation Flag, with a FlagType: > > class FlagType(models.Model): > name = models.CharField(maxlength=50) > description = models.TextField() > > class Flag(models.Model): > type = models.ForeignKey(FlagType) # type of flag > content_type = models.ForeignKey(ContentType) > object_id = models.PositiveIntegerField() > content_object = generic.GenericForeignKey() > user = models.ForeignKey(User) > created = models.DateTimeField() > > So, for example "illegal" or "to feature" would be flags. Now we're > flagging Song objects and I would like a queryset that gets me all Songs > flagged with a flag of type "illegal". > > I can do: > >flag = FlagType.objects.get(name='illegal') >ctype = ContentType.objects.get_for_model(Song) >flagged = Flag.objects.filter(type=flag, >content_type=ctype).order_by('-created') >songs = [item.content_object for item in flagged ] > > But the problem is: I can't do extra things to this list like order_by() > or an extra filter() or exclude(). > > How can I get the same result, but still have a queryset (containing > Songs) instead of a list?? > > - bram songs = Song.objects.filter(id__in=[item.content_object.id for item in flagged]) .. would hit the DB again .. but requires little code. Post back if another hit isn't a viable option and we'll take a closer look at the problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: get object qs with certain generic relation
On Aug 3, 1:31 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Aug 3, 12:54 pm, Bram - Smartelectronix <[EMAIL PROTECTED]> > wrote: > > > > > hello all, > > > I have a generic relation Flag, with a FlagType: > > > class FlagType(models.Model): > > name = models.CharField(maxlength=50) > > description = models.TextField() > > > class Flag(models.Model): > > type = models.ForeignKey(FlagType) # type of flag > > content_type = models.ForeignKey(ContentType) > > object_id = models.PositiveIntegerField() > > content_object = generic.GenericForeignKey() > > user = models.ForeignKey(User) > > created = models.DateTimeField() > > > So, for example "illegal" or "to feature" would be flags. Now we're > > flagging Song objects and I would like a queryset that gets me all Songs > > flagged with a flag of type "illegal". > > > I can do: > > >flag = FlagType.objects.get(name='illegal') > >ctype = ContentType.objects.get_for_model(Song) > >flagged = Flag.objects.filter(type=flag, > >content_type=ctype).order_by('-created') > >songs = [item.content_object for item in flagged ] > > > But the problem is: I can't do extra things to this list like order_by() > > or an extra filter() or exclude(). > > > How can I get the same result, but still have a queryset (containing > > Songs) instead of a list?? > > > - bram > > songs = Song.objects.filter(id__in=[item.content_object.id for item in > flagged]) > > .. would hit the DB again .. but requires little code. > > Post back if another hit isn't a viable option and we'll take a closer > look at the problem. ... item.object_id :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Only save if changed?
In my site_users model (which extends auth user), I've got: def save(self): self.geocode = self.get_geocode() super(SiteUser, self).save() # Call the "real" save() method. get_geocode makes a call out to google's geocoding service, gives the city and state, and returns the geocode. Since there's a lot of activity on site_users, updating for board post counts and all sorts of other things, I don't want to call get_geocode unless city and state have actually changed. Is there a way to check if they've changed. I know there's an ifchanged filter for templates, but don't know about this. Or should I move it to the update profile view, and only get geocode when they actually update their profile? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Job Fair F/OSS project
Well, all that stuff is still up in the air. This is the very-very beginning of the project. I think the first thing I'd like to do is to setup a site, like google code or sourceforge. If anyone has a suggestion about which one is better, that'd be great. I know they all use SVN (I use Git), so that's not a factor. It's also possible for me to just setup a Trac site (I'm most likely gonna setup one anyhow) like I've been using with my previous internal projects and forego sourceforge and google code. On Aug 3, 5:12 am, "Chris Hoeppner" <[EMAIL PROTECTED]> wrote: > What kind of volunteers do are you looking for? What kind of tasks are > you looking to resolve? > > If I could have some more details (maybe have a look at the proposed > timeline) I'd be in :) > > 2007/8/3, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > > > > > > I'm looking for some volunteers for a new open source project. At the > > Institute of Design (http://www.id.iit.edu), our next project is a > > system for the management of our job fair (http://www.id.iit.edu/ > > recruitID/ ) > > > The systems goal is to allow students and employers to enter their > > availability for interviews and have the system designate times and > > rooms for each to meet for interviews. The system includes much more > > than just this of course, but that is the main goal. We decided that > > this application is generic enough that it should be made into an F/ > > OSS project. > > > So far the system will be built on Django and uses (hopefully) > > Prototype.js > > > I've only really been using Django for a month now so anyone with real > > experience would be appreciated. > > > The project is on the ground floor and some basic wire frames and a > > few other preliminary designs. > > > I'm personally located in Chicago and West Virginia (about half of my > > time spent in each place), though you are welcome to help out from > > anywhere around the world! > > > If you're interested, reply to this message, or contact me at cezar AT > > id.iit.edu > > -- > Best Regards, > Chris Hoeppner -www.pixware.org// My weblog --~--~-~--~~~---~--~----~ You received this message because you are subscribed to the Google 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: Only save if changed?
Thanks! On Aug 3, 3:04 pm, Forest Bond <[EMAIL PROTECTED]> wrote: > On Fri, Aug 03, 2007 at 07:37:17PM -0000, [EMAIL PROTECTED] wrote: > > > In my site_users model (which extends auth user), I've got: > > > def save(self): > > self.geocode = self.get_geocode() > > super(SiteUser, self).save() # Call the "real" save() method. > > > get_geocode makes a call out to google's geocoding service, gives the > > city and state, and returns the geocode. Since there's a lot of > > activity on site_users, updating for board post counts and all sorts > > of other things, I don't want to call get_geocode unless city and > > state have actually changed. > > def save(self): > if self.id is not None: > old_self = self.__class__.get(id = self.id) > if self.id is None or (old_self.city != self.city) or ( > old_self.state != self.state): > self.geocode = self.get_geocode() > super(SiteUser, self).save() > > -Forest > -- > Forest Bondhttp://www.alittletooquiet.net > > signature.asc > 1KDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Only save if changed?
On Aug 3, 3:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Thanks! > > On Aug 3, 3:04 pm, Forest Bond <[EMAIL PROTECTED]> wrote: > > > On Fri, Aug 03, 2007 at 07:37:17PM -, [EMAIL PROTECTED] wrote: > > > > In my site_users model (which extends auth user), I've got: > > > > def save(self): > > > self.geocode = self.get_geocode() > > > super(SiteUser, self).save() # Call the "real" save() method. > > > > get_geocode makes a call out to google's geocoding service, gives the > > > city and state, and returns the geocode. Since there's a lot of > > > activity on site_users, updating for board post counts and all sorts > > > of other things, I don't want to call get_geocode unless city and > > > state have actually changed. > > > def save(self): > > if self.id is not None: > > old_self = self.__class__.get(id = self.id) > > if self.id is None or (old_self.city != self.city) or ( > > old_self.state != self.state): > > self.geocode = self.get_geocode() > > super(SiteUser, self).save() > > > -Forest > > -- > > Forest Bondhttp://www.alittletooquiet.net > > > signature.asc > > 1KDownload For anyone trying this, I had to make it old_self = self.__class__.objects.get(id = self.id) instead of old_self = self.__class__.get(id = self.id) --~--~-~--~~~---~--~----~ You received this message because you are subscribed to the Google 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: Compare column entries in database query
Hi Russ! Thanks for the info! Saves me from trying around more. Yours, Thomas On Aug 2, 1:25 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/2/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > I want to find all entries in a database where two specific fields are > > equal: > > > mytable.objects.filter(column_a='column_b') > > At present, the answer is unfortunately 'you can't do this' (unless > you use a hack like the one you mentioned). > > I've had a few ideas on how to fix this; however, fixing this area of > code would require changes to an area that is currently undergoing a > major refactor. Once the query engine changes are complete, I have a > number of issues to address - this is one of them. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
css 404?
I've got a seemingly simple setup that I'm having problems with. The urlconf is: == from django.conf.urls.defaults import * from django.views.generic.simple import direct_to_template urlpatterns = patterns('', # Example: # (r'^home/', include('home.foo.urls')), # Uncomment this for admin: (r'^$', direct_to_template, {'template': 'home.html'}), (r'^admin/', include('django.contrib.admin.urls')), (r'^blog/$', include('home.blog.urls')), == I have a template directory having home.html in it. home.html has , but the server always 404s the css _only_, whether it is written as home.css or ./home.css. Emphasizing here that home.html and home.css are in the same directory but the server is not finding the latter. Is this a problem wih direct_to_template? Should I be using a simple view? Or django.contrib.flatpages? 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 -~--~~~~--~~--~--~---
login issue
Hi, I just read chapter 12 in djangobook.com on authentication: http://www.djangobook.com/en/beta/chapter12/ I am creating a new user in response to a registration form I've made, doing something like this: from django.contrib import auth from django.contrib.auth.models import User def createAccount(request): # extract information for PUT form request # ... newUser = User.objects.create_user(username_, email, pwd) newUser.save() auth.login(request, newUser) return HttpResponseRedirect('/userHome/') But there is an exception with the login. Apparently the user doesn't have a backend, as shown below. Thoughts? Thanks, Ivan www.kirigin.com AttributeError at /createAccount/ 'User' object has no attribute 'backend' Request Method: POST Request URL:http://127.0.0.1:8201/createAccount/ Exception Type: AttributeError Exception Value:'User' object has no attribute 'backend' Exception Location: /usr/lib/python2.5/site-packages/django/contrib/ auth/__init__.py in login, line 53 /usr/lib/python2.5/site-packages/django/contrib/auth/__init__.py in login 46. Persist a user id and a backend in the request. This way a user doesn't 47. have to reauthenticate on every request. 48. """ 49. if user is None: 50. user = request.user 51. # TODO: It would be nice to support different login methods, like signed cookies. 52. request.session[SESSION_KEY] = user.id # THIS LINE 53. request.session[BACKEND_SESSION_KEY] = user.backend ... 54. 55. def logout(request): 56. """ 57. Remove the authenticated user's ID from the request. 58. """ 59. try: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Maps / Variables in template system.
Hi I'm working on a project, where I have several items in a database with x and y coordinates. I want to plot these out in such a way that if there is not an item for a space, it shows a blank image in the table, and a corresponding picture if there does exist an item. However, in the template system, due to a lack of the ability to change variables, I'm not sure how I can do this. If theres a snippet somewhere that I couldn't find for just an increment tag, I'd be fine. Thanks for the help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Without Apache
I'd second the recommendation for lighttpd, and would suggest sqlite for the backend if you want to go slim and trim. I've worked with plenty of mssql servers and none of them ever brought to mind the word 'minimal'. Derek Willis On Aug 5, 3:50 pm, Parnell Springmeyer <[EMAIL PROTECTED]> wrote: > On Sun, 2007-08-05 at 22:10 +0200, János Juhász wrote: > > Dear Django Users! > > > I would like to use Django for some intranet applications, but I > > wouldn't like to install apache, pgsql, mysql and so. > > I would like to install the minimal ingredients for a working > > environment. > > WebServer: lighttpd > > > I have a mssql 2000 server, so the database backend is fine. > > I would install only python, django, and some other modules (pil, > > reportlab, ...), but not external applications. > > I recommend (if you can) ditching mssql 2000, if you cannot, at the > LEAST upgrade it. There are just too many security holes in mssql (and > its heavy to boot) to 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 -~--~~~~--~~--~--~---
Enjoy it !
Enjoy it ! 1) http://www.mmopawn.com 2) http://www.mmopawn.com 3) http://www.mmopawn.com 4) http://www.mmopawn.com 5) http://www.mmopawn.com 6) http://www.mmopawn.com 7) http://www.mmopawn.com a good site about world of warcraft - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: DB queries with filter and exclude
Given your view code above, what would the template code look like to return something like this: object | tags ---+-- obj1 | food, meat obj2 | food, meat obj3 | food obj4 | food, cake obj5 | food, cake obj6 | food, vegetable obj7 | garden, vegetable On Aug 6, 1:46 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > Now I want to get all objects, which have set tag "food" *and* *have > > not* set tag "cake". > > > This get all objects with tag="food" set (obj1..obj5): > > >Obj.objects.filter(tags__in=[Tags.objects.filter(name='food')]) > > > This get all objects, which haven't set tag "cake" (obj1..obj3, obj6..obj7): > > >Obj.objects.exclude(tags__in=[Tags.objects.filter(name='cake')]) > > > When I try to combine DB queries together, I don't get what I expect > > (obj1..obj3, obj6): > > Django's ORM doesn't handle this sort of thing very gracefully, > so it requires dropping down to a little SQL with .extra() calls. > > Something like > > Obj.objects.extra(where=[""" > app_model.id IN ( >SELECT model_id >FROM app_tags >WHERE name = ? > ) > """, ['food']).extra(where[""" > app_model.id NOT IN ( >SELECT model_id >FROM app_tags >WHERE name = ? > ) > """, ['cake']) > > it's ugly and hackish, but when things scale up, this is the only > way to get it to work (I've got several hundred thousand records > in my app that does logic like this, so I need all the > speed-boost I can get) > > if your tagsets return small collections, you could use > sets...something like > > food = set(t.obj_id for t in Tags.objects.filter(name='food')) > cake = set(t.obj_id for t in Tags.objects.filter(name='cake')) > Obj.objects.filter(id__in=food - cake) > > (that last line might need to be "tuple(food-cake)") > > but as noted, this doesn't scale well once "food" or "cake" tags > thousands of things (or maybe even hundreds of things). > > -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: DB queries with filter and exclude
Wow, thanks for the reply. I can't get this to work though--I get an "iteration over non-sequence". Can you take a look? model... class Author(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=40) def __str__(self): return '%s %s' % (self.first_name, self.last_name) class Book(models.Model): title = models.CharField(maxlength=100) authors = models.ManyToManyField(Author) def __str__(self): return self.title view... def authors(request): a = Author.objects.all() return render_to_response('books/authors.html', {'authors':a,}) template... {% for author in authors %} {{ author }} {% for book in author.book_set %} {{ book }}{% if forloop.last %}{% else %}, {% endif %} {% endfor %} {% endfor %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 split up views into different files...
I'd like to have a separate view files for each model just to make everything a little neater. What's the best way to do 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 -~--~~~~--~~--~--~---
Single-line comment doesn't seem to work
I've the following template and when I render it, the single line comment doesn't get commented out. Am I missing something; I'm new to Django and just start playing with the templates. template Test single line and multi-lines comments Test1 hello {# This should be commented out #} hello {{ link|escape }} {% comment %} The following two lines should be commented out Test2 {{ link|urlencode }} {% endcomment %} Test3 {{ html|escape }} ### Render output >>> print render_to_response('testtmpl.html', {'link':link, 'html':html}) Content-Type: text/html; charset=utf-8 Test single line and multi-lines comments Test1 hello {# This should be commented out #} hello <<<--- http://172.27.78.97:/is/launch_calendar/event/?type__id__exact=3 Test3 this is a quote statment some other \stuff Thanks, ~Carmen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Single-line comment doesn't seem to work
The templates are html...so to comment you would use On Aug 7, 2:32 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I've the following template and when I render it, the single line > comment doesn't get commented out. > Am I missing something; I'm new to Django and just start playing with > the templates. > > template > Test single line and multi-lines comments > > Test1 > hello {# This should be commented out #} hello > {{ link|escape }} > > {% comment %} > The following two lines should be commented out > Test2 > {{ link|urlencode }} > {% endcomment %} > > Test3 > {{ html|escape }} > > ### Render output>>> print render_to_response('testtmpl.html', {'link':link, > 'html':html}) > > Content-Type: text/html; charset=utf-8 > > Test single line and multi-lines comments > > Test1 > hello {# This should be commented out #} hello > <<<---http://172.27.78.97:/is/launch_calendar/event/?type__id__exact=3 > > Test3 > this is a quote statment some other \stuff > > Thanks, > ~Carmen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 user account login
Hi, On Aug 8, 5:02 am, james_027 <[EMAIL PROTECTED]> wrote: > How do I enable multiple user account login in one computer? I don't > know what is the disadvantage if this works this way, I just need it > for development and testing purpose. I am using a little different approach on my dev. server. I've created 2 aliased for localhost (thanks its easy on Unix, just added entries to /etc/hosts) and now I am working on 2 URLs: http://dev.version:PORT/ http://admin.dev.version:PORT/ and I am running my app with: ../manage.py runserver dev.version:PORT This means that I can login as typical user and as admin from the same browser instance. Since domains are different, cookies are sent to different domains and they do not mix. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 rather big, new django site:
Hi, It's cool :) Can I ask one question: have you used patch 2070 to allow users to upload stuff? Or have you created one internally? Or do you just use Django default upload system, where everything goes into RAM? 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: How to add a javascript calendar to date textboxes
I've done that, and it's not hard, but there's quite a few good js datepickers out there, and on my most recent one I used one of those gives me a bit more control over how I want it to look on the public-facing part, and I'm not making 5 http calls to do it. Here's the one I went with: http://www.frequency-decoder.com/demo/date-picker-v2/ And again, it's just adding a class to the input. On Aug 7, 5:45 pm, Noam <[EMAIL PROTECTED]> wrote: > Hello, > > I wanted to add a javascript calendar (like the one you have in > Django's admin) to a date textbox in a form. > I found this post, which says how to do > it:http://groups.google.com/group/django-users/browse_frm/thread/3328829... > > I thought I might share with you how I did it - I think that it's > simpler than what's described there. > > To add the calendar, you only need to: > > 1. Make sure that the admin interface is enabled. > 2. Add this to the element in your HTML template: > > > > > > > > Note that this assumes that your admin media sits in "/media". If it's > not the case, you need to replace "/media" with your admin media path. > > 3. Add an attribute class="vDateField" to your > element. > If you're using the newforms library, you can do it by using a line > like this in your form definition: > date = > forms.DateField(widget=forms.TextInput(attrs={'class':"vDateField"})) > > Have a good day, > Noam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Why aren't my flatpages working?
OK, I've looked over this again: http://www.djangoproject.com/documentation/flatpages/ I've got MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 'django.middleware.doc.XViewMiddleware', 'classic.utils.lastseen.LastSeen', ) django.contrib.flatpages is an installed app. I can see it in the admin, and have the URL set to /about/ There's only one site, so it's selected. But when I go to /about/ I 404. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why aren't my flatpages working?
I believe so. There's only one, and the domain matches the site domain. In the DB, it has the ID 1. Not seeing anything wrong there. On Aug 8, 10:28 am, "Jay Parlar" <[EMAIL PROTECTED]> wrote: > On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > > OK, I've looked over this again: > >http://www.djangoproject.com/documentation/flatpages/ > > > I've got > > MIDDLEWARE_CLASSES = ( > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', > > 'django.middleware.doc.XViewMiddleware', > > 'classic.utils.lastseen.LastSeen', > > ) > > > django.contrib.flatpages is an installed app. > > > I can see it in the admin, and have the URL set to /about/ > > There's only one site, so it's selected. > > > But when I go to /about/ I 404. > > Do you have the domain set properly in the Sites app? > > Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why aren't my flatpages working?
Unless it's the subdomain... I've got it set up as test.domain.com, could that hose it? Should I just have domain.com? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why aren't my flatpages working?
I dunno. Never had a problem with them before. Lemme try the subdomain thing. On Aug 8, 10:36 am, "Jay Parlar" <[EMAIL PROTECTED]> wrote: > On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > Unless it's the subdomain... I've got it set up as test.domain.com, > > could that hose it? Should I just have domain.com? > > Not really sure :) All I know is that I've had 404s with flatpages > before, and it's always because I forgot to change out the default > "example.com" in Sites. > > Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: database permissions
On Aug 8, 9:49 am, Stephen Bunn <[EMAIL PROTECTED]> wrote: > I know it obviously needs to be able to execute SELECT, UPDATE, and > INSERT statements, but what about ALTER? SHOW? does it need to create > views? create indexes? what about locking tables and creating temporary > tables? The true minimum permissions for your DB are not dependent entirely on Django -- what you plan to do with the particular application you build using Django is just as important. Obviously, when you run syncdb to create tables from ORM, you are going to need to give the django user CREATE permission. Don't know if there are cases where it would use ALTER. Once the tables are created, you can revoke the user's CREATE, ALTER, and DROP perms. All tables are going to need SELECT; so far as I know, none of them are going to need SHOW. Most tables will need INSERT, but not necessarily all -- suppose you have a table that is populated by a different app, and all Django does is consume the data. You may or may not need DELETE for any given table, again depending on how you plan to use it. As with any serious security issue, there is no quick easy right answer. The safe bet is always assume your setup is insecure, unless you have solid reason to believe otherwise. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Single-line comment doesn't seem to work
Thanks for all the replies! I am using 0.95, maybe that's why it doesn't work. ~cw On Aug 8, 12:42 am, Collin Grady <[EMAIL PROTECTED]> wrote: > What version of django are you using? I seem to remember the single > line comments being added after 0.96, though I could be mistaken. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Access the request object in a filter?
Hey All, I'm trying to create a 'shopping' website, and one of the design elements that is necessary is that the "Purchase this item" link changes to a "Remove this item from your cart" link when the item has been added to the user's Shopping Cart. When an object is added to the shopping cart, a ShoppingCartItem object is created (this is necessary to allow for things like quantities, item discounts, shipping calculation etc...), and I need to tell whether a ShoppingCartItem the exists for a particular Item (fk'd to the user's ShoppingCart). Everything works great apart from this bit. I know that I can make a template tag that has access to the request object (added by the Context Processors), but am a bit stuck as to how to do this in a filter. Ideally I would like to do something like: {% if item|in_cart %}foo{% else %}bar{% endif %} So, all I really need to know is how I would get access to the request object in a filter. I haven't tried it, but don't think {% if item|in_cart:request.session.cart %} Would work. Any help in getting access to the request (or session) data in a filter, or a better way if anyone can think of it, would be much appreciated. Kind Regards, Oliver --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: testing
Для тестов существуют модули doctest и unittest, попробуй почитать документацию :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: (1040, 'Too many connections')
I'm pretty sure that will help you - http://blog.webfaction.com/tips-to-keep-your-django-mod-python-memory-usage-down --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is this not allowed select_related()
He means that you can remove: employee = models.ForeignKey(Employee) from your 'EmployeeAssignment' and 'EmployeeContract' models because the relationship is already defined in your 'Employee' model. You can use reverse relations to get the relation instead. On Aug 8, 10:58 pm, james_027 <[EMAIL PROTECTED]> wrote: > Hi collin > > On Aug 9, 1:06 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > > > Because you have an infinite loop there. > > > Why are you linking both directions? There's a reverse relation > > available to get from EmployeeAssignment and EmployeeContract back to > > the Employee model, you don't need to explicitly define it. > > The EmployeeAssignment and EmployeeContract keeps track the history of > each employee contract and assignment they receive, while the > employee_contract and the employee_assignment attributes tells their > current status ... > > Regards, > james --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
[Q] Django with modpython in Ubuntu
Dear all, I have a problem using mod_python with Django (v 0.95) under apache2 in Ubunu. I followed all the steps described in the online documentation, but it did not work. The followins is how I set up the httpd.conf and error message I got. httpd.conf: DirectoryIndex index.php index.html index.htm AcceptPathInfo on SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On PythonPath "['/home/yjlee/Worx/Django/Projects'] + sys.path" I created a project with "django-admin.py startproject mysite" at "/ home/yjlee/Worx/Django/Projects" directory. When I pointed my web browser to "http://edtech.soe.ku.edu/mysite/; I got the following error messages: Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/var/lib/python-support/python2.5/django/core/handlers/ modpython.py", line 163, in handler return ModPythonHandler()(req) File "/var/lib/python-support/python2.5/django/core/handlers/ modpython.py", line 136, in __call__ response = self.get_response(req.uri, request) File "/var/lib/python-support/python2.5/django/core/handlers/ base.py", line 59, in get_response response = middleware_method(request) File "/var/lib/python-support/python2.5/django/contrib/sessions/ middleware.py", line 69, in process_request request.session = SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)) File "/var/lib/python-support/python2.5/django/core/handlers/ modpython.py", line 59, in _get_cookies self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', '')) File "/var/lib/python-support/python2.5/django/http/__init__.py", line 150, in parse_cookie c.load(cookie) File "Cookie.py", line 619, in load self.__ParseString(rawdata) File "Cookie.py", line 650, in __ParseString self.__set(K, rval, cval) File "Cookie.py", line 572, in __set M.set(key, real_value, coded_value) File "Cookie.py", line 451, in set raise CookieError("Illegal key value: %s" % key) CookieError: Illegal key value: hide:inst11 Can anyone help me solve this problem? Thanks in advance. Young-Jin Lee --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django with modpython in Ubuntu
I cannot explain it, I was able to solve this problem by deleting cache of my browser. Young-Jin On Aug 9, 12:53 pm, John <[EMAIL PROTECTED]> wrote: > It would appear to > Be a problem with your cookie.py > File.In order for me to help you further I will need > To see The source of said file > > John Menerick > > Sent from my iPhone > > On Aug 9, 2007, at 9:03 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED] > > > wrote: > > > Dear all, > > > I have a problem using mod_python with Django (v 0.95) under apache2 > > in Ubunu. > > I followed all the steps described in the online documentation, but it > > did not work. > > The followins is how I set up the httpd.conf and error message I got. > > > httpd.conf: > > DirectoryIndex index.php index.html index.htm > > AcceptPathInfo on > > > > >SetHandler python-program > >PythonHandler django.core.handlers.modpython > >SetEnv DJANGO_SETTINGS_MODULE mysite.settings > >PythonDebug On > >PythonPath "['/home/yjlee/Worx/Django/Projects'] + sys.path" > > > > > I created a project with "django-admin.py startproject mysite" at "/ > > home/yjlee/Worx/Django/Projects" directory. > > > When I pointed my web browser to "http://edtech.soe.ku.edu/mysite/; > > I got the following error messages: > > Mod_python error: "PythonHandler django.core.handlers.modpython" > > > Traceback (most recent call last): > > > File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line > > 299, in HandlerDispatch > >result = object(req) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > modpython.py", line 163, in handler > >return ModPythonHandler()(req) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > modpython.py", line 136, in __call__ > >response = self.get_response(req.uri, request) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > base.py", line 59, in get_response > >response = middleware_method(request) > > > File "/var/lib/python-support/python2.5/django/contrib/sessions/ > > middleware.py", line 69, in process_request > >request.session = > > SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, > > None)) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > modpython.py", line 59, in _get_cookies > >self._cookies = > > http.parse_cookie(self._req.headers_in.get('cookie', '')) > > > File "/var/lib/python-support/python2.5/django/http/__init__.py", > > line 150, in parse_cookie > >c.load(cookie) > > > File "Cookie.py", line 619, in load > >self.__ParseString(rawdata) > > > File "Cookie.py", line 650, in __ParseString > >self.__set(K, rval, cval) > > > File "Cookie.py", line 572, in __set > >M.set(key, real_value, coded_value) > > > File "Cookie.py", line 451, in set > >raise CookieError("Illegal key value: %s" % key) > > > CookieError: Illegal key value: hide:inst11 > > > Can anyone help me solve this problem? > > > Thanks in advance. > > > Young-Jin Lee --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ReStructuredText, markdown and other
I'm watching on some light markup languages that can be used in Python - what they can and what they can't do. I'm planning to use one in a "sandbox" on my sites and more or less in other apps with some extra plugins. Markdown: + simple, easy to understand + there is showdown - markdown in JS so online preview :) (http:// www.attacklab.net/showdown-gui.html) - limited syntax (no tables) - hard to extend ReST: + powerfull syntax + rather easy to extend - not so obvious syntax in some places - errors on bad syntax Textile: + powerfull syntax + looks quite good ? never used it, ? are there some extras ? Currently I'm on Markdown + my template filter on top of it buy maybe it's better to use python-born ReST? What are your experiences with them? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Two Things
New to the group, so I thought I'd post my favorite Django video: http://video.google.com/videoplay?docid=-70449010942275062 Django book: http://www.amazon.com/Pro-Django-Development-Done-Right/dp/1590597257/ref=pd_bbs_sr_1/104-7275500-7139960?ie=UTF8=books=1186719760=8-1 Cheers, Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Two Things
Thanks Mike. -LJ On Aug 10, 12:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > New to the group, so I thought I'd post my favorite > > Django video:http://video.google.com/videoplay?docid=-70449010942275062 > Django > book:http://www.amazon.com/Pro-Django-Development-Done-Right/dp/1590597257... > > Cheers, > > Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
MediaWiki Port in Django - Project Interest?
I've got a project where I need to build a public wiki for some community websites. The main requirement is that the functionality be similar to Mediawiki since many people are familiar with the way that software works. Does anyone know if a project like this has been undertaken? Would anyone be interested in helping develop it? Would anyone be interested in using it if it was released as a contrib app? (Before anyone asks why I'm reinventing the wheel, I don't use PHP anymore, I don't have PHP installed on my production servers, and I want to use a common authentication system that is already in place with my very large Django project) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Feed question
I have an events model, and a feed for it - shows all events Events has a foreign key relationship with Club. What I'd like to do is have a feed for each club, but I'm not sure how to get that into a feed without explicitly defining it for each club. Say I have two clubs, Foo and Bar, I want something in feeds.py like: def items(self): return Event.objects.filter(club=theClub).order_by('-created') where theClub is Foo, or Bar, or whatever. Can I do this with the built-in feeds framework? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Google Checkout w/out a shopping cart?
I'm trying to build a very simple ecommerce page using Google Checkout without the use of a shopping cart. Here are my models: class Team(models.Model): name = models.CharField(maxlength=30, unique=True) def __str__(self): return self.name class Meta: ordering = ['name'] class Admin: pass class Association(models.Model): name = models.CharField(maxlength=30, unique=True) def __str__(self): return self.name class Meta: ordering = ['name'] class Admin: pass class OrderForm(forms.Form): association = forms.ModelChoiceField(queryset=Association.objects.all()) team = forms.ModelChoiceField(queryset=Team.objects.all()) I'd like users to be able to select their association and team from a drop down list, and send their selection immediately to Google Checkout without the use of a shopping cart. Is there a way to capture their selection and send "team" as the item- name, and "association" as its description? Here's my view function so far: def order(request): order_form = OrderForm() return render_to_response('order.html', {'order_form': order_form}) And here's how I'm currently trying to send the info through Google Checkout: Right now, when I send this to Google Checkout, instead of sending the name of the Association and Team that was selected, it sends the word "team" as the item-name, and "association" as the item-description. Please let me know if you have any insight! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Syncing microformat data with generic views
If anyone's interested, I posted how I'm creating vcard and ical data with generic views so people can just click a link or button to sync things up with their calendar or address book. I suspect it's riddled with errors and bad advice, so be kind: http://thebitterpill.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: Generating charts with ReportLab
This library looks pretty nice too... for graphs... if you decide not to go the reportlab route. I haven't fiddled with it any, but was looking over the docs and it looks promising: http://nullcube.com/software/pygdchart2.html On Aug 6, 4:12 am, "Ben Ford" <[EMAIL PROTECTED]> wrote: > Hi Carole, > Just FYI as they are kind of related topics, I've created a project called > django-reports <http://code.google.com/p/django-reports/> with some of my > code for reporting on your django objects. I thought you might find it > interesting and integration with reportlabs would be a cool feature for the > future. See my other message to the group or the link for more details. To > everyone else: Sorry for the double message for those of you not using gmail > :-) > Ben > > On 30/07/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > > Hey Ben...thanks...I'll check that out. > > > We'll most likely continue to use ReportLab for our project, as we are > > using the graphs in some reports we are going to export to PDF... but > > looks like an interesting read :) > > > I'll also add the other two samples to the wiki this week... > > Carole > > > On Jul 30, 4:29 am, "Ben Ford" <[EMAIL PROTECTED]> wrote: > > > Hey Carole, > > > A guy called Toby has put something together using R and rpy that does > > > graphs... I haven't been able to make it work as yet, but he's keen to > > move > > > on with it, and wants some testers and some help! > > > Check out: > >http://groups.google.com/group/django-users/browse_thread/thread/43ea... > > > > or just have a look through your gmail for *Re: Graphs and django.* > > > (The search string "contrib namespace r" worked for me.) > > > Ben > > > > On 30/07/07, David Reynolds <[EMAIL PROTECTED] > wrote: > > > > > On 28 Jul 2007, at 4:34 am, [EMAIL PROTECTED] wrote: > > > > > > I had the need to generate a few different types of charts using > > > > > ReportLab. The wiki only had a sample of a Horizontal Bar Chart, so > > > > > I've added a new sample on how to produce a Line Chart... > > > > >http://code.djangoproject.com/wiki/Charts > > > > > > If anyone is interested in a sample for a Pie or Scatter chart, let > > me > > > > > know, and I can add samples of these as well. > > > > > I would say, go ahead and add them, as I'm sure many people will find > > > > them useful at some point. > > > > > Thanks, > > > > > David > > > > > -- > > > > David Reynolds > > > > [EMAIL PROTECTED] > > > > -- > > > Regards, > > > Ben Ford > > > [EMAIL PROTECTED] > > > +628111880346 > > -- > Regards, > Ben Ford > [EMAIL PROTECTED] > +628111880346 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---