Re: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Alex Dong

Thanks Malcolm, sounds like `getattr` might be a good solution. I'll
take a look into that and post back. -- Alex

On Mar 26, 9:58 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-03-25 at 18:22 -0700, Alex Dong wrote:
> > Hi Malcolm,
>
> > Thanks for the quick reply.
>
> > What I'm wondering about is that I've seen the pattern repeat itself
> > quite a few times where I have to write a little wrapper doing nothing
> > more than retrieving something from the `request` object.
> > Like
> > * request.user.get_home_url
> > * request.user.get_watch_list_url
> > * request.user.private_message
> > ...
>
> > So my views.py file ends up with lots of this one line methods, which
> > I found a little bit 'unclean'.
>
> So write one function and one of the parameters you pass it is the name
> of the "thing" to get, using getattr() to get the item. You can pass in
> static parameter values as part of the url configuration (the optional
> third argument after the reg-exp and function). However that wasn't what
> your original example was doing at all.
>
> I'm not really sure what answer you are expecting here. You have to
> extract the user information at view processing time -- it can't be done
> any earlier because that is the only time you have the accurate request
> object. So you need to have views.
>
> Small functions that do slightly different things aren't untidy, or, at
> least, not universally so. Just try to factor out the common stuff,
> using all the power that Python give you. Your original example -- and
> similar things -- could be done with a decorator that extracts the
> request.user and tacks it onto the parameters passed to your view. You
> would need to decide to have a consistent name for that parameter. The
> (different) example you posted above can be handled by realising the
> only difference is the attribute you are retrieving, so using getattr()
> solves that.
>
> Regards,
> Malcolm


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



proxied to a directory

2007-03-25 Thread Ross M Karchner
Hello--

I'm running a django project mod_proxy'ed to a directory of a non-django
site, so that the django root is accessible at:

http://domain.com/tools/

Django is oblivious to the 'tools'-- in the url above, request.path would
just be "/", which makes perfect sense. This causes problems for anything
that uses the request.path variable-- for instance, the admin login screen,
or redirects caused by append_slash being turned on.

Just about every issue that crops up can be dealt with as it comes up, but
I'm wondering if there's a way to fix this via middleware or configuration.
Since request attributes are read-only, installing middleware that rejiggers
request.path on every request won't work, but I'm open to other ideas.

-Ross

--~--~-~--~~~---~--~~
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: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Malcolm Tredinnick

On Sun, 2007-03-25 at 18:22 -0700, Alex Dong wrote:
> Hi Malcolm,
> 
> Thanks for the quick reply.
> 
> What I'm wondering about is that I've seen the pattern repeat itself
> quite a few times where I have to write a little wrapper doing nothing
> more than retrieving something from the `request` object.
> Like
> * request.user.get_home_url
> * request.user.get_watch_list_url
> * request.user.private_message
> ...
> 
> So my views.py file ends up with lots of this one line methods, which
> I found a little bit 'unclean'.

So write one function and one of the parameters you pass it is the name
of the "thing" to get, using getattr() to get the item. You can pass in
static parameter values as part of the url configuration (the optional
third argument after the reg-exp and function). However that wasn't what
your original example was doing at all.

I'm not really sure what answer you are expecting here. You have to
extract the user information at view processing time -- it can't be done
any earlier because that is the only time you have the accurate request
object. So you need to have views.

Small functions that do slightly different things aren't untidy, or, at
least, not universally so. Just try to factor out the common stuff,
using all the power that Python give you. Your original example -- and
similar things -- could be done with a decorator that extracts the
request.user and tacks it onto the parameters passed to your view. You
would need to decide to have a consistent name for that parameter. The
(different) example you posted above can be handled by realising the
only difference is the attribute you are retrieving, so using getattr()
solves that.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1g3

2007-03-25 Thread James Bennett

On 3/25/07, coulix <[EMAIL PROTECTED]> wrote:
> Apparently we need to upgrade Mysql, which is already the 5.0 on my
> host and no latest version is available, or put mysql_old in the
> settings.py.

No, MySQL is the database server, and does not need to be upgraded.

MySQLdb (note the "db" on the end) is a Python module which connects
to MySQL database servers, and does need to be upgraded.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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: psyco

2007-03-25 Thread sansmojo

Well, I had looked in my error log and I just checked again.
Nothing.  I obviously am missing a lot.  Any recommendations?

