Re: Django form(s) for intermediary models

2011-01-26 Thread aa56280
Wow, that is bananas, Ian. I'll give your solution a try and see what happens. -- 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 dja

Re: Django form(s) for intermediary models

2011-01-25 Thread aa56280
> In your case it would become something like: > > class Membership(ModelForm): >         class Meta: >                 model = Membership >                 fields = ('person', 'date_joined') >                 widgets = { >                         'person' : CheckBox(), >                         'd

Django form(s) for intermediary models

2011-01-25 Thread aa56280
I have three models like so: class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Pe

Re: URLField strange error

2011-01-19 Thread aa56280
Something's not right with the data. Can you post more details - like, what string are you trying to insert exactly? -- 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 unsubscr

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread aa56280
Can't you specify the value using the initial argument? http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial On Sep 29, 3:33 pm, Shawn Milochik wrote: > Actually, I spoke too soon on this one. My original solution doesn't work > because the hidden input on the form doesn't have a valu

Re: Checkbox registration from

2010-09-29 Thread aa56280
You'll have to use the RegistrationFormTermsOfService class instead of RegistrationForm. -- 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 ema

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread aa56280
That seems pretty straightforward me. You want to customize the form based on the user and so you're doing it when the form is initialized. Makes perfect sense. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Something breaking if tag

2010-09-29 Thread aa56280
tried to deserialize URL params automatically into Python objects > (like int), you would have all sorts of issues (like a "username" > being passed in as an int because a user decides to make their name > "1234", and so on). > > On Sep 29, 12:52 pm, aa

Re: LOGIN FORM

2010-09-29 Thread aa56280
Do you have 'django.middleware.csrf.CsrfViewMiddleware' specified in your settings? On Sep 28, 2:55 pm, Saad Sharif wrote: > Hi all, >            I want to create  a simple login form in django..Please > help I am a complete beginner > > My Code: > dojoType="dijit.form.Form" >{% csrf_token %} >

Something breaking if tag

2010-09-29 Thread aa56280
I have in my template the following: {% if subtopic.id == selected_id %}...{% endif %} subtopic.id is being pulled from a list of subtopics that I'm looping over. selected_id is being sent to the template by the view after some form processing: #views.py selected_id = request.GET.get('subtopic',

Re: Updating user's unique e-mail

2010-08-19 Thread aa56280
> Is best practice to do this from a custom user profile? I have an > avatar imageField which will be editable as well. Well, the first name, last name and e-mail fields are part of the User model so you wouldn't need a profile model for that. As for the avatar, yes, that would have to go in that

Re: Encoding with {% url %} tag

2010-08-16 Thread aa56280
> In other words, if you designed the URL regex to handle a certain sort > of string, and the view it points to handle a certain sort of string, > and now in your template you're running that string through iriencode > first, then the URL definition and the view it points to is receiving > somethin

Re: Encoding with {% url %} tag

2010-08-15 Thread aa56280
> Does the view code in app.views.blah know what to do with the > iriencode'd values? What does that have to do with anything? Don't get me wrong, I'll figure that out eventually, but at the moment, I'm merely interested in encoding the URL first - which isn't happening. > Remember there are two

Encoding with {% url %} tag

2010-08-12 Thread aa56280
I'm using the url tag like so: {% url app.views.blah var1, var2 %} var1 and var2 need to be encoded, using the iriencode filter, so I tried this: {% url app.views.blah var1|iriencode, var2|iriencode %} That doesn't do anything though. I can't find any examples anywhere to figure this out. Any th

Re: Django sessions issue

2010-06-07 Thread aa56280
> You better show some code now... My urls.py has the following entry: (r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'next_page' : '/'}) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-

Re: Django sessions issue

2010-06-04 Thread aa56280
> How are you logging out? Are you sure you are calling > django.contrib.auth.logout() ? Yup, I'm calling django.contrib.auth.views.logout() -- 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...@googl

Django sessions issue

2010-06-03 Thread aa56280
Django's docs say: "When a user logs in, Django adds a row to the django_session database table. Django updates this row each time the session data changes. If the user logs out manually, Django deletes the row. But if the user does not log out, the row never gets deleted." I'm logging out of my a

Re: Separate views for form display and handling

2009-12-10 Thread aa56280
> render_to_response('foo.html', {'form' : form'}) Forgot to add: the form instance in this case will be bound to the submitted data and will contain the appropriate errors. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Separate views for form display and handling

2009-12-10 Thread aa56280
First of all, any reason why you're using different views and not the same view? Second, yes it's possible to do what you're trying to do. Try this: if form.is_valid(): # do something and redirect else: render_to_response('foo.html', {'form' : form'}) -- You received this message because yo

Re: django-registration terms of service link

2009-12-04 Thread aa56280
The "safe" filter works on a string, not the entire form. So you'll have to apply it to the label of the field: {{ form.tos.label|safe }} Hope that helps. On Dec 4, 11:55 am, Viktor wrote: > ahoj, > > I wrote a simple backend that extends RegistrationFormTermsOfService > of django-restration

Re: Show additional user information in admin

