How to get cms like features in Django
Hello All, I have pages like home, contact us, about us, that are on nearly every webapp that I create. The other parts of the webapps are specific to some business requirement, but the *us type pages are not. Unlike the application pages proper, this supporting pages need to be updated occasionally when the system is Live, and by non-programmers. I could use a CMS, and then have links to my app on the pages. But, I don't want to run a full blown CMS and Python/Django. And getting the templates working in both seem like extra work. I have searched a bit, and haven't found support for this. So I thought I would roll my own (see below.) Does anyone else have this need? How do you solve it? class CMSPage page_data = page = urls.py (r'^about/$', 'about'), views.py def about(request): page = CMSPages.objects.get(page='about') return render_to_response('cms_page.html', {'page':page}, context_instance=RequestContext(request) ) cms_page.html : {{page.page_data}} Then I can let the user edit the CMSPage via the admin. And, perhaps I could even get TinyMCE or DOJO Editor going for them them. I just want to check there isn't support for this sort of thing, before I run of doing something custom. thanks Gene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it secure "enough" to put login info in the session?
Hi Craig, I'm considering something like this Trigger: User comes to site for the first time 1. User requests to be a guest 2. system creates a guest User with randomness for username and password, authenticates and logs in the user, also sets a cookie in the browser with the id of the Guest User. 3. User has full access to the site, however some features will be limited. Trigger: User returns to site 1. User requests to be a guest, and expects to see the data created in the first session 2. System checks cookie in browser for an ID, if one is found, find a matching Guest User, auth and login 3. User continues to us the site If the user tried to log in as a guest from another computer, they will, of course, not see they're information. In fact, they will see the information that was saved, if a guest was every created on that machine. I'm not too worried about that at this point. I'm just working through when Django saves a cookie, and I think this will work. Gene On Sep 9, 5:54 pm, Craig McClanahan wrote: > On Tue, Sep 8, 2009 at 10:20 PM, ristretto.rb wrote: > > > Hi > > > I want to have a guest concept. You get instant access to my app. > > There are limits. But, you will be allowed to come back multiple > > times before I require you to register. > > How do you plan to tell if the guest "came back"? The only reasonable > mechanism I can think of is to use a session cookie (you can't rely on > things like IP address ... like most folks with a home router, all the > computers in my household will appear to have the same IP address to a > service we contact, and the same would be true for most business > situations). And even if you rely on a session cookie, your > restrictions are easily bypassed by the user who simply clears their > cookie cache. > > Until you can solve this problem reliably (good luck!), the > implementation details are not really worth thinking about. But > things like using a session cookie are no more or less secure for this > use case than they are for the usual approach to keep a user logged on > to a web app, other than the fact that you'd probably need to keep > your session alive a lot longer. > > Craig > > PS: The typical solution I've seen for a "guest" concept is to offer > only a limited subset of the overall functionality to non-registered > users, with lots of teasers about "if you would only bother to > register, you could do FOO and BAR and BAZ!". Example: ESPN's web > site has a bunch of "freely available" stories accessible to anonymous > users, but the (presumbably) good stuff requires a login. Figuring > out the balance point is a challenge -- for me, for example, I'm not a > fantasy football junkie, so the extra subscribers-only analysis > doesn't have enough value for me to bother to register (or pay, as the > case may be). > > > > > When a user comes in as a guest, I will create a user with a bogus > > username, password and email, and put the user_id in the session, so > > that when the user comes back I can read it and restore saved state. > > > I'm mildly concerned that it's unsafe to put the user_id in the > > session. I can imagine a hacker faking that somehow, and getting > > access to other guest accounts. I'm not sure the risk is that big, > > and once users register, the risk goes down. But, I'm wondering if > > this is at all foolhardy. Is there a better way to approach this? > > > Perhaps a hash key or something that isn't sequentially too > > guessable. Or some encryption. > > > This guest concept has inherent security issues with shared computers: > > labs, cafes, etc. The user will made aware of this when logging in as > > Guest. Also there will be no sensitive or private data in this guest > > account that if seen by another user would make much difference. > > > Thanks for any insight > > Gene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Is it secure "enough" to put login info in the session?
Hi I want to have a guest concept. You get instant access to my app. There are limits. But, you will be allowed to come back multiple times before I require you to register. When a user comes in as a guest, I will create a user with a bogus username, password and email, and put the user_id in the session, so that when the user comes back I can read it and restore saved state. I'm mildly concerned that it's unsafe to put the user_id in the session. I can imagine a hacker faking that somehow, and getting access to other guest accounts. I'm not sure the risk is that big, and once users register, the risk goes down. But, I'm wondering if this is at all foolhardy. Is there a better way to approach this? Perhaps a hash key or something that isn't sequentially too guessable. Or some encryption. This guest concept has inherent security issues with shared computers: labs, cafes, etc. The user will made aware of this when logging in as Guest. Also there will be no sensitive or private data in this guest account that if seen by another user would make much difference. Thanks for any insight Gene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: login required
Have you not had a peek in here yet? http://docs.djangoproject.com/en/dev/topics/auth/#topics-auth gene On Sep 9, 4:30 pm, putih wrote: > hii, > > need your help on this matter :- > > 1. how to restrict user for certain page. for example :- > > non-register user have to register first before they can join a > survey. after register, they login and redirect to the survey page. > (not main page.) > > anyone, please advise me on this problem. seriously i didn't have any > ideas on this matter.. > > thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
What do you use for a shopping cart (in an existing app?)
Hello, I would like to add shopping cart features to a current web application. Has anyone solved this type of problem? What did you do? Roll your own features (add to cart, view cart, payment, etc)? Use Satchmo? Use something else? Thanks Gene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Getting value from form in formset
Hi, I fear that I just haven't found this in the docs yet. But, here goes I'm using a formset to list out a number of text box fields. The initial number varies based on a couple of factors. But, never grows. The formset has initial_values. In the template, I have to preset the values in a jQuery block. I can look loop through the forms, and print the html text boxes fine, but I don't know how to get the integer value of the field, so I can set up the jQuery control. I'm thinking I may have used this formset feature for the wrong reason. But, I wanted to get the validation, and other support. Any thoughts? thanks Gene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Don't understand ModelForm
What I'm doing now is # TEMPLATE {% if modelform.instance.id %} {% endif %} # The POST part of the view method pk = request.POST.get('pk',None) if pk: model = models.House.objects.get(pk=pk) modelform = forms.MyModelForm(request.POST, instance=house) else: modelform = forms.MyModelForm(request.POST) Anyone else use this approach? gene On Aug 15, 12:07 pm, "ristretto.rb" wrote: > This is an excellent thread. I came here with the same questions as > Marc. My revelation seems to be that forms are for data, and saving > is control. And these two have separate concerns/goals. Such that > fields shouldn't be in forms for the sole reason to make control of > the form function properly. > > So you can put the id in you forms with a hidden, or in the action="" > attribute, or using some sort of JavaScript, or whatever. So, I > understand that the key should be controlled outside the scope of the > Django form support. > > But, I wonder if something like {{ form_set.management_form }} for > formsets could be used here. Perhaps something like > {{form.indentifier_key}} on a template in the form could by default > write out a hidden field of the pk of the instance. It would just be > shorthand for putting the instance in the context, and typing type="hidden" name="pk" value="{{instance.id}}"/> > > But, it could make your view work like this, so you don't have to > query up the model instance yourself. > > f = your_modelform(request.POST) > f.instance # would be the read from the DB and set for you. > > Gene > > On Jul 22, 9:23 am, Shawn Milochik wrote: > > > To expand on what Dan said with a full (tested and working) example: > > > In urls.py: > > > (r'^partner/$', 'partner_page'), > > (r'^partner/(?P\d+)/$', 'partner_page'), > > > In the form tag of your template: > > > > > The view: > > > @login_required > > def partner_page(request, partner_id = None): > > > if partner_id: > > #existing partner > > partner_instance = get_object_or_404(partner, pk = partner_id) > > else: > > #new partner > > partner_form = partnerForm() > > partner_instance = None > > > if request.POST: > > post_data = request.POST.copy() > > partner_form = partnerForm(post_data, instance = > > partner_instance) > > > if partner_form.is_valid(): > > the_partner = partner_form.save() > > partner_id = the_partner.id > > > template_file = 'partner.html' > > > context = { > > 'partner_form': partner_form, > > 'partner_id': partner_id, > > } > > > return render_to_response(template_file, context, > > RequestContext(request)) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Don't understand ModelForm
This is an excellent thread. I came here with the same questions as Marc. My revelation seems to be that forms are for data, and saving is control. And these two have separate concerns/goals. Such that fields shouldn't be in forms for the sole reason to make control of the form function properly. So you can put the id in you forms with a hidden, or in the action="" attribute, or using some sort of JavaScript, or whatever. So, I understand that the key should be controlled outside the scope of the Django form support. But, I wonder if something like {{ form_set.management_form }} for formsets could be used here. Perhaps something like {{form.indentifier_key}} on a template in the form could by default write out a hidden field of the pk of the instance. It would just be shorthand for putting the instance in the context, and typing But, it could make your view work like this, so you don't have to query up the model instance yourself. f = your_modelform(request.POST) f.instance # would be the read from the DB and set for you. Gene On Jul 22, 9:23 am, Shawn Milochik wrote: > To expand on what Dan said with a full (tested and working) example: > > In urls.py: > > (r'^partner/$', 'partner_page'), > (r'^partner/(?P\d+)/$', 'partner_page'), > > In the form tag of your template: > > > The view: > > @login_required > def partner_page(request, partner_id = None): > > if partner_id: > #existing partner > partner_instance = get_object_or_404(partner, pk = partner_id) > else: > #new partner > partner_form = partnerForm() > partner_instance = None > > if request.POST: > post_data = request.POST.copy() > partner_form = partnerForm(post_data, instance = > partner_instance) > > if partner_form.is_valid(): > the_partner = partner_form.save() > partner_id = the_partner.id > > template_file = 'partner.html' > > context = { > 'partner_form': partner_form, > 'partner_id': partner_id, > } > > return render_to_response(template_file, context, > RequestContext(request)) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why two identical entries in django.test.utils.ContextList while testing?
Ah, that's it. Thanks Karen. What an awesome quick response. My mistake. Thanks gene On Aug 7, 10:28 am, Karen Tracey wrote: > On Thu, Aug 6, 2009 at 5:41 PM, ristretto.rb wrote: > > > Hello, > > > I'm working on some unit tests using the Client that comes with > > subclassing django.test.TestCase. > > > When run code like this > > > response = self.client.get("/project/usecase") > > > The object response.context is a list type object containing two > > identical Dictionaries. > > The doc for this test response > attribute:http://docs.djangoproject.com/en/dev/topics/testing/#django.test.clie... > > notes that "If the rendered page used multiple templates, then context will > be a list of Context objects, in the order in which they were rendered." > > So I expect your page used multiple templates? > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Why two identical entries in django.test.utils.ContextList while testing?
Hello, I'm working on some unit tests using the Client that comes with subclassing django.test.TestCase. When run code like this response = self.client.get("/project/usecase") The object response.context is a list type object containing two identical Dictionaries. So, this errors ... self.assertTrue(response.context.has_key('blah'),"Blah not home.") But, this works self.assertTrue(response.context[0].has_key('blah'),"Blah not home.") or this self.assertTrue(response.context[1].has_key('blah'),"Blah not home.") Not sure why there are two. Any ideas? thanks Gene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ChoiceField, TypedChoiceField, ModelChoiceField and empty_label
Hello, I have stepped through code, and cruised the django docs, forums, and internet in general looking for how to setup an empty label with TypedChoiceField (or ChoiceField.) I suspected it would be done similar to the way it is done with ModelChoiceField. With ModelChoiceField, we can specify an empty_label. But, with TypeChoice and Choice you have to put an empty field in our choices list. And, None doesn't work, it has to be ''. I have code that is working fine. But, my question is... Is there any design reason empty_label was not included in the other Choice fields? thanks ristretto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: What debugger do you use?
I second that! WingIDE is aweome. I'm using NB with xdebug for PHP with one client, and WingIDE Pro (which gladly paid for) for python. I can say, for certain, that I would choose Wing over NB if I had to choose one. Gene Campbell On May 13, 1:54 am, James Matthews wrote: > I use WingIde and love it! > > On Mon, May 11, 2009 at 3:53 PM, Joshua Russo wrote: > > > > > I'm currently using Netbeans 6.5 with the Python plugin. I was just > > wondering what everyone else is using because NB is a bit buggy with > > the Python plugin at the moment. > > -- > > http://www.jewelerslounge.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ChoiceField with 0,1, or more than 1 choice, what's the best way to implement?
Hello, I have a page that must show data in one of the follow three ways. A. No choices: Nothing to choose from. Page will show nothing, or probably a message saying something about there being nothing to choose. B. 1 Choice: There is only 1 and you must choose it. So, not much of a choice here. Just show the one thing to the user a plain text, and don't show a choice menu at all. c. 2 or more Choices: In this case there is a choice to be made, so the user should see a menu to make a choice. I'm not sure if I should roll my own solution, or use a ChoiceField. I tried creating a ChoiceField in my form, and then not showing it in cases A or B, rather emitting a http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Does a Template Factory system exist, or do I need to build it?
Bloody brilliant! thanks for the reply Malcolm. gene On Dec 4, 4:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-12-03 at 19:19 -0800, ristretto.rb wrote: > > Hello, > > > I have a site that we plan to localize for different countries (all > > English speaking at this point.) Most of the templates in the site > > will localize fine as they are, but a few will need to be changed. I > > would like to have one set of templates that is the international > > (default) set, and then only create country specific templates when > > necessary. > > > Django template inheritance is excellent, and where I hope to find a > > solution. What I need is a way for my view methods to forward to > > generic template names, like 'home.html', 'info.html', etc, which > > correspond to the default set of templates, but if any of those > > templates have been overridden with a country specific template, (and > > the user is using the site from that locale,) that country specific > > one, for example 'home_au.html', should be used. > > This is one of the lesser-known features of Django and incredibly > useful. You can provide a list of template names that are to be tried in > order and the first one that is found is loaded. You can pass a list of > templates to render_to_response(), since it uses > django.template.loader.render_to_string(), which understands a list as > the first argument. Alternatively, you can use the > django.template.loader.select_loader() call directly to load the > template. You'll have to call render() on the template and put it in an > HttpResponse object yourself in that case, so normally > render_to_response() is going to be more useful. Documentation available > athttp://docs.djangoproject.com/en/dev/ref/templates/api/#the-python-api > > In your particular case, you'll arrive at the point where you're ready > to render the template and will know the language code. So pick a > consistent naming scheme and you'll be able to do something like this > (assuming 'locale' contains the locale you want to use) at the end of > your view function: > > return render_to_response(['home_%s.html' % locale, > 'home.html'], > ) > > If the 'home_au.html' template doesn't exist (and, personally, I can't > understand any site that doesn't make the Australian version the > default!), it will load the 'home.html' version. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Does a Template Factory system exist, or do I need to build it?
Hello, I have a site that we plan to localize for different countries (all English speaking at this point.) Most of the templates in the site will localize fine as they are, but a few will need to be changed. I would like to have one set of templates that is the international (default) set, and then only create country specific templates when necessary. Django template inheritance is excellent, and where I hope to find a solution. What I need is a way for my view methods to forward to generic template names, like 'home.html', 'info.html', etc, which correspond to the default set of templates, but if any of those templates have been overridden with a country specific template, (and the user is using the site from that locale,) that country specific one, for example 'home_au.html', should be used. I'm guessing I need to build a simple factory, and have all my views call it, and then rest the whole design on good file naming patterns. Any thoughts? 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: What do you use as a build tool (like Ant or make)
Thanks very much for the replies. I was really considering Vellum, and I still am. But, that was a very informative post from Kevin on zc.buildout. I'll have to give both a look. Look forward to your blog post Dan!! cheers gene On Sep 10, 9:58 pm, Dan Fairs <[EMAIL PROTECTED]> wrote: > > I haven't used any of them with Django, but for managing Zope, Plone > > and Grok based web apps, zc.buildout is the current preferred tool. > > I use zc.buildout to manage my Django builds. Blog post coming soon > (when the project's finished!) > > Cheers, > Dan > > -- > Dan Fairs <[EMAIL PROTECTED]> |http://www.stereoplex.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: What do you use as a build tool (like Ant or make)
Waf looks nice, I'll have a deeper look. Is anyone using Vellum - http://www.zedshaw.com/projects/vellum/index.html Thanks for all the replies On Sep 10, 1:52 am, Adam Stein <[EMAIL PROTECTED]> wrote: > I'm not doing unit tests at the moment, but for build and release I use > Waf (http://code.google.com/p/waf/), which happens to be written in > Python (including the configuration files). > > > > On Tue, 2008-09-09 at 01:14 -0700, ristretto.rb wrote: > > Hello, > > > What do you use to build a Django project? By build I mean, > > > * run unit tests > > * copy files to a distribution set based on a target (production, > > staging, clustered, etc.) > > * include config files specific to the target, and not including > > source control files and other development > > time artifacts. > > * transfer distribution > > > Perhaps you just hand build python scripts to do it. Or do you use > > Ant or make? I'm coming over from Java, and used to use Ant, but I'm > > migrating over to Python and would like to use what is generally > > considered the Pythonic way. > > > cheers > > > -- > > Adam Stein @ Xerox Corporation Email: [EMAIL PROTECTED] > > Disclaimer: Any/All views expressed > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
What do you use as a build tool (like Ant or make)
Hello, What do you use to build a Django project? By build I mean, * run unit tests * copy files to a distribution set based on a target (production, staging, clustered, etc.) * include config files specific to the target, and not including source control files and other development time artifacts. * transfer distribution Perhaps you just hand build python scripts to do it. Or do you use Ant or make? I'm coming over from Java, and used to use Ant, but I'm migrating over to Python and would like to use what is generally considered the Pythonic way. cheers --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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.views.generic.simple.direct_to_template doesn't support text/xml in urls.py?
I'm using 1.0 alpha, and had the same problem. Adding 'mimetype':'text/xml' as noted worked perfectly. thanks for the post!! On Aug 9, 8:25 pm, Valery <[EMAIL PROTECTED]> wrote: > Hi Julien, > > thank you for the answer. > > I've just tested your code, the effect is the same. Namely, > opensearch.xml returned from server has "text/html" type and not "text/xml". > > regards > Valery > > On 7 авг, 09:15, Julien Phalip <[EMAIL PROTECTED]> wrote: > > > The 'mimetype' argument is at the same level as 'template' and > > 'extra_context'. Therefore your code should be: > > > (r'^opensearch.xml$', > > 'django.views.generic.simple.direct_to_template', > > {'template': 'opensearch.xml', 'mimetype' : > > 'text/xml'}), > > > On Aug 7, 5:07 pm, "Valery Khamenya" <[EMAIL PROTECTED]> wrote: > > > > Hi all, > > > > the following entry: > > > > ... > > > (r'^opensearch.xml$', 'django.views.generic.simple.direct_to_template', > > > {'template': 'opensearch.xml', 'extra_context' : > > > {'mimetype' : "text/xml"}}), > > > ... > > > > inurls.pyworks out for me as text/html, nottext/xml. > > > > Anyone has comments on this? Thanks! > > > > best regards > > > -- > > > Valery A.Khamenya --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Another django db memory leak?
I wanted to point this out primarily to see if anyone was experiencing similar problems, or if there are any other general comments. I also am somewhat wondering if there should be bugs reported? Or am I outside the expected use cases for the db api? When I can free up time, I would be happy to investigate further and potentially contribute fixes or at least characterize the problems. With this I just wanted to start a dialog; I'm not asking for any help with a fixing the problem. I have temporarily fixed this problem by using some straight sql through a django.db.connection.query object in one case, and sequestering some db api client code in subprocs to keep the memory under control. Works fine, but may be not too DRY or portable, oh well. Bottom line: Django rocks, and I understand it's young, and supported by volunteers. all the best. thanks! On Aug 28, 12:13 pm, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > For some reason, when I do > > x.save() over an over, it takes about 200k, too. > > either I have something really messed up, or there is a real problem > with this api. > > On Aug 28, 10:34 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > > > To summarize - I double checked that DEBUG=False and ran all the tests > > again: > > > # 20k per call > > x = Page.objects.filter( > > #(Q(type='P') & (Q(status='N') | > > Q(status='R'))) & > > #(Q(last_action_datetime__isnull=True) | > > Q(last_action_datetime__lt=cut_off))).count() > > > # 4K-12K > > x= Page.objects.filter(type='P', status='N').count() > > > # 4K-12K > > x = Page.objects.filter(type='P').count() > > > # 4K-12K > > x = Page.objects.filter(status='N').count() > > > # 0K > > x = Page.objects.all().count() > > > # 0k > > x = Page.objects.extra(where= > > ["(type='P' and (status='N' or status='R') and > > \ > > (last_action_datetime is null or > > last_action_datetime < '2009-1-1'))"]).count() > > > On Aug 28, 10:17 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > > > > Previously I found get_or_create() to be leaky, so I stopped using > > > it. Now I'm seeing filter() to be leaky. > > > > First, yes, I have DEBUG=False, and I have double checked that > > > connection.queries is empty. > > > > Suppose the following model > > > > class Page(models.Model): > > > type = models.CharField(max_length=1,default='P') > > > status = models.CharField(max_length=2,default='N') > > > last_action_datetime = models.DateTimeField(null=True) > > > > All memory checked by looking for VmRSS: in /proc/{pid}/status - on > > > linux (Resident) > > > > If I call the following using filter() and Q() > > > > x = Page.objects.filter( > > > (Q(type='P') & (Q(status='N') | > > > Q(status='R'))) & > > > (Q(last_action_datetime__isnull=True) | > > > Q(last_action_datetime__lt=cut_off))).count() > > > > repeatedly, memory climbs by about 50KB / loop. > > > > Suspecting Q, I tried this > > > > x = Page.objects.filter(type='P', status='N').count() > > > > which increases at about 4-16KB per / loop > > > > as does > > > x = Page.objects.filter(type='P').count(), and > > > x = Page.objects.filter(status='N').count() > > > > If I change it to > > > > x = Page.objects.all().count() > > > > Memory stays constant, but that isn't filtering enough. So I tried > > > > x = Page.objects.extra(where= > > > ["(type='P' and (status='N' or status='R') and \ > > > (last_action_datetime is null or last_action_datetime < > > > '2009-1-1'))"]).count() > > > > Memory stays constant for this one too. Although this isn't the best > > > DRY form, it doesn't seem to leak. > > > > At this point, I figure that if you plan on making lots of calls that > > > would use filter() probably use extra instead. > > > > Clearly, I'm taking the django db layer, probably initially designed > > > to support webdev, and I'm using it to do heavy scripting. It works > > > great, other than these memory problems. And since we are also > > > building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Another django db memory leak?
For some reason, when I do x.save() over an over, it takes about 200k, too. either I have something really messed up, or there is a real problem with this api. On Aug 28, 10:34 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > To summarize - I double checked that DEBUG=False and ran all the tests > again: > > # 20k per call > x = Page.objects.filter( > #(Q(type='P') & (Q(status='N') | > Q(status='R'))) & > #(Q(last_action_datetime__isnull=True) | > Q(last_action_datetime__lt=cut_off))).count() > > # 4K-12K > x= Page.objects.filter(type='P', status='N').count() > > # 4K-12K > x = Page.objects.filter(type='P').count() > > # 4K-12K > x = Page.objects.filter(status='N').count() > > # 0K > x = Page.objects.all().count() > > # 0k > x = Page.objects.extra(where= > ["(type='P' and (status='N' or status='R') and > \ > (last_action_datetime is null or > last_action_datetime < '2009-1-1'))"]).count() > > On Aug 28, 10:17 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > > > Previously I found get_or_create() to be leaky, so I stopped using > > it. Now I'm seeing filter() to be leaky. > > > First, yes, I have DEBUG=False, and I have double checked that > > connection.queries is empty. > > > Suppose the following model > > > class Page(models.Model): > > type = models.CharField(max_length=1,default='P') > > status = models.CharField(max_length=2,default='N') > > last_action_datetime = models.DateTimeField(null=True) > > > All memory checked by looking for VmRSS: in /proc/{pid}/status - on > > linux (Resident) > > > If I call the following using filter() and Q() > > > x = Page.objects.filter( > > (Q(type='P') & (Q(status='N') | > > Q(status='R'))) & > > (Q(last_action_datetime__isnull=True) | > > Q(last_action_datetime__lt=cut_off))).count() > > > repeatedly, memory climbs by about 50KB / loop. > > > Suspecting Q, I tried this > > > x = Page.objects.filter(type='P', status='N').count() > > > which increases at about 4-16KB per / loop > > > as does > > x = Page.objects.filter(type='P').count(), and > > x = Page.objects.filter(status='N').count() > > > If I change it to > > > x = Page.objects.all().count() > > > Memory stays constant, but that isn't filtering enough. So I tried > > > x = Page.objects.extra(where= > > ["(type='P' and (status='N' or status='R') and \ > > (last_action_datetime is null or last_action_datetime < > > '2009-1-1'))"]).count() > > > Memory stays constant for this one too. Although this isn't the best > > DRY form, it doesn't seem to leak. > > > At this point, I figure that if you plan on making lots of calls that > > would use filter() probably use extra instead. > > > Clearly, I'm taking the django db layer, probably initially designed > > to support webdev, and I'm using it to do heavy scripting. It works > > great, other than these memory problems. And since we are also > > building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Another django db memory leak?
To summarize - I double checked that DEBUG=False and ran all the tests again: # 20k per call x = Page.objects.filter( #(Q(type='P') & (Q(status='N') | Q(status='R'))) & #(Q(last_action_datetime__isnull=True) | Q(last_action_datetime__lt=cut_off))).count() # 4K-12K x= Page.objects.filter(type='P', status='N').count() # 4K-12K x = Page.objects.filter(type='P').count() # 4K-12K x = Page.objects.filter(status='N').count() # 0K x = Page.objects.all().count() # 0k x = Page.objects.extra(where= ["(type='P' and (status='N' or status='R') and \ (last_action_datetime is null or last_action_datetime < '2009-1-1'))"]).count() On Aug 28, 10:17 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > Previously I found get_or_create() to be leaky, so I stopped using > it. Now I'm seeing filter() to be leaky. > > First, yes, I have DEBUG=False, and I have double checked that > connection.queries is empty. > > Suppose the following model > > class Page(models.Model): > type = models.CharField(max_length=1,default='P') > status = models.CharField(max_length=2,default='N') > last_action_datetime = models.DateTimeField(null=True) > > All memory checked by looking for VmRSS: in /proc/{pid}/status - on > linux (Resident) > > If I call the following using filter() and Q() > > x = Page.objects.filter( > (Q(type='P') & (Q(status='N') | > Q(status='R'))) & > (Q(last_action_datetime__isnull=True) | > Q(last_action_datetime__lt=cut_off))).count() > > repeatedly, memory climbs by about 50KB / loop. > > Suspecting Q, I tried this > > x = Page.objects.filter(type='P', status='N').count() > > which increases at about 4-16KB per / loop > > as does > x = Page.objects.filter(type='P').count(), and > x = Page.objects.filter(status='N').count() > > If I change it to > > x = Page.objects.all().count() > > Memory stays constant, but that isn't filtering enough. So I tried > > x = Page.objects.extra(where= > ["(type='P' and (status='N' or status='R') and \ > (last_action_datetime is null or last_action_datetime < > '2009-1-1'))"]).count() > > Memory stays constant for this one too. Although this isn't the best > DRY form, it doesn't seem to leak. > > At this point, I figure that if you plan on making lots of calls that > would use filter() probably use extra instead. > > Clearly, I'm taking the django db layer, probably initially designed > to support webdev, and I'm using it to do heavy scripting. It works > great, other than these memory problems. And since we are also > building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Another django db memory leak?
Previously I found get_or_create() to be leaky, so I stopped using it. Now I'm seeing filter() to be leaky. First, yes, I have DEBUG=False, and I have double checked that connection.queries is empty. Suppose the following model class Page(models.Model): type = models.CharField(max_length=1,default='P') status = models.CharField(max_length=2,default='N') last_action_datetime = models.DateTimeField(null=True) All memory checked by looking for VmRSS: in /proc/{pid}/status - on linux (Resident) If I call the following using filter() and Q() x = Page.objects.filter( (Q(type='P') & (Q(status='N') | Q(status='R'))) & (Q(last_action_datetime__isnull=True) | Q(last_action_datetime__lt=cut_off))).count() repeatedly, memory climbs by about 50KB / loop. Suspecting Q, I tried this x = Page.objects.filter(type='P', status='N').count() which increases at about 4-16KB per / loop as does x = Page.objects.filter(type='P').count(), and x = Page.objects.filter(status='N').count() If I change it to x = Page.objects.all().count() Memory stays constant, but that isn't filtering enough. So I tried x = Page.objects.extra(where= ["(type='P' and (status='N' or status='R') and \ (last_action_datetime is null or last_action_datetime < '2009-1-1'))"]).count() Memory stays constant for this one too. Although this isn't the best DRY form, it doesn't seem to leak. At this point, I figure that if you plan on making lots of calls that would use filter() probably use extra instead. Clearly, I'm taking the django db layer, probably initially designed to support webdev, and I'm using it to do heavy scripting. It works great, other than these memory problems. And since we are also building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: What is the fastest way to come up to speed with Django?
All excellent ideas. Great community here, thanks!! To be clear, I have been coding Python and Django for a few weeks now, and I've bought and read a few books, poured over some online docs and tried to get confortable with Komodo. I don't really WANT to learn the internals of Django at this point. (Perhaps someday, but right now I just want to use it.) But, when something goes wrong, I need to figure out if it's in my code, like something is misconfigured, or it's in Django. After all, I'm sure you all would appreciate me doing as much leg work as possible before reporting to this group. It's busy enough. Since Django is a bunch of python scripts, as I've been told, it isn't always clear where problems lie. I don't often need a debugger to debug my own code. Project isn't that big yet, and I generally import logging, and write unit tests. But, when I want to learn about how my code dips into Django, that's where a debugger and a comprehensive IDE with "code intelligence" can really help. I used to use Intellij IDEA with Java, this is my reference for good "code intelligents". I'll read up on pdb. That's looks great. Not sure if I'm going to bother upgrading to the KomodoIDE. I'm not too impressed so far. Thanks for the pointer to comp.lang.py On Jul 10, 9:31 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 9 juil, 04:08, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > > > I leading a project based on Django, and I come from 12 years of Java, > > and 0 years of Python. > > Well, if you insist : "ha ha ha". > > Oh, BTW:http://dirtsimple.org/2004/12/python-is-not-java.html > > Ok, done with this. What's next ?-) > > > I'm currently digging into the django-trunk on many an occasion, > > trying to explain things that I can't find in the docs. Because I > > don't understand how Django was designed, and can't guess too easily, > > I find that really slow. > > > I'm wondering if getting the KomodoIDE editor with a debugger would > > make learning Django faster. Or would WingIDE be a better bet? Or > > Eclipse with pyDev. In theory, I could see stepping through code to > > learn how it all fits. But, does this work well in practice? > > Note that you don't need any of these "IDE" to step thru the code. > There's a command line debugger in the standard lib, named pdb. But > anyway: yeps, stepping thru the code can sometimes help. But if you > really want to understand Django's inners, that won't be enough IMHO. > > > Any other tips to getting up to speed fast? > > wrt/ Django's inners ? Some parts really requires solid Python > knowledge. > > The template system should not be to hard to grasp, and the doc on > custom templatetags etc should get you started for what you really > need to know. > > Someone already pointed you to James Bennett's post on how Django > handles an HTTP request. But you can browse all other django-related > posts on James blog, there are tons of things to learn here. > > The ORM and newforms part is probably the one with the most "black > magic", specially if you don't have experience with highly dynamic > languages - like most Python frameworks, Django makes heavy use of > Python's dynamism and "advanced" instrospection and metaprogramming > features, and you'll have to learn about Python's object's model, and > more specifically: > - metaclasses > - descriptors and attribute lookup rules > - function decorators > - classmethods / staticmethods > - generally, use of functions and classes as first-class objects. > > Anyway, you'll have to learn about all this to really take advantage > of what Python has to offer... comp.lang.py is the place for language- > related questions, and it's mostly a friendly and helpful group. > > HTH --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: In admin, unable to save many-to-many relation objects with intermediate table
Wow, Karen, you're amazing. Thanks for that. I can say I learned a lot about Django today with your help. thanks!! On Jul 9, 6:38 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Wed, Jul 9, 2008 at 12:57 AM, ristretto.rb <[EMAIL PROTECTED]> > wrote: > > > I'm using the svn version. I updated this morning. I can't remember > > if I was getting the error before I updated, or not. > > That ticket I pointed to identifies r7710 as a revision where this problem > did not exist. With your models (much simpler than the ones in that ticket) > I was able to recreate the problem on r7871. Binary search shows that the > problem was introduced in r7790: > > http://code.djangoproject.com/changeset/7790 > > The change message says it was to "Make sure we only create the minimum > number of table indexes for MySQL" but I don't believe this problem has > anything to do with creating table indexes. (I did not recreate the tables > when recreating the problem, just attempted to "save and continue editing" a > problematic entry.) > > I have spent the day tracking this down (it's taken me all day because > > > I don't know Django or Python very well, and I haven't been able to > > find a comprehensive IDE that is worth much more then just an editor. > > Argh.) > > Well you picked some hairy code to start with. FWIW I use Eclipse with > PyDev which is good enough for stepping through code, setting breakpoints, > and examining variables, though it can run into problems with side-effects > of the variable display. For getting some clue about what code path is > running it's usually OK enough. > > In any case, here's what I'm up to > > > > > In django-trunk/django/oldforms/__init__.py line around 68, I have put > > some logging output. field.get_validation_errors(new_data) is coming > > back as a oldforms.HiddenField when it generated the following error. > > > 2008-07-09 04:03:08,227 DEBUG > > 2008-07-09 04:03:08,227 DEBUG {'jointable.0.id': [u'Join table with > > this ID already exists.']} > > > I don't know why the admin system needs to put this following hidden > > in the html > > > > name="jointtable.0.id" value="38" /> > > That's the primary key value of the inline-edited object. When the admin > code needs to update any of the visible fields, it needs to pull the primary > key value out of the hidden field in order to know the correct record to > update. > > > Now, I've traced this down to line 474, roughly of django-trunk/django/ > > oldforms/__init__.py where a the HiddenField class is defined. A > > validator is passed in called "_curried". I have no idea what that > > is. Going to stop here. > > Yeah, the problem is that validator. Prior to r7790, these hidden fields > did not have any validators attached to them. Now they have the > manipulator_validator_unique validator that is run. Problem is this > validator doesn't seem to be appropriate for this case. Tracing through it > it is looking up the inline edited object's primary key value in the parent > object's table and if it exists comparing it to the parent object's original > primary key value, so you get an error if the primary key value for the > inline edited object exists in the parent object's table and differs from > the parent primary key value. I don't believe that validator is supposed to > be associated with the hidden input field for the primary key of an > inline-edited object. > > It's being added here: > > (http://code.djangoproject.com/browser/django/trunk/django/db/models/f... > ) > > if self.unique or (self.primary_key and not rel): > > params['validator_list'].append(curry(manipulator_validator_unique, self, > opts, manipulator)) > > which points to the changes associated with setting unique in r7790 as what > has introduced the problem. I don't understand exactly what that change was > supposed to be doing, so I'm not sure what the right fix is. I'll update > #7682 with what I've figured out and hopefully someone who knows the code > can fix it. In the meantime if you drop back to r7789 I think you will find > the problem goes away. > > Karen > > > > > On Jul 9, 2:47 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > > On Tue, Jul 8, 2008 at 9:57 PM, ristretto.rb <[EMAIL PROTECTED]> > > wrote: > > > > > More details. I'm using MySQL at the moment (but with a plan to move > > > > t
Re: What is the fastest way to come up to speed with Django?
Hi Malcolm, Thanks for the reply. I just spent the day banging through the admin code down to the oldform fields to track down a problem I was having. It took a very long time because I don't know Django under the hood, and I only have just started to learn Python. I can think of some features in an IDE that would make this much easier for me, and no doubt other noobs like myself. I'll list them out here in hopes that someone that creates IDE's reads it. :) * go to last edit position (line/file), and keep going back through history. Komodo doesn't do this. * code completion and inspection in django templates and python code. Komodo does this a bit, but it's limited. * show """ doc for a object, if available * integrated debugger * Fast open - type file name to open it On Jul 9, 2:20 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-07-08 at 19:08 -0700, ristretto.rb wrote: > > I leading a project based on Django, and I come from 12 years of Java, > > and 0 years of Python. > > You won't get any crap from me, at least. The more languages people > know, the better. > > > I'm currently digging into the django-trunk on many an occasion, > > trying to explain things that I can't find in the docs. Because I > > don't understand how Django was designed, and can't guess too easily, > > I find that really slow. > > > I'm wondering if getting the KomodoIDE editor with a debugger would > > make learning Django faster. Or would WingIDE be a better bet? Or > > Eclipse with pyDev. In theory, I could see stepping through code to > > learn how it all fits. But, does this work well in practice? > > Personally I have no experience with any of those, so I'm not going to > give advice. > > The one cavaet I'll point out is that *running* pretty much anything in > Django requires a settings file, since there are a few places where code > is executed conditionally based on settings. Most files can now be > imported without a settings file being present (allowing you to import > things and then manually configure settings in advanced cases), but > there might be some deep internals where that isn't possible. All this > means is that you *might* need to have DJANGO_SETTINGS_MODULE set and > pointing to some reasonably simple settings file (specify a template > loader and a database engine). > > > Any other tips to getting up to speed fast? > > With the internal code? I wish there was some silver bullet like that. > > When you are poking around the internals, things are generally grouped > fairly logically. Although, like any piece of software with five or six > years of development behind it, there are some historical oddities as > well. But, by and large, you'll find like grouped with like. For > example, > > django/templates: > all the template loading and rendering code > django/core/handlers: > the stuff that is the outer layer of request/response > handling. > django/db/models/fields/ > all the model field code > django/db/models/sql > SQL statement creation > django/db/models/* > all the other model stuff > django/db/backends/ > the individual database backends and common wrapping > code for them. > django/utils/translation/ > i18n/l10n support > > django/utils is a bit of a grab bag of internal common stuff that is > used in multiple places. Django/core is stuff that didn't sit anywhere > else but was important. > > In something as modular and wide-ranging as Django there isn't really an > obvious way to read it from beginning to end. However, if you really > want to understand what's going on you could start with the lifecycle of > an HTTP request (django/core/handlers/wsgi.py, say), which leads to URL > resolving, following through to the middleware, view calling, middleware > again and response dispatching. Orthogonal to that is model handling, > database interaction (triggered by the model code) and various view > support stuff like generic views. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: In admin, unable to save many-to-many relation objects with intermediate table
I'm using the svn version. I updated this morning. I can't remember if I was getting the error before I updated, or not. I have spent the day tracking this down (it's taken me all day because I don't know Django or Python very well, and I haven't been able to find a comprehensive IDE that is worth much more then just an editor. Argh.) In any case, here's what I'm up to In django-trunk/django/oldforms/__init__.py line around 68, I have put some logging output. field.get_validation_errors(new_data) is coming back as a oldforms.HiddenField when it generated the following error. 2008-07-09 04:03:08,227 DEBUG 2008-07-09 04:03:08,227 DEBUG {'jointable.0.id': [u'Join table with this ID already exists.']} I don't know why the admin system needs to put this following hidden in the html Now, I've traced this down to line 474, roughly of django-trunk/django/ oldforms/__init__.py where a the HiddenField class is defined. A validator is passed in called "_curried". I have no idea what that is. Going to stop here. thanks! On Jul 9, 2:47 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Tue, Jul 8, 2008 at 9:57 PM, ristretto.rb <[EMAIL PROTECTED]> wrote: > > > More details. I'm using MySQL at the moment (but with a plan to move > > to Postgresql.) The association table has a number of rows loaded > > through these models, but not through my Django app directly. I used > > the Model classes in a script to pre load a bunch of data. Could this > > be the problem? > > > On Jul 9, 1:28 pm, ristretto.rb <[EMAIL PROTECTED]> wrote: > > > OK, I took core=True off, and added it to the reference_no field. The > > > problem seems to go away for the case when no there are no > > > pre-existing joins. Clearly, I don't understand what core is for. > > > I'll read the docs again, and see if it makes sense. > > > > However, it still errors with > > > > {'jointable.0.id': [u'Join Table record with this ID already exists.']} > > > > when I tried to save a LeftSide records with existing associations. > > > > thanks for any and all help. > > I have no idea what is going on, but a ticket was recently (4 hours ago) > opened reporting the same error message for inline-edited objects: > > http://code.djangoproject.com/ticket/7682 > > It seems like some code is thinking records are supposed to be new and > checking for primary key uniqueness when in fact it is existing records that > are being updated. This might be a recently introduced bug, it's a little > curious to have two people reporting the same (not common) error message > suddenly so close together. > > What version are you running? > > Karen > > > > > > On Wed, Jul 9, 2008 at 1:09 PM, ristretto. rb <[EMAIL PROTECTED]> > > wrote: > > > > Hello, I'm stuck. Any help will be much appreciated. > > > > > I followed > > > >http://www.djangoproject.com/documentation/models/m2m_intermediary/to... > > > > a > > > > Many-to-many relationship via an intermediary table. > > > > > class LeftSide(models.Model): > > > > : > > > > > class RightSide(models.Model): > > > > : > > > > > class JoinTable(models.Model): > > > > leftSide = models.ForeignKey(LeftSide, > > > > edit_inline=models.TABULAR, > > > > num_in_admin=3, core=True) > > > > rightSide = models.ForeignKey(RightSide, > > > > edit_inline=models.TABULAR, > > > > num_in_admin=3,core=True) > > > > reference_no = models.CharField(max_length=10, null=True, > > blank=True) > > > > > I can load the LeftSide in the admin, and choose to Change a record. I > > get > > > > 3 RightSide menu groups at the bottom. I can choose a RightSide to set > > as a > > > > join. When I choose Save (any of the 3 save variations on the page) > > nothing > > > > is saved. > > > > > There are two cases. > > > > > 1) If the are already records in the join table for that LeftSide, > > then I > > > > get an error when I save. {'jointable.0.id': [u'Join Table record > > with this > > > > ID already exists.']} I didn't actually make any changes to that > > > > association, so I don't know why it would complain. > > > > > 2) If there are no join table records associated with the LeftSide, > > then > > > > there is no error, but nothing is saved. > > > > > Am I doing something totally wrong here? Or is this a bug in the Admin > > > > system? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
What is the fastest way to come up to speed with Django?
I leading a project based on Django, and I come from 12 years of Java, and 0 years of Python. I'm currently digging into the django-trunk on many an occasion, trying to explain things that I can't find in the docs. Because I don't understand how Django was designed, and can't guess too easily, I find that really slow. I'm wondering if getting the KomodoIDE editor with a debugger would make learning Django faster. Or would WingIDE be a better bet? Or Eclipse with pyDev. In theory, I could see stepping through code to learn how it all fits. But, does this work well in practice? Any other tips to getting up to speed fast? I have both Django books, 2 python references and the python cookbook, and I'm working hard to get up to speed. 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: In admin, unable to save many-to-many relation objects with intermediate table
More details. I'm using MySQL at the moment (but with a plan to move to Postgresql.) The association table has a number of rows loaded through these models, but not through my Django app directly. I used the Model classes in a script to pre load a bunch of data. Could this be the problem? On Jul 9, 1:28 pm, ristretto.rb <[EMAIL PROTECTED]> wrote: > OK, I took core=True off, and added it to the reference_no field. The > problem seems to go away for the case when no there are no > pre-existing joins. Clearly, I don't understand what core is for. > I'll read the docs again, and see if it makes sense. > > However, it still errors with > > {'jointable.0.id': [u'Join Table record with this ID already exists.']} > > when I tried to save a LeftSide records with existing associations. > > thanks for any and all help. > > > > On Wed, Jul 9, 2008 at 1:09 PM, ristretto. rb <[EMAIL PROTECTED]> wrote: > > Hello, I'm stuck. Any help will be much appreciated. > > > I followed > >http://www.djangoproject.com/documentation/models/m2m_intermediary/to make > > a > > Many-to-many relationship via an intermediary table. > > > class LeftSide(models.Model): > > : > > > class RightSide(models.Model): > > : > > > class JoinTable(models.Model): > > leftSide = models.ForeignKey(LeftSide, > > edit_inline=models.TABULAR, > > num_in_admin=3, core=True) > > rightSide = models.ForeignKey(RightSide, > > edit_inline=models.TABULAR, > > num_in_admin=3,core=True) > > reference_no = models.CharField(max_length=10, null=True, blank=True) > > > I can load the LeftSide in the admin, and choose to Change a record. I get > > 3 RightSide menu groups at the bottom. I can choose a RightSide to set as a > > join. When I choose Save (any of the 3 save variations on the page) nothing > > is saved. > > > There are two cases. > > > 1) If the are already records in the join table for that LeftSide, then I > > get an error when I save. {'jointable.0.id': [u'Join Table record with this > > ID already exists.']} I didn't actually make any changes to that > > association, so I don't know why it would complain. > > > 2) If there are no join table records associated with the LeftSide, then > > there is no error, but nothing is saved. > > > Am I doing something totally wrong here? Or is this a bug in the Admin > > system? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
In admin, unable to save many-to-many relation objects with intermidiate table
Hello, I'm stuck. Any help will be much appreciated. I followed http://www.djangoproject.com/documentation/models/m2m_intermediary/ to make a Many-to-many relationship via an intermediary table. class LeftSide(models.Model): : class RightSide(models.Model): : class JoinTable(models.Model): leftSide = models.ForeignKey(LeftSide, edit_inline=models.TABULAR, num_in_admin=3, core=True) rightSide = models.ForeignKey(RightSide, edit_inline=models.TABULAR, num_in_admin=3,core=True) reference_no = models.CharField(max_length=10, null=True, blank=True) I can load the LeftSide in the admin, and choose to Change a record. I get 3 RightSide menu groups at the bottom. I can choose a RightSide to set as a join. When I choose Save (any of the 3 save variations on the page) nothing is saved. There are two cases. 1) If the are already records in the join table for that LeftSide, then I get an error when I save. {'jointable.0.id': [u'Join Table record with this ID already exists.']} I didn't actually make any changes to that association, so I don't know why it would complain. 2) If there are no join table records associated with the LeftSide, then there is no error, but nothing is saved, either. Am I doing something totally wrong here? Or is this a bug in the Admin system? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Need help including a queryset in every view
> I have a navigation list powered by a model in my base site template. > So, I need to create a queryset object that will be available to every > view. Middleware comes to mind (see the docs), but I'm new to django, and perhaps that's not the best way. I'd be interested to see what other djangonauts say. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---