Re: How to remove an app and its tables

2010-11-05 Thread Michael Sprayberry
Margie,
    I believe this may cause issues if for some reason that there is a call to 
those tables and it still finds a reference to it. Remember to go and remove 
them from the admin register that should get rid of all references to them.
 
 
Michael



I've stopped using a particular app  in my project.  I've used South
to remove its tables, but I still see those tables referenced by the
auth, content_type, and django_project_version tables.

Is this ok?  Anyone know if it will cause me any problems down the
line?

Margie

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: enable admin gives error

2010-11-05 Thread jt
Thank you very much Russ,
the missing comma was indeed the problem.  Having corrected my syntax
it runs fine. :D
jt

On Nov 5, 12:25 am, Russell Keith-Magee 
wrote:
> On Fri, Nov 5, 2010 at 11:59 AM, jt  wrote:
> > Hi,
> > I'm just starting out.  Things ran fine until I uncomment out:
> > (r'^admin/', include(admin.site.urls))
> > in my urls.py file.  When I access my local site from the development
> > server. I get:
> > * Exception Type: TypeError
> > * Exception Value: 'tuple' object is not callable.
>
> As a general rule, this error means that you've forgotten a comma
> somewhere in a list of tuples. As a result of the missing comma,
> Python thinks the set of brackets after the missing comma indicates a
> function call on the contents of the set of brackets before the
> missing comma, and reports the error that the contents of the first
> set of brackets isn't callable. If we look at your urls.py, we see:
>
> >    (r'^People/$', 'iFriends.People.views.index')
>
> You've missed the comma on the end of this line.
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Adding "Using foo" to the end of an order by

2010-11-05 Thread benbeec...@gmail.com
I need to sort results alphanumerically. Thanks to some code floating
around #postgres (http://www.rhodiumtoad.org.uk/junk/naturalsort.sql)
I now have some handy operators to do just that. The raw sql I'd issue
to ensure that the results are sorted correctly would be something
like "select * from foo order by bar USING <#"

Manager.order_by, and extra's order_by kwarg limit their arguments to
vaild fields - is there some way I can add that part on using django's
ORM? Or do I need to issue these queries in the raw?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to remove an app and its tables

2010-11-05 Thread Margie Roginski
I've stopped using a particular app  in my project.  I've used South
to remove its tables, but I still see those tables referenced by the
auth, content_type, and django_project_version tables.

Is this ok?  Anyone know if it will cause me any problems down the
line?

Margie

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



grouping of fields inside a model into a class

2010-11-05 Thread nitm
Hi,

Is there a way to combine a set of fields I have in a model class into
a different class without it having it's own separate table?
An example:

I want to implement the user profile model class, and in it I would
like to have the address of the user.
The address is group of fields (city, street, number, zip code) and
so, instead of having this:

class UserProfile(models.Model):
city = models.ForeignKey(City)
street = models.CharField(max_length=200)
number = models.IntegerField()
zip = models.IntegerField()



I would like to do something similar to:
class Address:
city = models.ForeignKey(City)
street = models.CharField(max_length=200)
number = models.IntegerField()
zip = models.IntegerField()

class UserProfile(models.Model):
address = ???