On Mar 25, 7:16 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-03-25 at 10:15 -0700, sansmojo wrote:
> > I was trying to test out psyco, according to the information at
> >http://code.djangoproject.com/wiki/PsycoMiddleware
> > For some reason, the following works at the shell (python manage.py
> > shell), but not on the web:
>
> > import psyco
> > psyco.full
>
> > It seems that the second I attempt to import psyco through a web
> > request, I get an error (shows as server error 500, but it's
> > ImportError).  I'm running on Dreamhost, with psycho installed in a
> > local site-packages.
>
> > Any ideas as to what could be wrong?  Thanks!
>
> If Python is raising an exception and you're not catching it, it should
> be sent to sys.stderr and your webserver must be catching that somehow
> (hopefully, otherwise you'll be missing a lot of errors, in general).
> Try to work out where the error log is so that you can see the details
> of the error.
>
> Regards,
> Malcolm


--~--~-~--~~~---~--~~
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: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Alex Dong

Hi Malcolm,

Thanks for the quick reply.

What I'm wondering about is that I've seen the pattern repeat itself
quite a few times where I have to write a little wrapper doing nothing
more than retrieving something from the `request` object.
Like
* request.user.get_home_url
* request.user.get_watch_list_url
* request.user.private_message
...

So my views.py file ends up with lots of this one line methods, which
I found a little bit 'unclean'.

Alex

On Mar 26, 8:59 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> Hi Alex,
>
>
>
> On Sun, 2007-03-25 at 17:55 -0700, Alex Dong wrote:
> > Hi folks,
> > I'd like to refactor the following code into one line in urls.py:
>
> > Now:
> > in `urls.py`:
> > +(r'^watchlist/$',
> > 'package.watchlist.views.rredirect_to_personalized_watch_list'),
> > +(r'^users/(?P.*)/watchlist/$',
> > 'package.watchlist.views.watchlist'),
>
> > in `views.py`:
> > [EMAIL PROTECTED]
> > +def redirect_to_personalized_watch_list(request):
> > +return HttpResponseRedirect('/users/%s/watchlist/' %
> > request.user.username)
>
> > I'm wondering how can I eliminate the need for the
> > `redirect_to_personalized_watch_list` and use django's `redirect_to`
> > generic view?  It'll be much easier if I could get `request` object in
> > the `urls.py`.
>
> You can't do this directly because of the different scopes the lines of
> code are executed in. Any solution would involve creating a "delayed
> execution" scope to extract the request.user variable, which is exactly
> what you've done. So either you have a short function as you've got, or
> Django would have to have a short function that does exactly the same
> thing. Same number of lines of code in either case and more flexible the
> current way.
>
> If you really want to put all the logic in one file, there's no reason
> your redirect function has to be in a file other than urls.py. However,
> it looks fine as you've got it now and I wouldn't be in a hurry to move
> it.
>
> Regards,
> Malcolm


--~--~-~--~~~---~--~~
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: Deploying multiple sites on one computer using SSL

2007-03-25 Thread Dan Goldner

Sincere thanks to both Malcom and Waylan. Things are working fine now.
Waylan's suggestion didn't have an effect, but after following
Malcom's
debugging advice I found that while I had remembered to create a link
from
the httpd DocumentRoot to the project1 directory, I had not created
a link to the project2 directory.

For other newbies who might be trying to set things up this way,
here is the full combination of httpd, directory structure and
settings.py
information that is working for me.

Thanks again for the help.
-DG


httpd.conf (relevant parts)


[...]

DocumentRoot "/usr/local/www/data"

[...]

LoadModule python_module /usr/local/libexec/apache2/mod_python.so



  ServerName projects.mycompany.com
  SetHandler python-program
  PythonInterpPerDirective On

  # Turn Off for production, On for dev:
  PythonAutoReload Off
  PythonDebug Off

  
  PythonHandler django.core.handlers.modpython
  PythonPath "['/usr/local/projects', \
   '/usr/local/projects/project2']+sys.path"
  SetEnv DJANGO_SETTINGS_MODULE project2.settings
  

  
  PythonHandler django.core.handlers.modpython
  PythonPath "['/usr/local/projects', \
   '/usr/local/projects/project1']+sys.path"
  SetEnv DJANGO_SETTINGS_MODULE project1.settings
  

  
  SetHandler None
  

  [... SSL stuff ...]



---
directory structure
---

/usr/local/www/data/
   project1 (link to /usr/local/projects/project1)
   project2 (link to /usr/local/projects/project2)

/usr/local/projects/
   project1/
  settings.py
  urls.py
  views.py
  static/
 css/
 img/
 admin (link to .../django/contrib/admin/media/)
   project2/
  settings.py
  urls.py
  views.py
  static/
 css/
 img/
 admin (link to .../django/contrib/admin/media/)

---
excerpt from settings.py (shown for project1; project2 is similar)
---

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/usr/local/projects/project1/static'

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com;
MEDIA_URL = 'https://projects.mycompany.com/project1/static'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/;, "/media/".
ADMIN_MEDIA_PREFIX = 'https://projects.mycompany.com/project1/static/
admin/'



--~--~-~--~~~---~--~~
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 as a platform for a commercial SaaS project?

2007-03-25 Thread Jonas Maurus

On Mar 24, 4:59 pm, "walterbyrd" <[EMAIL PROTECTED]> wrote:
> SaaS = Software as a service, just in case that was not clear.
>
> If I wanted to create commercial quality hosted software, would django
> be the best solution? The sort of things I have in mind would be very
> database oriented, and involve a lot of forms and reports. I would
> like to be able to easily customize the software.
>
> As much as I dislike microsoft, I wonder if I would be more productive
> with ASP.NET?

hey,

I'm a bit new to the whole Python thing in terms of knowing all the
libraries around the net, so I hope the other people on the list
forgive me if I say something stupid or just correct me right away.

Personally (and of course from my totally objective and uninfluenced
point-of-view ;-) ) I'd look at what Django *doesn't* give you and see
if it's important for your project. I think the "big" platforms like
Java with Tapestry/JSF or ASP.Net with WebForms have everything and
the kitchen sink and Django, or Python for that matter, hasn't had
that kind of exposure yet.

