Re: Has anyone looked into writing an SSH backend for file uploads?

2009-01-30 Thread Alex Robbins
It might be even easier to just set up an NFS mount of the other machines. It would be a lot like Jeff's idea, but NFS is pretty tried and true. (I don't know anything about SSHFS, it might be really good too.) On Jan 30, 9:54 am, Jeff FW wrote: > Instead of trying to get Django to do something

Re: How to pass the variable which is defined in the views.py to the jQuery function

2009-01-30 Thread Alex Robbins
You might also consider using simplejson to dump the python variable into something that JavaScript could understand. (This way you can pass more complicated variables like an array or an object.) I recently did that to get a list of tags out to some javascript on the front end. On Jan 29, 11:33 

Re: How to pass the variable which is defined in the views.py to the jQuery function

2009-01-30 Thread Alex Robbins
te = "%s" % simplejson.dumps(tags) Pass variable_to_insert_into_template to the template and then just put {{variable_to_insert_into_template}} somewhere in your code. Just my 2 cents. On Jan 30, 10:42 am, Alex Robbins wrote: > You might also consider using simplejson to dump the p

Re: How to pass the variable which is defined in the views.py to the jQuery function

2009-01-30 Thread Alex Robbins
e example should be added in the views.py. After that, I can use > the list by using var x = {{variable_to_insert_into_template}} in my > javascript? > > Regards > Min > > On Jan 31, 3:48 am, Alex Robbins > wrote: > > > Sorry, a code sample would have been more helpful.

Re: template error

2009-03-03 Thread Alex Robbins
It looks like your problem is probably on line 2. The {% comment_form_target %} tag is trying to do a reverse url lookup. However, there aren't any matches in your url conf. Hopefully, you just forgot to set up a url for post_comment. Unfortunately, what that usually means for me is that there is

Re: template blocks inside include?