It just seems more comfortable if I can group these fields into one
class and add methods to it (for example different string
representations) but I would still like the actual fields to be part
of the user profile table and not a new table just for address (since
it's a one to one relationship).

Is something like that possible ?
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Splitting tests.py to package

2010-11-05 Thread Jari Pennanen
I've been trying to split tests.py, but I've noticed that models
defined inside test module does not work. Normally one can define
models in tests.py like this:

class JSONFieldModel(models.Model):
json = JSONField()

class JSONFieldTest(TestCase):
def setUp(self):
pass

def test_json_serialization(self):
"""JSONField serialization"""
thedata = {'test': 5}

jsdb = JSONFieldModel(json=thedata)
jsdb.save()
del jsdb

jsdb = JSONFieldModel.objects.get(pk=1)
self.failUnlessEqual(thedata, jsdb.json,
 'JSON Serialization mismatch')

And they are created to test database just fine. But when I split the
tests.py to package and have tests/__init__.py import all, it throws
me error of not having database tables. Tests do start just fine, but
these models are not apparently created.

Is there any good workaround for this? I really like the idea of
splitting long tests.py to logical modules.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to get request.user when Django emails a 500 error report?

2010-11-05 Thread Margie Roginski
Thank you Sid!  Early on there were no responses to my question, and I
hadn't looked recently.  So just now I got back to this issue and
googled "django error email user" and what a suprise to find my own
question (with your response) came back near the top of my search!
Your response was so excellent and concise, took me just a few minutes
to get it integrated and working.  Thank you!!!

Margie

On Oct 25, 10:17 pm, Sid  wrote:
> I wrote a middleware that adds a process_exception handler. It adds
> the user info to the request.META so they show up in emails.
>
> Seehttp://gist.github.com/646372
>
> You can modify that to add any info to the emails.
>
> Sidhttp://sidmitra.com
>
> On Oct 16, 3:20 am, Margie Roginski  wrote:
>
> > I finally turned off DEBUG on my site and got set up so that the
> > django code would email me the exceptions.  This is ultra-cool!  So I
> > got m first one in the mail today, and was hard-pressed to figure out
> > the user that ran into the error.  I don't find request.user anywhere
> > in the report.  Do I need to write the process_exception() middleware
> > and add it in myself?  Anyone have an example?!
>
> > Thanks!
>
> > Margie

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



TemplateDoesNotExist - on Windows

2010-11-05 Thread deepak dhananjaya
Greetings!
  I have installed the latest django on windows, and the current folder
structure here is :

clinicmanager\clinic -  my app


clinicmanager\templates  -  template dir

i m using settings.py in clinicmanager\settings.py
TEMPLATE_DIRS = (
"C:/drives/workarea/Django/django/bin/clinicmanager/templates",
}


after that i have placed a html file in newpatient.html in templates folder.


now in views.py doing this:
return render_to_response(request, "newpatient.html", {"f":f})


even now i m getting this TemplateDoesNotExist exception..

i did go through lot of posts on this, but i have *not *installed python
through cygwin on windows..

So help REquired!!

Cheers!
Deepak

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Empty Response

2010-11-05 Thread Eric
Yep, that is what it was. Our SA did some Googling and found the
solution to the problem.

http://code.google.com/p/modwsgi/wiki/IssuesWithExpatLibrary

Thanks for the help and thoughts.


On Nov 5, 9:47 am, Eric  wrote:
> Actually, I just realized that Python is crashing silently during one
> of my method calls. But, this only happens when coming through Apache
> and not when I hit Django's own server directly. :(
>
> Thanks for the help!
>
> On Nov 5, 9:31 am, Eric  wrote:
>
> > In "Live HTTPS headers", a FF plugin, I see this:
>
> >http://cstoolstest.tnc.org/search/search?q=conservation=E...
>
> > GET /search/search?q=conservation=EAST%7CTEA=1 HTTP/
> > 1.1
>
> > Host: 
>
> > User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:
> > 1.9.2.12) Gecko/20101026 Firefox/3.6.12
>
> > Accept: application/json, text/javascript, */*
>
> > Accept-Language: en-us,en;q=0.7,de;q=0.3
>
> > Accept-Encoding: gzip,deflate
>
> > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
>
> > Keep-Alive: 115
>
> > Connection: keep-alive
>
> > Content-Type: application/x-www-form-urlencoded
>
> > X-Requested-With: XMLHttpRequest
>
> > Referer: http:///search/
>
> > HTTP/0.9 200 OK
>
> > There is no redirect and the status code is 200.
>
> > Also, in firebug I see the request sent and in my app log, I see the
> > request being received correctly. When I look at response in Firebug,
> > it is empty.
>
> > Eric
>
> > On Nov 2, 9:49 pm, adelein  wrote:
>
> > > You can easily look at the request/response by using firebug.
>
> > > TIP: Notice if there is a redirect. Sometimes depending on the config,
> > > for example, if django is set to append a / at the end, meaning it
> > > will do a redirect, then your request or response might be getting
> > > lost in the redirect (an HTTP 
> > > 302)http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>
> > > When you have django running with apache config might be different. So
> > > first step is look in firebug what requests are being made.
>
> > > On Nov 2, 3:13 pm, Reinout van Rees  wrote:
>
> > > > On 11/02/2010 09:29 PM, Eric wrote:
>
> > > > > I am returning a json structure in one of my views after the user
> > > > > performs a search when I only run Django's built in server. Following
> > > > > the asynchronous GET  I get a response with the expected json
> > > > > structure which I can then use to populate the page.
>
> > > > > However, when I have Apache in front, the response is empty. And this
> > > > > appears to be only when I make an AJAX request since all of the other
> > > > > requests and responses produce the expected results.
>
> > > > > I don't know how to go about troubleshooting this.
>
> > > > > Does anybody know what is going on here? Or, how to troubleshoot this?
>
> > > > Some random tips:
>
> > > > Take a hard look at what's actually being returned.  Empty response,
> > > > apparently.  But what about the http status code?  200 OK or 500
> > > > AARGH_ERROR?  Or something that's just not parsed as valid json?  Or
> > > > perhaps an invalid mimetype?
>
> > > > Useful tools: firebug (lets you inspect the headers).  Or just "wget" in
> > > > a pretty verbose mode.
>
> > > > Reinout
>
> > > > --
> > > > Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org
> > > > Collega's gezocht!
> > > > Django/python vacature in Utrecht:http://tinyurl.com/35v34f9

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multi-table Inheritance: How to add child to parent model?

2010-11-05 Thread ringemup
**{} is sort of the inverse of **kwargs in a function signature --
it's a way to use a dictionary in place of keyword arguments, and
should function identically.

Which "original example" are you referring to?



On Nov 5, 10:25 am, Derek  wrote:
> You mean "trying to add a Restaurant which is linked to an existing place"
>
> I am not familar with the syntax you are using for the **{} wrapper.
>
> The original example shows:
>
> r = Restaurant(place=p1, serves_hot_dogs=True, serves_pizza=False)
>
> and the attached note says:
>
> Pass the ID of the "parent" object as this object's ID.
>
> Are you sure that the place ID is, in fact, what is being transferred?
>
> On 5 November 2010 15:59, ringemup  wrote:
>
> > I'm not trying to create a Restaurant without a name and address.  I'm
> > trying to turn an existing Place into a Restaurant.
>
> > On Nov 5, 9:42 am, derek  wrote:
> > > Its not clear exactly what you think the problem is.  The system is
> > > behaving correctly ito the way you have set it up.
>
> > > 1. You have specified that name and address are compulsory fields in
> > > Place.
> > > 2. You have specifed that Restaurant must be linked to Place (i.e.
> > > Place must be created before Restaurant can be created)
>
> > > So why would you now want an entry in Restaurant that does _not_ have
> > > a name and address?
>
> > > On Nov 4, 10:25 pm, ringemup  wrote:
>
> > > > I have an existing model that I want to extend using multi-table
> > > > inheritance.  I need to create a child instance for each parent
> > > > instance in the database, but I can't figure out how.  I've scoured
> > > > google and haven't come up with anything other than Ticket #7623[1].
> > > > Here are some of the things I've tried...
>
> > > > Let's adapt the Place / Restaurant example from the docs:
>
> > > > class Place(models.Model):
> > > >     name = models.CharField(max_length=50)
> > > >     address = models.CharField(max_length=80)
>
> > > > class Restaurant(Place):
> > > >     place = models.OneToOneField(Place, parent_link=True,
> > > > related_name='restaurant')
> > > >     serves_hot_dogs = models.BooleanField()
> > > >     serves_pizza = models.BooleanField()
>
> > > > I want to do the following, in essence:
>
> > > > for place in Place.objects.all():
> > > >   restaurant = Restaurant(**{
> > > >     'place': place,
> > > >     'serves_hot_dogs': False,
> > > >     'serves_pizza': True,
> > > >   })
> > > >   restaurant.save()
>
> > > > Of course, doing this tries to also create a new Place belonging to
> > > > the new Restaurant, and throws an error because no values have been
> > > > specified for the name and address fields.  I've also tried:
>
> > > > for place in Place.objects.all():
> > > >   restaurant = Restaurant(**{
> > > >     'serves_hot_dogs': False,
> > > >     'serves_pizza': True,
> > > >   })
> > > >   place.restaurant = restaurant
> > > >   place.save()
>
> > > > This, however, doesn't create any records in the restaurant table.
>
> > > > Any suggestions?
>
> > > > [1]http://code.djangoproject.com/ticket/7623
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Forking a background process on request

2010-11-05 Thread Elver Loho
Celery is exactly what I'm looking for! Thanks! :)

On 4 November 2010 13:41, Brian Bouterse  wrote:
> I would look into django-celery to do asynchronous tasks.  It can also be
> executed as a webhooks style, see here.
>
> Brian
> On Thu, Nov 4, 2010 at 3:31 AM, Elver Loho  wrote:
>>
>> Hi,
>>
>> I am working on a web app that creates reports that may take up to a
>> minute to generate. (Or longer under heavy loads.) Ideally I would
>> like something like this to happen:
>>
>> 1. User presses a button on the website. Javascript sends a begin-
>> report-creation message to the server.
>> 2. Report creation begins on the server in a separate process and the
>> called view function returns "ok".
>> 3. A bit of Javascript checks every ten seconds if the report is done.
>> 4. If the report is done, another bit of Javascript loads it into the
>> website for display.
>>
>> My question is - what is the best way of forking a separate process in
>> step 2 to start the actual background report generation while also
>> returning an "ok" message to the calling Javascript? Or do I even need
>> a separate process? What sort of concurrency issues do I need to worry
>> about?
>>
>> Reports are currently generated once every hour by a cron-launched
>> Python script. This is working splendidly.
>>
>> Best,
>> Elver
>> P.S: Django is awesome! I've only been using it for a couple of days,
>> but I gotta say, I've never been so productive with any other
>> framework of any kind.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Brian Bouterse
> ITng Services
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multi-table Inheritance: How to add child to parent model?

2010-11-05 Thread Derek
You mean "trying to add a Restaurant which is linked to an existing place"

I am not familar with the syntax you are using for the **{} wrapper.

The original example shows:

r = Restaurant(place=p1, serves_hot_dogs=True, serves_pizza=False)

and the attached note says:

Pass the ID of the "parent" object as this object's ID.

Are you sure that the place ID is, in fact, what is being transferred?

On 5 November 2010 15:59, ringemup  wrote:

> I'm not trying to create a Restaurant without a name and address.  I'm
> trying to turn an existing Place into a Restaurant.
>
> On Nov 5, 9:42 am, derek  wrote:
> > Its not clear exactly what you think the problem is.  The system is
> > behaving correctly ito the way you have set it up.
> >
> > 1. You have specified that name and address are compulsory fields in
> > Place.
> > 2. You have specifed that Restaurant must be linked to Place (i.e.
> > Place must be created before Restaurant can be created)
> >
> > So why would you now want an entry in Restaurant that does _not_ have
> > a name and address?
> >
> > On Nov 4, 10:25 pm, ringemup  wrote:
> >
> > > I have an existing model that I want to extend using multi-table
> > > inheritance.  I need to create a child instance for each parent
> > > instance in the database, but I can't figure out how.  I've scoured
> > > google and haven't come up with anything other than Ticket #7623[1].
> > > Here are some of the things I've tried...
> >
> > > Let's adapt the Place / Restaurant example from the docs:
> >
> > > class Place(models.Model):
> > > name = models.CharField(max_length=50)
> > > address = models.CharField(max_length=80)
> >
> > > class Restaurant(Place):
> > > place = models.OneToOneField(Place, parent_link=True,
> > > related_name='restaurant')
> > > serves_hot_dogs = models.BooleanField()
> > > serves_pizza = models.BooleanField()
> >
> > > I want to do the following, in essence:
> >
> > > for place in Place.objects.all():
> > >   restaurant = Restaurant(**{
> > > 'place': place,
> > > 'serves_hot_dogs': False,
> > > 'serves_pizza': True,
> > >   })
> > >   restaurant.save()
> >
> > > Of course, doing this tries to also create a new Place belonging to
> > > the new Restaurant, and throws an error because no values have been
> > > specified for the name and address fields.  I've also tried:
> >
> > > for place in Place.objects.all():
> > >   restaurant = Restaurant(**{
> > > 'serves_hot_dogs': False,
> > > 'serves_pizza': True,
> > >   })
> > >   place.restaurant = restaurant
> > >   place.save()
> >
> > > This, however, doesn't create any records in the restaurant table.
> >
> > > Any suggestions?
> >
> > > [1]http://code.djangoproject.com/ticket/7623
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django apps and models

2010-11-05 Thread andy
Thanks for the advise, I had considers this option, and I really dose
seem that apps are move for generic features as you pointed out but I
have about 10 tables which are as depended in structure as the ones
noted above. I really don't what to have too much code in one view.py
or model.py file. For now I plan to create a customer app without the
ForeignKey relationship, work on it and when I add the branch model I
add the relationship that links them. Probably a bad idea but thats
the bes I have so far, this is something I'll need to think about a
bit more though.

Thanks for your 2c

Kimani

On Nov 5, 8:37 am, derek  wrote:
> I'll add my 2c here...
>
> I don't think you need to create an app for this (not yet).  Just
> create a normal Django project and go from there.  Apps are more meant
> for very generic types of functionality that can be used in many, many
> situations e.g. tagging.
>
> Your design is still very broad and so hard to comment on.  You may
> want to consider a many-to-many between customer and branch.  Then you
> can add data for each without being dependant on either existing
> first.  This also gives you the flexibility to link up the same
> customer to many branches.
>
> On Nov 4, 6:24 pm, andy  wrote:
>
> > Hi guys,
>
> > Say I have a CUSTOMER, BRANCH and a SALES table for my project design.
>
> > Question, should is it wise to create a customer, branch and sales
> > app. I like this idea of doing this but I have a few issues.
>
> > 1. If I create a customer app and create a Customer model class that
> > has a ForeignKey relationship with the branch table, I would seem that
> > I have to create the branch application first and create its Branch
> > model class.
>
> > 2. Also what if I plan for some reason to populate the branch table
> > using the admin interface, to avoid creating a view and templates for
> > it. Would I still make sense to create app just to host possibly one
> > model.
>
> > What came to mind what to create a app that only manages all the
> > database table or at least just table like branch which I don't plant
> > to create views for. I guess this is what generally happens in the MVC
> > frame works that are now app oriented like django.
>
> > I like the django Idea of having models in the apps at it seems more
> > portable, so I would like to keep things this way as much as possible
> > which is why I as seeking some advise on how to possibly deal with
> > this kind of situation. Maybe my opinion of an app is flawed is some
> > way, which is why I am having this issue.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: access an app on another server

2010-11-05 Thread Russ B.
I had a similar problem where I needed to get read-only access to a
Django model from a system script. I'm not sure what information
you're trying to pull, but in my own case I just wrote a view that
dumped the info I needed and write a simple authentication function
that tested the visitor's IP address to make sure it was coming from a
tuple of known and trusted static IP addresses else return a 404.

Of course, this method doesn't retain the model, but if you just need
to run a simple read-only query rather than the entire model, you
could use this method with one of the serializers to dump as XML or
JSON or just write a few lines to dump the query results as CSV then
return as "text/plain" for further processing.

Russ B.

On Nov 4, 3:28 pm, Cindy Moore  wrote:
> Hi, all.  I'm trying to figure out how to do this.  I have two django
> projects, on different servers (though I have control over each).
>
> On one of the projects (call this the primary project), I would like
> to *read* the info from the other (secondary) project.  No need to
> modify the secondary project's info, I just want to scrape its info at
> will.
>
> Now, I could just reach through the mysql databases and do direct
> queries, but I'd really rather use the other project's module
> definitions to access the information.
>
> I've set up a second database in settings.py of my primary project,
> eg
>
> DATABASES = {
>     'default': {
>         'ENGINE': 'django.db.backends.mysql',
>         'NAME': 'primary',
>         'USER': 'sysadmin',
>         'PASSWORD': 'xxx',
>         'HOST': '127.0.0.1',
>         'PORT': '',
>     },
>     # to examine the models on secondary
>     'dcswitchinfo': {
>         'ENGINE': 'django.db.backends.mysql',
>         'NAME': 'secondary',
>         'USER': 'sysadmin',
>         'PASSWORD': 'xxx',
>         'HOST': 'secondary.com',
>         'PORT': '',
>     }
>
> }
>
> Now, it seems like I'm going to have to copy the models.py from
> secondary over to the primary's directory?  I cant' see any other way
> of being able to import the relevant info when I want to write
> something up in the views.py.  That raises the question of what else
> besides models.py I'd need to copy over from the secondary project.
> Ideally I could jsut copy that over, and set up the DATABASE_ROUTERS
> to split out where it looks for each model.  (Or just do it manually
> using the 'using' method when referencing secondary's classes.)
>
> Is this a reasonable approach, or should I just bite the bullet and do
> raw sql commands to pull the info from secondary's mysql db?  Has
> anyone done this?  I googled around a fair bit, but all the extra
> database examples kept the django project as the central hub, spinning
> out the websites or the databases, but not instances of django
> installations...
>
> --Cindy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Why Won't Form Elements Display?

2010-11-05 Thread octopusgrabbus
Thanks. I'm starting from the beginning and will eventually get back
to this level of template extraction.

On Nov 5, 9:00 am, Daniel Roseman  wrote:
> On Nov 5, 12:10 pm, octopusgrabbus  wrote:
>
> > Thanks. I put back the {% block title %}, {% block head %}, and {%
> > block content %} directives, corrected the error in forms.py, but the
> > field still won't display. Any other ideas to try?
>
> Not really. Do those blocks exist in the parent template? Can you post
> the parent and edited child templates (or maybe put them in a pastebin
> somewhere and post a link here)?
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multi-table Inheritance: How to add child to parent model?

2010-11-05 Thread ringemup
I'm not trying to create a Restaurant without a name and address.  I'm
trying to turn an existing Place into a Restaurant.

On Nov 5, 9:42 am, derek  wrote:
> Its not clear exactly what you think the problem is.  The system is
> behaving correctly ito the way you have set it up.
>
> 1. You have specified that name and address are compulsory fields in
> Place.
> 2. You have specifed that Restaurant must be linked to Place (i.e.
> Place must be created before Restaurant can be created)
>
> So why would you now want an entry in Restaurant that does _not_ have
> a name and address?
>
> On Nov 4, 10:25 pm, ringemup  wrote:
>
> > I have an existing model that I want to extend using multi-table
> > inheritance.  I need to create a child instance for each parent
> > instance in the database, but I can't figure out how.  I've scoured
> > google and haven't come up with anything other than Ticket #7623[1].
> > Here are some of the things I've tried...
>
> > Let's adapt the Place / Restaurant example from the docs:
>
> > class Place(models.Model):
> >     name = models.CharField(max_length=50)
> >     address = models.CharField(max_length=80)
>
> > class Restaurant(Place):
> >     place = models.OneToOneField(Place, parent_link=True,
> > related_name='restaurant')
> >     serves_hot_dogs = models.BooleanField()
> >     serves_pizza = models.BooleanField()
>
> > I want to do the following, in essence:
>
> > for place in Place.objects.all():
> >   restaurant = Restaurant(**{
> >     'place': place,
> >     'serves_hot_dogs': False,
> >     'serves_pizza': True,
> >   })
> >   restaurant.save()
>
> > Of course, doing this tries to also create a new Place belonging to
> > the new Restaurant, and throws an error because no values have been
> > specified for the name and address fields.  I've also tried:
>
> > for place in Place.objects.all():
> >   restaurant = Restaurant(**{
> >     'serves_hot_dogs': False,
> >     'serves_pizza': True,
> >   })
> >   place.restaurant = restaurant
> >   place.save()
>
> > This, however, doesn't create any records in the restaurant table.
>
> > Any suggestions?
>
> > [1]http://code.djangoproject.com/ticket/7623
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Empty Response

2010-11-05 Thread Eric
Actually, I just realized that Python is crashing silently during one
of my method calls. But, this only happens when coming through Apache
and not when I hit Django's own server directly. :(

Thanks for the help!

On Nov 5, 9:31 am, Eric  wrote:
> In "Live HTTPS headers", a FF plugin, I see this:
>
> http://cstoolstest.tnc.org/search/search?q=conservation=E...
>
> GET /search/search?q=conservation=EAST%7CTEA=1 HTTP/
> 1.1
>
> Host: 
>
> User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:
> 1.9.2.12) Gecko/20101026 Firefox/3.6.12
>
> Accept: application/json, text/javascript, */*
>
> Accept-Language: en-us,en;q=0.7,de;q=0.3
>
> Accept-Encoding: gzip,deflate
>
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
>
> Keep-Alive: 115
>
> Connection: keep-alive
>
> Content-Type: application/x-www-form-urlencoded
>
> X-Requested-With: XMLHttpRequest
>
> Referer: http:///search/
>
> HTTP/0.9 200 OK
>
> There is no redirect and the status code is 200.
>
> Also, in firebug I see the request sent and in my app log, I see the
> request being received correctly. When I look at response in Firebug,
> it is empty.
>
> Eric
>
> On Nov 2, 9:49 pm, adelein  wrote:
>
> > You can easily look at the request/response by using firebug.
>
> > TIP: Notice if there is a redirect. Sometimes depending on the config,
> > for example, if django is set to append a / at the end, meaning it
> > will do a redirect, then your request or response might be getting
> > lost in the redirect (an HTTP 
> > 302)http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>
> > When you have django running with apache config might be different. So
> > first step is look in firebug what requests are being made.
>
> > On Nov 2, 3:13 pm, Reinout van Rees  wrote:
>
> > > On 11/02/2010 09:29 PM, Eric wrote:
>
> > > > I am returning a json structure in one of my views after the user
> > > > performs a search when I only run Django's built in server. Following
> > > > the asynchronous GET  I get a response with the expected json
> > > > structure which I can then use to populate the page.
>
> > > > However, when I have Apache in front, the response is empty. And this
> > > > appears to be only when I make an AJAX request since all of the other
> > > > requests and responses produce the expected results.
>
> > > > I don't know how to go about troubleshooting this.
>
> > > > Does anybody know what is going on here? Or, how to troubleshoot this?
>
> > > Some random tips:
>
> > > Take a hard look at what's actually being returned.  Empty response,
> > > apparently.  But what about the http status code?  200 OK or 500
> > > AARGH_ERROR?  Or something that's just not parsed as valid json?  Or
> > > perhaps an invalid mimetype?
>
> > > Useful tools: firebug (lets you inspect the headers).  Or just "wget" in
> > > a pretty verbose mode.
>
> > > Reinout
>
> > > --
> > > Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org
> > > Collega's gezocht!
> > > Django/python vacature in Utrecht:http://tinyurl.com/35v34f9

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multi-table Inheritance: How to add child to parent model?