So here's a few technical checkpoints:
  * do you need very fine-grained authorization controls (i.e. row or
attribute level) in the application or do you need to integrate
enterprisey hand-waving stuff like XACML or SAML?

  * do you need strong PDF support (like flowing two columns of text
over multiple pages with headlines, or Adobe Forms-support or even
digital signatures)? (There doesn't seem any Python library that can
match Lowagie's iText(.Net))

  * are there very high performance requirements or enormous amounts
of data? (i.e. management doesn't care if it's expensive, they only
care if their flashy dashboard is really fast and you have to process
huge result-sets in a data warehouse to create your reports)

  * can you profit extensively from ready-made components for a
component-oriented framework? (Django's admin is *great* and generic
views rock, but if your application presents a few hundred lines of
database rows in a spreadsheet-like manner, nothing beats dragging a
GridView from a toolbar and connecting it visually to a ADO.Net
dataset and be done with it unless there is some equivalent to that or
Tapestry's contrib:table and I haven't found it yet)

  * do you need to consume .Net-based web-services or do you need
strong support for the WS-* stack?

  * do you need to integrate legacy database(s) and anticipate that
there is a lot of character-set handling and character-set conversion
comint? (Judging from the coming "unicodization" and that Django seems
to require that the database and the templates share a character-set,
I'd say that it not its strongest point right now. However, someone's
proving me wrong at this instant probably... Python however would
support this requirement just fine).

  * do you need to work with a database that Django doesn't support,
yet? (assuming you don't have time to write and contribute a
driver ;-) )

A month ago I'd have talked about how full-text search might be
important, but thanks to PyLucene this problem is solved (and there's
a project called DjangoStuff that can be patched so the search-part
works).

And here's a few management checkpoints:
  * do you already have Python-knowledge in-house?

  * are the people in charge of the servers capable of running Python
in a predictable manner? (i.e. not "installing from ActiveState's .exe
and clicking restart", but "running it for at least 4 weeks with full
backup-protocols and a clear idea of what module versions are in
production and what they're last few security-holes were")

  * can you live with the coming changes in Django and can you afford
to forward-port your application? ASP.Net will be supported in its
current version for a long time, Django won't until it hits 1.0 and
then (no offense) other frameworks have not exactly be the poster-
children of backwards-compatibility, you'll have to hope Django's
different. Assuming that your reporting-application will run for 5
years, you'll either have to patch it or be very careful security-wise
because an upgrade or two will definitely come up in this time-frame.

>From the top of my head, these would be the main points I'd consider
if I wanted to adopt Python/Django. What you don't get with ASP.Net is
a lot of fun coding. Django is very elegant, but that also means most
of the buzzwords are missing. (something like Displaytag for JSP
however, is bound to happen in the next 3 months :-) ).

That said, we're using Django extensively now alongside PHP and Java
and it's by far the most productive platform and the missing pieces
seem to be arriving fast (see PyLucene, the auth-branch, the schema
migration-branch, unicodization).

I hope I was able to help you a bit.

Best regards from Germany,
Jonas


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to 

Re: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Malcolm Tredinnick

Hi Alex,

On Sun, 2007-03-25 at 17:55 -0700, Alex Dong wrote:
> Hi folks,
> I'd like to refactor the following code into one line in urls.py:
> 
> Now:
> in `urls.py`:
> +(r'^watchlist/$',
> 'package.watchlist.views.rredirect_to_personalized_watch_list'),
> +(r'^users/(?P.*)/watchlist/$',
> 'package.watchlist.views.watchlist'),
> 
> in `views.py`:
> [EMAIL PROTECTED]
> +def redirect_to_personalized_watch_list(request):
> +return HttpResponseRedirect('/users/%s/watchlist/' %
> request.user.username)
> 
> I'm wondering how can I eliminate the need for the
> `redirect_to_personalized_watch_list` and use django's `redirect_to`
> generic view?  It'll be much easier if I could get `request` object in
> the `urls.py`.

You can't do this directly because of the different scopes the lines of
code are executed in. Any solution would involve creating a "delayed
execution" scope to extract the request.user variable, which is exactly
what you've done. So either you have a short function as you've got, or
Django would have to have a short function that does exactly the same
thing. Same number of lines of code in either case and more flexible the
current way.

If you really want to put all the logic in one file, there's no reason
your redirect function has to be in a file other than urls.py. However,
it looks fine as you've got it now and I wouldn't be in a hurry to move
it.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Retrieve `request` object in `urls.py`?

2007-03-25 Thread Alex Dong

Hi folks,
I'd like to refactor the following code into one line in urls.py:

Now:
in `urls.py`:
+(r'^watchlist/$',
'package.watchlist.views.rredirect_to_personalized_watch_list'),
+(r'^users/(?P.*)/watchlist/$',
'package.watchlist.views.watchlist'),

in `views.py`:
[EMAIL PROTECTED]
+def redirect_to_personalized_watch_list(request):
+return HttpResponseRedirect('/users/%s/watchlist/' %
request.user.username)

I'm wondering how can I eliminate the need for the
`redirect_to_personalized_watch_list` and use django's `redirect_to`
generic view?  It'll be much easier if I could get `request` object in
the `urls.py`.

Thanks,
Alex


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How would You like to get $15,000 Absolutely Free within 30 Days ?

2007-03-25 Thread denglianchu




Certainly, It'll be very interesting. But the story began about one
month
ago.