2009-03-03 Thread Alex Robbins
Roy, I'd love to help but I don't think I understand the problem (and I am too lazy to set up the inheritance chain myself). You say it seems not to work? When does it fail? Try putting a little content into each template (maybe the template's name, in an h1 tag). Then how far does the rendering

Re: Starting custom settings with django-admin.py failed

2009-03-17 Thread Alex Robbins
Hmm, try opening up a python interpreter and importing "portal.settings". Does that work? If not there are two likely candidates: 1. It isn't enough for 'portal' to have an __init__.py file, it needs to be on your pythonpath. Check your pythonpath (import sys;print sys.path) 2. There is a syntax

Re: beginner model question - two tables without foreign keys (myslq - myisam)

2009-03-17 Thread Alex Robbins
The docs talk about models here: http://docs.djangoproject.com/en/dev/topics/db/models/ foreign keys here: http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey and queries here: http://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-objects This advice isn't tested, so i

Re: Using Signals as hooks

2009-06-26 Thread Alex Robbins
> should I just have it so that a few items from a task DB are done each > request (e.g. split up emails into groups, and email them a few per > request)? Hmm...what happens if there aren't any requests for an hour? Does the queue processing stop during that time? I can't get my email until there

Re: Display Data From Multiple Tables

2009-07-02 Thread Alex Robbins
You should take a look at select_related[1]. It will take the lot of queries TiNo was talking about and flatten it down to one big one. [1] http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4 Hope that helps, Alex On Jul 1, 1:34 pm, TiNo wrote: > On Wed, Jul 1, 2009 at 16:59, The Da

Re: creating user directories upon account activation

2009-07-13 Thread Alex Robbins
You might try pdb[1]. Drop "import pdb;pdb.set_trace()" into your code the line before "if SHA1_RE". Once at the pdb prompt you can just type n to move forward one line at a time. Any python code you type will get evaluated so you can check the status of variables at each step. (Pdb is a little cr

Re: New to unit testing, need advice

2009-07-16 Thread Alex Robbins
Whenever I do the same query in a couple of different views, I try to pull it out into a manager method[1]. For instance, get all the stories that are marked published from the last two days. I would make this a method on the manager so I can reuse it other places. Then I write a test for that man

Re: middleware cache problem

2009-07-22 Thread Alex Robbins
It sounds like the problem is that you are caching the whole page using the site wide cache. Maybe things would work better if you used the low level cache api.[1] from django.core.cache import cache MY_STORY_CACHE_KEY = "story_list" def story_list(request): story_list = cache.get(MY_STORY_CAC

Re: Slugs, why would you ever need to store one in the database?

2009-07-24 Thread Alex Robbins
You might want to look into the SlugField [1]. It makes sure you only have url friendly stuff. You can also autopopulate it from another field in the admin[2]. That way you just type the title and it makes a slug for you. One reason to hide pks is that they allow people to learn more about your s

Re: best way to format serialized data?

2009-07-28 Thread Alex Robbins
I'm not sure if this answers your question, but... I have had better luck using the jQuery.load [1] function. It takes an html response and just jams it into the dom. That way I can do all of the templating and formatting on the server side. The idea of writing "" and the like never seemed very ma

Re: Fatal Python error: Inconsistent interned string state.

2009-07-28 Thread Alex Robbins
You mentioned that it just happens sometimes, and I see from your traceback it happened in the autoreload.py file. Do you still see the errors if you call runserver --noreload ? Alex On Jul 27, 3:57 pm, Ken Schwencke wrote: > I'm working with GeoDjango and PostGIS, and I'm getting "Fatal Python

Re: I just need some feedback and advice about my project layout and design.

2009-07-28 Thread Alex Robbins
Sorry, I don't know anything about url namespaces, but this might help: If all you are doing is looking up an object and displaying it, I would use the built-in generic views[1]. Just provide a queryset and an object id or slug and slug field. Less code to debug and maintain. There is also a list

Re: Execute code after sending a http response?

2009-08-28 Thread Alex Robbins
You'll have to set something in a table and run a cron to send it later. Django-mailer [1] has all of this set up for, along with some other cool features. I've used it in a project before and been happy with it. [1] http://code.google.com/p/django-mailer/ On Aug 28, 1:10 am, Shadow wrote: > Hi

Re: Django and SSL Deployment using mod_wsgi

2009-08-29 Thread Alex Robbins
You'll probably want to look into something like this: http://www.djangosnippets.org/snippets/880/ It allows you to set some urls to redirect so they are always https. Otherwise those silly users will go to credit card pages without https. On Aug 29, 1:04 am, Vitaly Babiy wrote: > Hey guys, > W

Re: Advice on Subclassing a TextField

2009-08-30 Thread Alex Robbins
Also, maybe you aren't submitting all the code, but you could do the same thing by just passing an attrs dictionary to the text area widget. http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs Not sure that this requires two more classes. Hope that helps,

Re: Defining subsets of "list" variable at template level

2009-08-31 Thread Alex Robbins
First, if you aren't running into db performance problems, I wouldn't optimize. Keep everything as simple as possible, then optimize the parts that actually demonstrate themselves to be a performance issue. If this really is a performance issue, you could solve it like this: If you know that you

Re: Django and SSL Deployment using mod_wsgi

2009-09-01 Thread Alex Robbins
Graham, I'm interested in understanding what you just said. It seems like you are saying you can get the X-Forwarded-SSL environment variable to automatically be set, without needing the django middleware. Seems simple enough. The middleware also handles redirects, so that someone accidentally g

Re: FormWizard: how to pass in extra keyword arguments into a form's __init__?

2009-09-01 Thread Alex Robbins
I guess the question is when you know the additional keyword argument. If you already know what that extra keyword is when you are constructing the form list, you could use a partial[1] to put in the arguments you know already. Partials are python 2.5+ only, you can use a lambda instead if you are

Re: haml + sass + django

2009-09-09 Thread Alex Robbins
You might look at http://sandbox.pocoo.org/clevercss/, which is python based. On Sep 8, 9:19 am, ThinRhino wrote: > Hello, > > I just came across haml and sass, but looks like it is built for Ruby on > Rails. > > Any implementation that can work on Django? > > Though I also came acrosshttp://bit

Re: MySQL issues

2009-04-28 Thread Alex Robbins
Yeah, I think that is the problem. You have to execute CREATE DATABASE books; from the mysql command line. Syncdb will make tables, but it won't make the initial database. Hope that helps, Alex On Apr 27, 4:04 am, google torp wrote: > Hi. > > I haven't used Django with mysql, but judging from yo

Re: i need a unlimited subcategories

2009-04-28 Thread Alex Robbins
For a real simple solution you might just set up a foreign key field that points to the parent of any given category. (If you don't need the extra features of those libraries, they might just make things more complicated.) E.g. subcat1-1-1 and subcat1-1-2 are fk'ed to subcat1-1. subcat1-1 is fk'e

Re: Email error reporting not working

2009-05-26 Thread Alex Robbins
You could try using the mail_admins function directly. http://docs.djangoproject.com/en/dev/topics/email/#mail-admins Maybe it'll raise an informative exception. On May 25, 2:19 am, Rex wrote: > Hi, > > I am having trouble getting error reporting via email to work (as > described herehttp://doc

Re: jquery ajax form problem--Can't render template variables

2009-06-10 Thread Alex Robbins
I haven't used that form plugin before, but from the documentation it looks like the problem is this line: target:"#new", http://malsup.com/jquery/form/#options-object You are asking jQuery to jam the whole response in, just like you are seeing. What happens if you take that line out? It looks lik

Re: how to return ajax info in one case, and redirect to a different url in another?

2009-09-15 Thread Alex Robbins
Making the browser switch pages isn't too bad. Just set document.location to the new url using javascript. (The document object should be provided by the browser.) Maybe you should check the headers of the ajax response and if it is a redirect make the redirect happen using javascript? Or simply m

Re: Firefox search plugin for Django documents

2009-09-26 Thread Alex Robbins
Very nice. I just found out you can assign a keyword to search engines in the manage search engines menu. Now I just type "django search term" in the location bar and I get what I need. Don't have to change the search engine back and forth. Thanks for the awesome plugin. On Sep 24, 4:01 am, 玉东

Re: Retrieving the request URI inside the view function?

2009-09-26 Thread Alex Robbins
> 1. Consider the user requesting a page like '/orders/9123'.  We detect   > that the user needs to be logged in to see a particular order, so we   > redirect to a login form, saving the '/orders/9123'.  If the user logs   > in as the correct user, we then issue a redirect back to '/orders/9123'.

Re: TinyMCE in Admin (Practical Django Projects book)

2009-09-28 Thread Alex Robbins
If you use the net tab of firebug[1] you can tell when url/file paths are messed up. That is the only way I ever get tinymce running. [1]http://getfirebug.com/ On Sep 27, 7:29 am, Erik Kronberg wrote: > On Sun, Sep 27, 2009 at 1:54 PM, James Bennett wrote: > > > > > > > On Sun, Sep 27, 2009 at

Re: Admin why deleting related(null=True) objects?

2009-10-08 Thread Alex Robbins
This sounds related to this ticket http://code.djangoproject.com/ticket/9308, which supposedly fixed this issue 5 months ago. You should probably file a bug report. On Oct 7, 4:19 pm, Peter Sagerson wrote: > Yes, Django always cascades deletes. There's talk about providing more   > options in a

Re: {% url in templates

2009-10-29 Thread Alex Robbins
Maybe it is just me, but I feel like writing out the view functions like that is a beating. I just name[1] all the urls. Then the url tag is easy. I just do things like {% url home-page %} or {% url blog- index %}. If you set up a generic view in the views and name it, it will work like normal. [

Re: syncdb for INSTALLED_APPS throws errors

2009-10-29 Thread Alex Robbins
The warning on line 2 is because you are using python2.6, default in Ubuntu9.04. You don't need to worry about it. It is just telling the authors of mysqldb that ImmutableSet is going away in newer versions of python. Not something you need to care about. On Oct 29, 3:37 am, sridharpandu wrote:

Re: Display a view of a single record?

2009-11-10 Thread Alex Robbins
Derek, If you want something that display data but doesn't allow you to edit it, you should check out the databrowse[1] contrib app. You just register a model with it (like the admin) and it generates all the pages. It lets users look through the data, but not edit it. [1]http://docs.djangoproje

Re: Databrowse: Loading a large number of records

2009-11-10 Thread Alex Robbins
That error happens if you refresh the page while it is still loading from the dev server. You may have gotten impatient, refreshed and caused that error. It is possible that this isn't really the problem you are having, but just a secondary issue caused by the long load time and a page refresh. O

Re: Is there a way to integrate php to a django app?

2009-11-14 Thread Alex Robbins
I guess the answer depends on what you mean by "integrate." If you have both written parts that serve html pages, just setup apache configs so that part of the urls are routed to django and the other urls are routed to php. Another way to integrate would be by setting up one of the installs as an

Re: Auth and Sites in Admin

2009-11-15 Thread Alex Robbins
Those sections won't show up for anyone who doesn't have edit permissions. As long as you don't give the admin user superuser status or permissions for those apps they won't show up. On Nov 14, 6:34 pm, Zeynel wrote: > Is it possible to remove "Auth" and "Sites" sections from the Admin > panel?

Re: Is there a way to integrate php to a django app?

2009-11-23 Thread Alex Robbins
Great, If you want to get any sort of meaningful feedback you are going to have to be much more specific when you say integrate. Honestly, this type of post is normally just ignored because no one really knows what you are talking about. You only get (good) feedback if you ask good questions. Can

Re: Sick of defining urls

2009-12-03 Thread Alex Robbins
Todd, If you are just trying to define a restful interface to your objects, you might look at django-piston[1] If you really want the Rails approach, you are going to be pretty frustrated working with Django. The python equivalent of "convention over configuration" is "explicit is better than imp

Re: Sick of defining urls

2009-12-03 Thread Alex Robbins
>You are welcomed to disagree with it, all of us hackers view things >differently. >That said, understanding what Tim is saying will help you understand Python and >the people who use it. Most of us agree with most of Tim's points. I believe >this >was mentioned not to tell you to walk away. Exa

Re: What apps do besides provide views?

2009-12-03 Thread Alex Robbins
> Yeah, app integration right now seems very non-DRY and much too fiddly. > Stands to reason > that including an app implies you include the app's urls and templates - or > why include it? I > definitely cringe when copying an integrated app's templates into my > project's template > hierarchy

Re: how to allow RSS aggregators to use feeds available only for logged-in users?

2009-12-08 Thread Alex Robbins
Maybe you could just make another url that wasn't password protected. If the token doesn't get used up in your plan, you have roughly the same security (not much). def rss_view(request): askdmalkdmakds protected_rss_view = login_required(rss_view) Hope that helps, Alex On Dec 7, 8:57 am, Mie

Re: Filter (AND excluding empty values)

2009-12-15 Thread Alex Robbins
Does it work for one case at a time? Have you tried q = request.GET.get('city') properties = Property.objects.filter(city=q) I would make sure it is working for each variable before combining them together. (Maybe you already have, I don't know.) Alex On Dec 14, 5:32 pm, Osiaq wrote: > Andy, I

Re: Book

2009-12-22 Thread Alex Robbins
You could also try the free online book. http://djangobook.com/ On Dec 22, 3:46 am, Amine wrote: > Hi, > I'm new in django and i'm searching a book : > django 1.0 web site development PDF > > can u help me please ! > inhttp://my.softarchive.net/search/?q=django&x=0&y=0   I could not > download it

Re: get_absolute_url not recognized

2009-12-23 Thread Alex Robbins
Is the second line of your url function outdented? Maybe python thinks your class is finished at that point? You could try indenting it? If that doesn't fix it I would drop the decorator for now to see if that fixes it. Then you could try dropping the body of the get_absolute_url function and repl

Re: Disabling (or find a workaround for) the comment security checks

2010-05-06 Thread Alex Robbins
Disclaimer: Disabling the security stuff makes it really likely you'll get comment spammed. You should set up some kind of akismet protection on the backend if you disable the security. If you don't want the checking then you probably want a custom comment form. You can use this method to setup a

Re: Disabling (or find a workaround for) the comment security checks

2010-05-06 Thread Alex Robbins
Also, as I think more about this, are you sure you need static generator? You might get sufficient speed just by using cache. Premature optimization is bad On May 6, 8:37 am, Alex Robbins wrote: > Disclaimer: > Disabling the security stuff makes it really likely you'll get commen

Re: Security Question...

2010-05-24 Thread Alex Robbins
Just a thought, but if you are the only person using the url, you could make your own self-signed security cert. It would be free and protect your data. It won't show up as trusted to users, but your other server can be set to accept it. (Assuming the lack of ssl is a budget issue, that wouldn't fi

Re: view permission on django admin

2010-05-25 Thread Alex Robbins
If you want something like the admin, that lets users view objects from the database but not edit them, you could check out the databrowse contrib app. It is kind of a read-only admin. http://docs.djangoproject.com/en/dev/ref/contrib/databrowse/ Hope that helps, Alex On May 24, 3:49 pm, rahul ja

Re: Security Question...

2010-05-25 Thread Alex Robbins
lling to add a self-signed cert as > trusted. > > On May 24, 10:07 am, Alex Robbins > wrote: > > > > > Just a thought, but if you are the only person using the url, you > > could make your own self-signed security cert. It would be free and > > protect your data

Re: Security Question...

2010-05-25 Thread Alex Robbins
tion key registers as already in-use, not any sort of identity > theft or loss of financial credentials. > > Mostly with this I'm just trying to make sure that I can prevent > unauthorized users from using the API to make themselves free > activation keys. > > > On May 25,

Re: EmailField etc. and VARCHAR / TEXT

2010-05-26 Thread Alex Robbins
If you are using 1.2, then you could make a TextField with an email validator. That gets bonus points for using a new feature :) http://docs.djangoproject.com/en/dev/ref/forms/validation/#using-validators Alex On May 26, 8:24 am, Jonathan Hayward wrote: > Thanks! > > On Wed, May 26, 2010 at 5:32

Re: testing the comment framework using the test client

2010-05-26 Thread Alex Robbins
The way I've tested it in the past is: GET the page, using the client. Scrape the values you need. (BeautifulSoup makes this really easy, but you can do it with python's builtin stdlib I guess.) POST the comment message, along with all the values you just scraped. Hope that helps, Alex On May 25

Re: Grouping of applications in admin

2010-05-26 Thread Alex Robbins
You should check out django-admin-tools [0] It lets you make lots of changes to the admin index page. Hope that helps, Alex [0]http://bitbucket.org/izi/django-admin-tools/wiki/Home On May 25, 9:54 am, Dejan Noveski wrote: > Hello, > > Is there a way i can group admin models from different applic

Re: Installation problem (version 1.2.1)

2010-05-28 Thread Alex Robbins
I think Daniel might mean you can also use the __file__ attribute, as in: >>> import django >>> django.__file__ Hope that helps, Alex On May 28, 4:07 am, Daniel Roseman wrote: > On May 28, 9:56 am, Derek wrote: > > > > > I have just upgraded my version of Ubuntu, which then also installed > > P

Re: How can I test the correctness of my models against the schema of a database?

2010-06-01 Thread Alex Robbins
Its been a while since I worked with a live db and unit tests for this sort of thing, but I think this is how we did it: Put the tests in a tests.py file in an app like normal, but for the db test, inherit from the python test framework's UnitTest. That test will not get a special test db, so be ve

Re: How to write the reverse function for the following

2010-06-07 Thread Alex Robbins
Clark, The reverse call just uses kwargs to find out which pattern it matches to. If your url regex was r'^register/(?P\w+)/', then you would pass kwarg1 as a kwarg to reverse. You are not trying to find a url with a kwarg in the regex, so you shouldn't be adding that in the reverse call. You just

Re: Using array of URLs for MEDIA_URL

2010-06-08 Thread Alex Robbins
I haven't tested this, but it seems like you could do it one of two ways: Define media root as a function in your settings.py. If you pass a callable to the template, it will be called. MEDIA_ROOTS = ['server1', 'server2', 'server3'] def MEDIA_ROOT(): from random import choice return choic

Re: Upgrading Python from 2.4 to 2.6 - can I just copy site-packages folder?

2010-06-08 Thread Alex Robbins
You don't want to just copy site-packages. If you have any compiled modules (pyyaml, PIL, etc) they won't work, since they were compiled for the old version of python. Alex On Jun 8, 4:25 am, Nick wrote: > Hi, > > I'm currently running Django on CentOS using the supplied Python 2.4. > I now need

Re: Good idea to process form data in separate thread or process to avoid blocking? How?

2010-06-08 Thread Alex Robbins
Celery is a python job queue system that a lot of people really like. I think it would allow you to do the form processing asynchronously. http://celeryproject.org/ Hope that helps, Alex On Jun 7, 11:31 pm, Chris Seberino wrote: > I don't want Django site to block while form data is being proce

Re: Upgrading Python from 2.4 to 2.6 - can I just copy site-packages folder?

2010-06-08 Thread Alex Robbins
esh, in these bold > new days of distribute and pip install. > > Bill > > On Tue, Jun 8, 2010 at 10:32 AM, Alex Robbins > wrote: >> You don't want to just copy site-packages. If you have any compiled >> modules (pyyaml, PIL, etc) they won't work, since they wer

Re: multiple databases -- database across sites?

2010-06-10 Thread Alex Robbins
Chris, The sites contrib app seems to address your use case. http://docs.djangoproject.com/en/dev/ref/contrib/sites/ You could just add a foreign key to site in the second app and modify the manager to only get items for the current site. class SiteSpecificManager(db.Manager): def get_query_se

Re: assigning data based on a comparison between two tables

2010-06-10 Thread Alex Robbins
It is probably better to use candidates.count(), rather than len(candidates). len will cause the whole queryset to be loaded into memory. It doesn't look like you use it later, so that is kind of a waste. Hope that helps, Alex >From django docs: Note: Don't use len() on QuerySets if all you want

Re: Help: Custom ManyRelatedManager Behavior

2010-06-10 Thread Alex Robbins
I recently ran into this same problem (I wanted to only show related episodes that had been marked live). I ended up just making a method on Podcasts to do it. class Podcast(models.Model): ...some data fields... def live_episodes(self): return self.episode_set.filter(live=True) class Epi

Re: Looking for unavailable table?

2010-06-29 Thread Alex Robbins
You can also use ./manage.py validate to get django to check over your models. Sometimes syncdb or others will fail because of a model validation issue. Alex On Jun 28, 3:20 pm, Jonathan Hayward wrote: > P.S. This problem did not resurface after I made other changes discussed > elsewhere in the

Re: Beginner nead help

2010-06-29 Thread Alex Robbins
Eduan, This might be a little technical for a beginner, but you'll have to learn sometime :) Python looks for modules according to the python path. If your module isn't available on the path, then you'll get an error like you are seeing. I believe that manage.py adds the directory it is in to the

Re: Database systems

2010-07-16 Thread Alex Robbins
PostgreSQL is better supported by South, the leading django database migration tool. It allows you to make schema altering migrations within a transaction, so they can be rolled back if the migration fails. On MySQL you are just left with a half-migrated database. Also, if you are going to use muc

Re: Inline forms

2010-07-21 Thread Alex Robbins
The ability to make multiple forms of the same type is a formset. http://docs.djangoproject.com/en/1.2/topics/forms/formsets/#topics-forms-formsets If you want those forms to represent models, then you want a model formset. http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#id1 Hope th

Re: Inline forms

2010-07-21 Thread Alex Robbins
, I can add choices at the same time which > eventually add records at two tables. > I can add as many choices as I want by clicking at "Add another > Choice". > I would like to have same feature on my form which is outside the > admin site. How can do that ? > > Than

Re: django + serving static CSS

2010-07-23 Thread Alex Robbins
Thomas, MEDIA_URL isn't always defined in templates. Make sure that you have the MEDIA context preprocessor installed: http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media Also, when you actually render the template, are you using RequestContext? If you are

Re: URL reverse on username failing when username has a '.' literal in it

2010-07-23 Thread Alex Robbins
That probably means that the regex url pattern you defined for feed_user in your urls.py file doesn't allow '.' Hope that helps, Alex On Jul 22, 11:11 am, Roboto wrote: > I didn't expect this to occur, but when I attempt > {% url feed_user entry.username %} > > I will get a 500 error when the us

Re: Two apps with same url's in one project.

2010-07-24 Thread Alex Robbins
It sounds like you need to use url namespacing. When you include the urls in your main urls.py file, add a namespace for each one. Then you should be able to reverse them. Define them: http://docs.djangoproject.com/en/dev/topics/http/urls/#defining-url-namespaces Reverse them: http://docs.djangopr

Re: modelformset vs. inlineformset vs. DIY

2010-07-24 Thread Alex Robbins
If you need to edit the race and the candidates on the same page, and the candidates are FK'ed to the race, I'd do it like this: (Warning, just coding off the top of my head, might have bad syntax/ imports) forms.py - from django import forms from django.forms.models import modelf

Re: Calculate distance between 2 latitude/longitude Point

2010-07-29 Thread Alex Robbins
Geopy has a distance function build in, if you want something a little more widely used/tested: http://code.google.com/p/geopy/wiki/GettingStarted#Calculating_distances Alex On Jul 29, 5:23 am, Alexandre González wrote: > I've solved translating a JavaScript function to python: > > from math imp

Re: How to access a MySQL table in Django?

2010-07-29 Thread Alex Robbins
Whenever I have to pull data from legacy databases, I use './manage.py inspectdb > models.py'. That will dump models for the database. Then I rename the models to make more sense, and use the orm to get my data. Alex On Jul 28, 12:58 pm, snipinben wrote: > I have the python-mysqldb installed alr

Re: Regex problem in urls

2010-07-30 Thread Alex Robbins
Based on the urls.py file you are showing us, it seems like /start/ should be a valid url. Are you running the dev server with automatic reloading? Sometimes you need to force a reload on it to see changes. (I normally notice that in the admin, but it could come up anywhere stuff gets cached in me

Re: Need Help!

2010-07-30 Thread Alex Robbins
You could look here: http://djangopeople.net/us/ny/ Or try posting here: http://djangogigs.com/ or here: http://djangozen.com/jobs/ Hope that helps, Alex On Jul 29, 11:27 am, Ken wrote: > Looking for a django developer in the NYC area! > I would appreciate any help, if you know of anyone! > Than

Re: multiple forms for same model

2010-08-16 Thread Alex Robbins
I think the problem is that your form doesn't have all the required data. When you assign the instance, you provide initial data, and something for form.save to modify. However, when the data is posted back, It looks like maybe the non-editable fields aren't in the POST data. You could add the fiel

Re: multiple forms for same model

2010-08-17 Thread Alex Robbins
contract_form.is_valid() looks at the data that was bound to the form. This is normally the data in request.POST. It doesn't matter what a form's initial data happened to be. It only matters what data you POST back to it. If someone doesn't modify the form, then the initial and the POSTed data are

Re: CSRF verification failures (admin)

2010-08-17 Thread Alex Robbins
Have you done any admin template customization? If you copied a template from django before 1.2, then upgraded, your admin template might be missing the csrf_token template tag. Alex On Aug 17, 7:55 am, PieterB wrote: > For an internal application, I constantly receive CSRF verification > failed

Re: Long running process and time outs?

2010-08-17 Thread Alex Robbins
This is exactly the sort of issue that celery was created to solve. It is a task queue management system. http://celeryproject.org/ Alex On Aug 14, 1:28 pm, ydjango wrote: > I have a online user initiated synchronous process which runs anywhere > between 1-5 minutes and gives user status messag

Re: Validation and dynamically extending ChoiceField choices

2010-08-17 Thread Alex Robbins
Maybe the ChoiceField should just be a CharField that just uses the Select widget class? That way it won't have choices hardcoded into the field validation. Your clean method could check that the domain is valid. Alex On Aug 16, 1:39 pm, ringemup wrote: > I have a domain search form with two fiel

Re: Error working on many-to-many lookups

2010-08-26 Thread Alex Robbins
Jonathan, Pretty much any time you use __exact='text', you could use ='text' instead. I think the orm treats those two cases the same. (It adds __exact if there isn't another lookup specified. Alex On Aug 25, 1:37 pm, Christos Jonathan Hayward wrote: > I think I found the problem; for the recor

Re: manage.py: syncdb/sql do not pick up models from custom directory structure

2010-08-30 Thread Alex Robbins
If you define your models somewhere django doesn't expect, I think you need to add the app_label in the model's Meta class. http://docs.djangoproject.com/en/1.2/ref/models/options/#app-label They mention the models submodule use case in the docs. Hope that helps, Alex On Aug 30, 6:56 am, Daniel

Re: python manage.py runserver - can't see error stack traces when an Ajax handler throws an exception

2010-09-08 Thread Alex Robbins
I think Firebug can help with this. If you open the "Net" tab, you can see the ajax requests. Then click on the ajax request that errored. I think you can look at the exception in html down in the firebug window, or possibly click open in new tab to see it bigger. I'm not doing it right now, so my

Re: New-by Model traps and other questions...

2010-09-08 Thread Alex Robbins
Lance, Regarding the many to many field that shows too many images: I've used this project with some success in the past: http://code.google.com/p/django-ajax-filtered-fields/ They allow you to setup some ajax filtering for the field, which can make it a lot easier to find what you are looking fo

Re: New-by Model traps and other questions...

2010-09-08 Thread Alex Robbins
Lance, I wouldn't worry too much about having empty fields vs an extra table in your database. I think having data models that are easy to work with is far more important than making sure you don't have fields that are empty some time. I wouldn't worry at all about a field that is empty a lot. I w

Re: What's the best way to develop an app that is similar the django admin?

2010-09-21 Thread Alex Robbins
I think you'll definitely want to use ModelForms. http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ Alex On Sep 20, 8:13 am, Federico Capoano wrote: > Hi all, > > I try to explain it clearly. > > I have to develop an application that will implement similar > functionality and look of

Re: how can a test log in as a given user before calling client.get()?

2010-01-07 Thread Alex Robbins
I would use the create_user[1] function, then you can just enter the password, instead of the hash value. Might make your code a little more readable. Alex [1]http://docs.djangoproject.com/en/dev/topics/auth/#creating-users On Jan 6, 3:19 pm, Phlip wrote: > > Google cannot find any traffic on t

Re: Linked list of abstract objects

2010-01-18 Thread Alex Robbins
Also, I think you'll need to make those relations to a class that isn't abstract. Right now you have a 'class Meta: abstract=True' That means your model doesn't really exist for the relations to link to. Hope that helps, Alex On Jan 18, 2:26 am, Kerrick wrote: > I'm trying to implement a linked

Re: Admin list_display loop though sub objects and output sum of values - newbie

2010-01-18 Thread Alex Robbins
There is also an online version of one of the django books here: http://djangobook.com/ On Jan 17, 5:08 pm, pfwd wrote: > Thanks fantastic thank you > I was also able to do: > result = obj.task_set.aggregate(Count('id'))['id__count'] > to get the a count of the tasks for quote > > I don't suppose

Re: Efficient access through two manytomany layers

2010-01-18 Thread Alex Robbins
Hmm, you posted the save method for your Event model, but not the definition. I think you haven't gotten any feed back because no one really knows what you are asking. Could you show the Event model, and then show what a finished save should look like? What should the data end up like? Alex On Ja

Re: Efficient access through two manytomany layers

2010-01-18 Thread Alex Robbins
om/en/dev/ref/models/querysets/#id4 On Jan 18, 10:32 am, Alastair Campbell wrote: > On Mon, Jan 18, 2010 at 2:59 PM, Alex Robbins > > wrote: > > Hmm, you posted the save method for your Event model, but not the > > definition. I think you haven't gotten any feed back becaus

Re: read only django admin

2010-01-29 Thread Alex Robbins
It sounds like the databrowse[1] contrib app may be what you are looking for. It is basically a read-only admin. You'll have to register classes with it the same way you register with the admin, but it might be nicer than trying to force the admin to be read-only. Hope that helps, Alex [1] http:/

Re: Rebuild admin site after dropping field from models.py?

2010-02-02 Thread Alex Robbins
John, I don't think the problem is as fixed as it appears. You probably still have the foreign key in your database. Like Shawn said, syncdb only adds new models as tables in the db. It doesn't do anything to existing models. It won't delete a model that you delete, or change fields on a model that

Re: Template-Include and block.super

2010-02-02 Thread Alex Robbins
Daishy, it would help if you posted the template code you already tried. This is basically how you could do what you are describing: base.html {% block extrahead %} {% endblock %} sub_page.html {% extends "base.html" %} {% block extrahead %} {{ block.super }}

Re: Template-Include and block.super

2010-02-03 Thread Alex Robbins
include-tag and the > extra js should be inserted into the extrahead-block. I hope thats a > better example of what i want to do. Again, i wouldnt be suprised if > thats not the right way, but is there a way to achive such seperation > of the templates? > > On Feb 2, 4:41 pm, Alex Ro

Re: Problem with apache server

2010-02-04 Thread Alex Robbins
If you are in development, you can just use django dev server. "./ manage.py runserver" from your project. If you have deployed your app, then the best way to avoid restarting is to use mod_wsgi's reloading feature. If you deploy in daemon mode, you can just touch the wsgi file to trigger a reload

  1   2   >