2010-11-05 Thread derek
Its not clear exactly what you think the problem is.  The system is
behaving correctly ito the way you have set it up.

1. You have specified that name and address are compulsory fields in
Place.
2. You have specifed that Restaurant must be linked to Place (i.e.
Place must be created before Restaurant can be created)

So why would you now want an entry in Restaurant that does _not_ have
a name and address?

On Nov 4, 10:25 pm, ringemup  wrote:
> I have an existing model that I want to extend using multi-table
> inheritance.  I need to create a child instance for each parent
> instance in the database, but I can't figure out how.  I've scoured
> google and haven't come up with anything other than Ticket #7623[1].
> Here are some of the things I've tried...
>
> Let's adapt the Place / Restaurant example from the docs:
>
> class Place(models.Model):
>     name = models.CharField(max_length=50)
>     address = models.CharField(max_length=80)
>
> class Restaurant(Place):
>     place = models.OneToOneField(Place, parent_link=True,
> related_name='restaurant')
>     serves_hot_dogs = models.BooleanField()
>     serves_pizza = models.BooleanField()
>
> I want to do the following, in essence:
>
> for place in Place.objects.all():
>   restaurant = Restaurant(**{
>     'place': place,
>     'serves_hot_dogs': False,
>     'serves_pizza': True,
>   })
>   restaurant.save()
>
> Of course, doing this tries to also create a new Place belonging to
> the new Restaurant, and throws an error because no values have been
> specified for the name and address fields.  I've also tried:
>
> for place in Place.objects.all():
>   restaurant = Restaurant(**{
>     'serves_hot_dogs': False,
>     'serves_pizza': True,
>   })
>   place.restaurant = restaurant
>   place.save()
>
> This, however, doesn't create any records in the restaurant table.
>
> Any suggestions?
>
> [1]http://code.djangoproject.com/ticket/7623

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django apps and models