2009-12-03 Thread aa56280
> That works, but it would be nice to see and edit the > entrys in UserProfile directly via admin/auth/user. From my novice > standpoint, it looks like i have to overwrite the default admin.py > from the auth module. Is that right? And if yes, how do I do it "the > right way"? You can do that by c

Re: A Friendship relationship question.

2009-12-02 Thread aa56280
Couple things: 1) Your query is not working because if user1 added user2, then you should be looking at from_friend not to_friend. 2) You haven't posted the code where you're creating friendships but I'm assuming you are not creating symmetrical friendships there. That is, if user1 adds user2, yo

Re: Caught an exception while rendering: Reverse for 'portal.compliance_index' with arguments '()' and keyword arguments '{}' not found.

2009-12-02 Thread aa56280
Does your urls.py contain an entry for compliance_index? On Dec 2, 2:05 pm, Saravanan wrote: > Environment: > > Request Method: GET > Request URL:http://shellwing251.atdesk.com/ > Django Version: 1.0.2 final > Python Version: 2.4.2 > Installed Applications: > ['django.contrib.auth', >  'django.co

Re: Show additional user information in admin

2009-12-02 Thread aa56280
You'll have to "activate" the model like any other in order for it to show up on the Admin site. Have a look here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overview On Dec 2, 3:32 pm, Kai Timmer wrote: > Hello, > by following this > guide:http://docs.djangoproject.com/en/dev/to

Re: Application not showing in admin panel

2009-12-02 Thread aa56280
On Dec 2, 2:17 pm, "dr.NO" wrote: > I've installed application djangodblog, it's working, it's logging > everything into db - but it's not showing in the admin panel ... - any > idea how to fix thax ? Did you follow the steps outlined in the doc? http://docs.djangoproject.com/en/dev/ref/contrib/a

Re: missing template for login page

2009-12-02 Thread aa56280
> I tried copying /django/contrib/auth/tests/templates/ to > /django/contrib/auth/ but this gives me a form with only two fields and >   no submit button ... The form you are getting sounds like the right one. You'll get a username field and a password field, but you'll have to provide your own

Re: Forms ModelMultipleChoiceField with checkboxes?

2009-11-23 Thread aa56280
leoz01, Django comes with a widget for precisely this use case (check link above). Creating your own would be a complete waste of time. On Nov 20, 3:52 am, leoz01 wrote: > I think the easiest way is to make your own widget or otherwise you > can make your own form field. > > On 19 nov, 10:19, Ben

Re: Forms ModelMultipleChoiceField with checkboxes?

2009-11-21 Thread aa56280
Yes, have a look at this: http://docs.djangoproject.com/en/dev/ref/forms/widgets/#specifying-widgets The widget class for Checkboxes would be django.forms.widgets import CheckboxSelectMultiple Hope that helps. On Nov 19, 3:19 am, Benjamin Wolf wrote: > Hello, > > I'm using Django's form and Mo

Re: Customizing error message for unique ModelForm field

2009-11-05 Thread aa56280
e of my users. On Nov 5, 4:38 pm, aa56280 wrote: > I have a ModelForm with a slug field with unique=True. I need to make > the error message a bit more "friendly." Is there a way to override > the default error message? The default is: "

Customizing error message for unique ModelForm field

2009-11-05 Thread aa56280
I have a ModelForm with a slug field with unique=True. I need to make the error message a bit more "friendly." Is there a way to override the default error message? The default is: "[model_name] with this [field_label] already exists." --~--~-~--~~~---~--~~ You rece

Re: How manage (for testserver) fixtures files when use django.contrib.auth

2009-10-15 Thread aa56280
Are you looking for help on creating fixtures? If so, try this: http://docs.djangoproject.com/en/dev/howto/initial-data/#howto-initial-data If you're trying to add users using fixtures, then have a look here: http://groups.google.com/group/django-users/browse_thread/thread/c66f564797e64d47/35ab82

Customizing form widget

2009-10-15 Thread aa56280
I have a Category and SubCategory model. Each SubCategory belongs to a Category via a Foreign Key. (So each Category can have many SubCategories.) I have several places throughout my app where I show the list of SubCategories as part of some ModelForm. It renders like so: subcategory 1 subcateg

Re: Querying for objects created on a certain date

2009-10-12 Thread aa56280
_year=today.year) Thanks again. On Oct 12, 5:00 pm, Karen Tracey wrote: > On Mon, Oct 12, 2009 at 5:07 PM, aa56280 wrote: > > > I have a DateTimeField called "created_on" on a model called > > "Documents". It serves as a timestamp for when the record was added.

Querying for objects created on a certain date

2009-10-12 Thread aa56280
I have a DateTimeField called "created_on" on a model called "Documents". It serves as a timestamp for when the record was added. I'm trying to write a query that will return all Documents created_on a particular date, say today. I can make it work if I look for a record within a range of dates..

Re: send_mass_mail on object creation

2009-09-19 Thread aa56280
> The way I have handled this in the past is to create a simple app that you > can run from the command line. I had it check a table that was updated with > the list of emails to send and set it up as a scheduled task (cron job) for > every 20 minutes or so. I was leaning toward a similar solutio