It was 23rd November' 2006, 9:30pm. As an accountant  of a non-govt.
organization, I've always a little time to relax after my all day hard
work.
And there is no exception today. After my dinner, for relaxing I sat
to
browse Internet with a mug of hot milk. It's one of my hobbies. When I
get
sometime, I browse Internet. And find - are there any suitable work at
home
opportunities available or not, so I can free from my endless hard
work.


I've found a lot of site and I've joined several work at home program
for a
lots of money. But all are worthless. And dear friend, What I
experienced ?
Most of the website are cheating online. They sound very sweet. But
the
realities are another. They promise to you that they will bring the
moon
from sky to you. And will ask you some money for it. You have to
always
remember that, those who want to give you a home job really, why they
need
to take money from you ? Actually, they live by the money what they
take
from you. They are begging  and depending on you; how will they show
you
money ?


Secondly, the work should have to be easy. If the work will very
complex and
difficult to do for you, You can't do it and will lost your
interests.


Third, You have to know, will they supply the necessary step by step
instruction or not ? Because without step by step instruction it will
difficult to be succeed.


Fourth, is that program available for your country ? There have many
work at
home job that are not available for every country.


And finally, How much you can earn from the work ?


Work at Home | Get $15,000 Absolutely Free within 30 Days... Guaranteed

These are the main analysis about online work at home program.


However, This day while searching, I've found a work at home site
where I
never have to expend any money. And if I work with their instruction,
I can
earn $15,000 within 30 days. Not bad if it is real ! I joined there as
a
curiosity. At least I have nothing to lose though it is free to join.
So
what's problem to join ? So I joined. However, 3 days after joining I
got an
ebook download link in my email inbox. I downloaded the ebook and as
their
instruction I was working 1 hour everyday. Day by day were passing.
And  I
am working & waiting.


Today is 36th day after my joining. And I have received a $16,428
check just
an hour ago from writing this article.


Actually, sometime Opportunity knocks the door very silently. Visit
now the
site where I have made $16,428 Absolutely Free; Click Here & Make
Money > Work
at Home 


Visit Now: http://www.worldspot.cn/


[ You have free reprint and redistribution right to this article. Feel
free
to publish it on your website, in your Newsletters, ezines, email
promotions
etc as long as the content, the resource box and the link not
altered. ]


--~--~-~--~~~---~--~~
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: ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1g3

2007-03-25 Thread Malcolm Tredinnick

On Mon, 2007-03-26 at 00:14 +, coulix wrote:
> Same problem,
> ImproperlyConfigured: Error importing middleware
> django.contrib.flatpages.middleware: "MySQLdb-1.2.1p2 or newer is
> required; you have 1.2.1g3"
> 
> Apparently we need to upgrade Mysql, which is already the 5.0 on my
> host and no latest version is available, or put mysql_old in the
> settings.py.

No. You need to upgrade MySQLdb, not MySQL. It's not complaining about
the MySQL version.

Malcolm.



--~--~-~--~~~---~--~~
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: Trouble setting up Django and Apache

2007-03-25 Thread Malcolm Tredinnick

Hi Ben,

On Sun, 2007-03-25 at 14:23 -0700, benrawk wrote:
> Hello all,
> 
> With Graham's hint about possible problems caused by SELinux, I
> finally figured out what was going on. Django can now serve pages!
> Here is what I learned:

Firstly, well done for sticking at solving the problem rather than just
turning off the SELinux infrastructure. Writing up your conclusions is
bound to help other people, too.

> SELinux is installed and running by default on Fedora Core 6. This
> means that along with the correct file permissions, for files to be
> readable by apache they have to have the correct security context.
> When you first set up Apache and serve a simple html page from '/var/
> www' there is no problem because SELinux has by default already given
> this path the correct security context. When you start creating
> projects in Django using the 'django-admin.py startproject [project
> name]' files are created that do not have the correct security
> context.
> 
> Default security contexts are controlled by files in '/etc/selinux/
> targeted/contexts/files'. If you grep for 'www' in this directory you
> will see that '/var/www(/.*)?' has been given the correct security
> context, as previously described. Interestingly, directories labeled
> 'www' under you home directory will also be given the correct security
> context by defaule because of the following regx '/home/[^/]*/((www)|
> (web)|(public_html))(/.+)? '.
> 
> Looking at the security conext of files under the /var/www directory
> (using 'ls -Z'), I found that files should have the following context
> inorder to be served up by Apache:
> 'system_u:object_r:httpd_sys_content_t'. This is compared to what my
> Django files currently had: 'user_u:object_r:user_home_t'. I had to
> change the type of the files, and I did so using the following
> command:
> 
> chcon -R -t httpd_used_content_t myproject
> 
> My knowledge of SELinux configuration is still pretty low, and I will
> continue to study it if I run into more problems. The references I
> used to figure this all out are here:
> 
> http://linux.web.cern.ch/linux/scientific4/docs/rhel-selg-en-4/rhlcommon-chapter-0017.html#RHLCOMMON-SECTION-0066
> http://docs.fedoraproject.org/selinux-apache-fc3/sn-simple-setup.html

I'm fairly comfortable with SELinux systems and, for what it's worth,
your explanation of the problems, why it isn't a problem for /var/www/
and your solution seem exactly right to me. Nice debugging job. :-)