2010-11-05 Thread derek
I'll add my 2c here...

I don't think you need to create an app for this (not yet).  Just
create a normal Django project and go from there.  Apps are more meant
for very generic types of functionality that can be used in many, many
situations e.g. tagging.

Your design is still very broad and so hard to comment on.  You may
want to consider a many-to-many between customer and branch.  Then you
can add data for each without being dependant on either existing
first.  This also gives you the flexibility to link up the same
customer to many branches.


On Nov 4, 6:24 pm, andy  wrote:
> Hi guys,
>
> Say I have a CUSTOMER, BRANCH and a SALES table for my project design.
>
> Question, should is it wise to create a customer, branch and sales
> app. I like this idea of doing this but I have a few issues.
>
> 1. If I create a customer app and create a Customer model class that
> has a ForeignKey relationship with the branch table, I would seem that
> I have to create the branch application first and create its Branch
> model class.
>
> 2. Also what if I plan for some reason to populate the branch table
> using the admin interface, to avoid creating a view and templates for
> it. Would I still make sense to create app just to host possibly one
> model.
>
> What came to mind what to create a app that only manages all the
> database table or at least just table like branch which I don't plant
> to create views for. I guess this is what generally happens in the MVC
> frame works that are now app oriented like django.
>
> I like the django Idea of having models in the apps at it seems more
> portable, so I would like to keep things this way as much as possible
> which is why I as seeking some advise on how to possibly deal with
> this kind of situation. Maybe my opinion of an app is flawed is some
> way, which is why I am having this issue.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Empty Response

2010-11-05 Thread Eric
In "Live HTTPS headers", a FF plugin, I see this:

http://cstoolstest.tnc.org/search/search?q=conservation=EAST%7CTEA=1



GET /search/search?q=conservation=EAST%7CTEA=1 HTTP/
1.1

Host: 

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:
1.9.2.12) Gecko/20101026 Firefox/3.6.12

