more info when serializing

2007-11-17 Thread Bryan L. Fordham

So, say I have a model something like this:

class Bar(models.Model):
user = models.ForeignKey(User)
name = models.CharField(maxlength=50)
description = models.TextField()

where user is tied to a django.contrib.auth.models.User entity. When I 
serialize this to json, I get:
[{"pk": "1", "model": "foo.bar", "fields": {"description": "", "user": 
1, "name": "Phone"}}]

Which is fine, but I need both the username and user id on the front 
end. Is there a simple way to get this info all in one shot that I'm 
just missing?

Ideally, it would return something like: ..."user": 
{"username":"bfordham", "pk":1}...

I'm using the django-rest-interface, if that makes a difference one way 
or the other.

Thanks
--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: spam

2007-11-06 Thread Bryan L. Fordham


> About all you can do is mark it as spam and let that train Google's spam 
> filter.
>
>   
A mail client that doesn't automatically show images will help, too.

--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error loading MySQLdb module

2007-07-06 Thread Bryan L. Fordham

looks like you need to install MySQLdb: 
http://sourceforge.net/projects/mysql-python
Jalil wrote:
> I keep getting this below error when I try to sync my database. 
> I am using python2.3. Any ideas?
>
>
>
> [no job set:~/dev/mysite] 113% python2.3  manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
> execute_manager(settings)
>   File "/usr/lib/python2.3/site-packages/django/core/management.py", 
> line 1672, in execute_manager
> execute_from_command_line(action_mapping, argv)
>   File "/usr/lib/python2.3/site-packages/django/core/management.py", 
> line 1571, in execute_from_command_line
> action_mapping[action](int(options.verbosity), options.interactive)
>   File "/usr/lib/python2.3/site-packages/django/core/management.py", 
> line 486, in syncdb
> from django.db import connection, transaction, models, 
> get_creation_module
>   File "/usr/lib/python2.3/site-packages/django/db/__init__.py", line 
> 11, in ?
> backend = __import__('django.db.backends.%s.base' % 
> settings.DATABASE_ENGINE, {}, {}, [''])
>   File 
> "/usr/lib/python2.3/site-packages/django/db/backends/mysql_old/base.py", 
> line 12, in ?
> raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb 
> module: No module named MySQLdb
> bykergrove [no job set:~/dev/mysite] 114%


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Could you please share your django-based website source code with me?

2007-07-02 Thread Bryan L. Fordham


oh wow, I don't know how I managed to send that to this list. That was a 
reply to a private email, having nothing to do with Django. Obviously.

Sincere apologies

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Could you please share your django-based website source code with me?

2007-07-02 Thread Bryan L. Fordham

I don't know that I ever listened to his message at the mormon tabernacle.

http://www.rzim.org/radio/archives.php?p=JT=detail=784 is the first 
part

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Introducing DjangoSites.Org

2007-06-22 Thread Bryan L. Fordham


> still havent got the mail, but the login is working
>
>   
I created a login for bfordham the other day, never got an email, 
account isn't working.

--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination

2007-06-21 Thread Bryan L. Fordham


> I don't understand. If you're one /foo/bar/baz/page1/, then why can't
> you write  as the link? It will work, is a
> well-formed URL and is independent of the prefix. Note that you must
> ensure your URLs are canonicalised if you use this system, though:
> always ending with a trailing slash, so that the "../" will go to the
> right place.
>   
that will work of the first page is /foo/bar/baz/page1/  and not 
/foo/bar/baz/



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL query with LIKE statement

2007-06-21 Thread Bryan L. Fordham


