Re: Getting Django admin to display new autoincremented values in primary key model forms

2011-05-04 Thread pjrhar...@gmail.com
Hi, See this ticket for details on the error you are seeing: http://south.aeracode.org/ticket/407 If I understand correctly, it sounds like you're asking for something that isn't possible anyway. The id isn't known until the item is inserted into the database, because the database assigns the

Re: parameter, but not in the URL

2011-03-05 Thread pjrhar...@gmail.com
You should definitely be using a POST request - an important aspect of the design of any web application is that get requests should not change server side state, for this exact reason. http://stackoverflow.com/questions/46585/when-do-you-use-post-and-when-do-you-use-get -- You received this

Re: Broken link emails

2011-02-19 Thread pjrhar...@gmail.com
I realised the second question is answered here: http://docs.webfaction.com/software/django/troubleshooting.html#accessing-remote-addr which is a middleware that was removed a while back. The first bit of my question still stands though! -- You received this message because you are subscribed

Re: ManyToManyField('self') doesn't works as expect

2010-12-24 Thread pjrhar...@gmail.com
By default many to many fields on self are symmetric[1], yours can't be (if A is up from B, B isn't up from A), so you need to specify symmetrical=False. You'll also need to specify some related names because they will clash. You might want to rethink your model though anyway, I'm not convinced

Re: Error in ajax request

2010-12-02 Thread pjrhar...@gmail.com
On Dec 1, 2:43 am, Andre Terra wrote: > Noob question here: why would it need limit=5 if the funcion has default > values? Even if it has a default value, you still need to call it to get your decorator. As someone wrote above, its a function that returns a decorator, not

Re: Suspicious Operation from session decoding

2010-11-10 Thread pjrhar...@gmail.com
On the unlikely chance that anyone turns up with the same problem for google, I'll post my solution. Still would love to know what the original problem was. from django.utils.importlib import import_module session_engine = import_module(settings.SESSION_ENGINE) session =

Suspicious Operation from session decoding

2010-11-07 Thread pjrhar...@gmail.com
Hi all, I've recently updated to svn trunk and I think the new HMAC changes are causing me an issue. I have a custom admin view that handles uploads from the YUI flash uploader. Unfortunately the flash applet doesn't send cookies with it, so in order to check authentication in the page

Re: Graphic and form in the same template

2010-10-28 Thread pjrhar...@gmail.com
It can't be done like that. Look at any website and you'll see that never is the picture somehow "embedded" in the page, it's linked by an img tag that points at the url of the image. What he was saying is that you need two separate views. In the first, return your page with an img tag pointing

Re: Really slow performance on webfaction

2010-09-28 Thread pjrhar...@gmail.com
Thanks for the help guys. I started trying to log things, and only then did I notice that I'd missed the obvious - one of the few queries was taking 11s! Turns out it was a pointless join from a weird use of queries (a queryset contructed one place with more filters added elsewhere in an odd

Re: Displaying the fields of two tables on the same admin page

2010-04-01 Thread pjrhar...@gmail.com
On Mar 31, 9:42 pm, Asim Yuksel wrote: > The people and publication are not related so I cant use manytomany Can you post the schema of this "bridge" table you keep talking about? Because it sounds _exactly_ like a ManyToMany Peter -- You received this message because

Re: Django Distinct on queryset in forms.py

2010-03-30 Thread pjrhar...@gmail.com
On Mar 30, 2:10 pm, Thomas wrote: > I already found a solution by myself: > > doing this into the forms.py inside the class does the trick: > >         def __init__(self, *args, **kwargs): >                 super(FilterForm, self) .__init__(*args, **kwargs) >              

Re: deepcopying form classes and thread safety