Accept: application/json, text/javascript, */*

Accept-Language: en-us,en;q=0.7,de;q=0.3

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 115

Connection: keep-alive

Content-Type: application/x-www-form-urlencoded

X-Requested-With: XMLHttpRequest

Referer: http:///search/


HTTP/0.9 200 OK


There is no redirect and the status code is 200.

Also, in firebug I see the request sent and in my app log, I see the
request being received correctly. When I look at response in Firebug,
it is empty.

Eric


On Nov 2, 9:49 pm, adelein  wrote:
> You can easily look at the request/response by using firebug.
>
> TIP: Notice if there is a redirect. Sometimes depending on the config,
> for example, if django is set to append a / at the end, meaning it
> will do a redirect, then your request or response might be getting
> lost in the redirect (an HTTP 
> 302)http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>
> When you have django running with apache config might be different. So
> first step is look in firebug what requests are being made.
>
> On Nov 2, 3:13 pm, Reinout van Rees  wrote:
>
> > On 11/02/2010 09:29 PM, Eric wrote:
>
> > > I am returning a json structure in one of my views after the user
> > > performs a search when I only run Django's built in server. Following
> > > the asynchronous GET  I get a response with the expected json
> > > structure which I can then use to populate the page.
>
> > > However, when I have Apache in front, the response is empty. And this
> > > appears to be only when I make an AJAX request since all of the other
> > > requests and responses produce the expected results.
>
> > > I don't know how to go about troubleshooting this.
>
> > > Does anybody know what is going on here? Or, how to troubleshoot this?
>
> > Some random tips:
>
> > Take a hard look at what's actually being returned.  Empty response,
> > apparently.  But what about the http status code?  200 OK or 500
> > AARGH_ERROR?  Or something that's just not parsed as valid json?  Or
> > perhaps an invalid mimetype?
>
> > Useful tools: firebug (lets you inspect the headers).  Or just "wget" in
> > a pretty verbose mode.
>
> > Reinout
>
> > --
> > Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org
> > Collega's gezocht!
> > Django/python vacature in Utrecht:http://tinyurl.com/35v34f9

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to aggregate values by month

2010-11-05 Thread derek
Maybe slightly "off topic" but does anyone have robust strategies for
readily switching between different DB-specific SQL code which is
(presumably) embedded in one's app/project?  (As shown in the two
examples presented here)

On Nov 5, 1:10 am, David Zhou  wrote:
> FWIW, on Postgres DBs, I've done the following:
>
> qs = FooModel.objects.filter(date__gte=start_date,
> date__lt=end_date).extra(select={'datetrunc': "date_trunc('month',
> date)"}).values('datetrunc').annotate(total=Sum("value"))
>
> date_trunc in postgres also accepts "day" and "week" truncations.
>
> -- dz
>
> 2010/11/4 Rogério Carrasqueira 
>
> > Hello Folks!
>
> > I've got the solution, putting here for future searchs:
>
> > sales =
> > Sale.objects.extra(select={'month':'month(date_created)','year':'year(date_created)'}).values('year','month').annotate(total_month=Sum('total_value'),
> > average_month=Avg('total_value'))
>
> > This query works only using MySQL, to use with PGSQL you need to know to
> > work with EXTRACT clauses.
>
> > Cheers
>
> > Rogério Carrasqueira
>
> > ---
> > e-mail: rogerio.carrasque...@gmail.com
> > skype: rgcarrasqueira
> > MSN: rcarrasque...@hotmail.com
> > ICQ: 50525616
> > Tel.: (11) 7805-0074
>
> > Em 4 de novembro de 2010 10:34, Rogério Carrasqueira <
> > rogerio.carrasque...@gmail.com> escreveu:
>
> > Hi Sebastien!
>
> >> Thanks for you reply. I'm a newbie on Django and I must confess
> >> unfortunately I don't know everything yet ;-). So I saw that you made a
> >> snippet regarding about the use of Django Cube. So, where do I put this
> >> snippet: at my views.py? Or should I do another class at my models.py?
>
> >> Thanks so much!
>
> >> Regards,
>
> >> Rogério Carrasqueira
>
> >> ---
> >> e-mail: rogerio.carrasque...@gmail.com
> >> skype: rgcarrasqueira
> >> MSN: rcarrasque...@hotmail.com
>
> >> ICQ: 50525616
> >> Tel.: (11) 7805-0074
>
> >> 2010/10/29 sebastien piquemal 
>
> >> Hi !
>
> >>> You could also give django-cube a try :
> >>>http://code.google.com/p/django-cube/
> >>> Unlike Mikhail's app, the aggregates are not efficient (because no
> >>> optimization is made, I am working on this), but this is more than
> >>> enough if you have a reasonable amount of data (less than millions of
> >>> rows !!!).
> >>> Use the following code, and you should have what you need :
>
> >>>    from cube.models import Cube
>
> >>>    class SalesCube(Cube):
>
> >>>        month = Dimension('date_created__absmonth',
> >>> queryset=Sale.objects.filter(date_created__range=(init_date,ends_date)))
>
> >>>       �...@staticmethod
> >>>        def aggregation(queryset):
> >>>            return queryset.count()
>
> >>> The advantage is that if you want to add more dimensions (type of sale/
> >>> place/month, etc ...), you can do it very easily.
> >>> Hope that helps, and don't hesitate to ask me if you can't have it
> >>> working (documentation is not very good yet).
>
> >>> On Oct 29, 12:54 am, Mikhail Korobov  wrote:
> >>> > Hi Rogério,
>
> >>> > You can givehttp://bitbucket.org/kmike/django-qsstats-magic/srca
> >>> > try.
> >>> > It currently have efficient aggregate lookups (1 query for the whole
> >>> > time series) only for mysql but it'll be great if someone contribute
> >>> > efficient lookups for other databases :)
>
> >>> > On 28 окт, 19:31, Rogério Carrasqueira
>
> >>> >  wrote:
> >>> > > Hello!
>
> >>> > > I'm having an issue to make complex queries in django. My problem is,
> >>> I have
> >>> > > a model where I have the sales and I need to make a report showing
> >>> the sales
> >>> > > amount per month, by the way I made this query:
>
> >>> > > init_date = datetime.date(datetime.now()-timedelta(days=365))
> >>> > > ends_date = datetime.date(datetime.now())
> >>> > > sales =
>
> >>> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_
> >>> created__month).aggregate(total_sales=Sum('total_value'))
>
> >>> > > At the first line I get the today's date past one year
> >>> > > after this I got the today date
>
> >>> > > at sales I'm trying to between a range get the sales amount grouped
> >>> by
> >>> > > month, but unfortunatelly I was unhappy on this, because this error
> >>> > > appeared:
>
> >>> > > global name 'date_created__month' is not defined
>
> >>> > > At date_created is the field where I store the information about when
> >>> the
> >>> > > sale was done., the __moth was a tentative to group by this by month.
>
> >>> > > So, my question: how to do that thing without using a raw sql query
> >>> and not
> >>> > > touching on database independence?
>
> >>> > > Thanks so much!
>
> >>> > > Rogério Carrasqueira
>
> >>> > > ---
> >>> > > e-mail: rogerio.carrasque...@gmail.com
> >>> > > skype: rgcarrasqueira
> >>> > > MSN: rcarrasque...@hotmail.com
> >>> > > ICQ: 50525616
> >>> > > Tel.: (11) 7805-0074
>
> >>> --
> >>> You received this message because you are 

Strange Error

2010-11-05 Thread mwarkentin
In the middle of the night, I started getting a bunch of emails about
server errors on my Django app.  I haven't touched it for over a
month.

I logged onto the server and restarted Apache.. the error continued
popping up for a couple of seconds, and then everything went back to
normal.

Any ideas what could've caused this?

Here's the stack trace:

Traceback (most recent call last):

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/
core/handlers/base.py", line 86, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/
views/generic/date_based.py", line 28, in archive_index
   date_list = queryset.dates(date_field, 'year')[::-1]

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/db/
models/query.py", line 234, in __getitem__
   return k.step and list(qs)[::k.step] or qs

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/db/
models/query.py", line 162, in __len__
   self._result_cache.extend(list(self._iter))

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/db/
models/sql/subqueries.py", line 377, in results_iter
   for rows in self.execute_sql(MULTI):

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/db/
models/sql/query.py", line 1733, in execute_sql
   cursor = self.connection.cursor()

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/db/
backends/__init__.py", line 56, in cursor
   cursor = self._cursor(settings)

 File "/home/mwarkentin/webapps/come_together/lib/python2.5/django/db/
backends/postgresql_psycopg2/base.py", line 90, in _cursor
   cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])

DataError: unrecognized time zone name: "America/Toronto"



,
POST:,
COOKIES:{},
META:{'DOCUMENT_ROOT': '/etc/httpd/htdocs',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': '*/*',
 'HTTP_ACCEPT_CHARSET': 'utf-8;q=0.7,iso-8859-1;q=0.2,*;q=0.1',
 'HTTP_ACCEPT_ENCODING': 'gzip',
 'HTTP_CONNECTION': 'close',
 'HTTP_HOST': 'come-together.ca',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; DotBot/1.1;