> This should be writable in a slightly more Djangoic (I suppose if 
> Python code is Pythonic, Django code is Djangoic?  Djanonic? 
> Djangonical?  Djangoish?) fashion:
>   
my vote would be to user "superfly," as in:
This should be writable in a slightly more superfly fashion
>entries = Journal.objects.filter(note__startswith = q)
>entries = entries.extra(where='length(note) > 0')
>   
I've spent some time recently rewriting some of my custom managers to 
use the extra method, and I highly recommend it. I know it may not be 
possible in all circumstances, but for things like sorting and using 
generic views it made my life a lot easier. I do suggest spending time 
playing with it in the shell to get the hang of it.

So, nothing of real substance to impart here, just to encourage you to 
check out the extras() method.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Introducing DjangoSites.Org

2007-06-20 Thread Bryan L. Fordham

[EMAIL PROTECTED] wrote:
> A week ago I posted about a project I was working on, Djangosites.org.
> It's intended to be a showcase of what's out there in Django Land.
>   
Very nice.

A few minor things:
One the register page, since the "Terms of Service" link is in the label 
for the checkbox, when I clicked it to read the TOS it checked the box 
before going to the page.

In the 2 item on the TOS page, it says "We're aiming for an audience of 
"G" and above." I know what you mean but, what's below G? 8)

I don't think these would really confuse anyone, or affect the sites 
use, but there ya go anyway

--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Help Wanted at CritterWatch.Org

2007-06-14 Thread Bryan L. Fordham

As I announced recently, I'm currently working on a project at 
www.critterwatch.org. The overall goal is to provide people with 
up-to-date information on how their state represenatives and senators 
are voting, as well as data on legislation. Long term goals include an 
API to make this information available to other projects.

The near term goal, however, is to load all the data for all 50 states 
into the database, and keep it updated. That's where you can come in:

If you're interested in helping this project by writing some scripts to 
get the information for your state, please reply to me off-list. I 
haven't worked everything out just yet, but essentially you'd be 
screen-scraping your state legislature's website and putting the 
information into a standard format, which would be loaded into the database.

Another way to help is to suggest new features. You can also be my BFF 
if you submit ideas on how to make the interface look better.

As always, any feedback at all is appreciated.

Thanks
--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: new Django site: critterwatch.org

2007-06-13 Thread Bryan L. Fordham

Michael Trier wrote:
> Nice work. You need someone to spice up the UI, but the content rocks.
>  Great job.
>
>   
Thanks

And yeah, I'm not a UI design guy. Given a design I can code it, but I 
suck at coming up with the design from scratch.

So if anyone on this list wants to donate a nice design, feel free 8)

--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: new Django site: critterwatch.org

2007-06-13 Thread Bryan L. Fordham

Jeremy Dunck wrote:
> Nice.  Screen-scraping the votes, or is there actually an API?
>   
Screen scraping, I'm afraid. Georgia was easy, which is nice since it 
was the logical place for me to start (I'm near Savannah, Ga.). Some 
other states, for instance South Carolina, have their Senate/House 
journals online, where I have to go through everything and find the votes.

One of my goals is to make a usable API for this stuff available.
> Consider mentioning on the GovTrack mailing list; there are people
> there interested in political transparency and a few that have
> specifically wanted to work on state-level legislatures.
>   
Nice, thanks. Didn't know that even existed.

Thanks
--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



new Django site: critterwatch.org

2007-06-12 Thread Bryan L. Fordham

Not officially launched yet, but I'd appreciate some people banging on 
critterwatch.org and telling me what breaks.

It's a site to track how you state senators and congressmen vote. Right 
now it only has information for Georgia, but I'm working on adding the 
next state (namely, South Carolina) right now.

Thanks
--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django newbie: lost in custom managers

2007-04-24 Thread Bryan L. Fordham

[EMAIL PROTECTED] wrote:
> cursor.execute("""
> SELECT sports_players.city_id, sports_players.team_id,
> count(sports_players.team_id) FROM sports_players,
> sports_mastercitylist
> WHERE sports_players.city_id=sports_mastercitylist.id
> AND sports_mastercitylist.cityslug = %s
> GROUP BY 1, 2
> ORDER BY 1""" % city)
try changing that last part to "Order by 1 """, [city])