I don't have FC6 installed, but often these systems log access
violations to /var/log/secure (or another place), so you might have been
able to see a bunch of failures in there. On SELinux-enabled systems, if
something isn't working, it's often worth seeing if /var/log/secure is
growing or being updated each time you make an attempt (you can run "ls
-lrt /var/log/" without being root on many systems, whereas you can't
view the file without changing to a more privileged user).

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: fcgi - issues

2007-03-25 Thread Malcolm Tredinnick

On Sun, 2007-03-25 at 15:54 -0700, David M. Besonen wrote:
> are there any issues/caveats/problems around using django + fcgi?
> 
> i'm guessing there might things to be wary of, given that
> mod_python appears more prominently in the installation
> instructions.

Every installation method has its own little tricks. However, there's no
reason not to use fastcgi. The reason mod_python may be slightly more
prominent is that it was the first interface used and is the one
originally used by the developers. A built-in fastcgi interface was only
added around the middle of last year (not long before we released 0.95,
from memory). These days, anecdotal evidence seems to suggest there's a
lot broader range of connection possibilities in use.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: psyco

2007-03-25 Thread Malcolm Tredinnick

On Sun, 2007-03-25 at 10:15 -0700, sansmojo wrote:
> I was trying to test out psyco, according to the information at
> http://code.djangoproject.com/wiki/PsycoMiddleware
> For some reason, the following works at the shell (python manage.py
> shell), but not on the web:
> 
> import psyco
> psyco.full
> 
> It seems that the second I attempt to import psyco through a web
> request, I get an error (shows as server error 500, but it's
> ImportError).  I'm running on Dreamhost, with psycho installed in a
> local site-packages.
> 
> Any ideas as to what could be wrong?  Thanks!

If Python is raising an exception and you're not catching it, it should
be sent to sys.stderr and your webserver must be catching that somehow
(hopefully, otherwise you'll be missing a lot of errors, in general).
Try to work out where the error log is so that you can see the details
of the error.

Regards,
Malcolm




--~--~-~--~~~---~--~~
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: multiple field primary key and foreign keys as primary keys

2007-03-25 Thread Malcolm Tredinnick

On Sun, 2007-03-25 at 10:52 +, Michael wrote:
> Hi Francesco,
> I had a similar issue the other day, and came up with a solution of
> sorts - but will be interested to hear from people with more Django
> experience as to whether what I've done is a good idea.
> 
> If we your example to:
> 
> class MyModel(models.Model):
> field1 = ForeignKey('table1', db_index=True)
> field2 = ForeignKey('table2', db_index=True)
> 
>class Meta:
> unique_together = (('field1', 'field2'),)
> 
> Then from my understanding, you should end up with a table for MyModel
> that has a primary key automatically generated by Django, but your two
> fields will be indexed, and you will not be able to have two records
> where the combination of field1 and field2 is the same. So it has the
> properties that I needed in the first place.
> 
> Does that help? Or, more importantly, can some one tell us whether
> it's a bad idea?

This certainly works and is the currently recommended way to have
multi-column uniqueness at the moment.

It's not 100% equivalent to multi-column primary keys, though, but the
differences generally only arise when you're trying to use Django over
an existing database. We might be able to fix this problem one day,
although the current real difficulty is how to address them in the admin
interface -- there hasn't yet been any good ideas that don't make
existing admin URLs ugly. [Aside: If you're wondering why this is hard,
consider a model in Django that has a custom primary key and an instance
with a key value of 'a/b/c', now try to make an admin URL from that and
another column without having to somehow put escaping on every slash in
sight, which we don't need to do at the moment.]

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1g3

2007-03-25 Thread coulix

Same problem,
ImproperlyConfigured: Error importing middleware
django.contrib.flatpages.middleware: "MySQLdb-1.2.1p2 or newer is
required; you have 1.2.1g3"

Apparently we need to upgrade Mysql, which is already the 5.0 on my
host and no latest version is available, or put mysql_old in the
settings.py.


On Mar 22, 9:11 pm, "Tomas Jacobsen" <[EMAIL PROTECTED]> wrote:
> I checked out the newest django trunk to my dreamhost domain, and
> suddenly I got an error when I tried to go to the admin site.
>
> ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1g3
>
> Tried 'python manage.py validate' and got this:
>
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
> execute_manager(settings)
>   File "/home/username/django/django_src/django/core/management.py",
> line 1666, in execute_manager
> execute_from_command_line(action_mapping, argv)
>   File "/home/username/django/django_src/django/core/management.py",
> line 1565, in execute_from_command_line
> action_mapping[action](int(options.verbosity),
> options.interactive)
>   File "/home/username/django/django_src/django/core/management.py",
> line 486, in syncdb
> from django.db import connection, transaction, models,
> get_creation_module
>   File "/home/username/django/django_src/django/db/__init__.py", line
> 11, in ?
> backend = __import__('django.db.backends.%s.base' %
> settings.DATABASE_ENGINE, {}, {}, [''])
>   File "/home/username/django/django_src/django/db/backends/mysql/
> base.py", line 20, in ?
> raise ImportError, "MySQLdb-1.2.1p2 or newer is required; you have
> %s" % Database.__version__
> ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1g3
>
> Is there any way to fix this?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



fcgi - issues

2007-03-25 Thread David M. Besonen

are there any issues/caveats/problems around using django + fcgi?

i'm guessing there might things to be wary of, given that
mod_python appears more prominently in the installation
instructions.


thanks,
david


--~--~-~--~~~---~--~~
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: psyco

2007-03-25 Thread sansmojo

Thanks, Jeremy.  I just typed it wrong here instead of copying and
pasting.

On Mar 25, 2:01 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 3/25/07, sansmojo <[EMAIL PROTECTED]> wrote:
>
> > import psyco
> > psyco.full
>
> Unrelated to your import error, but make sure you use parens after
> .full().  iPython is probably helping you with that, but modpython
> won't.


--~--~-~--~~~---~--~~
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: Trouble setting up Django and Apache

2007-03-25 Thread benrawk

Hello all,

With Graham's hint about possible problems caused by SELinux, I
finally figured out what was going on. Django can now serve pages!
Here is what I learned:

SELinux is installed and running by default on Fedora Core 6. This
means that along with the correct file permissions, for files to be
readable by apache they have to have the correct security context.
When you first set up Apache and serve a simple html page from '/var/
www' there is no problem because SELinux has by default already given
this path the correct security context. When you start creating
projects in Django using the 'django-admin.py startproject [project
name]' files are created that do not have the correct security
context.

Default security contexts are controlled by files in '/etc/selinux/
targeted/contexts/files'. If you grep for 'www' in this directory you
will see that '/var/www(/.*)?' has been given the correct security
context, as previously described. Interestingly, directories labeled
'www' under you home directory will also be given the correct security
context by defaule because of the following regx '/home/[^/]*/((www)|
(web)|(public_html))(/.+)? '.