http://www.dotnetdotcom.org/, craw...@dotnetdotcom.org)',
 'HTTP_X_FORWARDED_FOR': '208.115.111.244',
 'HTTP_X_FORWARDED_HOST': 'come-together.ca',
 'PATH': '/usr/bin:/bin',
 'PATH_INFO': u'/events/',
 'PATH_TRANSLATED': '/home/mwarkentin/webapps/come_together/
come_together.wsgi/events/',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '127.0.0.1',
 'REMOTE_PORT': '44902',
 'REQUEST_METHOD': 'GET',
 'REQUEST_URI': '/events/',
 'SCRIPT_FILENAME': '/home/mwarkentin/webapps/come_together/
come_together.wsgi',
 'SCRIPT_NAME': u'',
 'SERVER_ADDR': '127.0.0.1',
 'SERVER_ADMIN': '[no address given]',
 'SERVER_NAME': 'come-together.ca',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'SERVER_SIGNATURE': '',
 'SERVER_SOFTWARE': 'Apache/2.2.3 (CentOS) mod_wsgi/2.0 Python/2.5.4',
 'mod_wsgi.application_group': 'web47.webfaction.com|',
 'mod_wsgi.callable_object': 'application',
 'mod_wsgi.listener_host': '',
 'mod_wsgi.listener_port': '7379',
 'mod_wsgi.process_group': '',
 'mod_wsgi.reload_mechanism': '0',
 'mod_wsgi.script_reloading': '1',
 'wsgi.errors': ,
 'wsgi.file_wrapper': ,
 'wsgi.input': ,
- Hide quoted text -
 'wsgi.multiprocess': True,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Why Won't Form Elements Display?

2010-11-05 Thread Daniel Roseman
On Nov 5, 12:10 pm, octopusgrabbus  wrote:
> Thanks. I put back the {% block title %}, {% block head %}, and {%
> block content %} directives, corrected the error in forms.py, but the
> field still won't display. Any other ideas to try?

Not really. Do those blocks exist in the parent template? Can you post
the parent and edited child templates (or maybe put them in a pastebin
somewhere and post a link here)?
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: inserting bits of javascript into individual pages

2010-11-05 Thread Daniel Roseman
On Nov 5, 8:26 am, Ellen  wrote:
> Dear all,
>
> I am just learning the ropes of django so please direct me to a better
> place if my question has been asked a million times before or plain
> ridiculous.
>
> I am managing a website that uses the django platform -- I am not
> responsible for building it from scratch so the basic functionality is
> already there, but I am managing the database, customising the css,
> templates and adding content etc. My programming knowledge is fairly
> basic, but not nothing...
>
> My question is:
> I would like to add bits of javascript to individual pages on the
> site, such as heatmaps and polymaps, interactive google gadgets, some
> movies and also some games written in flash.
> With our old site, I would just insert the standard  the html.
>
> How do I insert these kind of things into the django-based site?
> -I have tried pasting them into the html box of a text widget via the
> django admin page without success
> -I have also tried adding them to a base_x.html file with their own
> css but this seems to overwrite the base template and fill the whole
> browser and so doesn't fit in with the site.
>
> -Do I need to create a base_x.html template for each jscript I wish to
> include? i.e. one for games, one for maps, one for interactive
> gadgets?
> or do I need to add a django widget that deals with jscript?
> or is it not possible to dynamically add bits of code here and there?
>
> Thanks very much in advance!
>
> Ellen

It's not really clear what you are asking. For instance "pasting them
into the html box of a text widget" doesn't really make sense.

I suspect your issue is that you're thinking of Django as a CMS in
itself, which it isn't - it's a tool for building CMSes. So whoever's
built your system will know the right way of including page-specific
javascript.

One thing I can tell you though is that Django's templating system
works in terms of blocks, which are defined in a parent template and
overridden in the children, so you should be able to override the
relevant blocks in your page template to include the javascript. You
might benefit from reading the template documentation here:
http://docs.djangoproject.com/en/1.2/topics/templates/
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: inserting bits of javascript into individual pages

2010-11-05 Thread Tereno
Hi Ellen,

Sounds like what you're looking to do is template inheritance. You can
most definitely add dynamic bits of code based on individual pages.
Some documentation on the topic can be found here:
http://docs.djangoproject.com/en/dev/topics/templates/

Basically what I think you'll need is to create a main template and
have your individual page inherit it:

-
maintemplate.html:


   
  {% block content %}{% endblock %}
   


-
flashpage.html:

{% extends "maintemplate.html" %}
{% block content %}

 
{% endblock %}

-

That said, if that doesn't answer your question or it's not clear to
you, my apologies and don't hesitate to question more.

Cheers,
Teren

On Nov 5, 4:26 am, Ellen  wrote:
> Dear all,
>
> I am just learning the ropes of django so please direct me to a better
> place if my question has been asked a million times before or plain
> ridiculous.
>
> I am managing a website that uses the django platform -- I am not
> responsible for building it from scratch so the basic functionality is
> already there, but I am managing the database, customising the css,
> templates and adding content etc. My programming knowledge is fairly
> basic, but not nothing...
>
> My question is:
> I would like to add bits of javascript to individual pages on the
> site, such as heatmaps and polymaps, interactive google gadgets, some
> movies and also some games written in flash.
> With our old site, I would just insert the standard  the html.
>
> How do I insert these kind of things into the django-based site?
> -I have tried pasting them into the html box of a text widget via the
> django admin page without success
> -I have also tried adding them to a base_x.html file with their own
> css but this seems to overwrite the base template and fill the whole
> browser and so doesn't fit in with the site.
>
> -Do I need to create a base_x.html template for each jscript I wish to
> include? i.e. one for games, one for maps, one for interactive
> gadgets?
> or do I need to add a django widget that deals with jscript?
> or is it not possible to dynamically add bits of code here and there?
>
> Thanks very much in advance!
>
> Ellen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Why Won't Form Elements Display?

2010-11-05 Thread octopusgrabbus
Thanks. I put back the {% block title %}, {% block head %}, and {%
block content %} directives, corrected the error in forms.py, but the
field still won't display. Any other ideas to try?