http://www.djangoproject.com/documentation/model-api/#executing-custom-sql

--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django newbie: lost in custom managers

2007-04-24 Thread Bryan L. Fordham

[EMAIL PROTECTED] wrote:
> Mr. Fordham, if you are ever within 500 miles of St. Petersburg
> Florida, I owe you beer or dinner or my firstborn or something. That
> tiny little change is all I needed. It works. Thank you so much for
> your help.
>   
I actually live w/in 500 miles (Savannah, Ga) but saying "thanks" is 
enough 8)

--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Giving easy access to designers

2007-04-17 Thread Bryan L. Fordham


>> 3. Set up an Apache server for development (as indicated in the
>> mod_python documentation).  This has the disadvantages that I would
>> need to manually set up a VirtualHost in apache2.conf for each project
>> everytime one is added and also that they would need to maintain a
>> hosts file on their workstations (we don't have an internal DNS
>> server.)
>>
>> 
At a previous job we had dozens of developers working on various bits to 
a java/j2ee project running on weblogic. Each developer had their own 
instance to develop on, spread across a couple of dev servers. One would 
have http://devserver:8001, the next 8002, etc

They used scripts to start and stop their server as needed, without 
interfering with anybody else. Basically they would call something like 
"startserver " and off it would go. The advantage of this is, as 
we added things, we only had to edit one script. All configuration files 
were setup when the server started, again to keep up with changes.

It might be overkill for what you need, but it's one way to do your idea 
#3. I think it would be pretty straightforward to do with django

Just an idea
--B

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: print_r

2006-10-14 Thread Bryan L. Fordham

code enquest wrote:

>in PhP i used to print_r(array) to see what if got in my array that I
>want to bring on the screen. Smarty even had a popup screen to show this.
>
>How can I see in Django what I got in the view? So that working in the
>template goes a tat faster? What is the print_r($array) in the template
>or Django version?
>
>  
>
you might want to look at the PrettyPrinter 
http://docs.python.org/lib/module-pprint.html

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: more fun with custom fields

2006-10-12 Thread Bryan L. Fordham


>Not at the moment. There are two problems that need solving here (I've
>mentioned this before either on this list or django-dev) and they're
>both still on my endless TODO list. I'll get to them one day.
>  
>
I bet your todo list looks like mine 8)

>(1) For fields that are Python wrappers over existing database fields,
>there is a small change that needs to be made to the model attribute
>creation so that the data from the database is passed to the Field
>sub-class's constructor for converting into the right type. This change
>is relatively simple (about two lines of code).
>  
>
I may take a look at this

>An example of this is if you make a field called Sudoku, say,
>but the data is stored as a string of 81 characters in the
>database. After retrieving the data, it would be nice if the
>model attribute was actually a Sudoku class instance, rather
>than a seemingly opaque string.
>  
>
...because it would solve a lot of my problem. In my case, I could call 
the function to transform the database's geometry object into something 
the user can use and understand

>(2) For fields that are new database types, it is slightly more fiddly.
>We need a way to have them created correctly in the database (possibly
>also adding introspection, on the "give an inch and somebody is going to
>complain about the rest of the mile being missing" principle). We
>possibly need a retrieval mapping function -- imagine if we didn't have
>a native date field; how might we implement it as a third-party class --
>or possibly just hand off the rest of the work to case (1).
>
>  
>
In my case, I don't think I could need this if I had (1). Saving the 
data isn't my real problem, it's getting it out into a useful format

thanks for the info
--B


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Pro Django from Apress

2006-09-18 Thread Bryan L. Fordham

> Try searching the list, this question has been asked and answered to
> varying degrees a few times before. If memory serves me right, the
> authors seem to think that October is overly optimistic and it will
> more likely be latter.

someone should set up a FAQ page for this 8)