Looking at the security conext of files under the /var/www directory
(using 'ls -Z'), I found that files should have the following context
inorder to be served up by Apache:
'system_u:object_r:httpd_sys_content_t'. This is compared to what my
Django files currently had: 'user_u:object_r:user_home_t'. I had to
change the type of the files, and I did so using the following
command:

chcon -R -t httpd_used_content_t myproject

My knowledge of SELinux configuration is still pretty low, and I will
continue to study it if I run into more problems. The references I
used to figure this all out are here:

http://linux.web.cern.ch/linux/scientific4/docs/rhel-selg-en-4/rhlcommon-chapter-0017.html#RHLCOMMON-SECTION-0066
http://docs.fedoraproject.org/selinux-apache-fc3/sn-simple-setup.html

On Mar 23, 2:30 am, "Graham Dumpleton" <[EMAIL PROTECTED]>
wrote:
> On Mar 23, 6:47 pm, "benrawk" <[EMAIL PROTECTED]> wrote:
>
> > Thank you again for helping. FYI, I am using Fedora Core 6. I set
> > 'PythonHandlermod_python.testhandler' in httpd.conf and got a bunch
> > of info. The sys.path appears to be correct...relevant bits, and then
> > full text beneath.
>
> > sys.path containes /home/benrawk
>
> What is the full path to the directory that Django admin project
> created. Is it:
>
>   /home/benrawk/mysite
>
> What is the output of running:
>
>   ls -las
>
> inside of that directory. Are all the files in that directory readable
> to others.
>
> > REQUEST_URI /mysite/
> > SCRIPT_NAME /mysite
> > PATH_INFO   /
> > PATH_TRANSLATED /var/www/html/index.html
> > ***Is this Path being translated correctly?***
>
> That is normal in this case. Because the request was against the
> directory Apache tried applying targets listed in DirectoryIndex
> directive and first one listed was probably 'index.html'.
>
> > DOCUMENT_ROOT   /var/www/html
> > SCRIPT_FILENAME /var/www/html/mysite
> > ***There is no "mysite" script under the Document root, is this being
> > interpreted correctly?***
>
> Nothing to worry about, just part of Apache's strange URL matching
> algorithm which is made somewhat more confusing by presence of
> mod_python.
>
> Graham


--~--~-~--~~~---~--~~
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 as a platform for a commercial SaaS project?

2007-03-25 Thread ScottB

Hi Walter.

On Mar 24, 3:59 pm, "walterbyrd" <[EMAIL PROTECTED]> wrote:
> If I wanted to create commercial quality hosted software, would django
> be the best solution? The sort of things I have in mind would be very
> database oriented, and involve a lot of forms and reports. I would
> like to be able to easily customize the software.
>
> As much as I dislike microsoft, I wonder if I would be more productive
> with ASP.NET?

For what it's worth, I spent the last couple of years developing in
ASP.NET and the last couple of months developing in Django and I find
I'm much more productive in Django.

It's hard to say if Django is the "best solution" for your particular
app, but there aren't any obvious reasons why it wouldn't do a good
job in a SaaS situation.  Using newforms is definitely a timesaver
when your app has a lot of forms and Django doesn't seem to have any
problems with scalability.  If you have specialised requirements for
security or audit/repudiation type stuff you'll need to figure out how
to do what you want, but that's true of any web framework and mostly
comes down to your design.

Scott

Scott


--~--~-~--~~~---~--~~
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: Fwd: Different subdomain for each application (again)

2007-03-25 Thread ScottB

Hi Tom.

On Mar 24, 2:42 pm, Tom Smith <[EMAIL PROTECTED]> wrote:
> A while ago Doug and Eivind asked about using subdomains for each app.
>
> I'd like to do this, but in the example they had a stab at they were
> using Apache whereas I'm using Lighttpd...

One thing you might like to consider is having Lighty map the
subdomain in to the url where it can be matched against your
urlpatterns.

