Re: Encrpting urls to hide PKs

2011-05-10 Thread Sean Brant
my code is a bad idea. If security is a issue this should be behind a password. > On 10/05/2011 15:32, Sean Brant wrote: >> Sorry I think I only responded to the original poster. >> >> >>> from django.utils.http import int_to_base36, base36_to

Re: Encrpting urls to hide PKs

2011-05-10 Thread Sean Brant
Sorry I think I only responded to the original poster. >>> from django.utils.http import int_to_base36, base36_to_int >>> int_to_base36(123) '3f' >>> base36_to_int('3f') 123 Sean -- You received this message because you are subscribed to the Google Groups "Django users" gro

Converting from Wordpress, upgrading users.

2011-01-15 Thread Sean Brant
I am migrating a site from Wordpress to Django and I need the old username and passwords to keep working. I first create auth.User objects for all Wordpress users. Wordpress' login username does not conform to Django's so I need to fix some of the usernames during migration. I then store Wordpress

Admin Inline inside another admin inline

2010-07-03 Thread Sean Brant
I have these models and model admins and I was hoping inlines = [] inside a admin.TabularInline would work, but it doesn't seem to. class Size(models.Model): pass class Product(models.Model): pass class ProductType(models.Model): titl

SQL along side NoSQL

2010-06-02 Thread Sean Brant
Whats the best way to use django's orm along side a NoSQL DB? I want to keep my users and other data in postgres but have some data that would be better suited for a NoSQL DB like redis. I see a lot of talk about switching to NoSQL but little talk on integrating it with existing systems. I think i

Re: Switching a Models Field Class at Runtime

2009-11-12 Thread Sean Brant
Yeah that would work. I'd like to avoid that because every Item will need its child content, so you would have to always use a join (which are slow). One more thought is it possible to has multiple models that all save to the same table? I only really need the helpful Image and File fields for wri

Switching a Models Field Class at Runtime

2009-11-12 Thread Sean Brant
Let me start out by saying this feels a little over engineered but I wanted to see what people thought anyways. I would like to create a list similar to a Facebook wall. You can post stuff and attach content to the post. In the past I have create a table with properties for all content formats and

Sessions for Anonymous Users

2009-11-05 Thread Sean Brant
So I have a invite system for one of my projects and right now when a user clicks the link /invitations// I get the invitation object and store it in request.session['invitation']. Then I redirect to / accounts/new/ if request.session['invitation'] is None then I produce and error if not I present

Re: Marking usernames as not for use dynamically

2009-11-02 Thread Sean Brant
Thanks Ethan. bruno you are right moving stuff under the /profiles/ namespace would solve everything. Moving the pattern last but allowing users to still create the username of "login" would prevent there username from working. You are also right about "whenever you add any other url..." this w

Marking usernames as not for use dynamically

2009-11-02 Thread Sean Brant
So i have user profiles at http://domain.com/username. I'd like to prevent a user from signing up with a username that is the same as a page on my site (ie: /login/, /blog/, etc). I was thinking I could inspect my url patterns to determine what pages exist so I can prevent that from being a usern

Testing code that uses geopy

2009-08-10 Thread Sean Brant
I have written some unit tests that test various parts of code that utilize geopy for determining geo locations. Should I be running my tests using the geocoder class, or should I create a mock class that does not actually ping any services? If creating a mock class is recommended should I specify

QuerySet question, getting latest 3 objects filtered by a key.