-- 
Bryan L. Fordham
socialistsushi.com
Sushi For Everyone

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: How do I make something available everywhere?

2006-08-31 Thread Bryan L. Fordham

> What I don't understand (and I know this is a total newbie question) is
> how I do this so it's available to drop in on any page I like.

I'd suggest a template tag. That way you could (for example) put the tag
into your base template and it'll show up on all pages that extend it,
without being tied to any view-specific logic.

-- 
Bryan L. Fordham
socialistsushi.com
Sushi For Everyone

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ImportError - No module named index

2006-08-24 Thread Bryan L. Fordham

> All worked well. I added the app in installed apps list and added the
> following url
> (r'^site/$', include('mysite.hello.views.index')),
> into urls.py file.

you either want include('mysite.hello.urls') to include the urls.py in your
app, or 
(r'^site/$', 'mysite.hello.views.index'),
to execute that view when they visit site/

You're trying to include the view as urls, and that won't work 8)

-- 
Bryan L. Fordham
socialistsushi.com
Sushi For Everyone

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Urls not matched in production mode [n00b]

2006-08-24 Thread Bryan L. Fordham

> The current URL, /metadata/, didn't match any of these."

Apache is passing the entire URL. Try changed your urls.py to

(r'^metadata/', include('..urls')),

and moving things to a urls.py in your add directory

hth
--B

-- 
Bryan L. Fordham
socialistsushi.com
Sushi For Everyone

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Serious Noobie question, what the $ for in urlpatterns.

2006-06-05 Thread Bryan L. Fordham

$ is part of the regular expression. It matches the end of the line. ^ 
matches the beginning

So, '^polls/(\d+)/$' would match
polls/1234/
but not
polls/1234/1
because the ending is wrong, and not
the_polls/1234/
because the beginning is wrong

You can read more about this at http://docs.python.org/lib/re-syntax.html

Here's how it looks at the command line:
 >>> import re
 >>> spam=re.compile(r'^polls/(\d+)/$')
 >>> print spam.match('polls/1234/')
<_sre.SRE_Match object at 0x00AD54A0>
 >>> print spam.match('polls/1234/1')
None
 >>> print spam.match('the_polls/1234/')
None

Since django stops matching urls after the first match, if you leave the 
$ off the first one will match. That's why it doesn't continue down the 
line.

I hope this makes sense. Regular expressions sometimes take a while to 
get your head around. Read the docs some and play with them. Once they 
click, they *really* click, so don't be afraid to take some time.

--B

John M wrote:

>Ok, so im gong through the turtorial and trying to adopt it to my own
>project, and I see this  in urlpatterns:
>
>(r`^polls/$'),
>(r'^polls/(\d+)/$')
>
>how does that differ from
>
>(r'^polls/'),
>(r'^polls/(\d+)/$')
>
>Note the $ is missing from the first line of the second example.
>
>When you don't have a $  in the polls/ setup, it doesn't scan down to
>the other entries.
>
>Since I'm so new to python and web stuff, was wondering if anyone could
>explain this.
>
>Sorry for such a noob question.
>
>Thanks
>
>John
>
>
>>
>  
>


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Why it doesn't work in Django

2005-11-18 Thread Bryan L. Fordham

On Fri, Nov 18, 2005 at 01:32:34PM -0800, PythonistL wrote:

> But why? Where did I make a mistake?

because it's trying to serve the page like it's a view.  For instance, if
your view is /foo/bar, go to /foo/style.css and you'll get a 404. But that's
where it's trying to load it.

You'll want to serve the style sheet from another place.

--B


app repository

2005-09-13 Thread Bryan L. Fordham

So I'm wasting some time before my next class hacking on this 8) Thought I'd
get some ideas before I get too far in

The model is something like:
App:
name
description
maintainer
version
min django version
max django version

Maintainer:
name
email

Dependencies:
App
depends on (app)
dependency version

So you have apps, which have maintainers.  You can also have dependencies,
in the case of add-ons or whatever.

For the basic site:
/   latest news, updates to apps
/news   full version of news (basically a blog)
/allrss feed of all apps (more on this shortly)
/app/  Info for an app, including a blog for updates and comments
/app//rss  rss feed for this one app
/app/

Re: Packaging django apps

2005-09-13 Thread Bryan L. Fordham

> - We need to fix on a good structure for app packages.  As a few  
> people have mentioned, the one that django-admin startapp creates may  
> or may not be good in the long term.  Personally, I think it would be  
> cool to load apps from ZIP files (like JARs) so that an app is a  
> single package...  If the app repository is structured well enough,  
> we could conceivably roll installing of apps from the repository into  
> django-admin -- "django-admin download gallery"?

+1

I'll volunteer to do a mockup of the django-admin code if no one else is
working on it. 

--B

 
> This is a great idea; let's run with it.
> 
> Jacob


Re: initial data

2005-09-01 Thread Bryan L. Fordham

On Thu, Sep 01, 2005 at 07:33:56AM -0400, Jason F. McBrayer wrote:
> 
> On Thu, 2005-09-01 at 10:15 +0100, Rachel Willmer wrote:
> > is there a django way to set up the tables with the initial data I
> > want? or should I just do this using a postgres script?
> 
> You could either do it with a postgres script, or you could write a
> python script that imports your models, instantiates objects, and saves
> them.  Or, of course, you could use the admin interface, but that would
> quickly get tedious.

I took this approach when importing data recently.  Part of it was in xml
files, the other in html.  I wrote the appropriate parsers and used django
models to load the data, it worked well but, if you're doing *a lot* of data
it may be slow, depending on your machine.

--B


Re: NameError Exception

2005-08-29 Thread Bryan L. Fordham

On Mon, Aug 29, 2005 at 09:45:33AM -0700, Sebastien Fievet wrote:
> 
> Complete python interpreter code :
> >>> from django.models.mobilespecs import devices
> >>> d = mobilespecs.Device('generic', 'root', '', False)
> Traceback (most recent call last):
>   File "", line 1, in ?
> NameError: name 'mobilespecs' is not defined

try

>>> d = devices.Device(a='generic', b='root', c='', d=False)

where a,b,c,d are the field names

--B


Re: fun with imports

2005-08-23 Thread Bryan L. Fordham

On Tue, Aug 23, 2005 at 07:36:06AM -0500, Jacob Kaplan-Moss wrote:

> See "Using module globals in models" at http://code.djangoproject.com/ 
> wiki/DataModelPitfalls -- the short answer is that your model is  
> turned into a virtual module at run time, and the namespace changes.

A couple of us in irc figured it was something along these lines. Thanks for
confirming.

Looking at that page, my solution (importing in the method itself) is a
viable solution. My concern was that I might have to do that import multiple
times if more than one method had to use the same function.  But the
module_constants solves most of that.

Thanks
--B


Re: CSS and PNG files in templates

2005-08-23 Thread Bryan L. Fordham

On Tue, Aug 23, 2005 at 12:12:31PM +0100, Andy Shaw wrote:

> It does seem somewhat contradictory to refuse to let the built-in server 
> serve static media in general whilst hacking it so that it does output 
> the admin media. Presumably this is so that the admin CSS/Javascript is 
> available, and so the admin works properly - but what happens when the 
> same features are used in application views? The test server is no 
> longer particularly useful to test applications with.

Sure it's useful.  It's not unusual at all to have static content served
from a server that's designed for that (ie apache) even when you're running
a very expensive app server such as weblogic.

I think the larger point is that the dev server isn't for serving static
content, it's for development.  I've used it on windows and linux, and it's
never been is issue in either case to have my style sheets, et al served
from apache.

Having said that... it would be nice (going back to a previous thread) to
have global properties available in templates so you could easily change
where the static content is coming from.

--B