Re: request.user not pickable anymore

2011-09-16 Thread Tim Shaffer
Looks like there might already be a ticket open to fix this: https://code.djangoproject.com/ticket/16563 -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: Trouble expressing a query in the ORM

2011-09-09 Thread Tim Shaffer
Maybe something like this... for target in Target.objects.all(): property = target.property_set.latest("export_date") print target.name, target.t1, target.t2, property.export_date, property.p1, property.p2 -- You received this message because you are subscribed to the Google Groups

Re: FTP prefic in URL field

2011-07-15 Thread Tim Shaffer
Yeah, it doesn't look like 1.1 allowed for ftp protocol: https://github.com/django/django/blob/1.1.X/django/forms/fields.py#L545 Best bet might be to create your own URLField class and overwrite the __init__ method to use your own regular expression. Kind of a pain. It's a little easier in

Re: FTP prefic in URL field

2011-07-15 Thread Tim Shaffer
It looks like the URLValidator should in fact accept ftp: https://github.com/django/django/blob/master/django/core/validators.py#L46 What's the specific error you're getting? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Re: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
On Thursday, July 14, 2011 2:32:26 PM UTC-4, Petey wrote: > > Is there a way around? > This isn't really something that can/should be solved in the model itself. You could try overwriting the formfield_for_foreignkey method in your ModelAdmin:

Re: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
You should still probably remove the user_logged_in from your default value. It doesn't do what you think it does, and could cause other strange things to happen. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the

Re: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
I just noticed that you had the default value set to the "user_logged_in" signal method. That's not going to work at all. You probably want to remove that from the field definition. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Re: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
When you do this: created = models.ForeignKey(User, default=user_logged_in, editable=False ) It's going to create a method on the user instance called "news_set". Then when you then do this: edited = models.ForeignKey(User, default=user_logged_in, editable=False) It's going to try to

Re: Model IPAddressField not validating?

2011-07-05 Thread Tim Shaffer
Django trunk also contains validate_ipv6_address and validate_ipv46_address. But as of 1.3 I think it only validates ipv4 -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: unable to import Modules Present in subdirectores

2011-06-29 Thread Tim Shaffer
You do have a __init__.py file in each of the sub folders, correct? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/G33m7AMAv7wJ. To post to this group,

Re: 'module' object has no attribute 'Manipulator'

2011-06-24 Thread Tim Shaffer
On Friday, June 24, 2011 4:30:13 PM UTC-4, django_cd wrote: > > Thanks Jacob for the reply although u didn't answer giving a reason for the > error. > The reason for the error is that you are using a different version of Django than that tutorial was written for. That tutorial is from 2006

Re: Automatic internal link middleware

2011-06-22 Thread Tim Shaffer
Shouldn't be too hard to implement I don't think. Basically just loop through your list of keywords and replace them with a link. Something like this: def make_keyword_links(content): for keyword in Keyword.objects.all(): content = content.replace(keyword.text, keyword.link)

Re: UpdateView help

2011-06-20 Thread Tim Shaffer
Django automatically calls get_object() to get the object that needs to be updated by your form. There is a default get_object() method in the SingleObjectMixin that just gets the object based on the "model" and the "pk" that's passed in:

Re: How to load CSS: Django Template, CSS and image

2011-06-16 Thread Tim Shaffer
Shouldn't you really be putting your js/css in your static directory? Check out the docs for managing static files: https://docs.djangoproject.com/en/1.3/howto/static-files/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Re: Helper methods like rails or taglibs/tagfiles like java

2011-06-15 Thread Tim Shaffer
The link was just an example. It could be a more complex block of HTML. Point being if the tag just massaging data into HTML, you can accomplish it with another template without creating a tag. -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: Helper methods like rails or taglibs/tagfiles like java

2011-06-15 Thread Tim Shaffer
Another option, if your use-case doesn't require anything terribly complex, is to just include another template and pass your variables to it: {% include "link_to.html" with url="google.com" text="check out google" %} In link_to.html: {{ text }}

Re: Need help with tutorial

2011-06-15 Thread Tim Shaffer
There should be two underscores before and after the "unicode" in the method name: "__unicode__" instead of "_unicode_" -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: Dynamic verbose_name_plural to display number of models in admin panes

2011-06-05 Thread Tim Shaffer
You could probably do it using a signal. Every time a record is created or deleted, you can update the verbose_name_plural with the current count. from django.db.models.signals import post_save, post_delete def update_verbose_name(sender, **kwargs): Elephant._meta.verbose_name_plural =