2009-06-22 Thread Sean Brant
This is best explained with an example. i have a model for Stats class Stat(models.Model): key = models.CharField(max_length=50) value = models.TextField() pub_date = models.DateTimeField() so if i create a few stat objects lets say these. stat1 = Stat(key='total_books_sold', value

Dual Storage Backends?

2009-06-18 Thread Sean Brant
has anyone come across dual storage backend, ideally id would like a way to save a file locally and then in a back ground process save to s3, the guess the storage class would handle the files locally until the background process has finished then switch to serving the files off of s3? Basecamp d

Re: Images not uploading in the admin tool

2009-06-17 Thread Sean Brant
Nope, there customer support takes to long so I just gave up. Please post if you have any updates. Last I remember it might be a NFS issue on there end. Not really sure. On Jun 17, 2009, at 9:43 AM, mmarshall wrote: > > On Jun 9, 9:19 am, Sean Brant wrote: >> "Did M

Re: Is there a way to calling a model field method on model save

2009-06-16 Thread Sean Brant
Okay I just came up with this, let me know if this is a really hacky way to do this. With this it will save the model, then the file and then the model again, not sure how to do this since we don't get the filename until after we save the file and we have to set the filename in the database. clas

Is there a way to calling a model field method on model save

2009-06-16 Thread Sean Brant
I am creating a custom image field, that I would like for it not to save the image until after the model instance is written to the database (i want the id for the object to use in the filename). The ImageField class saves the image to storage via pre_save. Is there any methods or any other code t

Re: Problem with query set order_by

2009-06-11 Thread Sean Brant
You the man Alex, that was the problem! On Jun 11, 11:19 am, Alex Gaynor wrote: > On Thu, Jun 11, 2009 at 11:15 AM, Tom Evans wrote: > > > > > > > On Thu, 2009-06-11 at 09:04 -0700, Sean Brant wrote: > > > If I have 2 sql queries one with a limit of 5 and the o

Problem with query set order_by

2009-06-11 Thread Sean Brant
If I have 2 sql queries one with a limit of 5 and the other with a limit or 6 they return there results in diffrent orders. Here is a example. >>> class Book(models.Model): >>>title = models.CharField(max_length=150) >>>author = models.CharField(max_length=100) >>> book_list_1 = Books.o

Re: Images not uploading in the admin tool

2009-06-09 Thread Sean Brant
I'll reach back out to them and see what they say. On Tue, Jun 9, 2009 at 9:15 AM, Karen Tracey wrote: > On Tue, Jun 9, 2009 at 9:49 AM, Sean Brant wrote: >> >> I am running on a MediaTemple Django container with the SVN version of >> Django. When I try and upload a image

Images not uploading in the admin tool

2009-06-09 Thread Sean Brant
I am running on a MediaTemple Django container with the SVN version of Django. When I try and upload a image in the admin tool I get a proxy error. The following is the part of the traceback that gets emailed to me. Traceback (most recent call last): File "/home/58124/data/python/django/django/c

Re: UnicodeEncodeError

2009-05-21 Thread Sean Brant
Thanks Karen. This is a script that fetched some json from a remote service. I switched from using the normal simplejson module to the one provided by Django and that seems to decode things in a unicode safe way. On May 21, 2009, at 8:48 AM, Karen Tracey wrote: > I see I specified the unic

UnicodeEncodeError

2009-05-20 Thread Sean Brant
Traceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/home/58124/data/python/django/django/core/management/ __init__.py", line 362, in execute_manager utility.execute() File "/home/58124/data/python/django/django/core/management/ __init__

Re: Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant
I rechecked out trunk and it seems to work as expected. Thanks. On May 15, 2009, at 10:54 PM, Alex Gaynor wrote: > > > On Fri, May 15, 2009 at 8:40 PM, Sean Brant > wrote: > > On more thing I reverted back to rev: 9500 (choose it randomly) every > thing seems to work. &

Re: Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant
On more thing I reverted back to rev: 9500 (choose it randomly) every thing seems to work. On May 15, 8:24 pm, Sean Brant wrote: > Im running trunk rev: 10790 with Postgres 8.3 and when I access the > admin area or when using login_required i get this error: > > Traceback (most rece

Re: Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant
It might be due to threading, every once in a while I can pull up the admin page. It's pretty random thought. On May 15, 8:24 pm, Sean Brant wrote: > Im running trunk rev: 10790 with Postgres 8.3 and when I access the > admin area or when using login_required i get this error: &g

Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant
Im running trunk rev: 10790 with Postgres 8.3 and when I access the admin area or when using login_required i get this error: Traceback (most recent call last): File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/ servers/basehttp.py", line 278, in run self.result = application

Re: django.contrib.auth tests fail

2009-05-13 Thread Sean Brant
I am also having a issue with contrib.auth test errors. They errors seem to be caused by url tags in my base.html template. When I comment out all of those tags the tests pass. The url tags seem to work when i look at the site im my browser. ===

Re: Help a noob with a stupid question - forms

2009-05-12 Thread Sean Brant
problem since, at least in my opinion, the calendar widget might be a > little confusing. > > Thanks for the suggestion. > > On May 12, 7:56 am, Sean Brant wrote: > > > Did you try date = models.DateTimeField(). This will show up in the > > admin tool as a cale

Re: Help a noob with a stupid question - forms

2009-05-12 Thread Sean Brant
Did you try date = models.DateTimeField(). This will show up in the admin tool as a calendar widget that you can use to select the date. Django takes care of converting the dates into Python objects and into whatever format your database needs for storing. You could also just use a DateField if yo

Re: ModelForm customizing

2009-05-08 Thread Sean Brant
Try this, not tested but it might work. class ProfileForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.error_class = DivErrorList super(ProfileForm, self).__init__(*args, **kwargs) class Meta: model = P exclude = ('date', 'user', 'public')

Re: Template tags and variables overlapping

2009-04-30 Thread Sean Brant
If the tag excepts more than one argument you should be able to do something like this. {% sayHello "Robert and" currentname %} You would just need to figure out how best to break the bits up (a regex probably would work) and iterate over those bits resolving the variables to strings, keeping th

Re: request.urlconf does not get used in URL template tag

2009-04-15 Thread Sean Brant
I knew I couldn't be that easy. Thanks for the heads up. Any other work around? besides the patch mentioned. On Apr 15, 11:17 pm, Alex Gaynor wrote: > On Thu, Apr 16, 2009 at 12:15 AM, Sean Brant wrote: > > > If you set request.urlconf in say a Middleware then the reverse >

request.urlconf does not get used in URL template tag

2009-04-15 Thread Sean Brant
If you set request.urlconf in say a Middleware then the reverse function and the url tag will not work because those try to match based on your ROOT_URLCONF. I was trying to find a solution to this problem and came across this ticket. http://code.djangoproject.com/ticket/5034 Then It dawned on me

Setting and deleting cache keys with tags

2009-04-13 Thread Sean Brant
I wrote up a blog post the other day on how I go about deleting multiple related objects from cache based on tags. It allows you to tag objects as you add them to cache that way you can delete a bunch with one call. http://stepsandnumbers.com/archive/2009/04/11/setting-and-delete-cache-in-django-

Re: Django wont display images on my CSS file

2009-03-27 Thread Sean Brant
In most of my projects I have a img, css, js folder. In my css file I reference images like this url(../img/path/to/img.jpg) in my css files. The ../ basically says start the path back one directory. Not sure if this is what's causing your problem. On Mar 27, 8:10 am, Martin Ostrovsky wrote: > I

Re: Problem outputting date in template as timestamp

2009-02-21 Thread Sean Brant
BTW, That is with a timezone of "America/New_York" On Feb 21, 1:05 pm, Sean Brant wrote: > Would something like this work? > > def U(self): >     "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" >     import calendar >     timestamp

Re: Problem outputting date in template as timestamp

2009-02-21 Thread Sean Brant
Would something like this work? def U(self): "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" import calendar timestamp = calendar.timegm(self.data.timetuple()) return timestamp + time.timezone Test: r""" >>> print dateformat.format(my_birthday, 'U') 40437 """ fr

Re: Problem outputting date in template as timestamp

2009-02-20 Thread Sean Brant
> I asked a similar question a while ago... turns out the server i'm > using from godaddy was set for Arizona and was an additional 20 some > minutes off... I checked my server and the timezone is set to US/CENTRAL and my settings file is set to America/Chicago. So that should be the same. Plus t

Problem outputting date in template as timestamp

2009-02-20 Thread Sean Brant
I am trying to render a timestamp in my template with date:"U" but the timestamps are days off. I wrote up a simple test case that fails. Do you think this is a bug or a user error? I am running rev: 9846. from django.test import TestCase class SimpleTest(TestCase): def test_template_timesta

Re: Query that grabs objects before and after object

2009-02-19 Thread Sean Brant
> current_show = 5 #Presumably you get this in your request > show_range = (current_show - 4, current_show + 4) > shows = Show.objects.filter(show_order__range=show_range) This seems to work so far. shows = Show.objects.filter(Q(pk__range=(show_id - 4, show_id + 4) & Q (category=category)) Behi

Query that grabs objects before and after object

2009-02-18 Thread Sean Brant
Is there a simple way to say get me 4 objects from model that come before this object and 4 that come after this object. So lets say I have a Show. I would like to know which 4 shows come before the current show and which 4 come after, however I must limit the shows based on a category type. Woul

Re: Svn pre-commit hooks with beanstalkapp.com

2009-02-15 Thread Sean Brant
In case anyone else in interested I whipped up this simple script that seems to do the job. http://dpaste.com/121117/ It basically works like svn commit but looks thru all of directories under your current directory for manage.py files. If it finds one it runs manage.py test. If all tests pass i

Svn pre-commit hooks with beanstalkapp.com

2009-02-15 Thread Sean Brant
Has anyone created a work around for lack of pre-commit support at beanstalkapp.com. I would like to run tests on my apps before they get committed to my repository however with beanstalk you do not get access to subversion hooks. I was thinking of creating a python script that would preform the t