On Nov 4, 6:44 pm, Daniel Roseman  wrote:
> On Nov 4, 10:32 pm, octopusgrabbus  wrote:
>
>
>
> > I have a forms class in forms.py
>
> > from django import forms
>
> > class ReadSnapForm(forms.Form):
> >     cycle = forms.CharField(max_length=1)
> >     message = forms.CharField(widget-forms.Textarea,required=False)
>
> > Here is the form that uses the class
> > {% extends "base.html" %}
>
> > 
> > 
> >     Enter Billing Cycle
> > 
> > 
> >         Enter Billing Cycle
> >         {% if form.errors %}
> >         
> >             Please correct the error{{ form.errors|pluralize }} below.
> >         
> >         {% endif %}
>
> >          {% csrf_token %}
> >             
> >                 {{ form.as_table }}
> >             
> >             
> >         
> > 
> > 
>
> > Here's the code in views.py
>
> > from forms import ReadSnapForm
>
> > def read_snap(request):
> >     if request.method == 'POST':
> >         form = ReadSnapForm(request.POST)
> >         if form.is_valid():
> >             cleaned_data = form.cleaned_data
> >             return HttpResponseRedirect('/read_snap/
> > after_read_snap.html')
> >     else:
> >         form = ReadSnapForm()
>
> >     return render_to_response('/read_snap/read_snap.html', {'form':
> > form})
>
> > I can get to the form through an href on a main page, but nothing
> > displays on the form.
>
> > What am I doing wrong?
>
> There's a typo in the message field declaration, but presumably that's
> not actually in your code, as it wouldn't even compile, so I'm
> assuming it's just a copy/paste issue.
>
> The actual issue is nothing to do with forms - it's in your template.
> You're extending base.html, but not providing any {% block %} elements
> to actually insert into that parent template. As a result, the parent
> is just displayed, without any of the child data.
>
> Either remove the {% extends %} tag, or provide the proper {% block %}
> elements that override blocks in your parent, and put the form HTML in
> there.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-avatar image src

2010-11-05 Thread Sithembewena Lloyd Dube
Mario, thank you very much! You just made my day.

Regards,
Lloyd

On Fri, Nov 5, 2010 at 1:23 PM, Mário Neto  wrote:

> instead this:
> MEDIA_URL = os.path.realpath(PROJECT_PATH + '/media/')
> try:
> MEDIA_URL = '/media/'
>
> 2010/11/5 Sithembewena Lloyd Dube 
>
>> Update: I added AVATAR_STORAGE_DIR = MEDIA_ROOT to my settings.py file.
>>
>> When I load the page, the avatar's src is
>> "C:/Websites/TPFRepository/projectname/media/username/image.jpg" - which is
>> correct. if i paste that into Windows Explorer, I do find the image.
>>
>> Still, it is not displayed on the page. What am I missing? Any help would
>> be appreciated.
>>
>> Thanks,
>> Sithu.
>>
>>
>> On Fri, Nov 5, 2010 at 10:58 AM, Sithembewena Lloyd Dube <
>> zebr...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I installed the django-avatar app in my project and, in a template, i
>>> have the {% load avatar_tags %} and {% avatar user 65 %} template tags. When
>>> I load the page and view source, the avatar's alt tag is correct but the
>>> image src is wrong. It appears relative to the template's directory instead
>>> of pointing to the project's media directory. Naturally, it is not found
>>> there and does not display.
>>>
>>> In settings.py, I have:
>>>
>>> import os
>>> PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
>>> MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
>>> MEDIA_URL = os.path.realpath(PROJECT_PATH + '/media/')
>>>
>>> What can I do to have the image src pointing to the correct avatar
>>> directory (C:\Websites\ProjectRepository\projectname\media)?
>>>
>>> Thanks...
>>>
>>> --
>>> Regards,
>>> Sithembewena Lloyd Dube
>>> http://www.lloyddube.com
>>>
>>
>>
>>
>> --
>> Regards,
>> Sithembewena Lloyd Dube
>> http://www.lloyddube.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Att. Mário A. Chaves Neto
> Designer / U.I. Engineer
> MBA - Design Digital
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-avatar image src

2010-11-05 Thread Mário Neto
instead this:
MEDIA_URL = os.path.realpath(PROJECT_PATH + '/media/')
try:
MEDIA_URL = '/media/'

2010/11/5 Sithembewena Lloyd Dube 

> Update: I added AVATAR_STORAGE_DIR = MEDIA_ROOT to my settings.py file.
>
> When I load the page, the avatar's src is
> "C:/Websites/TPFRepository/projectname/media/username/image.jpg" - which is
> correct. if i paste that into Windows Explorer, I do find the image.
>
> Still, it is not displayed on the page. What am I missing? Any help would
> be appreciated.
>
> Thanks,
> Sithu.
>
>
> On Fri, Nov 5, 2010 at 10:58 AM, Sithembewena Lloyd Dube <
> zebr...@gmail.com> wrote:
>
>> Hi all,
>>
>> I installed the django-avatar app in my project and, in a template, i have
>> the {% load avatar_tags %} and {% avatar user 65 %} template tags. When I
>> load the page and view source, the avatar's alt tag is correct but the image
>> src is wrong. It appears relative to the template's directory instead of
>> pointing to the project's media directory. Naturally, it is not found there
>> and does not display.
>>
>> In settings.py, I have:
>>
>> import os
>> PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
>> MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
>> MEDIA_URL = os.path.realpath(PROJECT_PATH + '/media/')
>>
>> What can I do to have the image src pointing to the correct avatar
>> directory (C:\Websites\ProjectRepository\projectname\media)?
>>
>> Thanks...
>>
>> --
>> Regards,
>> Sithembewena Lloyd Dube
>> http://www.lloyddube.com
>>
>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Att. Mário A. Chaves Neto
Designer / U.I. Engineer
MBA - Design Digital

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



inserting bits of javascript into individual pages

2010-11-05 Thread Ellen
Dear all,

I am just learning the ropes of django so please direct me to a better
place if my question has been asked a million times before or plain
ridiculous.

I am managing a website that uses the django platform -- I am not
responsible for building it from scratch so the basic functionality is
already there, but I am managing the database, customising the css,
templates and adding content etc. My programming knowledge is fairly
basic, but not nothing...

My question is:
I would like to add bits of javascript to individual pages on the
site, such as heatmaps and polymaps, interactive google gadgets, some
movies and also some games written in flash.
With our old site, I would just insert the standard http://groups.google.com/group/django-users?hl=en.



how to use csvimport.py successfully - integrity error _id moy not be null

2010-11-05 Thread shofty
ive built a mini shop as part of a project. im trying to drag content
in from csv, using one of the django snippets link:(http://
djangosnippets.org/snippets/788/)

so my models are Brand Category Product and product references both a
brand and a category.

python csvimport.py --csv dubkorps.csv --mappings "1=partno,
2=brand1(Brand|id),3=category1(Category|id),4=pr..
snipped for brevity, but that is the format of the import statement.
however the foreign key doesnt work, it fails with

django.db.utils.IntegrityError: shop_product.brand1_id may not be NULL

it fails with this same error whether i put brand.name or brand.id
into the csv file.

anyone used this csvimport successfully?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Sample Auto Log Out Code

2010-11-05 Thread Daniel Roseman
On Nov 3, 12:43 pm, octopusgrabbus  wrote:
> Does anyone have samples for auto logging out a user?

What do you mean by 'auto logging out'?
--
DR,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Sample Auto Log Out Code

2010-11-05 Thread Daniel Roseman
On Nov 5, 6:51 am, derek  wrote:
> Fred
>
> This seems not related to the original topic; please start a new
> thread.

That seems to be a constant issue with Fred's posts: I think every one
of his that I've seen has been added onto the end of an existing
thread, while changing the subject.

Fred, please start new threads when you want to ask a question
unrelated to the original post.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-avatar image src

2010-11-05 Thread Sithembewena Lloyd Dube
Update: I added AVATAR_STORAGE_DIR = MEDIA_ROOT to my settings.py file.

When I load the page, the avatar's src is
"C:/Websites/TPFRepository/projectname/media/username/image.jpg" - which is
correct. if i paste that into Windows Explorer, I do find the image.

Still, it is not displayed on the page. What am I missing? Any help would be
appreciated.

Thanks,
Sithu.

On Fri, Nov 5, 2010 at 10:58 AM, Sithembewena Lloyd Dube
wrote:

> Hi all,
>
> I installed the django-avatar app in my project and, in a template, i have
> the {% load avatar_tags %} and {% avatar user 65 %} template tags. When I
> load the page and view source, the avatar's alt tag is correct but the image
> src is wrong. It appears relative to the template's directory instead of
> pointing to the project's media directory. Naturally, it is not found there
> and does not display.
>
> In settings.py, I have:
>
> import os
> PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
> MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
> MEDIA_URL = os.path.realpath(PROJECT_PATH + '/media/')
>
> What can I do to have the image src pointing to the correct avatar
> directory (C:\Websites\ProjectRepository\projectname\media)?
>
> Thanks...
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.com
>



-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-avatar image src

2010-11-05 Thread Sithembewena Lloyd Dube
Hi all,

I installed the django-avatar app in my project and, in a template, i have
the {% load avatar_tags %} and {% avatar user 65 %} template tags. When I
load the page and view source, the avatar's alt tag is correct but the image
src is wrong. It appears relative to the template's directory instead of
pointing to the project's media directory. Naturally, it is not found there
and does not display.

In settings.py, I have:

import os
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
MEDIA_URL = os.path.realpath(PROJECT_PATH + '/media/')

What can I do to have the image src pointing to the correct avatar directory
(C:\Websites\ProjectRepository\projectname\media)?

Thanks...

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



index for fields with unique=True and db_index True

2010-11-05 Thread jordi
When I create the following model I get an index for field2 with syndb
or sqlindexes. Why doesn't it create an index for field3?

from django.db import models
class Entitat(models.Model):
field1 = models.CharField(max_length=4, unique=True)
field2 = models.CharField(max_length=4, db_index=True )
field3 = models.CharField(max_length=4, unique=True,
db_index=True )

To create an index for field3 I have to remove "unique=True", create
the index and after add again "unique=True", so django admin captures
non unique entries.

I am using sqlite (with spatialite).

I don't know if this is a bug, a feature or I understand something
wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Sample Auto Log Out Code

2010-11-05 Thread derek
Fred

This seems not related to the original topic; please start a new
thread.

On Nov 3, 2:56 pm, "Sells, Fred"  wrote:
> I'm running on Windows 7, Python 2.4 and Django 1.2.1
>
> I'm trying to change one table "facility" by dropping it and then
> letting syncdb recreate it.  I thought syncdb was supposed to ignore
> already created tables, but that does not appear to be the case.  
>
> What am I doing wrong?
>
> >python manage.py syncdb
>
> Creating table facility
> Creating table Assessment
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
>     execute_manager(settings)
>   File
> "c:\alltools\python\Lib\site-packages\django\core\management\__init__.py
> ", line 438, in execute_manager
>     utility.execute()
>   File
> "c:\alltools\python\Lib\site-packages\django\core\management\__init__.py
> ", line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "c:\alltools\python\Lib\site-packages\django\core\management\base.py",
> line 191, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File
> "c:\alltools\python\Lib\site-packages\django\core\management\base.py",
> line 218, in execute
>     output = self.handle(*args, **options)
>   File
> "c:\alltools\python\Lib\site-packages\django\core\management\base.py",
> line 347, in handle
>     return self.handle_noargs(**options)
>   File
> "c:\alltools\python\Lib\site-packages\django\core\management\commands\sy
> ncdb.py", line 95, in handle_noargs
>     cursor.execute(statement)
>   File
> "c:\alltools\python\Lib\site-packages\django\db\backends\util.py", line
> 15, in execute
>     return self.cursor.execute(sql, params)
>   File
> "c:\alltools\python\Lib\site-packages\django\db\backends\mysql\base.py",
> line 86, in execute
>     return self.cursor.execute(query, args)
>   File
> "c:\alltools\python\lib\site-packages\mysql_python-1.2.2-py2.4-win32.egg
> \MySQLdb\cursors.py", line 166, in execute
>   File
> "c:\alltools\python\lib\site-packages\mysql_python-1.2.2-py2.4-win32.egg
> \MySQLdb\connections.py", line 35, in defaulterrorhandler
> _mysql_exceptions.OperationalError: (1050, "Table 'assessment' already
> exists")

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: access an app on another server

2010-11-05 Thread Russell Keith-Magee
On Fri, Nov 5, 2010 at 6:28 AM, Cindy Moore  wrote:
> Hi, all.  I'm trying to figure out how to do this.  I have two django
> projects, on different servers (though I have control over each).
>
> On one of the projects (call this the primary project), I would like
> to *read* the info from the other (secondary) project.  No need to
> modify the secondary project's info, I just want to scrape its info at
> will.
>
> Now, I could just reach through the mysql databases and do direct
> queries, but I'd really rather use the other project's module
> definitions to access the information.
>
> I've set up a second database in settings.py of my primary project,
> eg
>
> DATABASES = {
>    'default': {
>        'ENGINE': 'django.db.backends.mysql',
>        'NAME': 'primary',
>        'USER': 'sysadmin',
>        'PASSWORD': 'xxx',
>        'HOST': '127.0.0.1',
>        'PORT': '',
>    },
>    # to examine the models on secondary
>    'dcswitchinfo': {
>        'ENGINE': 'django.db.backends.mysql',
>        'NAME': 'secondary',
>        'USER': 'sysadmin',
>        'PASSWORD': 'xxx',
>        'HOST': 'secondary.com',
>        'PORT': '',
>    }
> }
>
> Now, it seems like I'm going to have to copy the models.py from
> secondary over to the primary's directory?  I cant' see any other way
> of being able to import the relevant info when I want to write
> something up in the views.py.  That raises the question of what else
> besides models.py I'd need to copy over from the secondary project.
> Ideally I could jsut copy that over, and set up the DATABASE_ROUTERS
> to split out where it looks for each model.  (Or just do it manually
> using the 'using' method when referencing secondary's classes.)
>
> Is this a reasonable approach, or should I just bite the bullet and do
> raw sql commands to pull the info from secondary's mysql db?  Has
> anyone done this?  I googled around a fair bit, but all the extra
> database examples kept the django project as the central hub, spinning
> out the websites or the databases, but not instances of django
> installations...

You shouldn't need to copy anything, models.py or otherwise. It's just
a matter of setting up your PYTHONPATH.

Yes, Django's tutorial suggests that you use a 'project' as a hub, but
that not a requirement. A Django application is just a Python module
that happens to contain a models.py file. As long as that app/module
is on your PYTHONPATH, you can import and use it in your project.

So - put the apps from project 2 on your PYTHONPATH, and reference
them in the INSTALLED_APPS for project 1, and you should be able to
import those models, use them to query your secondary database, and/or
use a router to direct query traffic as required.

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: enable admin gives error

2010-11-05 Thread Russell Keith-Magee
On Fri, Nov 5, 2010 at 11:59 AM, jt  wrote:
> Hi,
> I'm just starting out.  Things ran fine until I uncomment out:
> (r'^admin/', include(admin.site.urls))
> in my urls.py file.  When I access my local site from the development
> server. I get:
> * Exception Type: TypeError
> * Exception Value: 'tuple' object is not callable.

As a general rule, this error means that you've forgotten a comma
somewhere in a list of tuples. As a result of the missing comma,
Python thinks the set of brackets after the missing comma indicates a
function call on the contents of the set of brackets before the
missing comma, and reports the error that the contents of the first
set of brackets isn't callable. If we look at your urls.py, we see:

>    (r'^People/$', 'iFriends.People.views.index')

You've missed the comma on the end of this line.

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



enable admin gives error

2010-11-05 Thread jt
Hi,
I'm just starting out.  Things ran fine until I uncomment out:
(r'^admin/', include(admin.site.urls))
in my urls.py file.  When I access my local site from the development
server. I get:
* Exception Type: TypeError
* Exception Value: 'tuple' object is not callable.
My urls.py file contains:
from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^People/$', 'iFriends.People.views.index')

# Example:
# (r'^iFriends/', include('iFriends.foo.urls')),

# Uncomment the admin/doc line below to enable admin
documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
 thanks in advance for any help.
jt

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



access an app on another server

2010-11-05 Thread Cindy Moore
Hi, all.  I'm trying to figure out how to do this.  I have two django
projects, on different servers (though I have control over each).

On one of the projects (call this the primary project), I would like
to *read* the info from the other (secondary) project.  No need to
modify the secondary project's info, I just want to scrape its info at
will.

Now, I could just reach through the mysql databases and do direct
queries, but I'd really rather use the other project's module
definitions to access the information.

I've set up a second database in settings.py of my primary project,
eg

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'primary',
'USER': 'sysadmin',
'PASSWORD': 'xxx',
'HOST': '127.0.0.1',
'PORT': '',
},
# to examine the models on secondary
'dcswitchinfo': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'secondary',
'USER': 'sysadmin',
'PASSWORD': 'xxx',
'HOST': 'secondary.com',
'PORT': '',
}
}

Now, it seems like I'm going to have to copy the models.py from
secondary over to the primary's directory?  I cant' see any other way
of being able to import the relevant info when I want to write
something up in the views.py.  That raises the question of what else
besides models.py I'd need to copy over from the secondary project.
Ideally I could jsut copy that over, and set up the DATABASE_ROUTERS
to split out where it looks for each model.  (Or just do it manually
using the 'using' method when referencing secondary's classes.)

Is this a reasonable approach, or should I just bite the bullet and do
raw sql commands to pull the info from secondary's mysql db?  Has
anyone done this?  I googled around a fair bit, but all the extra
database examples kept the django project as the central hub, spinning
out the websites or the databases, but not instances of django
installations...

--Cindy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.