send_mass_mail on object creation

2009-09-18 Thread aa56280
When a new instance of some object is created, I need to send out X number of emails. X could potentially mean hundreds of emails. What would be the most efficient way to do this? I know if I use send_mass_mail() it could potentially hang for quite a long time. Any thoughts greatly appreciated.

Re: Imagefield, PIL and save()

2009-09-03 Thread aa56280
On Sep 3, 5:31 pm, Rob Broadhead wrote: > If you are on a Mac there are some issues with the imagelib you will   > need to fix. Very interesting. I am on a Mac. So I'll investigate and update. Thanks, Rob. --~--~-~--~~~---~--~~ You received this message because yo

Imagefield, PIL and save()

2009-09-03 Thread aa56280
I have an ImageField in a model. I also have a ModelForm for this model. I'm overriding save() so that I can take the image that was uploaded and make a thumbnail out of it using PIL. I'm using the simplest of examples just to get started: ... def save(self): from PIL import Image im = Imag

Re: unique=True and IntegrityError

2009-09-01 Thread aa56280
> The check for unique fields is done in the base ModelForm clean method.  By > overriding clean without calling the superclass clean you are causing the > checks to be bypassed. I read up on it while you were posting your reply :) http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#ov

Re: unique=True and IntegrityError

2009-09-01 Thread aa56280
You're right, I did leave out something - the clean() method. Nothing unusual there. In fact, if I take out everything from the method and leave the shell: def clean(self): return self.cleaned_data It still craps out. However, if I take away the entire method, then I do get the validation erro

Re: unique=True and IntegrityError

2009-08-31 Thread aa56280
On Aug 31, 9:51 pm, Karen Tracey wrote: > However if you use a ModelForm to validate the data prior to attempting to > save the model you get these problems reported as validation errors: Karen, Thanks for the thorough explanation. I really appreciate it. What I took from it is that if I'm usi

unique=True and IntegrityError

2009-08-31 Thread aa56280
I can't find an answer to this, so I'm hoping folks here can help: why is it that Django catches IntegrityError for a field with unique=True in the Admin tool but requires you to catch it yourself in your app? That is, why isn't it handled like all other built-in validation checks that come bundle

Class Meta discovery

2009-08-16 Thread aa56280
Not sure how well known this is but I thought I'd share seeing as how it cost me a lot of time and I can't find any discussion of it: I have a form for a model. The model has three fields, but I only want one displayed in the form. So I do this: class NoteForm(ModelForm): class Meta:

Re: Creating users in fixtures

2009-06-30 Thread aa56280
Worked like a charm. Thanks, Alex. On Jun 30, 6:36 pm, Alex Gaynor wrote: > On Tue, Jun 30, 2009 at 6:32 PM, aa56280 wrote: > > > I'm trying to create a bunch of users in a initial_data.yaml fixture > > file. What should I be using for the Model? > > django.contr

Creating users in fixtures

2009-06-30 Thread aa56280
I'm trying to create a bunch of users in a initial_data.yaml fixture file. What should I be using for the Model? django.contrib.auth.user does not seem to be working. Django throws a DeserializationError: Invalid model identifier: 'django.contrib.auth.user' Any help would be greatly appreciated.

Re: ForeignKey with null=True

2009-05-15 Thread aa56280
ample) On May 15, 12:13 pm, Alex Gaynor wrote: > On Fri, May 15, 2009 at 12:11 PM, aa56280 wrote: > > > So to be clear then, yes, I want to delete the object from the > > database entirely. How to go about doing that using location_set? > > > On May 15, 12:07 pm, Alex

Re: ForeignKey with null=True

2009-05-15 Thread aa56280
So to be clear then, yes, I want to delete the object from the database entirely. How to go about doing that using location_set? On May 15, 12:07 pm, Alex Gaynor wrote: > On Fri, May 15, 2009 at 12:04 PM, aa56280 wrote: > > > I'm trying to wrap my head around why a ForeignKe

ForeignKey with null=True

2009-05-15 Thread aa56280
I'm trying to wrap my head around why a ForeignKey needs to be set with null=True in order for its related model to call remove() on one of its instances. For example: # models class Company(models.Model): ... class Location(models.Model): ... company= models.ForeignKey(Company) #

Re: login decorator losing POST data

2009-05-14 Thread aa56280
Tim, Thanks for the fantastic insight into the browser issues with 307 redirects. I'll explore this a bit further and see which route I want to take. Given that the form in question is simply a button that says "Join network," I may be inclined to just let the user login, come back to the page a

Re: login decorator losing POST data

2009-05-14 Thread aa56280
On May 14, 8:29 am, TiNo wrote: > Isn't it possible to force the user to login before filling out the form? > That eliminates all the issues with redirecting the POST data. How ironic. I clicked on the Reply link and Google told me I need to sign in in order to reply. I was then brought back an

login decorator losing POST data

2009-05-13 Thread aa56280
Hello there, I have a form. Once it's submitted (method=POST) the view handling the submit uses the @login_required decorator. Problem is that when the login page intercepts to enforce login, it passes the user over to the view via the "next" parameter but that's no longer considered a POST requ