Re: Template - counter for if loop

2011-06-02 Thread Tim Shaffer
I think you might want the heading outside the loop: My Heading {% for val in data %} {% ifnotequal val 2 %} {{val}} {% endifnotequal %} {% endfor %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Re: propagating values up the template chain

2010-04-21 Thread Tim Shaffer
You should be able to do both those with the block tag, unless I'm misunderstanding something, or you have some other requirement. {% extends "base.html" %} {% block content %} {% block extra-js %} {% if user.is_authenticated %} {% endif %} {% endblock %} ... more block content ... {% endblock

Re: propagating values up the template chain

2010-04-21 Thread Tim Shaffer
Can you put the whole script tag in a block? = template.html = {% block extra-js %} {% endblock %} = base.html = {% block extra-js %}{% endblock %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Why doesn't my isinstance() work?

2010-04-21 Thread Tim Shaffer
Sorry, "class MP3Media(object):" should have been class "MP3Media(Media):" -- 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

Re: Why doesn't my isinstance() work?

2010-04-21 Thread Tim Shaffer
I think then you will run into a problem with you add another media type: class WAVMedia(Media): file = models.CharField() def play(self): # do stuff >>> m = Media() >>> m.wavmedia = WAVMedia() >>> m.mp3media = MP3Media() >>> playlist = Playlist >>> playlist.media_set.append(m) for

Re: Why doesn't my isinstance() work?

2010-04-21 Thread Tim Shaffer
On Apr 21, 9:28 am, Tom Evans <tevans...@googlemail.com> wrote: > On Wed, Apr 21, 2010 at 2:15 PM, Tim Shaffer <t...@tim-shaffer.com> wrote: > > On Apr 21, 8:25 am, Torsten Bronger <bron...@physik.rwth-aachen.de> > > wrote: > >> calls the method of th

Re: Why doesn't my isinstance() work?

2010-04-21 Thread Tim Shaffer
On Apr 21, 8:25 am, Torsten Bronger wrote: > Yes, but normally, you have tools like type(instance) or > instance.__class__.  However, in Django, you don't.  That's the > problem. Sure you do... >>> from website.blog.models import Entry >>> e =

Re: Why doesn't my isinstance() work?

2010-04-21 Thread Tim Shaffer
Why should an author instance ever return True for isinsnace(author_instance, Translator). That's not really the way Python or Django are designed to work. Why not just check to see if the author instance has an associated translator instance? That's the proper way. See the docs on multi- table

Re: Login problem, django does not remember user

2010-04-16 Thread Tim Shaffer
I suspect you have a clash in names here. You have two methods named "login": 5: from django.contrib.auth import authenticate, login 9: def login(request, template_name='auth/login.html'): So when you call login(request, user) on line 21, it's calling the method you created on line 9, not the

Re: Concat a message with send_mail

2010-04-15 Thread Tim Shaffer
Can't you just concatenate them like so? message = "Last Name: " + last_name + " Message: " + message Or if you want to get really fancy, you could create a template, pass the form as a context, and render the template for the e-mail message. -- You received this message because you are

Re: forms.py and javascript functions

2010-04-14 Thread Tim Shaffer
Check out the attrs dictionary option for the form widget. http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: WSGIScriptAlias

2010-04-13 Thread Tim Shaffer
Try reversing the order. The first alias is probably picking up the / test URL. If you specify the test alias first, it should work. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: ORM Query question

2010-04-12 Thread Tim Shaffer
Or, using range: MyModel.objects.filter( Q(a__range=(1,5)) | Q(b__range=(20,70)) ) -- 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

Re: ORM Query question

2010-04-12 Thread Tim Shaffer
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects MyModel.objects.filter( ( Q(a__gt=1) & Q(a__lt=5) ) | ( Q(b__gt=20) & Q(b__lt=70) ) ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: why can't i display my data onto my template and error on HttpResponse object

2010-04-09 Thread Tim Shaffer
To be able to use the form variable in the template, you have to pass it to the template in render_to_response in the context like so: return render_to_response('add_user.html', {'form':form}) Check out the documentation for more examples:

Re: django.forms.widgets.Select error

2010-04-08 Thread Tim Shaffer
Choices should be a list/tuple of lists/tuples in the form of (value,display). So this: choices = (('M','Male'),('F','Female'),) Would give you this: Male Female -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: Setting up Django on snow leopard

2010-04-08 Thread Tim Shaffer
Very strange. What happens if you open a new Terminal window and run the following? python -c "import sys; print sys.path" -- 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

Re: Setting up Django on snow leopard

2010-04-08 Thread Tim Shaffer
What is the absolute path to the django site-packages folder? What does the following code output when you run it in the python interpreter? import sys for p in sys.path: print p -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: URL Patterns for Nested Catagories.

2010-04-07 Thread Tim Shaffer
Oh, check out the Category class from django-simplecms. It implements the first method. Specifically, check out the save() method that builds the path based on all the parent categories if it doesn't exist. http://code.google.com/p/django-simplecms/source/browse/trunk/simplecms/cms/models.py#47

Re: URL Patterns for Nested Catagories.

2010-04-07 Thread Tim Shaffer
> I suppose I could do something like r'^(?P.*)$' and then parse path in > the view but this could wreak havoc with other URLs. Yes, that's the way to do it. You can prevent it from clashing with other URLs by prefixing it with something like categories/ so the URL would be:

Re: Middlewares disable for specific views

2010-04-06 Thread Tim Shaffer
It's actually the auth context processor that queries for messages, not the auth middleware. The TEMPLATE_CONTEXT_PROCESSORS are only processed when you using RequestContext. So there are numerous ways to get prevent the auth context processor from being used. You could just not use

Re: Catching User's First Log in

2010-04-05 Thread Tim Shaffer
This might be slightly off topic, but why is the last_login set to the current date when a user is created? Wouldn't it make more sense for that date to be null until the user actually logs in? On Apr 5, 4:25 pm, Wesley Childs wrote: > Thanks for the advice. > > I'm

Re: conditional loading of template tags

2010-04-05 Thread Tim Shaffer
and {% include %} tags are parsed at the same time as the {% if %} tag. On Apr 5, 2:51 pm, Owen Nelson <onel...@gmail.com> wrote: > Tim Shaffer wrote: > > I haven't tested this at all, but maybe try putting all the tagging > > stuff, include {% load tagging_tags %}, in a separate templa

Re: conditional loading of template tags

2010-04-05 Thread Tim Shaffer
I haven't tested this at all, but maybe try putting all the tagging stuff, include {% load tagging_tags %}, in a separate template, then wrapping the if statement around an include for that template: {% if object.tags %} {% include "tag_stuff.html" %} {% endif %} Like I said, I haven't tested

Re: Hosting for Django sites

2010-04-03 Thread Tim Shaffer
+1 for Webfaction Their hosting plans are great, and the customer service is absolutely amazing. I'm just on a shared plan, but usually get a response to tickets within an hour or so. Top notch. -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: basic django auth fails on valid user

2010-03-24 Thread Tim Shaffer
I think this could all be simplified a bit if you used a UserProfile model instead of subclassing auth.User. http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users Was there a specific reason you were subclassing auth.User? -- You received this message

Re: Dynamic multi-site - running many sites from one Django instance

2010-03-24 Thread Tim Shaffer
You are right. I understand now. I must have misread the original request, because I now see that describes multiple instances in memory wouldn't work properly. On Mar 24, 12:52 am, Graham Dumpleton <graham.dumple...@gmail.com> wrote: > On Mar 24, 12:53 pm, Tim Shaffer <timster.

Re: Dynamic multi-site - running many sites from one Django instance

2010-03-23 Thread Tim Shaffer
No, it would just be one instance of the project with 20 different configuration files. On Mar 23, 5:29 am, Tom Evans <tevans...@googlemail.com> wrote: > On Mon, Mar 22, 2010 at 5:53 PM, Tim Shaffer <timster...@gmail.com> wrote: > > It gives you multiple sites from one c

Re: Permissions for groups and users

2010-03-22 Thread Tim Shaffer
SVN diff is here: http://code.google.com/p/django-namespace/source/diff?spec=svn3=3=side=/trunk/namespace/admin.py_path=/trunk/namespace/admin.py=2 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Permissions for groups and users

2010-03-22 Thread Tim Shaffer
a new > task, he can choose tasks from other namespaces as parent tasks. > > I tried that with a different model combination, with the same result. > As soon as a model refers to a foreignkey the user is able to choose > from ever other namespace. > Can that be resolved somehow? &

Re: Negate querysets

2010-03-22 Thread Tim Shaffer
It depends. This will only run one query, when negated_queryset is used. queryset = User.objects.filter(first_name='vinicius') negated_queryset = User.objects.exclude(id__in=queryset.values("id")) Since the first queryset is not evaluated until it's used in the negated_queryset (as a subquery).

Re: Permissions for groups and users

2010-03-22 Thread Tim Shaffer
Django doesn't support that out of the box. I searched and couldn't find anything. Self plug: I created an app that does exactly this. http://code.google.com/p/django-namespace/ Only difference is I called the model Namespace instead of Domain. Just download it, then add it to your

Re: Negate querysets

2010-03-22 Thread Tim Shaffer
Might be possible. I'm not terribly familiar with the innards of the QuerySet class. Seems like it could get real complex real fast, especially if you're using Q objects. On Mar 22, 4:17 pm, Phlip wrote: > > Just create another queryset that excludes everything in your first

Re: Negate querysets

2010-03-22 Thread Tim Shaffer
Just create another queryset that excludes everything in your first queryset: negated_queryset = User.objects.exclude(id__in=queryset.values("id")) On Mar 22, 3:47 pm, Vinicius Mendes wrote: > Is there any way to negate a queryset? Let's supose i have this queryset: > >

Re: Dynamic multi-site - running many sites from one Django instance

2010-03-22 Thread Tim Shaffer
It gives you multiple sites from one codebase with multiple settings files. They are using the same project module. So your project would look like this: project - app1 - app2 - settings.py - settings_site1.py - settings_site2.py - urls.py settings.py would contain all the settings like a normal

Re: Dynamic multi-site - running many sites from one Django instance

2010-03-22 Thread Tim Shaffer
How are you serving the Django project? Are you using Apache? mod_python? mod_wsgi? If you are using mod_python or mod_wsgi, you should be able to change the DJANGO_SETTINGS_MODULE for each site. So basically for each site, you would have a separate settings file in your project. So for the

Re: Is the user member of a certain group

2010-02-22 Thread Tim Shaffer
There may be a more efficient way, but you can use this for starters: if ( "admin" in request.user.groups.values_list("name",flat=True) ): On Feb 22, 5:56 pm, Joakim Hove wrote: > Hello, > > using the django auth framework I have created two groups called > "admin" and

Re: Problem with PIL in Mac OS X 10.4

2010-02-22 Thread Tim Shaffer
You'll have to manually install libjepg to get PIL working on a Mac. If you have MacPorts installed, you should just be able to do "sudo port install jpeg". Otherwise, you can download it from one of these locations: http://dir.filewatcher.com/d/GNU/Other/jpegsrc.v6b.tar.gz.613261.html Then

Re: POST from external site

2010-02-22 Thread Tim Shaffer
What does the HTML for the Django-generated form look like? What does the HTML for the non-Django-generated form look like? Are you using Django Cross Site Request Forgery protection? On Feb 22, 12:27 pm, kkerbel wrote: > Let me further clarify...when I post using django it

Re: Making a User Registration form

2010-02-20 Thread Tim Shaffer
> Wait, but do profile fields get displayed as part of the form? Just add them to RegistrationForm and they will. Or create another form class for Profile, and use the fields from that to populate the Profile... {{ reg_form.as_p }} {{ profile_form.as_p }} On Feb 20, 10:22 am, Shawn Milochik

Re: Making a User Registration form

2010-02-20 Thread Tim Shaffer
Sorry... char.save() should read profile.save() On Feb 20, 9:05 am, Tim Shaffer <timster...@gmail.com> wrote: > It's really not that difficult. You can just override the save() > method and create the Profile there. > > class RegistrationForm(forms.ModelForm): > >     cla

Re: Making a User Registration form

2010-02-20 Thread Tim Shaffer
It's really not that difficult. You can just override the save() method and create the Profile there. class RegistrationForm(forms.ModelForm): class Meta: model = User def save(self): user = super(RegistrationForm, self).save() profile =

Re: Admin screen pluralizing models inappropriately and database relations question

2010-02-19 Thread Tim Shaffer
e this discussion is helping > other users who are new to django. I had searched extensively for django > implementations of RPG-like inventories and characters and didn't find any. > I'm sure there are other people in the same boat. > > Cheers. > > -Tim > > On Fri, Feb 19,

Re: Admin screen pluralizing models inappropriately and database relations question

2010-02-19 Thread Tim Shaffer
at I can't associate a unique condition (100% or > less) with each item. And I can't seem to add the same item twice. > > I would like to have an inventory that looked like this: > > Inventory for Samurai Sam: > (item - condition) > Item1 - 100% > Item1 - 75% > Item2 - 100% >

Re: Admin screen pluralizing models inappropriately and database relations question

2010-02-18 Thread Tim Shaffer
1) You can change this in your model. Check out "verbose_name" and "verbose_name_plural" for the model's Meta class. http://docs.djangoproject.com/en/dev/ref/models/options/ 2) If you have a ManyToMany field to samurai on the item, you don't need the inventory model at all. A samurai's inventory

Re: Problem with order_with_respect_to

2006-10-30 Thread Tim Shaffer
I'm guessing you're using MySQL? I believe order_with_respect_to has been broken for a while now when used with MySQL. I haven't been able to get it working since I can remember. There is a ticket regarding this issue... http://code.djangoproject.com/ticket/1760

Re: Custom Template Tag - What do I need in my actual template?

2006-10-13 Thread Tim Shaffer
Your code looks valid as it is right now. The get_latest_polls function should return a QuerySet of the three latest polls. When you call this function it will get the polls and assign the QuerySet to the "polls" variable for use in your template. In order to display the polls, you would need

Re: Simple Template Syntax Question: ljust

2006-09-25 Thread Tim Shaffer
It should be {{ product.title|ljust:"40" }} --~--~-~--~~~---~--~~ 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,

help with custom validators

2006-09-01 Thread Tim Shaffer
This is my first time using custom validators, so I want to make sure I'm on the right track. Here's a stripped down version of my model and the validation requirements: class Event(models.Model): date = models.DateField() recurrence = models.SmallIntegerField(blank=True, null=True,

Re: My blog is now Django -- source is available

2006-08-22 Thread Tim Shaffer
It looks like some of your views are very simple and could use generic views, if you wanted. def home(request): return render_to_response('home.html') could use django.views.generic.simple.direct_to_template def entry(request, entry_id): e = get_object_or_404(Entry,

Re: Better way to do this?

2006-08-22 Thread Tim Shaffer
You can use choices for the Frequency model, if you like. It may simplify things. DAY_CHOICES = ( ('Sa', 'Saturday'), ('Su', 'Sunday'), ('Mo', 'Monday'), ('Tu', 'Tuesday'), ('We', 'Wednesday'), ('Th', 'Thursday'), ('Fr', 'Friday'), ) class Frequency(models.Model):

Re: Using choices with list_display

2006-08-18 Thread Tim Shaffer
Thanks... that fixed it. I don't know how I missed that. It's always the simple things. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Using choices with list_display

2006-08-18 Thread Tim Shaffer
I have a model that holds events... simplified, it looks like this: RECURRENCE_CHOICES = ( ('1', 'Daily'), ('2', 'Weekly'), ('3', 'Monthly'), ('4', 'Yearly'), ) class Event(models.Model): title = models.CharField(maxlength=50) recurrence =

Re: Current *preferred* fcgi setup, lets settle this once for all

2006-08-17 Thread Tim Shaffer
It shouldn't. Here are a couple other things to check, just in case it's something simple. 1. Is the domain setup with "FastCGI Support?" in the Dreamhost Panel? 2. Are the permissions on django.fcgi set to 755? Post the last 10 lines or so of ~/logs/yoursite.com/http/error.log This will show

Re: filter by related data

2006-08-15 Thread Tim Shaffer
comments = Comment.objects.filter(usubjid__study_id__exact='CP-AI-005') By using the usubjid__study_id syntax it lets django know that you want to filter by study_id field in the usubjid (Patient) model. --~--~-~--~~~---~--~~ You received this message because

Re: Current *preferred* fcgi setup, lets settle this once for all

2006-08-15 Thread Tim Shaffer
Here is my .htaccess file... let me know if you have any questions. AddHandler fastcgi-script .fcgi RewriteEngine On RewriteRule ^(media/.*) - [L] RewriteCond %{REQUEST_URI} !(django.fcgi) RewriteRule ^(.*)$ django.fcgi/$1 [L] --~--~-~--~~~---~--~~ You received

Re: Current *preferred* fcgi setup, lets settle this once for all

2006-08-15 Thread Tim Shaffer
I am using Dreamhost and just recently switched from the "old" way to the "new" way that uses flup. I haven't had any problems. It's hard to tell where your problem is occurring without seeing any errors... can you check the server logs and post the error? Just for reference, here is what my