In the Lighty config you can use a regex to match the host.  If the
regex has captures, these are available to be passed to FastCGI using
%1, %2, etc (captures in the rewrite rule are $1, $2, etc).  So in the
Lighty config you can use something like:

$HTTP["host"] =~ "([\w\d-]+)?\.?example\.com" {
... snip ...
url.rewrite-once = (
... snip ...
"^(/.*)$" => "/extraset.fcgi/%1$1",
)
}

Now if you go to blog.example.com, the URL Django gets is /blog.
If you go to blog.example.com/2006/, Django gets /blog/2006/.

This makes it easy to match the subdomain in urlpatterns:

urlpatterns = patterns('',
(r'^blog/$', include('project.blog.urls'),
... etc

The blog app doesn't know anything about the prefix in the url and
doesn't need to know it is running on a subdomain.  The user never
sees the /blog prefix because this happens within the webserver.  I've
had this working, so let me know if you need any more details.

Scott


--~--~-~--~~~---~--~~
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: psyco

2007-03-25 Thread Jeremy Dunck

On 3/25/07, sansmojo <[EMAIL PROTECTED]> wrote:
> import psyco
> psyco.full

Unrelated to your import error, but make sure you use parens after
.full().  iPython is probably helping you with that, but modpython
won't.

--~--~-~--~~~---~--~~
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 and Routing SUBDOMAIN STYLE URL

2007-03-25 Thread Michael Cuddy

> I have tried:
> 
> http://api.localhost:8000/
> http://api.127.0.0.1:8000/
> 
> This is not working on my windows machine (using development server,
> not apache+mod_python).

You have two choices.  If you have access to /etc/hosts on the
server, you can define somehost.localhost and someother.localhost as
aliases for localhost

and then you should be able to access via http://somehost.localhost:8000  
and http://someother.localhost:8000

OR ... (and this is what I do, because my web client is not on my dev
host)

You can run the dev server so that it binds to all IP addresses on the
host:

python manage.py runserver 0.0.0.0:8000

and then your CNAMEs should work.

http://somehost.example.com:8000/, http://someother.example.com:8000/

--
Mike Cuddy ([EMAIL PROTECTED]), Programmer, Baritone, Daddy, Human.
Fen's Ende Software, Redwood City, CA, USA, Earth, Sol System, Milky Way.

"The problem with defending the purity of the English language is
that English is about as pure as a cribhouse whore. We don't just
borrow words; on occasion, English has pursued other languages down
alleyways to beat them unconscious and rifle their pockets for new
vocabulary." -- James D. Nicoll

   Join CAUCE: The Coalition Against Unsolicited Commercial E-mail.
  

--~--~-~--~~~---~--~~
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 and Routing SUBDOMAIN STYLE URL

2007-03-25 Thread johnny

I have tried:

http://api.localhost:8000/
http://api.127.0.0.1:8000/

This is not working on my windows machine (using development server,
not apache+mod_python).

Thank you.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



psyco

2007-03-25 Thread sansmojo

I was trying to test out psyco, according to the information at
http://code.djangoproject.com/wiki/PsycoMiddleware
For some reason, the following works at the shell (python manage.py
shell), but not on the web:

import psyco
psyco.full

It seems that the second I attempt to import psyco through a web
request, I get an error (shows as server error 500, but it's
ImportError).  I'm running on Dreamhost, with psycho installed in a
local site-packages.

Any ideas as to what could be wrong?  Thanks!

Branton


--~--~-~--~~~---~--~~
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: Newbie problem with view/model interaction

2007-03-25 Thread Ross Burton

(re-sending, apologies if this hits the list twice)

On Mar 24, 5:27 pm, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> What is it you want to do with the ones they've voted on vs. haven't? If
> you're going to hide the ones they've already voted on, just write a
> query in the view method that only returns those and pass that to the
> context. (Note: the view method, not the template. See Ivan's response.)

I thought I'd go this route -- it seemed simplier and more useful.
However, I can't seem to work out the query.  My initial attempt:

def pending(request):
return object_list(request,
Paper.objects.exclude(vote__user=request.user))

However this appears to joining Paper and Vote, filtering out the rows
where I voted, and then showing the rows remaining (which leads to
duplicates).

What would the correct filter be for all Papers which don't have a
related Vote object with a given user field?

Thanks,
Ross


--~--~-~--~~~---~--~~
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: building a django rpm, probs with adding documentation

2007-03-25 Thread Paul Rauch

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lars Stavholm schrieb:
> Paul Rauch wrote:
>> Hello,
>>
>> I'm currently building a rpm of django for suse.
>>
>> But I can't figure out how to add the documentation, it doesn't get
>> added, when running "python setup.py build"
> 
> Assuming that you've unpacked your source with...
> 
> %prep
> %setup -q
> 
> ...you should be able to do...
> 
> %files
> %doc AUTHORS docs examples extras INSTALL LICENSE README
> 
> ...where the doc directory contains the documentation files
> that comes with the distribution.
> 
> If need be, download and install
> 
> and have a look at the spec file.
> 
> I haven't had time to test the package yet, but still.
> 
> Good Luck
> /Lars
> 
thanks for your help. the following line was missing:

%doc AUTHORS docs examples extras INSTALL LICENSE README

mfg Paul Rauch

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iQIVAwUBRgZuyRG67lyyQrltAQJYtBAArGxoBSETCFp5+58yN+Pej16YeM1zW0kD
1IlcvkztnFRQmQn0OEFMb6JqnRTI2//2w5IIv2vVouhRjPuN1e4/ayipYZOTjlHD
Fso9cqhzHd6TelCXdM4rvzR645tMA0BW9P3YTuikOo0RroNMkxy4FgVpUXKGaH6y
s3OI2tom1la4qilGicnOdCef0UGCtVnFvHYKFDaOqopgqT58loZDYANang2hYtLp
24r1pOD/4Uf8W6DPrNciSf5Fhqw/6JuMKYccRqglz6nGvqK2KogLsmmTEn/3akfd
NZb5tx1Scrsu004Wt7fO7GKYDZwoKLMjxcYsGG0YgDp3jY5ZN7WAzOgB8HEiaCxt
GRnvbwBRaFEeBmLYGGlxAwQCNcn9gBCQuinKJOj4hx2li7Si8XykrzFsAVIoyo0i
q2b0p6k1CXIFIuj+nhDZRyhjpoyyJmKMwI+N9qZ9WFevG72Yvjly77I5JzlIV2gu
riyHoDMWiYL5V/HTt9tEal9EYnsiM66QFigdtFs6nMQAvIxSfIVoehD8WR4ToQy/
N73hByZ5t4Due9yMcjHlv353Pn2Et8B5kP0U+0/g/z/Sg5bwohgOgB9bYV9sYoku
txKnR6KKDsSbWHMBtE8d2mkgfTAoptgr/S5UfuZ5cvCwq/ILbJHeg5HlBQYAZMy0
ncCKLV/KCnM=
=Kgml
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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: building a django rpm, probs with adding documentation

2007-03-25 Thread Lars Stavholm

Paul Rauch wrote:
> Hello,
> 
> I'm currently building a rpm of django for suse.
> 
> But I can't figure out how to add the documentation, it doesn't get
> added, when running "python setup.py build"

Assuming that you've unpacked your source with...

%prep
%setup -q

...you should be able to do...

%files
%doc AUTHORS docs examples extras INSTALL LICENSE README

...where the doc directory contains the documentation files
that comes with the distribution.

If need be, download and install

and have a look at the spec file.

I haven't had time to test the package yet, but still.

Good Luck
/Lars

--~--~-~--~~~---~--~~
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: multiple field primary key and foreign keys as primary keys

2007-03-25 Thread Michael

Hi Francesco,
I had a similar issue the other day, and came up with a solution of
sorts - but will be interested to hear from people with more Django
experience as to whether what I've done is a good idea.

If we your example to:

class MyModel(models.Model):
field1 = ForeignKey('table1', db_index=True)
field2 = ForeignKey('table2', db_index=True)

   class Meta:
unique_together = (('field1', 'field2'),)

Then from my understanding, you should end up with a table for MyModel
that has a primary key automatically generated by Django, but your two
fields will be indexed, and you will not be able to have two records
where the combination of field1 and field2 is the same. So it has the
properties that I needed in the first place.

Does that help? Or, more importantly, can some one tell us whether
it's a bad idea?

Thanks in advance!
-Michael

Note: I think if you add the unique_together clause (or the db_index
for that matter), you'll need to either (1) recreate your database
tables (manage.py reset appname) which will destroy all your data, or
(2) modify your SQL tables manually to add the indexes and unique
fields.

On Mar 25, 10:07 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 3/25/07, checco <[EMAIL PROTECTED]> wrote:
>
>
>
> > and I want to create a primary key that is composed of field1 and
> > field 2 in table 3, is this possible in django? Can I do something
> > like...
>
> > field1 = ForeignKey('table1', primarykey=True)
> > field2= ForeignKey('table2', primarykey=True)
>
> Hi Francesco,
>
> You can make any individual field the primary key using
> `primary_key=True` - so, for example:
>
> class MyModel(models.Model):
> key = ForeignKey('table1', primary_key=True)
> data = ...
>
> would make a foreign key on Table1 the primary key on MyModel.
> However, if you give multiple fields the primary_key attribute, only
> the first will be used to designate a primary key. Django does not
> currently support multiple field primary keys.
>
> Yours,
> Russ Magee %-)


--~--~-~--~~~---~--~~
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 as a platform for a commercial SaaS project?

2007-03-25 Thread frank h.

> If I wanted to create commercial quality hosted software, would django
> be the best solution?

it depends!


--~--~-~--~~~---~--~~
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 and Routing SUBDOMAIN STYLE URL

2007-03-25 Thread Michael Cuddy

> 
> How do you test the subdomin url style in Django development server?

Since I control my own server and DNS, All of the subdomain URLs point to
the same IP.  I just have the dev server on my.ip.com:8000 (which means
that myother.ip.com and yetanother.ip.com are all CNAMEs for my.ip.com,
so the production host works, too (apache + mod_python)

--
Mike Cuddy ([EMAIL PROTECTED]), Programmer, Baritone, Daddy, Human.
Fen's Ende Software, Redwood City, CA, USA, Earth, Sol System, Milky Way.

"The problem with defending the purity of the English language is
that English is about as pure as a cribhouse whore. We don't just
borrow words; on occasion, English has pursued other languages down
alleyways to beat them unconscious and rifle their pockets for new
vocabulary." -- James D. Nicoll

   Join CAUCE: The Coalition Against Unsolicited Commercial E-mail.
  

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---