2010-03-30 Thread pjrhar...@gmail.com
This is quite old but still relevant: http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/ Basically, create your form and edit the widget with an __init__ like this: class FlightForm(forms.ModelForm): def __init__(self, profile, *args, **kwargs): super(FlightForm,

Re: Displaying the fields of two tables on the same admin page

2010-03-30 Thread pjrhar...@gmail.com
On Mar 29, 4:17 pm, Asim Yuksel wrote: > I am entering them on the same page otherwise I will have to note down > the ids of people and publications table and then go to bridge table > and insert the ids there. So the reason I want to enter in the same > page is I will

Re: Initializing a ModelForm don't work - BUG ?

2010-03-30 Thread pjrhar...@gmail.com
On Mar 29, 12:24 pm, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On 29 mar, 09:12, Thierry Chich <thierry.ch...@gmail.com> wrote: > > > Le lundi 29 mars 2010 02:14:34, pjrhar...@gmail.com a écrit :> > OK. I can > > also put an hidden fi

Re: Displaying the fields of two tables on the same admin page

2010-03-29 Thread pjrhar...@gmail.com
> I cant use inlines option ind admin,py because the > tables should be related. If they aren't related why would you want to be entering them on the same page? When you come to edit them again what two instances should be loaded together if they are completely unrelated? Given what you first

Re: Initializing a ModelForm don't work - BUG ?

2010-03-28 Thread pjrhar...@gmail.com
> OK. I can also put an hidden field in my form. I will evaluate what is the > better option for me. Bear in mind if you exclude it from your form altogether there is nothing to stop a malicious user setting it by modifying the post data. Peter -- You received this message because you are

Re: Why must {% extends '' %} be first value in template? Inconvenient for ajax versions.

2010-03-28 Thread pjrhar...@gmail.com
Ideally, I want to do: > > {% if not ajax %} >     {% extends 'base.html' %} > {% endif %} > {% block content %}Content Here.{% endblock %} Extends can't be optional. Consider the following: base_template.html: Foo {% block foo %}{% endblock %} Bar {% block bar %}{% endblock %}

Re: Using ModelForm to edit ManyToMany in both directions?

2010-03-28 Thread pjrhar...@gmail.com
See this snippet: http://www.djangosnippets.org/snippets/1295/ Peter On Mar 27, 6:02 am, jwils2...@gmail.com wrote: > I believe the answer is to append a regular Form to the ModelForm) with a   > single ModelMultipleChoice field and use its queryset member to manage the   > selected volunteers

Re: Conflict between django csrf and credit card clearing?

2010-03-17 Thread pjrhar...@gmail.com
On Mar 17, 7:37 pm, Joakim Hove wrote: > Summary of redirections: > >       Form at my site --> DIBS --> simple view at my site. > > Any tips? > > Joakim My best guess is that the user must be getting posted back to that address when they click a button on the external

Re: What validation tests are applied to ImageField?

2010-03-17 Thread pjrhar...@gmail.com
> What constitutes a 'valid' image? > The documentation states "ImageField... Like FileField, but validates > that the uploaded object is a valid image." I haven't read through the code, but the error must be caught somewhere because I just tested it out. Trying to upload in the admin a random

Re: Handling upload, adding M2M relation before saving object in admin form

2010-03-16 Thread pjrhar...@gmail.com
On Mar 15, 10:17 pm, Henry Andersen wrote: > Thanks for your answer, but I do need a ManyToManyField(). > > In case anyone is curious about the answer, I solved my problem by > overriding my custom admin form's save method. In save(), I checked for the > existence of the file

Re: Putting dictionary element according to another element's value

2010-03-16 Thread pjrhar...@gmail.com
On Mar 15, 2:38 pm, "ge...@aquarianhouse.com" wrote: > {% with o.id as key %}{{ dictionary.key }}{% endwith %} > > would be better, as in comments mentioned It might be, if it worked. That will try and look up dictionary['key'] still. Peter -- You received this

Re: Putting dictionary element according to another element's value

2010-03-15 Thread pjrhar...@gmail.com
You'll need a custom template tag. Something like this will probably do: http://push.cx/2007/django-template-tag-for-dictionary-access Peter On Mar 12, 7:48 pm, Rishat Muhametshin wrote: > Hello everyone, > > I just can't solve a problem. I have an array of dictionaries

Re: Handling upload, adding M2M relation before saving object in admin form

2010-03-15 Thread pjrhar...@gmail.com
On Mar 12, 12:42 pm, Henry A wrote: > Hi, > > For a client, I've got the following (simplified) models: > > class Document (models.Model): >   file = models.FileField() > > class Publication (models.Model): >   title = models.CharField() >   ... >   documents =

Re: def reload(model): model.__dict__ = model.__class__.objects.get(pk=model.pk).__dict__ ; return model

2010-03-11 Thread pjrhar...@gmail.com
Why bother? Cant you just do: def reload(model): return model.__class__.objects.get(pk=model.pk) The call it as: instance = reload(instance) Peter -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: ModelAdmin

2010-03-11 Thread pjrhar...@gmail.com
On Mar 11, 6:27 am, Praveen wrote: > I know i can not directly register a form but i do not have any model > for Email. i just have plain form *forms.Form* > is there any other way to register Form with admin. > Thanks What would you expect it to do if you could?

Re: How to display PendingDeprecationWarning using dev. server?

2010-03-06 Thread pjrhar...@gmail.com
On Mar 6, 2:28 am, Brian Neal wrote: > Any ideas? Can anyone else try this and report back? Just insert the > code below into a view function and start the dev. server with "python > -Wall manage.py runserver". Thanks. Hi, Just to confirm I tried it and can't see them either,

Re: Send variable from view function to a templatetag

2010-03-03 Thread pjrhar...@gmail.com
On Mar 3, 4:52 pm, alecs wrote: > How can I send variable from my view function(which renders my > template) to a template tag library(which is {% load blah %} in this > template? I want to make my tag cloud independent from model: Your template tag has access to any

Re: non stop media player on site - similar to facebook chat

2010-02-24 Thread pjrhar...@gmail.com
If you watch the URL as you navigate facebook with the chat open you'll notice it doesn't actually change, just the fragment bit after the '#' does. I believe that the whole page minus the chat is just loaded asynchronously, and the url fragment is changed to match so that if you reload it it

Re: Dictionary Model Merge

2010-02-16 Thread pjrhar...@gmail.com
> values = model_to_dict(instance) > values.update(request.POST) > > It then fails on form.is_valid() because it's trying to match a date > string in a date value that is actually a list with one value in it > instead of a date string! I can see two problems here. Firstly, the post "dictionary"

Re: Expiring view caches

2010-02-12 Thread pjrhar...@gmail.com
The other thing you may want to consider is whether you need to cache the entire page or not. When users change some data, if it doesn't change everything you could use template fragment caching, and just delete the relevant bits when data is changed. Otherwise you could use lower level caching in

Re: Filtering only on Annotations

2010-01-20 Thread pjrhar...@gmail.com
On Jan 20, 1:36 am, Russell Keith-Magee wrote: > On Wed, Jan 20, 2010 at 3:42 AM, Collin Anderson > > wrote: > > Is there anyway to have the filter only apply to the annotation, so it > > would return all publishers, with some having a

Re: authentication and an http POST from a java applet

2010-01-20 Thread pjrhar...@gmail.com
On Jan 18, 10:58 pm, stephendwolff wrote: > I'm having problems authenticating an http POST from a java applet > (which is loaded from a fully authenticated django view). I had to do a similar thing from flash. I ended up manually putting the session cookie into the

Re: Custom filters and partial mark_safe?

2010-01-16 Thread pjrhar...@gmail.com
> Just as I feared. Thanks for the reply. It's not as bad as you fear! Just escape it, then apply your filter, then mark it all safe. You'll find the escape function in django.utils.html Peter -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: Form field required only if other fields are filled

2009-12-23 Thread pjrhar...@gmail.com
> I can use clean() method of form to od validation, but I embedded some > complex rules in field validation and dont want to repeat the code This. Use the clean method, you'll have to add add errors to the error dict if you want them to appear by the field. Not sure I follow why you would have

Re: Enable users to input formatted text

2009-12-21 Thread pjrhar...@gmail.com
You've got to decide what you want to allow. If the users are trusted you could allow them to input HTML, then you have to make sure its marked as safe so the HTML is not escaped.[1] Alternatively you could use a markup language that can be converted to HTML.[2] If you just want the newlines,

Re: Scope of variables in template blocks

2009-12-12 Thread pjrhar...@gmail.com
In your template tag you can add the variable to the global context like this: context.dicts[-1]['last_upload'] = whatever Pete -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: How to get the last item of array in a built-in template tag?

2009-12-08 Thread pjrhar...@gmail.com
Whoops, didn't actually try that as I'm not at my normal pc, I just remembered reading it somewhere. Thinking about it now, you can actually just do: {{ my_list|last }} Pete On Dec 7, 8:35 pm, Gaffar Overcomes wrote: > hey pete this does not work :S > negative index

Re: How to get the last item of array in a built-in template tag?

2009-12-06 Thread pjrhar...@gmail.com
Try: {{ my_array|slice:"-1:" }} Pete -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

Re: Trouble setting a form field's value in clean()

2009-11-16 Thread pjrhar...@gmail.com
>         if not cleaned.has_key("string2") and > cleaned.has_key("string1"): >             cleaned["string2"] = string1 > >         return cleaned > I think the problem here is that if string2 is not required it will be in the cleaned dictionary but an empty string. So instead you might need: if

Re: Confirm email by matching on form

2009-11-15 Thread pjrhar...@gmail.com
In addition to the above, cleaning that requires two fields is best put in the forms overall clean method. This makes it a bit harder because you can't raise a validation error if you want the error to appear by the field, you have to insert it into self._errors. Also, I have an even simpler

Re: ModelForm usage

2009-11-12 Thread pjrhar...@gmail.com
> - first try for empty record, expecting an empty Project-object to be created > from the form automatically: > projectForm = forms.ProjectForm() > projectForm.save() > => result: 'ProjectForm' object has no attribute 'cleaned_data' You need to run the clean method on the form to make sure the

Re: A simple database project

2009-11-11 Thread pjrhar...@gmail.com
> I tried > > search_fields = ['school__lawyer'] > > but I get an error message when I did a search for last name of > lawyer: > > Related Field has invalid lookup: icontains You need something like: search_fields = ['school__lawyer_last'] to specify which field on the related 'lawyer'

Re: Model field validation for admin

2009-11-10 Thread pjrhar...@gmail.com
> > > Hello, I want to make a field optional (blank=True), only if another > > > text field's options match a certain value in the admin. Is there any > > > way to do this? Thanks! You want to do this in a modelform, and then specify that model form in your admin.py. Put the checks in the

Re: Crop interface for ImageFields?

2009-11-03 Thread pjrhar...@gmail.com
YUI has a great library for this. Should be fairly easy to integrate with django, but I haven't seen a snippet for it. Should save you some time on the client side though. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Distributing a Django site along with Apache and MySQL

2009-11-02 Thread pjrhar...@gmail.com
I've done this exact thing before, I had to package apache, django, my project and a ton of other packages that I needed. I found the easiest way in the end was using nsis(1). I packaged django up as an msi(2), got python and apache as msi installers, mod_python as an exe and then just had it

Re: Display Certain Fields of the Model Formset As Text

2009-10-30 Thread pjrhar...@gmail.com
On Oct 30, 5:47 am, Anthony Simonelli wrote: > Is there any way to display the fields as text rather than as input fields? My suggestion would be to write your own widget that simply renders as text, and make all the uneditable fields use that widget. Have a look in the

Re: Passing Parameter to form in inlineformset_factory

2009-10-23 Thread pjrhar...@gmail.com
Try using a lambda function. The problem is that the factory wants a callable that creates a form, not a form instance (ie it wants to be able to execute MyForm() for each form in the formset. Formset = inlineformset_factory(ModelA, ModelB form=lambda: MyForm (readOnly=True)) Note I've not

Re: Template code runs in both branches of an if statement

2009-10-17 Thread pjrhar...@gmail.com
ally a good design consideration. > > Of course this advice might not really apply to your problem - it's > just a suggestion > > -Chip > > On Oct 16, 8:49 am, "pjrhar...@gmail.com" <pjrhar...@gmail.com> wrote: > > > I have some template code

Re: Template code runs in both branches of an if statement

2009-10-16 Thread pjrhar...@gmail.com
> > {% if var1 %} >     {{ var1 }} > {% else %}{% if var2 %} >     {{ var2 }} > {% else %}{% if var3 %} >     {{ var3 }} > {% endif %}{% endif %}{% endif %} > > On Oct 16, 9:49 am, "pjrhar...@gmail.com" <pjrhar...@gmail.com> wrote: > > > I have s

Template code runs in both branches of an if statement

2009-10-16 Thread pjrhar...@gmail.com
I have some template code which looks something like this: {% if condition %} {% get_latest parameter1 %} - foo {% else %} {% get_latest parameter2 %} - bar {% endif %} get_latest is a custom template tag, and I noticed that in my debugging output it is being run both times - ie with parameter1