SOAPpy and pyxml installation/usage

2008-12-11 Thread Steve

This may be a more of a generic Python question, but I'm working with
Django so thought that I'd see if there's a Django specific solution
to it.

I'm trying to work with SOAP. I'm new to it and a Jr. programmer as
well. From Dive into Python it has this great example about how to
handle SOAP calls.
http://www.diveintopython.org/soap_web_services/index.html

The problem is that I'm trying to install the SOAPpy module and it
requires pyxml, which appears to be no longer available or supported.
http://pyxml.sourceforge.net/

My main goal is to configuremy system to get this code, from the dive
into python link above, to run. Or to find an equivalent set of
packages that work instead. I'm working on windows with python 2.5.1,
with Django .96. I deploy on ubuntu linux. Any thoughts?

...
from SOAPpy import WSDL

# you'll need to configure these two values;
# see http://www.google.com/apis/
WSDLFILE = '/path/to/copy/of/GoogleSearch.wsdl'
APIKEY = 'YOUR_GOOGLE_API_KEY'

_server = WSDL.Proxy(WSDLFILE)
def search(q):
"""Search Google and return list of {title, link, description}"""
results = _server.doGoogleSearch(
APIKEY, q, 0, 10, False, "", False, "", "utf-8", "utf-8")
return [{"title": r.title.encode("utf-8"),
 "link": r.URL.encode("utf-8"),
 "description": r.snippet.encode("utf-8")}
for r in results.resultElements]




--~--~-~--~~~---~--~~
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: SOAPpy and pyxml installation/usage

2008-12-12 Thread Steve

Hello Paul,

Thanks for pointing me in the right direction. I had already
downloaded and installed ZSI 2.0 but failed to gain any utility from
it. Now I know where to apply my efforts. I'm still trying to get a
basic call response working with ZSI. :\ I'll post for posterity when
I figure out how to convert the above code to ZSI.

-Steve

On Dec 11, 5:57 am, "Paul Nendick"  wrote:
> Hello Steve,
> SOAPy appears to be moribund. I was once using it within a Python SOA
> I'd worked with and chose to abandon it when we moved that system to
> Python 2.5. It wasn't an issue for us as SOAP was going nowhere (for
> us anyway).
> Good news for you (possibly) is the SOAP infrastructure generally
> discussed by the Twisted Matrix community: ZSI.
>
> Relevant code:http://tinyurl.com/betterthansoapy
>
> Full project:http://pywebsvcs.sourceforge.net/
>
> What I feel is the best XML library for 
> Python:http://uche.ogbuji.net/tech/4suite/amara/
>
> regards,
>
> /p
>
> 2008/12/11 Steve 
>
>
>
> > This may be a more of a generic Python question, but I'm working with
> > Django so thought that I'd see if there's a Django specific solution
> > to it.
>
> > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as
> > well. From Dive into Python it has this great example about how to
> > handle SOAP calls.
> >http://www.diveintopython.org/soap_web_services/index.html
>
> > The problem is that I'm trying to install the SOAPpy module and it
> > requires pyxml, which appears to be no longer available or supported.
> >http://pyxml.sourceforge.net/
>
> > My main goal is to configuremy system to get this code, from the dive
> > into python link above, to run. Or to find an equivalent set of
> > packages that work instead. I'm working on windows with python 2.5.1,
> > with Django .96. I deploy on ubuntu linux. Any thoughts?
>
> > ...
> > from SOAPpy import WSDL
>
> > # you'll need to configure these two values;
> > # seehttp://www.google.com/apis/
> > WSDLFILE = '/path/to/copy/of/GoogleSearch.wsdl'
> > APIKEY = 'YOUR_GOOGLE_API_KEY'
>
> > _server = WSDL.Proxy(WSDLFILE)
> > def search(q):
> >    """Search Google and return list of {title, link, description}"""
> >    results = _server.doGoogleSearch(
> >        APIKEY, q, 0, 10, False, "", False, "", "utf-8", "utf-8")
> >    return [{"title": r.title.encode("utf-8"),
> >             "link": r.URL.encode("utf-8"),
> >             "description": r.snippet.encode("utf-8")}
> >            for r in results.resultElements]
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: SOAPpy and pyxml installation/usage

2008-12-12 Thread Steve

Hello Jarek,

That did the trick! I'm still curious to get ZSI working but suds was
simpler. Here's my first functioning webservice call.

from suds.client import Client

url = 'http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl'
client = Client(url)
result = client.service.GetCityWeatherByZIP('94552')
print result.Temperature

Thanks!

On Dec 12, 12:24 am, Jarek Zgoda  wrote:
> Wiadomość napisana w dniu 2008-12-11, o godz. 09:31, przez Steve:
>
> > This may be a more of a generic Python question, but I'm working with
> > Django so thought that I'd see if there's a Django specific solution
> > to it.
>
> > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as
> > well. From Dive into Python it has this great example about how to
> > handle SOAP calls.
> >http://www.diveintopython.org/soap_web_services/index.html
>
> Drop SOAPpy and ZSI, they are not documented and nearly dead. Try suds.
>
> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda, R&D, Redefine
> jarek.zg...@redefine.pl
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: SOAPpy and pyxml installation/usage

2008-12-15 Thread Steve

OK. I'm having second thoughts on suds. It seems to work great some
times, but not so great on others. I have the following code, where
vid is the wsdl of the video.
Many of them fail. I got these wsdl's from http://www.xmethods.net and
presumably they're good.

def check(vid):
   try:
  client = Client(vid)
  print "succeeded: " + vid
   except:
  print "failed: " + vid

for x in wsdl:
   check(x)

It fails quite a bit, just to load the wsdl file. Here's the results:
succeeded: http://ws2.fraudlabs.com/mailboxvalidator.asmx?wsdl
succeeded: http://www.imcomponents.com/imsoap/?wsdl
succeeded: 
http://coeservice.en.kku.ac.th:8080/TemperatureConvertor/TemperatureConvertorService?WSDL
failed: http://ws.strikeiron.com/RealTimeNASDAQStockQuotes?WSDL
failed: http://ws.strikeiron.com/RealTimeStockQuotes3?WSDL
failed: http://ws.strikeiron.com/DelayedStockQuotes15min?WSDL
failed: http://www.siprod.net/webservices/xemail/xemailwebservice.asmx?WSDL
failed: https://api.postalmethods.com/PostalWS.asmx?WSDL
succeeded: http://ws.fraudlabs.com/browserobjectwebservice.asmx?wsdl
succeeded: http://ws.fraudlabs.com/areacodeworldwebservice.asmx?wsdl
succeeded: http://ws.cdyne.com/ProfanityWS/Profanity.asmx?wsdl
succeeded: http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL
succeeded: http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl
succeeded: http://www.ecubicle.net/whois_service.asmx?WSDL

If anyone has any thoughts, I'm all ears. I'm going to try to post
this on the suds page, see if they can't fix it.

-Steve

On Dec 12, 12:24 am, Jarek Zgoda  wrote:
> Wiadomość napisana w dniu 2008-12-11, o godz. 09:31, przez Steve:
>
> > This may be a more of a generic Python question, but I'm working with
> > Django so thought that I'd see if there's a Django specific solution
> > to it.
>
> > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as
> > well. From Dive into Python it has this great example about how to
> > handle SOAP calls.
> >http://www.diveintopython.org/soap_web_services/index.html
>
> Drop SOAPpy and ZSI, they are not documented and nearly dead. Try suds.
>
> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda, R&D, Redefine
> jarek.zg...@redefine.pl
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: SOAPpy and pyxml installation/usage

2008-12-17 Thread Steve

Here it is, the specific error is RuntimeError: maximum recursion
depth exceeded. I haven't attempted to debug it, since I'm totally in
the dark at wsdl and still fairly junior with Python. I tried this on
two machines, but I still don't out rule it being my own
configuration. Is anyone else able to fire up suds and let me know if
they get the same failures with the calls above? I submitted a ticket
to suds.
https://fedorahosted.org/suds/ticket/65

Traceback (most recent call last):
  File "fliqz.py", line 5, in 
client = Client(url)
  File "suds\client.py", line 103, in __init__
  File "suds\wsdl.py", line 190, in __init__
  File "suds\wsdl.py", line 235, in open_imports
  File "suds\wsdl.py", line 316, in load
  File "suds\wsdl.py", line 192, in __init__
  File "suds\wsdl.py", line 253, in build_schema
  File "suds\xsd\schema.py", line 83, in load
  File "suds\xsd\schema.py", line 269, in open_imports
  File "suds\xsd\sxbasic.py", line 872, in open
  File "suds\xsd\sxbasic.py", line 883, in download
  File "suds\xsd\schema.py", line 354, in instance
  File "suds\xsd\schema.py", line 187, in __init__
  File "suds\xsd\schema.py", line 269, in open_imports
  File "suds\xsd\sxbasic.py", line 872, in open
  File "suds\xsd\sxbasic.py", line 883, in download
  File "suds\xsd\schema.py", line 354, in instance
  File "suds\xsd\schema.py", line 187, in __init__
  File "suds\xsd\schema.py", line 269, in open_imports
  File "suds\xsd\sxbasic.py", line 872, in open
  File "suds\xsd\sxbasic.py", line 883, in download
  File "suds\xsd\schema.py", line 354, in instance

for ~1000 more lines of this, then

  File "suds\xsd\sxbasic.py", line 872, in open
  File "suds\xsd\sxbasic.py", line 881, in download
  File "suds\sax\parser.py", line 121, in parse
  File "suds\transport.py", line 130, in open
  File "suds\transport.py", line 162, in __open
  File "c:\python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
  File "c:\python25\lib\urllib2.py", line 374, in open
response = self._open(req, data)
  File "c:\python25\lib\urllib2.py", line 392, in _open
'_open', req)
  File "c:\python25\lib\urllib2.py", line 353, in _call_chain
result = func(*args)
  File "c:\python25\lib\urllib2.py", line 1100, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File "c:\python25\lib\urllib2.py", line 1072, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "c:\python25\lib\httplib.py", line 862, in request
self._send_request(method, url, body, headers)
  File "c:\python25\lib\httplib.py", line 885, in _send_request
self.endheaders()
  File "c:\python25\lib\httplib.py", line 856, in endheaders
self._send_output()
  File "c:\python25\lib\httplib.py", line 728, in _send_output
self.send(msg)
  File "c:\python25\lib\httplib.py", line 695, in send
self.connect()
RuntimeError: maximum recursion depth exceeded




On Dec 15, 8:57 am, Matias  wrote:
> Try checking the specific exception and its message.
>
> Matias.
>
> 2008/12/15 Steve 
>
>
>
>
>
> > OK. I'm having second thoughts on suds. It seems to work great some
> > times, but not so great on others. I have the following code, where
> > vid is the wsdl of the video.
> > Many of them fail. I got these wsdl's fromhttp://www.xmethods.netand
> > presumably they're good.
>
> > def check(vid):
> >   try:
> >      client = Client(vid)
> >      print "succeeded: " + vid
> >   except:
> >      print "failed: " + vid
>
> > for x in wsdl:
> >   check(x)
>
> > It fails quite a bit, just to load the wsdl file. Here's the results:
> > succeeded:http://ws2.fraudlabs.com/mailboxvalidator.asmx?wsdl
> > succeeded:http://www.imcomponents.com/imsoap/?wsdl
> > succeeded:
> >http://coeservice.en.kku.ac.th:8080/TemperatureConvertor/TemperatureC...
> > failed:http://ws.strikeiron.com/RealTimeNASDAQStockQuotes?WSDL
> > failed:http://ws.strikeiron.com/RealTimeStockQuotes3?WSDL
> > failed:http://ws.strikeiron.com/DelayedStockQuotes15min?WSDL
> > failed:
> >http://www.siprod.net/webservices/xemail/xemailwebservice.asmx?WSDL
> > failed:https://api.postalmethods.com/PostalWS.asmx?WSDL
> > succeeded:http://ws.fraudlabs.com/browserobjectwebservice.asmx?wsdl
> > succeeded:http://ws.fraudlabs.com/areacodeworldwebservice.asmx?wsdl
> > succeeded:http://ws.cdyne.com/ProfanityWS

Re: Django Development Process

2009-01-11 Thread steve

You'll find the perfect way for you to approach each stage of it I'm
sure.

I'm always into figuring out Use Cases the very first thing.  I like
to establish at least 4 or 5 different major tasks that a user would
need/want to do, and then get these out of my head into a concrete
form  (currently this means the Treepad outliner in a "use case"
branch).

This first step naturally, without too much mental effort, steers me
next into making decisions about what screens I will need, and what
models I will need to read/write in each of those screens.
 
--
So my first step is 1.) sketching what I need highlevel-wise,

2. ) Then deciding what those urls will be, going into urls.py to
write three or four mappings (for only read operation functions such
as getScores or whatever, i'll worry later about writing the write
operations when I start writing the html forms in the views )

3. ) And then start writing the models I know I will need. When I'm
finished with about 80% of the models I know I will need, I use the
Python shell to check things. When I'm satisfied that all of the
related tables give me the right result on the shell console by
manually running model.objects.all(), etc.., the next step

4. ) I go into views.py and write three or four functions that do some
reading

5.) Then the views - write the tags for retrieving database results.

.. and then I view a Djangocon speaker on youtube and realize how much
I have to learn when it comes to performance, and all of the different
areas to look at:
  check out: http://www.youtube.com/watch?v=D-4UN4MkSyI

  Seriously, not that we will all have sites that demand that type of
bandwidth, but it is definitely educational.



On Jan 11, 7:03 pm, AlexiPoliski  wrote:
> This is a call for opinion based on experience :)
>
> I'm in the process of creating the models for my very first Django
> application in my very first project. I have read the book up to and
> including chapter 7 (everything i need to know to get started).
>
> Naturally I have the design of the system I want fairly well figured
> out, and have moved on to do most of the work for the models
> (primarily as far as the database is concerned).
>
> Currently I am wondering what the next stages are going to be, and I'm
> not too sure what I would like to do as a matter of process. I
> remember reading a section in the book highlighting that you could do
> it either way, depending perhaps on your own programming preference or
> the situation.
>
> I've given it some thought, but I'll keep my current inclination for
> what I would prefer to myself for now; I'm still undecided anyway. If
> the decision is 50/50 and absolutely depends on what you are
> developing, then let me know what cases illustrate the deciding
> factors. I would imagine that experienced developers would have a
> predominant preference by now and THAT is what I would really like to
> hear about :)
>
> ---
> tldr;
> What I would like to ask is, from more experienced Django developers,
> what way do you prefer to create your applications? Models then views
> then templates? Models then templates then views? Or models then views
> AND templates concurrently.
>
> If there has been a discussion that addresses this subject already
> then I would appreciate a link to that just as much.
>
> Thank you,
> -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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Which Postgresql/Psycopg2 version should we use?

2008-07-22 Thread Steve

Recently we migrated from a working version of our site with MySQL
with the MySIAM engine to Postgresql 8.3.3/Pyscopg2.07. I built/
installed both on the site and after some finagling got our site to
connect and ran syncdb successfully. All our unit tests passed, but
the site behaves erratically now. We haven't begun to debug that but
it sometimes allows us to enter data, and other times doesn't. Out
unit tests don't include GET/POST tests, they only exercise the back
end code.

Before we spend an inordinate amount of time debugging this, I'm
curious what version of Postgresql/Psycopg people are successfully
using. We're using Django 0.96 on Ubuntu Gutsy Gibbons. 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-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: Which Postgresql/Psycopg2 version should we use?

2008-07-22 Thread Steve

I ended up rebuilding everything with postgresql 8.29/pyscopg2.07 and
everything works fine. Email me if you have questions or a similar
problem as I never figured out why it didn't work with postgresql
8.33. I'd like to know what the issue was.

For now I'm just going to back away slowly from the database and pray
it doesn't spontaneously combust.

On Jul 22, 11:36 am, Steve <[EMAIL PROTECTED]> wrote:
> Recently we migrated from a working version of our site with MySQL
> with the MySIAM engine to Postgresql 8.3.3/Pyscopg2.07. I built/
> installed both on the site and after some finagling got our site to
> connect and ran syncdb successfully. All our unit tests passed, but
> the site behaves erratically now. We haven't begun to debug that but
> it sometimes allows us to enter data, and other times doesn't. Out
> unit tests don't include GET/POST tests, they only exercise the back
> end code.
>
> Before we spend an inordinate amount of time debugging this, I'm
> curious what version of Postgresql/Psycopg people are successfully
> using. We're using Django 0.96 on Ubuntu Gutsy Gibbons. 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-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
-~--~~~~--~~--~--~---



ModelForm and submitting a null value via JSONI

2009-01-30 Thread steve

Hi everyone,  this issue is related simply to using jquery's $.post to
send some data to my view. I want to edit an item via Ajax (i..e the
way de.li.cious lets you edt an item without refreshing page) :

JAVASCRIPT
-

data =  { "name":"apple",
  "id":ingred_id,
  "category":"",
  "stock_status":0,
  "storename":"albertsons",
  "user":0
  };

$.post(url,data,processSuccessfulEdit, "json");


VIEWS.PY
---
 #  first get the item to edit---
 id = request.POST['id']
 Item  = Ingredient.objects.get(pk=int(id))

 # then save it
 Ingr = IngredientEditForm(request.POST, instance=I)
 Ingr.save()

 The problem is that the form validation fails. And it's because I'm
sending a blank string in the category field. This field, in the
Ingredient table, is null=TRUE, so I was expecting it to work.

If I launch a python shell manually and run this:
--
p =  Ingredient
(name="testingr",category_id="",stock_status=1,user_id=0,storename="vons")
p.save()

It works, it gets inserted succesfully. Django accepts the blank
string and creates a record with this foreign integer field as null.

I'm thinking I should put aside the usage of ModelForm for now and
manually do the updating of the record in the view function,  unless
there's something I'm not doing right.

Wondering if anyone had run into this
thanks,
Steve
=

in case needed, here is the modelform class as well
--
class IngredientEditForm(ModelForm):
class Meta:
model = Ingredient

class Ingredient(models.Model):
name = models.CharField(max_length=250)
stock_status = models.PositiveSmallIntegerField()
category = models.ForeignKey(Ingredcategory, null=True)
user = models.ForeignKey(FhyUser)
storename = models.CharField(max_length=50)

def __unicode__(self):
return self.name
class Meta:
db_table = u'ingredient'


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



Re: ModelForm and submitting a null value via JSONI

2009-01-30 Thread steve

Dang, I need to make a correction. Meant to type:

  Ingr = IngredientEditForm(request.POST, instance=Item),

  not:
instance=I

On Jan 30, 2:01 pm, steve  wrote:
> Hi everyone,  this issue is related simply to using jquery's $.post to
> send some data to my view. I want to edit an item via Ajax (i..e the
> way de.li.cious lets you edt an item without refreshing page) :
>
> JAVASCRIPT
> -
> 
> data =  { "name":"apple",
>                   "id":ingred_id,
>                   "category":"",
>                   "stock_status":0,
>                   "storename":"albertsons",
>                   "user":0
>                   };
>
> $.post(url,data,processSuccessfulEdit, "json");
> 
>
> VIEWS.PY
> ---
>  #  first get the item to edit---
>  id = request.POST['id']
>  Item  = Ingredient.objects.get(pk=int(id))
>
>  # then save it
>  Ingr = IngredientEditForm(request.POST, instance=I)
>  Ingr.save()
>
>  The problem is that the form validation fails. And it's because I'm
> sending a blank string in the category field. This field, in the
> Ingredient table, is null=TRUE, so I was expecting it to work.
>
> If I launch a python shell manually and run this:
> --
> p =  Ingredient
> (name="testingr",category_id="",stock_status=1,user_id=0,storename="vons")
> p.save()
>
> It works, it gets inserted succesfully. Django accepts the blank
> string and creates a record with this foreign integer field as null.
>
> I'm thinking I should put aside the usage of ModelForm for now and
> manually do the updating of the record in the view function,  unless
> there's something I'm not doing right.
>
> Wondering if anyone had run into this
> thanks,
> Steve
> =
>
> in case needed, here is the modelform class as well
> --
> class IngredientEditForm(ModelForm):
>     class Meta:
>         model = Ingredient
>
> class Ingredient(models.Model):
>     name = models.CharField(max_length=250)
>     stock_status = models.PositiveSmallIntegerField()
>     category = models.ForeignKey(Ingredcategory, null=True)
>     user = models.ForeignKey(FhyUser)
>     storename = models.CharField(max_length=50)
>
>     def __unicode__(self):
>         return self.name
>     class Meta:
>         db_table = u'ingredient'
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm and submitting a null value via JSONI

2009-01-30 Thread steve

This is frustrating. I need to slow down before posting.
I wanted to make it clear that I still have the problem, it's just
that I was correcting the way I typed out the example in this forum.

On Jan 30, 2:03 pm, steve  wrote:
> Dang, I need to make a correction. Meant to type:
>
>   Ingr = IngredientEditForm(request.POST, instance=Item),
>
>   not:
>         instance=I
>
> On Jan 30, 2:01 pm, steve  wrote:
>
> > Hi everyone,  this issue is related simply to using jquery's $.post to
> > send some data to my view. I want to edit an item via Ajax (i..e the
> > way de.li.cious lets you edt an item without refreshing page) :
>
> > JAVASCRIPT
> > -
> > 
> > data =  { "name":"apple",
> >                   "id":ingred_id,
> >                   "category":"",
> >                   "stock_status":0,
> >                   "storename":"albertsons",
> >                   "user":0
> >                   };
>
> > $.post(url,data,processSuccessfulEdit, "json");
> > 
>
> > VIEWS.PY
> > ---
> >  #  first get the item to edit---
> >  id = request.POST['id']
> >  Item  = Ingredient.objects.get(pk=int(id))
>
> >  # then save it
> >  Ingr = IngredientEditForm(request.POST, instance=I)
> >  Ingr.save()
>
> >  The problem is that the form validation fails. And it's because I'm
> > sending a blank string in the category field. This field, in the
> > Ingredient table, is null=TRUE, so I was expecting it to work.
>
> > If I launch a python shell manually and run this:
> > --
> > p =  Ingredient
> > (name="testingr",category_id="",stock_status=1,user_id=0,storename="vons")
> > p.save()
>
> > It works, it gets inserted succesfully. Django accepts the blank
> > string and creates a record with this foreign integer field as null.
>
> > I'm thinking I should put aside the usage of ModelForm for now and
> > manually do the updating of the record in the view function,  unless
> > there's something I'm not doing right.
>
> > Wondering if anyone had run into this
> > thanks,
> > Steve
> > =
>
> > in case needed, here is the modelform class as well
> > --
> > class IngredientEditForm(ModelForm):
> >     class Meta:
> >         model = Ingredient
>
> > class Ingredient(models.Model):
> >     name = models.CharField(max_length=250)
> >     stock_status = models.PositiveSmallIntegerField()
> >     category = models.ForeignKey(Ingredcategory, null=True)
> >     user = models.ForeignKey(FhyUser)
> >     storename = models.CharField(max_length=50)
>
> >     def __unicode__(self):
> >         return self.name
> >     class Meta:
> >         db_table = u'ingredient'
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm and submitting a null value via JSONI

2009-01-30 Thread steve

That's got to be it. Thanks a lot, Daniel.

On Jan 30, 4:02 pm, Daniel Roseman 
wrote:
> On Jan 30, 10:01 pm, steve  wrote:
> 
>
> >  The problem is that the form validation fails. And it's because I'm
> > sending a blank string in the category field. This field, in the
> > Ingredient table, is null=TRUE, so I was expecting it to work.
>
> 
>
> > class Ingredient(models.Model):
> >     name = models.CharField(max_length=250)
> >     stock_status = models.PositiveSmallIntegerField()
> >     category = models.ForeignKey(Ingredcategory, null=True)
> >     user = models.ForeignKey(FhyUser)
> >     storename = models.CharField(max_length=50)
>
> Yes, you have set null=True - but you haven't set blank=True. Read
> this for the distinction, hopefully that should explain why your form
> validation is 
> failing:http://docs.djangoproject.com/en/dev/topics/db/models/#field-options
> --
> 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-users@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
-~--~~~~--~~--~--~---



Tagging extension app? When a tag is more than a tag

2009-07-28 Thread Steve

Hi,
I'm using django-tagging as part of a pinax based project and I'm
looking to see if an idea I've had has already been codifed by someone
before I go off and write it.

In my app Users can tag application objects and query for those
objects via the tags; so far just basic tagging. I'd also like them to
also be able to specify that they would like a one or more tags to act
as permanent navigation elements (i.e. folder/menu/tab groups). So
clicking on that nav item (menu, tab or whatever) would filter the
tagged objects. They then could select additional tag from those
filtered objects and  specify that tag as a submenu nav item. So they
end up building a custom (per user) menu tree by selecting tags and
they can view the filtered objects at each level of the tree.

I guess another extension would be to allow them to flatten or
arbitrarily arrange the "paths" of tags so that they could reduce the
number of levels of the hierarchy to suit their needs. Then allowing
for user defined names for a path would give shorter top level nav
(tab name/menu name/folder, etc).

If you applied this to something like the Gmail interface you could
imagine mail tagged with "django", "pinax", "django-apps", "app-
engine". Then you could then create (at least) two top level menu
items (folders), one called django-apps which could be an alias for
the intersection/path of tags django/pinax/django-apps and another
called django-ae that was an alias for the intersection/path for tags
django/app-engine/django-apps

Has anyone done this type of thing already?

Best Regards,
Steve
http://agilitynerd.com
http://googility.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-users@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: Record won't Insert, possibly due to not using built in 'ID'?

2010-05-18 Thread steve
Hi,

  Are you wrapping the insert statement in a Try?  First, make sure
you're doing that.

  Also, add a parameter after "except Exception" like so:

try:
   instance = TableClassName.(field="a value",
user_id=request.user.id)
   instance.save()

except Exception, msg <--- add this
   print msg


The output of msg will tell you exactly what's going on.

(Make sure also you're including all of the fields that are "not
null", but I'm guessing that particular error would cause the full-
page development error output that Django gives you.)

Steve



On May 18, 8:37 am, beetlecube  wrote:
> ( Not sure what happened to the post, the subject appeared, but post
> content is missing)
> -
> Hi I am currently using 1.1:
>
> For the first time, I'm using a table without the built in
> autoincrement field. As we know, the way to tell Django -not- to use
> the "id" is to manually specify one of the fields as primary_key=True.
>
> Here is my table:
>
> class Rssitem(models.Model):
>     url_key = models.CharField(max_length=40, primary_key=True)
>     title = models.CharField(max_length=1024)
>     date_to_resend = models.DateTimeField()
>     user = models.ForeignKey(User)
>
> When I run the app and my View function is called - the one that
> inserts a record into the table - the insert never happens.
>
> I get no error while watching the console.   I know that the values to
> be inserted into the table, are being passed into the view, via my
> print statements.
>
> Would this be related to some other configuration I'm not taking care,
> due to me breaking the usual mold of not allowing Django to use the
> 'id' field?
>
> The postgresql schema:
>
> CREATE TABLE rssitem
> (
>   url_key character varying(40) NOT NULL,
>   title character varying(1024) NOT NULL,
>   date_to_resend timestamp with time zone NOT NULL,
>   user_id integer NOT NULL,
>   CONSTRAINT rssitem_pkey PRIMARY KEY (url_key),
>
>   CONSTRAINT rssitem_user_id_fkey FOREIGN KEY (user_id)
>       REFERENCES auth_user (id) MATCH SIMPLE
>       ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY
> DEFERRED
> )
> WITH (OIDS=FALSE);
> ALTER TABLE rssitem OWNER TO postgres;
>
> --
> 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 
> athttp://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.



Missing Response

2010-05-18 Thread steve
Just wondering what happened to my response to:

  Record won't Insert, possibly due to not using built in 'ID'?

  It says Last Post by Steve, but the message is missing.

Steve

-- 
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: Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread steve
That was it, Tom, thanks

On May 19, 9:43 am, Tom Evans  wrote:
> On Wed, May 19, 2010 at 5:37 PM, pyfreak  wrote:
> > I was on this page, but I went directly to the "1.1" link in that
> > first sentence because I am using 1.1 actually
>
> > This page is for the development version.
>
> > Thanks though.
>
> The same information is in the 1.1 manual:
>
> http://docs.djangoproject.com/en/1.1/topics/forms/#displaying-a-form-...
>
> I clicked 'docs.djangoproject.com', then 'Forms - overview' halfway
> down the page. That then has a menu item for 'Displaying a form using
> a template'.
>
> Cheers
>
> Tom
>
> --
> 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 
> athttp://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.



One of those C.Y.A. User Policy Liability Pages?

2010-05-23 Thread steve
Just wondering if anyone has found a "recipe" anywhere that advices a
good way to add an intermediate (after they enter new Registration
info)  ..."New User, you Have to Agree to these risks, etc.."
pages, where they have to click on "Agree" before it takes them to the
opening page of their newly created account.

I'd imagine, I wouldn't even have to change the pages I'm using
(currently doing a HttpResponseRedirect("main_page")).

I could simply have a popup DIV appear with the scrollable text on top
and the "Agree" button at the bottom of the opening page. And that
would simply read all the rules (yeah right), and then click "Agree",
dismissing the popup and they'd be at the /main_page.

-Steve

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



Feedparser strange behaviour on Unix-platform Django

2010-05-26 Thread steve
Feedparser doesn't like, for some reason, the "http://
rss.news.yahoo.com/rss/topstories" feed for some reason, but only
under specific conditions.

-Won't- work: (i.e. 'bozo_exception': SAXParseException('not well-
formed (invalid token)',)
 Inside a Django views.py file, and only on my live webfaction
account.


-Will- work:
   In my Django App, but on my *Dev Server*, on my Win 95 PC -
parses fine

   In *any* separate Python script anywhere, whether on my win
machine, or on Webfaction's system,
   it gets parsed fine.

 [  It just simply doesn't like this Yahoo feed, when on live
Django views.py, on webfaction  ]


If anyone is using feedparser, I would be grateful if you could try
out the yahoo feed above, and tell me if it gets parsed successfully
on your live unix-based Django server.

If not, no prob, I'll narrow it down eventually.

Steve

-- 
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: Feedparser strange behaviour on Unix-platform Django

2010-05-26 Thread steve
Resolved.  Here it is, but don't throw a tomatoe at me or anything
when I tell you.

The database table that I was reading my feeds from - the record for
the yahoo field.. it had a tab character right before the feed string.

:\

On May 26, 12:33 pm, steve  wrote:
> Feedparser doesn't like, for some reason, the "http://
> rss.news.yahoo.com/rss/topstories" feed for some reason, but only
> under specific conditions.
>
> -Won't- work: (i.e. 'bozo_exception': SAXParseException('not well-
> formed (invalid token)',)
>      Inside a Django views.py file, and only on my live webfaction
> account.
>
> -Will- work:
>        In my Django App, but on my *Dev Server*, on my Win 95 PC -
> parses fine
>
>        In *any* separate Python script anywhere, whether on my win
> machine, or on Webfaction's system,
>        it gets parsed fine.
>
>          [  It just simply doesn't like this Yahoo feed, when on live
> Django views.py, on webfaction  ]
>
> If anyone is using feedparser, I would be grateful if you could try
> out the yahoo feed above, and tell me if it gets parsed successfully
> on your live unix-based Django server.
>
> If not, no prob, I'll narrow it down eventually.
>
> Steve

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



Getting brackets at the end of your Keys?

2010-05-28 Thread steve
I'm having to, in Javascript, create a dictionary ( my_dict = {} ),
then put in some Arrays.

 my_dict["stringkey"] = Array("hey","hey1")
 my_dict["stringkey1"] = Array("more","stuff")


In the views function:

for key in request.POST:
 prop_rec = request.POST.getlist(key)


 The Python var, "prop_rec"  has the array contents that I'm
expecting.

 However, I also need to use "key".  But when I'm sending over stuff
from javascript like above,
the key has a "[]" tacked on the end of it, like "stringkey[]"

If I code the normal in js:
  my_dict["stringkey"] = "1",
then  if I do a print key in the views function, I don't get
the brackets at the end

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



OAuth/Twitter flow question

2010-06-02 Thread steve
Hi, for those using OAuth for a Twitter-based app, I'm wondering what
page you take the User after they click on a "logout" link.

Do you take them to a simple login page where you simply display the
standard Twitter-brand "Log in with Twitter" image button?

If they're still logged into Twitter itself, though,  then they
haven't really logged out of your app either, even if
contrib.auth.logout does clear the session.

Here's why:  All they need to do is literally type in one of the main
URL's on your page, such as www.yourtwitterapp.com/listYourDMs, and if
you're using login_required(), then they get directed to the login
view, which then does the back and forth with Twitter,  etc.. and then
they're logged in again.

I'm wondering if I should be displaying a message on the page after
they logout, stating: "You need to also log out of Twitter in ensure
you are logged out here" or something to that effect.

Just curious as to how anyone else is doing that
Steve

( maybe I should be setting settings.LOGIN_URL - which
login_required() takes you to -  to a page that simply displays the
"log in with twitter" button - I think I'm trying to follow the
example listed on simplegeo's Oauth2 github page too closely, and need
to make this one change )

-- 
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: Recommendations for a twitter oauth library?

2010-06-04 Thread steve
I wanted to second my thumbs up for oauth2. It's working for my site
as well.
 I'm using http://github.com/simplegeo/python-oauth2 specifically
(though the official Twitter library page mentions that the "brosner
fork" should be the one to use, which is forked from the one I'm
using, and I haven't read the details on the difference )
-Steve

On Apr 28, 1:22 am, Aliaksandr Abushkevich 
wrote:
> Hi Adam,
>
> OAuth2 works for me. You can use it in any of your python projects.
>
> Best regards,
> Alex
>
> On Wed, Apr 28, 2010 at 5:33 AM, adamjamesdrew  wrote:
> > Hi has anyone found a good twitteroauthlibrary for django?
>
> > --
> > 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 
> > athttp://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 
> athttp://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.



Textile not working

2007-06-11 Thread Steve

On my server, I am having some issues with the Textile filter. When I
first setup my site, I did not install PyTextile, consequently when I
used the textile filter on my pages I was throwing an error. To remedy
the situation, I installed PyTextile into my site-packages directory.
To check that it was installed properly, I opened a Python shell and
tried to import textile. It succeeded, so I restarted my server,
refreshed the page, and was able to get the page without a Django
error. Unfortunately though, the page was not being piped through
PyTextile and was simply rendering the Textile pseudo-code as-is on my
page.

In efforts to try to fix the issue, I have tried reinstalling
PyTextile numerous times. Not once has it started working.

Now, I have removed PyTextile from my site-packages directory,
restarted my server, checked a page again, and am no longer receiving
an error about the use of Textile on the page. The page is still being
rendered without parsing the textile code, and I am unable to import
textile in a python shell so I am at a complete loss as to why Django
is not giving me an error.

If anybody has any suggestions on how to debug this issue, I would be
extremely appreciative.


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



Advertisement Management

2007-07-22 Thread Steve

Does anybody know about a publicly available ad management program
written using Django that I could easily drop into my project? If
there isn't one, I could always write my own, but if there's one
already started I'd rather not reinvent the wheel.


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



Django.contrib.markup problems

2007-07-27 Thread Steve

I am on a shared hosting environment, and am attempting to make use of
the textile filter. I have installed the textile library in $HOME/lib/
python2.3/site-packages, which is on my $PATH, and my $PYTHONPATH. I
can import textile through the python interactive interpreter and
execute it correctly. However, when I place 'django.contrib.markup'
into my INSTALLED_APPS, and add the textile filter to my template tag,
Django throws this error:

  Error in {% textile %} filter: The Python textile library
isn't installed.

Since I couldn't get textile to work, I've since tried Markdown.
Again, I installed it into $HOME/lib/python2.3/site-packages, can
import it through the interpreter, but cannot use it in my Django
templates.

If anybody could offer my any advice on how to get it working properly
I would greatly appreciate it.


--~--~-~--~~~---~--~~
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.contrib.markup problems

2007-07-29 Thread Steve

On Jul 27, 6:57 pm, "Robert Coup" <[EMAIL PROTECTED]>
wrote:
>
> I suspect whatever is hosting your site (mod_python? fcgi?) is using a
> different path or a different interpreter (like 2.4). Print the value
> of sys.path from a view and see whether it includes the right folder.
>
> The other thing is to look in the
> django/contrib/markup/templatetags/markup.py file and make sure django
> is importing the same thing you are in the shell.
>
> Rob :)

Thanks for your tips. I finally figured out that my dispatch.fcgi
wasn't settings the proper folder in sys.path.


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



elif or elseif template tag

2008-01-04 Thread Steve

It's possible that maybe I've missed an obvious way of performing this
feat, and if that's the case I'll apologize early for my naivety.

I'm working on some templates that are drawing a form, and there are a
couple of special cases that I want to account for, but I don't want
to have to have ifequal after ifequal statements nested inside of each
other, just to cover the special cases that I'm wanting to cover.

Is there possibly an elif or elseif template tag? If not, how hard
would it be to make it? I'm not much of a Python programmer, though I
know enough to be dangerous.

Example:
{% for field in form %}
{% ifequal field.name "city" %}
{{ 
field.label|
title }}{{ field }}
{% elif field.name "state" %}
...
{% else %}
more form markup
{% endif %}
{% endfor %}
--~--~-~--~~~---~--~~
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: elif or elseif template tag

2008-01-04 Thread Steve

>
> You would have to write your own version of the "ifequal" tag, since
> that is what is responsible for parsing the whole
> "ifequal"..."else"..."endif" block in these cases, so you'd need to
> teach it about "elif" as well. Copy the existing code in
> django/template/defaulttags.py if you want to do this.
>
> Malcolm
>
> --
> The only substitute for good manners is fast 
> reflexes.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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: elif or elseif template tag

2008-01-04 Thread Steve

> You would have to write your own version of the "ifequal" tag, since
> that is what is responsible for parsing the whole
> "ifequal"..."else"..."endif" block in these cases, so you'd need to
> teach it about "elif" as well. Copy the existing code in
> django/template/defaulttags.py if you want to do this.
>
> Malcolm

I'm trying to wrap my head around adding elif into the ifequal tag,
but I'm not sure if I'm doing it right (not being a python programmer
and all...).

Here's what I have right now, but I'm not sure how to tell it to parse
more bits when it encounters the elif portion of the tag.

def do_ifequal(parser, token, negate):
bits = list(token.split_contents())
if len(bits) != 3:
raise TemplateSyntaxError, "%r takes two arguments" % bits[0]
end_tag = 'end' + bits[0]
nodelist_true = parser.parse(('elif','else', end_tag))
token = parser.next_token()
if token.contents == 'elif':
nodelist_false = parser.parse(('elif','else',end_tag))
parser.delete_first_token()
elif token.contents == 'else':
nodelist_false = parser.parse((end_tag,))
parser.delete_first_token()
else:
nodelist_false = NodeList()
return IfEqualNode(bits[1], bits[2], nodelist_true,
nodelist_false, negate)


--~--~-~--~~~---~--~~
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: elif or elseif template tag

2008-01-04 Thread Steve

> You would have to write your own version of the "ifequal" tag, since
> that is what is responsible for parsing the whole
> "ifequal"..."else"..."endif" block in these cases, so you'd need to
> teach it about "elif" as well. Copy the existing code in
> django/template/defaulttags.py if you want to do this.
>
> Malcolm

I'm trying to wrap my head around adding elif into the ifequal tag,
but I'm not sure if I'm doing it right (not being a python programmer
and all...).

Here's what I have right now, but I'm not sure how to tell it to parse
more bits when it encounters the elif portion of the tag.

def do_ifequal(parser, token, negate):
bits = list(token.split_contents())
if len(bits) != 3:
raise TemplateSyntaxError, "%r takes two arguments" % bits[0]
end_tag = 'end' + bits[0]
nodelist_true = parser.parse(('elif','else', end_tag))
token = parser.next_token()
if token.contents == 'elif':
nodelist_false = parser.parse(('elif','else',end_tag))
parser.delete_first_token()
elif token.contents == 'else':
nodelist_false = parser.parse((end_tag,))
parser.delete_first_token()
else:
nodelist_false = NodeList()
return IfEqualNode(bits[1], bits[2], nodelist_true,
nodelist_false, negate)



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



template UnicodeDecodeError at / 'utf8' codec can't decode byte 0xa9 in position 1393: unexpected code byte

2008-02-12 Thread Steve

Hi,
I get this error:
UnicodeDecodeError at / 'utf8' codec can't decode byte 0xa9 in
position 1393: unexpected code byte
The string that could not be encoded/decoded was: ight � 2006

The part of the static template it is complaining about is the ©
character:

Copyright © 2006-2008 .. 

How do I get the © character translated correctly?

Thanks
Steve
--~--~-~--~~~---~--~~
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: template UnicodeDecodeError at / 'utf8' codec can't decode byte 0xa9 in position 1393: unexpected code byte

2008-02-13 Thread Steve

Thanks for all the quick replies, fixed it with © and I'm looking
into the utf-8 encoding.
Steve

On Feb 14, 12:56 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Steve napisał(a):
>
> > UnicodeDecodeError at / 'utf8' codec can't decode byte 0xa9 in
> > position 1393: unexpected code byte
> > The string that could not be encoded/decoded was: ight ? 2006
>
> > The part of the static template it is complaining about is the (c)
> > character:
>
> > Copyright (c) 2006-2008 .. 
>
> > How do I get the (c) character translated correctly?
>
> Use character entity © (apply the same to ®, ™ etc.).
>
> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



MySQLdb Error

2007-05-15 Thread Steve

When trying to perform a syncdb I get the following error:

Traceback (most recent call last):
  File "./manage.py", line 11, in 
execute_manager(settings)
  File "/usr/local/lib/python2.5/site-packages/django/core/
management.py", line 1674, in execute_manager
execute_from_command_line(action_mapping, argv)
  File "/usr/local/lib/python2.5/site-packages/django/core/
management.py", line 1573, in execute_from_command_line
action_mapping[action](int(options.verbosity),
options.interactive)
  File "/usr/local/lib/python2.5/site-packages/django/core/
management.py", line 468, in syncdb
from django.db import connection, transaction, models,
get_creation_module
  File "/usr/local/lib/python2.5/site-packages/django/db/__init__.py",
line 11, in 
backend = __import__('django.db.backends.%s.base' %
settings.DATABASE_ENGINE, {}, {}, [''])
  File "/usr/local/lib/python2.5/site-packages/django/db/backends/
mysql/base.py", line 12, in 
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: dlopen(/tmp/.egg-cache/MySQL_python-1.2.2-py2.5-macosx-10.3-
i386.egg-tmp/_mysql.so, 2): image not found


Any ideas on what to do?


--~--~-~--~~~---~--~~
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: MySQLdb Error

2007-05-15 Thread Steve

I forgot to mention...

Syncdb was working yesterday when I first ran it. I have added some
django.contrib applications to my settings.py, which I have since
removed in an effort to try to figure out if that was causing the
problem. Sadly, it didn't fix the problem, and that's the only thing
that's changed since my last successful run of syncdb.


--~--~-~--~~~---~--~~
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: MySQLdb Error

2007-05-15 Thread Steve

Apparently there is a difference between the cache created by apache
and the one created by django that makes them incompatible. In order
for me to run syncdb I had to delete the cache, and before apache
could create a new cache, run syncdb... however this caused apache to
start throwing the same error, which required the same fix... deleting
the cache so that it could be recreated by apache.


--~--~-~--~~~---~--~~
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: MySQLdb Error

2007-05-15 Thread Steve

As far as I know. I could have screwed something up, but everything
related to django and apache is owned by root:wheel

It's only a test environment anyway... so it's not that big of a deal
if I need to delete the caches before doing things...

On May 15, 3:18 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 5/15/07, Steve <[EMAIL PROTECTED]> wrote:
>
>
>
> > Apparently there is a difference between the cache created by apache
> > and the one created by django that makes them incompatible. In order
> > for me to run syncdb I had to delete the cache, and before apache
> > could create a new cache, run syncdb... however this caused apache to
> > start throwing the same error, which required the same fix... deleting
> > the cache so that it could be recreated by apache.
>
> Are you sure that apache and you are running with compatible
> permissions, python versions, and sys.path's?


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



Django and MySQLdb on Bluehost

2006-07-12 Thread Steve

Hi all,

I'm trying to set up Django on Bluehost with MySQL as my db, and I'm
running into problems.  I was hoping someone who has successfully
married MySQLdb to Django on Bluehost can help me out.  I'm sure it's
something really simple that I am omitting.

Bluehost doesn't have MySQLdb installed by default, so I built and
installed it locally under $HOME/python_modules, and added
$HOME/python_modules to $PYTHONPATH in my .bash_profile.  Given this
change, I can manipulate my Django models just fine when using the
Python interpreter.  However, I run into problems when I attempt to
access my Django app via a browser.  I get the following message:

ImproperlyConfigured: Error loading MySQLdb module: No module named
MySQLdb
  args = ('Error loading MySQLdb module: No module named MySQLdb',)

Apparently the Python path being used in this instance is not correct.
How do I correct that?  

Thanks,
Steve


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django and MySQLdb on Bluehost

2006-07-12 Thread Steve

Nevermind, I figured it out.  Gosh I get smarter just by writing to
this group :)

All I had to do was add the local path of MySQLdb to my .fcgi file
under my web root directory.  So:
sys.path += ['/homedir/pythondir']


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



Registering only folks with .org email

2012-08-03 Thread Steve
I am very new to Django but I like it a lot. I learned about the registration 
plugin and I am trying to modify it such that only the individuals who have and 
can validate an email with .org address can register. I was wondering if 
someone could point me in the right direction in terms of how exactly I should 
modify the plugin. I am reading the docs and I see some forms for the default 
strategy. For example, there is one form disallowing the hotmail, gmail, etc. 
addresses. My strategy would be similar to that. However, since I am new to 
Django and Python, I don't know how I should modify the app. For ex., should I 
download a copy and put it in the main project folder? Any best practices and 
tips would be greatly appreciated.

Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/iaxHEo8NmWoJ.
To post to this group, send email to django-users@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: Registering only folks with .org email

2012-08-04 Thread Steve
Thanks, Kurtis. I'll start with subclassing and see how it goes.

On Friday, August 3, 2012 4:25:46 PM UTC-4, Kurtis wrote:
>
> Hey Steve,
>
> There's a number of ways you could go about tackling this task. I, 
> typically, would read the original's application code and first determine 
> how it worked. In some cases, I would write my code to subclass (or re-use) 
> theirs and just make the modifications required. Other times, depending on 
> the complexity of the particular function/feature, I would simply roll my 
> own out based on what I've learned.
>
> Another great way to go about this, since your effort could potentially be 
> something useful to others, is to see if the "registration plugin" is 
> available on github with the proper licensing and then "fork" it. You could 
> make all of your changes there on github and use "pip" to install your copy 
> (the fork you made) instead of the original author's. This would be great 
> because you get to share with others, have a manageable way of monitoring 
> your changes, and may even get some help from others.
>
> Anyways, those are just some ideas... I'm sure others will have more!
>
> Good luck!
> - Kurtis
>
> On Fri, Aug 3, 2012 at 3:58 PM, Steve wrote:
>
>> I am very new to Django but I like it a lot. I learned about the 
>> registration plugin and I am trying to modify it such that only the 
>> individuals who have and can validate an email with .org address can 
>> register. I was wondering if someone could point me in the right direction 
>> in terms of how exactly I should modify the plugin. I am reading the docs 
>> and I see some forms for the default strategy. For example, there is one 
>> form disallowing the hotmail, gmail, etc. addresses. My strategy would be 
>> similar to that. However, since I am new to Django and Python, I don't know 
>> how I should modify the app. For ex., should I download a copy and put it 
>> in the main project folder? Any best practices and tips would be greatly 
>> appreciated.
>>
>> Steve
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/iaxHEo8NmWoJ.
>> To post to this group, send email to django-users@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/T-dlcSLdHv8J.
To post to this group, send email to django-users@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.



Should someone with no programming experience start learning Python, or Django (along with Python) first?

2012-01-27 Thread Steve
Just as the title says, I have basically no programming experience.  I
want to program purely for the web.  I know a bit of HTML, CSS, and
very minimal amounts of Java.  Can I start learning Django first and
go from there?  Is that a bad idea?

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



Re: Apache2 with static file

2011-04-05 Thread Steve
I'm not sure what settings you have defined outside the 'VirtualHost'
section in your http.conf.

My guess is that you haven't set up the permissions to allow access to
the static media directory:


Order allow,deny
Allow from all


Also, I can't see your WSGIScriptAlias anywhere? Are you using
mod_wsgi with Apache?


On Apr 5, 8:33 am, yongzhen zhang <4...@live.cn> wrote:
> Hi,
> i have one problem with my apache2 work with static file.
> In apache2/sites-available file:
> 
>         ServerNamewww.imaboy.cn
>         ServerAlias shop.imaboy.cn
>        Alias /static /home/yongzhen/workspace/www/iStore/static
> 
> I want use apache to route to my static file. It works somehow, like
> if i type:imaboy.cn/static, i has the results .in my development
> server i opened 8000 port, like that:http://imaboy.cn:8000/ .The
> problem is that the static file is not shown, in the command window,
> it shows: "GET /static/images/ipad2_6.jpg HTTP/1.1" 200 5175. Anyone
> can help me? thanks a lot.

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



trouble logging in to post ticket for django documentation

2014-08-22 Thread Steve
Total noob here.  I'm working through the (very helpful) django tutorials. 
 I'd like to enter a suggestion ticket.  I've created a github account and 
logged into it, yet I still receive the following error message from 
code.djangoproject.com:

You are currently not logged in. You may want to do so 
 now.
Error: Forbidden

TICKET_CREATE privileges are required to perform this operation. You don't 
have the required permissions.

I try to login again via the "do so" link above; I enter my new github 
username and password but instead of logging in I'm stuck in an infinite 
loop whereby I'm asked for my login credentials forever.  What gives? 
 Cheers.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b2505d7c-769e-4e4a-8bb4-4f4e988fb8b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: trouble logging in to post ticket for django documentation

2014-08-22 Thread Steve
Thanks Russ.  Everything's peachy.

I poked around enough before posting my message that I ought have put that 
together myself.  Sorry to have bothered you.  Cheers.

On Friday, 22 August 2014 20:33:58 UTC-4, Russell Keith-Magee wrote:
>
> Hi Steve,
>
> We recently changed the login procedures for our Trac instance, and we're 
> still shaking out some of the bugs. In this case, the forbidden page has 
> the wrong link on it. If you want to log in with your Github account, visit:
>
> https://code.djangoproject.com/github/login
>
> then go ahead an lodge your ticket.
>
> Apologies for the inconvenience.
>
> Yours,
> Russ Magee %-)
>
>
>
> On Sat, Aug 23, 2014 at 4:06 AM, Steve > 
> wrote:
>
>> Total noob here.  I'm working through the (very helpful) django 
>> tutorials.  I'd like to enter a suggestion ticket.  I've created a github 
>> account and logged into it, yet I still receive the following error message 
>> from code.djangoproject.com:
>>
>> You are currently not logged in. You may want to do so 
>> <https://code.djangoproject.com/login> now.
>>  Error: Forbidden
>>
>> TICKET_CREATE privileges are required to perform this operation. You 
>> don't have the required permissions.
>>
>> I try to login again via the "do so" link above; I enter my new github 
>> username and password but instead of logging in I'm stuck in an infinite 
>> loop whereby I'm asked for my login credentials forever.  What gives? 
>>  Cheers.
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b2505d7c-769e-4e4a-8bb4-4f4e988fb8b4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/b2505d7c-769e-4e4a-8bb4-4f4e988fb8b4%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68333c36-fd6f-46fb-b13a-4549d34372de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DoesNotExist behavior in db.models query.py

2017-10-23 Thread steve
I have been tripping over the following exception
DoesNotExist: INSERT_YOUR_MODEL_NAME_HERE matching query does not exist.

The error is source in django 1.11.2 in db.models query.py file, in the 
get(self, *args, **kwargs) function, line 378 to be exact
...
raise self.model.DoesNotExist(...)
...
This throws a 500 error and I would like my code not to throw a 500 error 
in this situation, rather a customized message more along a 4xx error e.g.
{"message": "record matching identifier A and identifier B not found in 
database"}
rather than a 500 error.

It seems to me that my only choice right now is to subclass QuerySet and 
write my own version of the get(self, *args, **kwargs) method. Is that my 
only choice or is there a django parameter I can set so that 0 matching 
results does not return a 500?

Or do I need to intercept the 500 error somewhere else.

Sorry, am a bit of a newbie to django internals, all help and advice is 
appreciated.

Thanks,
Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/499aad32-3e2d-4717-97cb-f65feccc0d65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DoesNotExist behavior in db.models query.py

2017-10-23 Thread steve
Replying to myself here: as is often the case, the problem lies with my own 
source code.
I was calling
MODELNAME.objects.get(modelfieldname1='foo',modelfieldname2='bar')


which raises the 500 when no such record exists.

Turns out that calling
MODELNAME.objects.filter(modelfieldname1='foo',modelfieldname2='bar')


behaves politely when finding no matching record and returns a 0 length 
QuerySet array. So with calling filter I can then just test on length of 
result and make my behavior omit a 400 and some helpful information to 
client side about the nature of the 400 error.

Separately, this does raise the question of should get() and filter() 
behave similarly or is there a reason that filter() allows empty result 
sets but get() does not?

Thanks,
Steve

On Monday, October 23, 2017 at 2:49:28 PM UTC-7, st...@fitcode.com wrote:
>
> I have been tripping over the following exception
> DoesNotExist: INSERT_YOUR_MODEL_NAME_HERE matching query does not exist.
>
> The error is source in django 1.11.2 in db.models query.py file, in the 
> get(self, *args, **kwargs) function, line 378 to be exact
> ...
> raise self.model.DoesNotExist(...)
> ...
> This throws a 500 error and I would like my code not to throw a 500 error 
> in this situation, rather a customized message more along a 4xx error e.g.
> {"message": "record matching identifier A and identifier B not found in 
> database"}
> rather than a 500 error.
>
> It seems to me that my only choice right now is to subclass QuerySet and 
> write my own version of the get(self, *args, **kwargs) method. Is that my 
> only choice or is there a django parameter I can set so that 0 matching 
> results does not return a 500?
>
> Or do I need to intercept the 500 error somewhere else.
>
> Sorry, am a bit of a newbie to django internals, all help and advice is 
> appreciated.
>
> Thanks,
> Steve
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/67bd9382-0ac1-49c6-8b26-1827b91a852c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DoesNotExist behavior in db.models query.py

2017-10-23 Thread steve
Thank you Aaron, I started to figure this all out too as I read the docs 
more carefully and looked at the source code more thoughtfully.

One nuance on the try/except block you propose: doesn't work as expected in 
the request framework because even though the except block can be stated as 
you propose, the exception gets thrown by db.models query.py and is 
declared as a simple
raise DoesNotExist...

And this then bubbles all the way back through the middleware.

The simplest answer for my use case is to just use filter().

As get() is defined as a method of the QuerySet class, at first glance I 
assumed it would return a queryset, but as you point out, it doesn't. It 
returns an instance of a model class.  In my perfect world, get() would 
have been named as get_as_model_object so that it was clear this is a 
convenience method of the class. But that's just quibbling. Had I read the 
source code more carefully, it would have dawned on me what to do and why I 
had been confused.

Thank you.
steve

On Monday, October 23, 2017 at 2:49:28 PM UTC-7, st...@fitcode.com wrote:
>
> I have been tripping over the following exception
> DoesNotExist: INSERT_YOUR_MODEL_NAME_HERE matching query does not exist.
>
> The error is source in django 1.11.2 in db.models query.py file, in the 
> get(self, *args, **kwargs) function, line 378 to be exact
> ...
> raise self.model.DoesNotExist(...)
> ...
> This throws a 500 error and I would like my code not to throw a 500 error 
> in this situation, rather a customized message more along a 4xx error e.g.
> {"message": "record matching identifier A and identifier B not found in 
> database"}
> rather than a 500 error.
>
> It seems to me that my only choice right now is to subclass QuerySet and 
> write my own version of the get(self, *args, **kwargs) method. Is that my 
> only choice or is there a django parameter I can set so that 0 matching 
> results does not return a 500?
>
> Or do I need to intercept the 500 error somewhere else.
>
> Sorry, am a bit of a newbie to django internals, all help and advice is 
> appreciated.
>
> Thanks,
> Steve
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/775408b6-0ece-486a-9026-1c09ba34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Import error exception "No module named urls" when running from eclipse

2008-10-26 Thread Steve Holden

DragonSlayre wrote:
[at the top, but it's now moved to the bottom]
> On Oct 22, 2:03 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote:
>   
>> DragonSlayre wrote:
>> 
>>> Hi, I'm new to django/python, and I'm testing out eclipse for
>>> development.
>>>   
>>> I'm using pydev, and managed to run my app, but then when I go to the
>>> web page, I get:
>>>   
>>> ImportError at /time/
>>> No module named urls
>>>   
>> You'll need to include the code for the view that is being called, and
>> possibly your urls.py
>> Do you have a urls.py in your project?
>>
>> Jeff Anderson
>>
>>  signature.asc
>> < 1KViewDownload
>> 
> Thanks for your help,
>
> It turns out that it was a problem to do with the renaming
> functionality not working properly in eclipse.  I tried renaming my
> package - and that doesn't work for some reason, and then my hack
> around caused a problem when I created a new package, which ultimately
> stuffed up which package eclipse was looking in when launching the
> app.
>
> Is it *normal* for rename to not work properly for the packages in
> eclipse using pydev?
>
> My solution to this was to create a new project, with the package name
> I wanted, and to import the code I was previously using.  If it's just
> my version, then I should probably find out why my version doesn't
> support rename.
>
>   
It would be helpful if there were an "app rename" and "project rename"
tool but at present I don't believe there is.  The fact is that these
names do pervade the code, so as you have found out it's not as
straightforward as it should be to change them retrospectively (though
it's by no means impossible).

regards
 Steve



--~--~-~--~~~---~--~~
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: Urlconf page not found question

2008-10-26 Thread Steve Holden

David Rodrigues wrote:
> Or if you have ^accounts in parent urls.py file, then perhaps the '$'  
> at the end of the ^login/$ expression is problematic, as the dollar  
> sign represents the end of a line, I believe.
> 
It's fairly obvious that the listing of the URLconfs is from the 404
output of the test server. If so, subsidiary url.py files are show by
inserting a space between the main line and the lines from the included
files.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Receiving emails via app

2008-10-26 Thread Steve Holden

felix wrote:
> In general I agree with Jeff's suggestion.  
>
> but OTOH you might be able to get pop to work
> and using the pop interface maybe you can get the headers in a clean
> pythonic fashion.
>
> it sounds like you will also have to deal with attachments, so maybe
> the pop library can handle that nicely.
>
Nope. poplib is simply for accessing the message from the POP server.
Jeff's suggestion would not, as you correctly identified, give access to
the headers. But processing MIME-structured messages requires the email
module no matter what method of delivery you choose.

regards
 Steve


--~--~-~--~~~---~--~~
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: database API from external tools?

2008-10-26 Thread Steve Holden

Russell Keith-Magee wrote:
> On Mon, Oct 27, 2008 at 6:05 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote:
>   
>> Russell Keith-Magee wrote:
>> 
>>> On Sat, Oct 25, 2008 at 3:55 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote:
>>>
>>>   
>>>> My question is how to package up and deploy the Django python code for
>>>> external tools to access the database? I'm hoping to have the Django app
>>>> sitting on the web server, with the source tree inaccessible to a bunch
>>>> of workstations. ...
>>>> 
>>> If you just want the Django database API, then put the Django code
>>> (i.e., django.*) on the workstations, and just write your tools to
>>> import that code, setting up DJANGO_SETTINGS_MODULE as required.
>>>
>>> If you also want your model definitions, then you're going to have to
>>> deploy those too...
>>> ...the model layer will work fine if the views are missing -
>>> strictly, the only part of your code that should need to exist on the
>>> workstation are the model definitions. Managing an extraction of a
>>> partial checkout of your project code is left as an exercise for the
>>> reader...
>>> *Obviously, the easiest way to get all the required code is to do a
>>> full checkout of your web application on the workstation...*
>>>   
>> Ok, thanks.
>> I just wanted to confirm that duplicating the web app out to the
>> workstations just so they can access the database API was the expected
>> course of action in this scenario.
>> It feels dirty to me!
>> 
>
> No - that isn't what I said at all.
>
> What I said is that you will need _pieces_ of the web app -
> specifically the model   definitions, plus the main configuration
> file. I expect that the model definitions will also have some
> dependencies, but I can't tell what those are without seeing your
> code.
>
> The _easiest_ way to know you have satisfied all internal dependencies
> is to copy the full web app. However, this is not the _only_ way, and
> if you're willing to handle the configuration management issues, you
> could provide a partial checkout and achieve the same outcome.
>
>   
Here's a specific example of a piece of code that uses a web app's
models. It should get you started - just dive in and write some code!
The tricky bit is providing the settings without using a "settings"
module. I can't remember who I got this code from, but the kudos belongs
to them, not me. Enjoy.

regards
 Steve

from django.conf import settings
settings.configure( DATABASE_ENGINE="postgresql_psycopg2",
DATABASE_NAME ="PyTeach",
DATABASE_USER='django',
DATABASE_PASSWORD='djangopw',
DATABASE_HOST='localhost',
DATABASE_PORT='',
INSTALLED_APPS=('info', 'invoicing', 'training'))
from invoicing.models import (Address, Organization, Person, Project, Task)
# I've chopped a lot of code that created and saves instances of other
models
hweb = Organization(
name="Holden Web, LLC",
notes="""A tidy little company that works with Django""")
hweb.save()




--~--~-~--~~~---~--~~
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: When should I do my imports, in views.py?

2008-10-27 Thread Steve Holden

7timesTom wrote:
> I have a large number of view functions which require various python,
> django and other import statements.
>
> My question is: is it ok to put ALL my import statements at the top of
> views.py and then not have to worry about which view fuction uses
> what. Or must I put my imports within the view fuctions that require
> them?
>
>   
It's OK, and indeed that's the normal way of programming.
> Does it depend on how many functions require I certain import? And if
> so, how many imports justifies a global import at the top of the code?
>
>   
One.
> I'm interested on the effect this decision has on speed/memory usage
> etc.
>   
If you want to, you can do some timings with the "timeit" Python module,
but essentially the usual justifications for putting imports inside
functions are

a. The function is very rarely called: putting the import inside the
function means that the import may never have to be executed.

b. Lowering startup overhead: with the import inside the function it
needn't be performed until the function is called, so the program gets
started quicker.

Almost no impact on speed unless you are using a heavily-layered
approach to your programming with many function calls. The import
functionality checks the sys.modules dict first thing to see whether the
module has already been imported. If so then the value of the
sys.modules entry is immediately used to satisfy the import, so there
isn't much overhead.

regards
 Steve


--~--~-~--~~~---~--~~
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: Triggering a custom signal

2008-10-27 Thread Steve Holden

redmonkey wrote:
> Thanks Matías, you've come up with a good solution, but unfortunately
> this won't really work for my situation.
>
> For my client, online bidding ends immediately before they open
> bidding on the shop floor. The catalogue for that sale must go offline
> at that point. I can't expect my client to postpone things while they
> wait for my cron job to decide to close the catalogue down. Thanks for
> posting the save method though, it's quite neat.
>
> I'm finding it hard to believe there isn't an easy way to do this, not
> even with the full Python Library behind it. I understand what signals
> are, and I know that you can create http://code.google.com/p/
> django-cron/source/browse/trunk/cron/signals.py" title"Django-cron:
> Signals">custom ones. I'd like to know how I can send my custom
> signal at the DateTimeField value.
>
> On Oct 27, 12:14 pm, "Matías Costa" <[EMAIL PROTECTED]> wrote:
>   
>> BTW this is the save method for the model with the rounding function:
>>
>> def save(self):
>> def roundminute(d,  r):
>> """Rounds the datetime d to the nearer r multiple
>> If r == 15 =>
>> 3:00 -> 3:00
>> 3:05 -> 3:00
>> 3:27 -> 3:30
>> 3:55 -> 4:00
>>
>> Adds hours correctly
>> """
>> from datetime import datetime,  timedelta
>> m = d.minute
>> if m > (60 - r/2):
>> m = 0
>> d += timedelta(60*60)
>> else:
>> m = m - (m%r) if (m%r)<(r/2) else m+(r-(m%r))
>> return d.replace(minute=m,  second=0, microsecond=0)
>>
>> if self.price == None:
>> self.price = self.start_price
>> self.start_date = roundminute(self.start_date,  15)
>> self.end_date = roundminute(self.end_date,  15)
>> super(Auction, self).save()
>>
>> On Mon, Oct 27, 2008 at 1:06 PM, Matías Costa <[EMAIL PROTECTED]> wrote:
>> 
>>> I have the exact problem. I round end and start dates to 15 minutes. I
>>> mean, user enters 12:10, I write 12:15. So each 15 minutes cron runs a
>>> script with django-commands-extensions runscript. Is a balance between
>>> accuracy and load.
>>>   
>>> The perfect should be finding the next success to happen (easy) and program
>>> django-cron or anything else to run at that time (I don't know how)
>>>   
>>> I am very interested in the solutions people have found for this
>>>   
>>> On Mon, Oct 27, 2008 at 12:45 PM, redmonkey <[EMAIL PROTECTED]
>>>   
>>>> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I'm working on a simple auctioneer's website. My Catalogue app
>>>> consists of a list of Lots arranged into Catalogues. Each catalogue
>>>> has an auction_data field which stores a status and a date and time of
>>>> the sale:
>>>> 
>>>> class Catalogue(models.Model):
>>>>DRAFT_STATUS = 1
>>>>LIVE_STATUS = 2
>>>>CATALOGUE_CHOICES = (
>>>>(DRAFT_STATUS, 'Draft'),
>>>>(LIVE_STATUS, 'Live'),
>>>>)
>>>>status = models.IntegerField("Status", choices=CATALOGUE_CHOICES,
>>>>default=DRAFT_STATUS)
>>>>auction_date = models.DateTimeField("Date of Auction")
>>>>...
>>>> 
>>>> class Lot(models.Model):
>>>>catalogue = models.ForeignKey(Catalogue, related_name="lots")
>>>>...
>>>> 
>>>> Pretty simple stuff. My problem is that I need to run a function at
>>>> the auction_date of the catalogue that will do a few things like
>>>> change the status of the catalogue, and send an email out to some
>>>> admins.
>>>> 
>>>> I've done some brief research, and found django-cron,
>>>> and I imagine I could write something that checked each hour to see if
>>>> any catalogues had expried recently, but that seems mad.
>>>> 
>>>> Another solution I came up with involved checking for the expiry date
>>>> every time a record is pulled up from the database. But this add's a
>>>> hit to user r

Re: How to get site's root path in Django

2008-10-27 Thread Steve Holden

yuanyun.ken wrote:
> Hi, all great Django users and developers, I have a little problem.
> To make @login_required work,
> I have to configure those in settings.py:
> root_url = '/root_url/'
> LOGIN_URL = root_url + '/login/'
> LOGOUT_URL =  root_url + '/logout/'
>
> But this is obviously not a good idea, as it couples with project's
> root url.
>
>   
But in Django your project's root URL is "/", which is why the default
settings.LOGIN_URL is "/accounts/login/".
> I tried to use:
> LOGIN_URL = '/login/'
> or
> LOGIN_URL = 'login/'
>
> the first can not work, apache would try to access http://localhost/login/,
> not http://localhost/root_url/login/
>   
So what you are saying is that you aren't running Django mapped to the
root of your server's web address space?
> the second option would not work, when access 
> http://localhost/root_url/dira/pageb,
> this would lead to access http://localhost/root_url/dira/login
>
> urls.py
> (r'^login/$', 'django.contrib.auth.views.login'),
> (r'^logout/$', 'django.contrib.auth.views.logout')
>
> The following are my configuration in apache's httpd.conf
> Alias /root_url/ D:/ws/django/myproject/
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE Regrroot_url.settings
> PythonOption django.root /root_url
> PythonDebug On
> PythonPath "['D:/ws/django/myproject/'] + sys.path"
> Options ExecCGI
> Options +Indexes
> Order allow,deny
> Allow from all
> 
>
> Any help is appreciated, and Thanks in advance.
If you don't want Django at the root of your web space then you will
have to take special pains to remap it. What's the reason you want your
project to appear at "/root_url/" rather than "/"?

regards
 Steve


--~--~-~--~~~---~--~~
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: Triggering a custom signal

2008-10-27 Thread Steve Holden

redmonkey wrote:
> h. Yeah, That's pretty simple.
>
> I could even get a reference to the Job number using -v with at,
> storing that in the DB and then removing and recreating another at-job
> if the user changes the time.
>
> Brilliant, thank you.
>
> On Oct 27, 4:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>   
>> I believe you are over-thinking this one. Why not just have a program
>> access a known URL (with authentication, because you don't want just
>> *any* user to be able to do this) to bring a catalog off-line? You can
>> then use the Linux "at" utility to schedule each catalog's off-lining
>> when you create it.
>>
>> regards
>>  Steve
>> 
A pleasure. Sometimes more technology isn;t the answer, just the
technology we've had so long we've forgotten about it ;-)

regards
 Steve


--~--~-~--~~~---~--~~
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: Easiest way to pass django documentation from rest to HTML?

2008-10-28 Thread Steve Holden

Mr. Z wrote:
> Which is the easiest way to pass the new django documentation from
> rest to HTML?
>
> Thank you,
>
>   
I believe you will find a makefile that drives the Sphinx tool in the
docs subdirectory. The command "make html" will create HTML
documentation in docs/_build/html.

regards
 Steve


--~--~-~--~~~---~--~~
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: Foreign key with tons of items

2008-10-28 Thread Steve Holden

Fabio Natali wrote:
> gearheart wrote:
>   
>> maybe limit_choices_to is what you're looking for
>> i had similar problem and solved with ajax autocomplete widget.
>> 
>
> I haven't yet get rid of those too-much-long inline drop down menus.
>
> I was thinking to use js to open up a window and let the user choose
> from some hyerarchical menu... something like a first drop down menu
> for the category and then a second drop down menu for the real
> product, the latter being properly filtered by category.
>
> Could anyone provide some tips on how to get this?
>
> Thank you so much,
>
>   
The generic solution to this problem is to have a link in your main form
that opens up the sub-window, then have the sub-window (before closing
itself) set an appropriate attribute of its "opener", to set the form
value in the main form. Was that what you wanted?

regards
 Steve



--~--~-~--~~~---~--~~
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: How to get site's root url path in Django

2008-10-28 Thread Steve Holden

The answer to your question is the same as the first time you posted it,
about fourteen hours previously. Please do not just repeat the same
question - wait patiently for the answer, and if no answer comes in a
couple of days then add more information to your request or otherwise
change it to increase the probability of a reply.

Graham Dumpleton has told you the solution in the other thread.

regards
 Steve

yuanyun.ken wrote:
> Hi, all great Django users and developers, I have a little problem.
> To make @login_required work,
> I have to configure those in settings.py:
> root_url = '/root_url/'
> LOGIN_URL = root_url + '/login/'
> LOGOUT_URL =  root_url + '/logout/'
>
>   
[...]


--~--~-~--~~~---~--~~
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: 500 displayed instead of 404

2008-10-28 Thread Steve Holden

janedenone wrote:
> Hi,
>
> I use the following simple view
>
> def index(request, page_id, current_subpage=1):
>   try:
>   current_page = get_object_or_404(Page, pk=page_id)
>   except:
>   # if anything else goes wrong, display the 404 anway
>   raise Http404
>
> In debug mode, my app returns the detailed 'page not found' page for
> non-existing pages, but as soon as I switch debug to false, the
> 500 template is shown. I can, however, display render and return the
> 404 template manually.
>
> What could possibly go wrong when a Http404 exception is raised, i.e.
> why does Django use the 500 template in this case?
>
>   
That depends whether your site does anything special with 404 errors.
Some sites display them with full decoration, and so there's always the
chance that 404 processing goes squiffy, in which case you may well see
a 500.

It's clear that some code is being executed in processing the 404
without debug that *isn't* executed when you process a 404 with debug
set. Now you just have to find out what ...

regards
 Steve


--~--~-~--~~~---~--~~
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: Admin page: How to add a column for user that added an item

2008-10-28 Thread Steve Holden

Robert Dailey wrote:
> Hi,
>
> I currently have the following model:
>
> class Note( models.Model ):
>   content = models.TextField()
>
> I've setup the admin page to allow users to add "notes", which
> basically lets them fill in the content variable. However, on the
> admin page I want to add a column to show the user that added that
> note. This would be the username in the admin page that they logged in
> with. I hope that I can do this without adding any information to my
> Note class, but if I must then I don't mind.
>
> So column 1 should be the user that added that note, and Column 2
> should be the note itself.
>   
The usual way to do this is to establish a relationship between User and
Note. Since each note will only be created by a single user, and each
user can (presumably) issue many notes the sensible thing to do would be
to add a foreign key to Note to express which user created it.

OK, assuming you can import your User model into the module that defines
your Note model, you would just need to add

user = models.ForeignKey(User)

to the Note model.

regards
 Steve


--~--~-~--~~~---~--~~
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: Admin page: How to add a column for user that added an item

2008-10-28 Thread Steve Holden

Robert Dailey wrote:
> On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>   
>> Robert Dailey wrote:
>> 
>>> Hi,
>>>   
>>> I currently have the following model:
>>>   
>>> class Note( models.Model ):
>>>content = models.TextField()
>>>   
>>> I've setup the admin page to allow users to add "notes", which
>>> basically lets them fill in the content variable. However, on the
>>> admin page I want to add a column to show the user that added that
>>> note. This would be the username in the admin page that they logged in
>>> with. I hope that I can do this without adding any information to my
>>> Note class, but if I must then I don't mind.
>>>   
>>> So column 1 should be the user that added that note, and Column 2
>>> should be the note itself.
>>>   
>> The usual way to do this is to establish a relationship between User and
>> Note. Since each note will only be created by a single user, and each
>> user can (presumably) issue many notes the sensible thing to do would be
>> to add a foreign key to Note to express which user created it.
>>
>> OK, assuming you can import your User model into the module that defines
>> your Note model, you would just need to add
>>
>> user = models.ForeignKey(User)
>>
>> to the Note model.
>> 
>
> Thanks for your help. I tried the following:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> # Create your models here.
> class Note( models.Model ):
>   content = models.TextField()
>   user = models.ForeignKey( User )
>
> However, now when I visit the page that lists my notes, I get the
> following error:
>
> OperationalError at /admin/core/note/
> (1054, "Unknown column 'core_note.user_id' in 'field list'")
>
> Any idea what is going on?
>   
You'll need to add the corresponding field to your database. If you
don't have any data worth keeping on the Note table (it will be called
YourappnameNote in the database) then the easiest thing to do is delete
the whole table then run

  python manage.py syncdb

to re-create the table with the additional field.

regards
 Steve



--~--~-~--~~~---~--~~
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: Is this a quirk with the admin template override mechanism or is it me?

2008-10-29 Thread Steve Holden

AndyB wrote:
> I can see why it would fail - but I still wonder whether the current
> behaviour is ideal. I would say that it's more likely someone would
> want to override a template project wide and I can't see a neat way to
> do this.
>   

The easiest way would surely be to add another template directory at the
stat of settings.TEMPLATE_DIRS and define the global defaults in there.

regards
 Steve


--~--~-~--~~~---~--~~
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: Admin page: How to add a column for user that added an item

2008-10-29 Thread Steve Holden

Robert Dailey wrote:
> On Oct 28, 2:47 pm, Robert Dailey <[EMAIL PROTECTED]> wrote:
>   
>> On Oct 28, 11:17 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>> [...]
>>
>> I'm have some more questions for you if you don't mind. When I add a
>> note, now there is a combo box with a list of users to choose from. I
>> would like for this combo box to not be visible and for it to
>> automatically choose the user submitting the note (The user currently
>> logged in). Is there a way to do this?
>> 
>
> Bump
>
> Any ideas on this?
>   
As Barbara suggested you should look at adding your own save() method to
the form, but you will also want to tag the field as non-editable by
adding editable=False to the field declaration. That way it shouldn't
appear in the form either.

regards
 Steve


--~--~-~--~~~---~--~~
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: Form with 2 models

2008-10-29 Thread Steve Holden

Masklinn wrote:
> On 29 Oct 2008, at 15:06 , Paddy Joy wrote:
>> Is there an easy way of doing this or do I need to create a custom
>> form that contains the fields of both models and then separate the
>> data in my view?
>>
>> Paddy
> 
> What's wrong with creating two different Forms (one for the account,  
> one for the user) and displaying them together in the template? Django  
> has no problem with that (it's in fact one of Django's strengths,  
> being able to mix and match several Forms in a single view&template).
> 
Are you sure that both forms' save() methods will be called on a submit?

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: 'RegistrationForm' object has no attribute 'clean_data'

2008-10-29 Thread Steve Holden

Tsinga wrote:
> I am working with a new book (Learning Website Development with
> Django) from Ayman Hourieh.
> I am going through the application presented in that book.
>   
If you want people who *don't* have the book to help you, you should
provide a little more information. I realise that may not be easy if
English isn't your first language, but many readers of this group are
very sympathetic, so give it a try.

regards
 Steve


--~--~-~--~~~---~--~~
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: Problem with pyExcelerator and response

2008-10-30 Thread Steve Holden

I suspect the issue is the response you are returning. I have never seen
attachments on HTTP responses: can't you just return the contents of the
"output.xls" file by writing it to response before returning it? You
would also need to remove the "Content-Disposition" header.

Just a thought.

regards
 Steve

laspal wrote:
> Any one can help me out.
> Thanks.
> 
> On Oct 29, 11:41 am, laspal <[EMAIL PROTECTED]> wrote:
>> Hi,
>> I am trying to create Excel file usingpyExceleratorbut my problem is
>> I am not able
>> to attach file to response.
>>
>> code :
>> workbook = Workbook()
>> worksheet = workbook.add_sheet('My Test Sheet')
>>
>> worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
>> worksheet.write(1,1, 'Hello World!', font_style('left', 1,
>> 'black'))
>> worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))
>>
>> response = HttpResponse( mimetype='application/vnd.ms-excel')
>> response['Content-Disposition'] = 'attachment;
>> filename=output.xls'
>> workbook.save('output.xls')
>>
>>return response.
>>
>> I am able to generate output.xl file but without any data.
>> Can anyone help me out
>> Thanks.
> > 
> 


-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Problem with pyExcelerator and response

2008-10-30 Thread Steve Holden

laspal wrote:
> Any one can help me out.
> Thanks.
> 
> On Oct 29, 11:41 am, laspal <[EMAIL PROTECTED]> wrote:
>> Hi,
>> I am trying to create Excel file usingpyExceleratorbut my problem is
>> I am not able
>> to attach file to response.
>>
>> code :
>> workbook = Workbook()
>> worksheet = workbook.add_sheet('My Test Sheet')
>>
>> worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
>> worksheet.write(1,1, 'Hello World!', font_style('left', 1,
>> 'black'))
>> worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))
>>
>> response = HttpResponse( mimetype='application/vnd.ms-excel')
>> response['Content-Disposition'] = 'attachment;
>> filename=output.xls'
>> workbook.save('output.xls')
>>
>>return response.
>>
>> I am able to generate output.xl file but without any data.
>> Can anyone help me out
>> Thanks.

Correction: the "Content-Disposition" header is fine, but you do need to
write the file contents to the response.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: __unicode__() method not working in models.py

2008-10-30 Thread Steve Holden

Andrew wrote:
> I am currently working through the django book and I've got to the
> fifth chapter where I would like to replace the __str__() methods with
> __unicode__() methods instead. The reason is that my database will
> hold a great deal of Japanese text, UTF-8 encoded. After declaring the
> UTF-8 encoding at the top of models.py, as a test, I replace
> 
> def __str__(self):
> return self.name
> 
> with
> 
> def __unicode__(self):
> return u'テスト'
> 
> Entering the following code into the manage.py shell doesn't give the
> expected output.
> 
>>>> from books.models import Publisher
>>>> publisher_list = Publisher.objects.all()
>>>> publisher_list
> 
> I expect:
> 
> [, ]
> 
> but instead, the テスト is replaced with random Japanese characters that
> are not the ones I expected.
> 
> I am using a Japanese version of Windows XP with PostgreSQL installed.
> The encoding of the database and the file are both UTF-8. The cmd.exe
> prompt doesn't let me type in Japanese but it does display Japanese if
> print out something I've saved in a file for example.
> 
> Any ideas on where I'm going wrong?
> 
Are you declaring the encoding of your source file?

Try putting

# -*- coding: UTF-8 -*-

at the top of your file.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Help regarding Login form in client side (front end) in Django.

2008-10-30 Thread Steve Holden

sadeesh Arumugam wrote:
> Hi Friends,
>
>  I want to create a login form in client side, anybody please send me
> the Sample login page for the client side coding..
>
Are you reading the answers to your questions before sending them out again?

regards
 Steve


--~--~-~--~~~---~--~~
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: Problem with pyExcelerator and response

2008-10-31 Thread Steve Holden

Try replacing

workbook.save('output.xls')
return response

with

workbook.save('output.xls')
response.write(open('output.xls', 'b').read())
return response

regards
 Steve

laspal wrote:
> So how can I fix it.
> I am not able to fix it.
> Thanks
>
> On Oct 30, 4:26 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>   
>> laspalwrote:
>> 
>>> Any one can help me out.
>>> Thanks.
>>>   
>>> On Oct 29, 11:41 am,laspal<[EMAIL PROTECTED]> wrote:
>>>   
>>>> Hi,
>>>> I am trying to create Excel file usingpyExceleratorbut my problem is
>>>> I am not able
>>>> to attach file to response.
>>>> 
>>>> code :
>>>> workbook = Workbook()
>>>> worksheet = workbook.add_sheet('My Test Sheet')
>>>> 
>>>> worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
>>>> worksheet.write(1,1, 'Hello World!', font_style('left', 1,
>>>> 'black'))
>>>> worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))
>>>> 
>>>> response = HttpResponse( mimetype='application/vnd.ms-excel')
>>>> response['Content-Disposition'] = 'attachment;
>>>> filename=output.xls'
>>>> workbook.save('output.xls')
>>>> 
>>>>return response.
>>>> 
>>>> I am able to generate output.xl file but without any data.
>>>> Can anyone help me out
>>>> Thanks.
>>>> 
>> Correction: the "Content-Disposition" header is fine, but you do need to
>> write the file contents to the response.
>>
>> regards
>>  Steve
>> --
>> Steve Holden+1 571 484 6266   +1 800 494 3119
>> Holden Web LLC  http://www.holdenweb.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-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
-~--~~~~--~~--~--~---



Formset in template with extra per form

2008-11-01 Thread Steve Bergman

I have a formset, each form representing a row in a table. I also have
a list of dictionaries, each list item providing additional data to
print on that row.  The formset and list of dictionaries are of
arbitrary lengths, and potentially in the hundreds or even low
thousands, so efficiency counts.  I also want to keep the logic as
simple and clear as possible.

I would like to be able to loop over both at once in the template
while rendering the table, but I don't see a good way to do that with
Django templates.  And I don't see an obvious way to efficiently zip
up 'formset.forms' with 'items' to do things that way, But I don't
have the deepest understanding of formsets, so perhaps that is
possible.

Any thoughts?

Thanks,
Steve Bergman
--~--~-~--~~~---~--~~
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: sharing a module level variable

2008-11-02 Thread Steve Holden

belred wrote:
> i have an wget event in a cron job.  the view does some processing
> which involves calling external websites and databases (takes about 25
> seconds) and updates some module level dictionary lookup variables
> (about 7 MB of data) which the rest of the program reads.  but
> unfortunately, only the one apache child process seems to be updated,
> not all the others.  how can i share this module level variable across
> processes?  this lookup happens multiple times per  request.  but the
> internal data gets updated nightly.
>   
Aah, so this is the real question! I don't believe Django signals are
intended to serve needs like this. How does "the rest of the program"
read the module-level dictionary items? The more explicit you are about
the exact communication mechanism involved the more likely it is someone
(probably not me) will be able to help.

regards
 Steve


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

2008-11-02 Thread Steve Holden

belred wrote:
> i'm having touble finding documention about django signals that
> explain how they behave under apache child processes. if i have a
> signal go off and have a listener for that signal. will only the
> listener in same child process receive it or will that same listener
> in all apache child processes receive it?
>
> what is the best way to signal all of your apache child process for
> you project?
I don't think the intention of Django signals is to allow notifications
to be sent to independent processes. It's more that when a request
causes certain things to happen then signals can be used to notify an
appropriate handler that it's time to run. In other words it's a
flexible communications mechanism for in-process (single-request)
decoupled notifications.

What events are you feeling the need to notify to all your Apache
sub-processes? Maybe there's some more appropriate mechanism you could
use ... or I could be wrong about Django signals.

regards
 Steve


--~--~-~--~~~---~--~~
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: Cascading List List Boxes

2008-11-02 Thread Steve Bergman

You will need to display the dependent ChoiceField empty at first, but
set the first ChoiceField to submit the form "onchange". (I like to
use the JQuery events system for this, but you can do it with "attr".)
Then have the view redisplay the form with the dependent ChoiceField
populated.  IIRC, to get dynamic choice fields you have to override
__init__() in the form to accept a "choices" argument and use it to
set the choices at form instantiation time rather than once when the
class is defined. You can set initial *values* at instantiation time,
but not choices. That's always seemed awfully clunky to me, as this is
a fairly common need. Would dynamic choices be a reasonable request
for 1.1, I wonder?
--~--~-~--~~~---~--~~
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: random queryset, how to

2008-11-02 Thread Steve Holden

AvK wrote:
> hi,
> i want to get random records form the database, the queryset looks
> like this :
> "
>   questions = Question.objects.filter(quiz__pk=quiz_id).order_by('?')
> [:10]
>
> "
> the problem is that if i want to use questions variable again, it
> everytimes changes the returned records from db for a new random and
> that is  not desired. i mean if i have code like this :
> ""
> def create_quiz_forms(quiz_id, data=None):
>
>questions =
> Question.objects.filter(quiz__pk=quiz_id).order_by('?')[:10]
>print questions
>#and then i have this:
>form_list = []
>for pos, question in enumerate(questions):
>form_list.append(QuestionForm(question, data,
> prefix=pos))
>if not form_list:
># No questions found, so the quiz_id must have been bad.
>raise Http404('Invalid quiz id.')
>return form_list
>
>  ""
> the  ferst reference to the questions variable  (print questions) will
> give another effects(records) than in the second reference  in the for
> loop.(for pos, question in enumerate(questions).
> how can i make the quesions variable   in a differents references
> returned the same records from the db.
>   
Try replacing

   questions =
Question.objects.filter(quiz__pk=quiz_id).order_by('?')[:10]


with

   questions =
list(Question.objects.filter(quiz__pk=quiz_id).order_by('?')[:10])

That way the question list is fixed. It would also make more sense to test 
immediately whether the question list is empty rather than waiting until you 
build the forms, by following that with


if not questions:
raise Http404('Invalid quiz id.')

regards
 Steve


--~--~-~--~~~---~--~~
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: random queryset, how to

2008-11-02 Thread Steve Holden

AvK wrote:
> hi,
> i want to get random records form the database, the queryset looks
> like this :
> "
>   
PS: You asked this question at 11:44, then again at 11:45 and yet again
at 12:25. Please have a little patience!

regards
 Steve


--~--~-~--~~~---~--~~
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's decoupling apps but template should couple them together, right?

2008-11-02 Thread Steve Holden

ilmarik wrote:
> It's just simple amazing that I waste another night to figure out how
> to glue two and more apps together inside one template.
> I read about custom tags and I thing it isn't (or at least it
> shouldn't be) the way of doing it. too much fuss imho.
> 
> Example:
> I have home page with menu on one side, news on other side, greetings
> article inside, footer menu on bottom and a survey somewere else.
> everything on one page of course.
> 
> Walking with the idea of decoupled apps, I should create News app,
> Survey app, Menu app and so on...
> It was simple and fun for a newbe like me to do it but...
> How in the name of God to put all these Views' responses into ONE
> template ?
> djangobook.com says nothing about it. djangoproject.com neighter. at
> least not explicitly...
> 
> I'm trying to google this problem out but without success.
> 
> Can anybody point some simple explanation to me ?
> or is Django blind for such fundamental and common task and isn't
> simplifying it at all ?
> 
Since a view is intended to provide a response to an HTTP request, if
you want a single page that includes the output from multiple views you
need a page structure that fills various sections by making HTTP
requests in the manner of a portal.

However, it's not clear that you really *do* want to use a separate view
for each piece of output. In that case you need to write views that
structure their output by making calls on function imported from the
various apps, each of which renders the appropriate small portion of the
final page, or provides the information tho be inserted into that part
of the template.

You might also want to look into ContextManager objects, which are a way
of providing information to all pages.

A slightly fuller description of your intended page structure might let
people provide more accurate answers to your needs.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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's decoupling apps but template should couple them together, right?

2008-11-03 Thread Steve Holden

bruno desthuilliers wrote:
>
> On 3 nov, 03:56, Steve Holden <[EMAIL PROTECTED]> wrote:
> (snip)
>   
>> You might also want to look into ContextManager objects, which are a way
>> of providing information to all pages.
>> 
>
> I assume you meant 'Context processors' ?-)
>
>   
Are you some kind of a mind-reader? I suppose that would mean I had to
have some kind of a mind ;-)

Thanks, Bruno, I did indeed mean context processors.

regards
 Steve


--~--~-~--~~~---~--~~
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: Python package names

2008-11-03 Thread Steve Holden

Dj Gilcrease wrote:
> I run into this issue all the time since I put all of my apps in
> "site-packages/django_apps/*", the only thing you can do is manually
> change the imports to fit your naming structure
> 
The ONLY thing?

> So for all mine I have to edit the imports and prepend "django_apps."
> for all of the internal imports (eg. "from django_apps.tagging.fields
> import TagField")
> 
Why not just add .../site-packages/django_apps to your PYTHONPATH,
making direct imports from that directory possible? That seems much
easier than modifying the source, and it's a standard Python mechanism.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Using Django

2008-11-03 Thread Steve Holden

[EMAIL PROTECTED] wrote:
> I understand the mapping of urls.py but I guess I'm not clear on a few
> things to begin with, like what is the equivalent to an index.html
> page in django? I know that the system works off of a template system
> like using "base.html" as the design skeleton for a site and extending
> that system with calls to different views, but what happens when I
> want to just request the index page for a django site? Let's say I
> register and add a subdomain to my Dreamhost account say...
> mysite.com, when I issue the startproject command as django-admin.py
> startproject mysite is there some sort of connection between the two?
> Do I scrap the Dreamhost generated directory "mysite.com" and the
> actual command I should be issuing is django-admin.py startproject
> mysite.COM? What is returned for an index page if there is no
> ndex.html or index.php?
>
>   
Your site's root page is whatever is mapped to r"^$", the empty URL.

It's the same for directories. If you *want* to map something on to
.../something.html you can, but there is no need to. When a
"directory-like URL" is passed by a browser the returned result is
whatever is generated by the view the the URL is mapped to. Or a 404 if
no such mapping can be found.

regards
 Steve


--~--~-~--~~~---~--~~
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: An interesting URL dispatcher problem

2008-11-04 Thread Steve Holden

redmonkey wrote:
> Hi,
> 
> I have a small form on a page that is mostly optional fields with the
> exception of some drop down boxes. I want to take the data submitted
> through this form and use them to form a URL.
> 
> My problem is with the URL writing. I first wrote some unit tests to
> find the regular expressions that worked but Django doesn't seem to
> like the '?' in URL configurations.
> 
> How can I write a workflow that converts optional, POSTed data to a
> RESTful URL for processing?
> 
> Here's an example:
> 
> class IceCreamForm(forms.form):
> description = forms.CharField(required=False)
> flavour = forms.ChoiceField(choices=FLAVOUR_CHOICES, initial=0)
> FLAVOUR_CHOICES = (
>   ...
> )
> 
> This is my form class. It contains one optional field, and one
> required field. When rendered on a page, the form POSTs it's data to
> the the 'process' view:
> 
> def process(request):
> # Standard form stuff (is_valid) ...
> params = {}
> if form.cleaned_data['description']:
> params.update(description=form.cleaned_data['description'])
>   if form.cleaned_data['flavour']:
>   params.update(flavour=form.cleaned_data['flavour'])
> 
>   return HttpResponseRedirect('proj.app.views.filter', kwags=params)
> 
> def filter(request, description=None, flavour=0):
> ... do stuff ...
> 
> Here, I collect the parameters from the form and try to turn them into
> a pretty URL that redirects to the filter view to do something with
> the data. It's the URL writing I'm having problems with. I want to
> write things like:
> 
> urlpatterns += patterns('proj.app.views',
> (r'^(?P\w+)/((?P\w+)/)?$', 'filter'),
> )
> 
It might be better to try something that makes the last slash optional
in a different way. How about

(r'^(?P\w+)(/(?P\w+))/?$', 'filter'),

> The question mark is wrapped around an extra '/' to complete the URL,
> but it doesn't work. Nor does
> 
> urlpatterns += patterns('proj.app.views',
> (r'^(?P\w+)/$', 'filter'),
>     (r'^(?P\w+)/(?P\w+/$', 'filter'),
> ) 
> 
> I'm surprised with the result of the last one, and so I'm sure I'm
> missing something. Does anyone have any ideas or simplifications for
> me?
> 
The last one doesn't even appear to be a syntactically correct re due to
mismatching parentheses ... did you copy and paste, or mis-transcribe?

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: including javascript in templates

2008-11-06 Thread Steve Holden

You don't need to serve them from Apache for development - then it's OK
to use Django. It's only in production you want to use some other server
for media and static content.

I have this at the end of my settings.py just to keep my test sites
looking reasonable:

# Serve static content so test site looks reasonable
if settings.SERVE_STATIC:
urlpatterns += patterns('',
*tuple(
(r'^%s/(?P.*)$' % d, 'django.views.static.serve',
  {'document_root':
'/home/holdenwe/websites/test_holdenweb_com/static/%s' % d})
    for d in settings.STATIC_DIRS ))

regards
 Steve

David Sáez wrote:
> Hi Håkan,
>
> yes, I missed the reading of that link. Now that I have set up
> correctly it works fine.
>
> But it has a BIG disclaimer, and the reccommendation is to let the
> webserver to serve these files (that is what I really want)
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-media-files
>
> So, I should configure my own development Apache to serve them. (We
> will probably have only one webserver in the production environment,
> although separated webserver are recommended).
>
> Thanks a lot!
>
> On 6 nov, 17:53, Håkan Waara <[EMAIL PROTECTED]> wrote:
>   
>> 6 nov 2008 kl. 17.35 skrev David Sáez:
>>
>>
>>
>>
>>
>> 
>>> Hi, I'm a newbie to django and I'm dealing with some configuration
>>> stuff that is making me going crazy. My problem is very simple and I
>>> have a temporal solution, but I guess there might be a better way to
>>> do it. So... there goes the question...
>>>   
>>> ¿ How do I include javascript in a basic template ? I mean, imagine
>>> this template:
>>>   
>>> 
>>>
>>>

Re: how to get the id in an admin template

2008-11-06 Thread Steve Holden

It's in the only row in your sites table.

regards
 Steve

webcomm wrote:
> I don't understand the documentation.  I am able to get the "view on
> site" link to show, but the URL is wrong.  The correct URL for the
> instance is...
>
> http://www.mysite.com/billing/321
>
> ...so I tried this...
>
> def get_absolute_url(self):
> return "/billing/%i" % self.id
>
> ...but when I click the resulting "view on site" link, I'm redirected
> to...
>
> http://example.com/billing/321/
>
> I'm not sure where that "example.com" is coming from.  I went looking
> for it in settings.py and urls.py and don't see it anywhere.
>
> -Ryan
>
>
>
>
>
> On Nov 4, 11:25 am, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:
>   
>> On 04.11.2008 17:19 Uhr,webcommwrote:> How do I get the instance id from 
>> within an admin template?  I want to
>> 
>>> add a link to view the instance, and I need the id to create that
>>> link.  Like so...
>>>   
>>> View this item
>>>   
>> if your Model supplies a get_absolute_url method, then the Admin will
>> automatically create a "view on site" link
>> on the change detail page.
>> See 
>> alsohttp://docs.djangoproject.com/en/dev/ref/models/instances/#get-absolu...
>>
>> adi
>>
>> --
>> Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
>> Freelance developer   web:http://www.sieker.info/profile
>> SAP-Developer
>> 
> >
>
>   



--~--~-~--~~~---~--~~
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: App initialized twice? plus, debugging tips.

2008-11-06 Thread Steve Holden

project2501 wrote:
> Hi,
>   I'm new to django and have a couple questions.
>
> I have a __init__.py in my app and try to declare a simple module wide
> variable. I noticed __init__.py is called twice when I run "python
> manage.py runserver". Is this normal?
>
>   
I believe it can happen, yes.
> Also, I tried to run "manage.py runserver" through my Wing IDE in
> debug mode, but it failed. Is there a convenient way to debug django
> apps?
>   
Did you follow the instructions in the Wing IDE documentation? You need
to use the --noreload option. It's very practical to debug Django under
Wing.

regards
 Steve



--~--~-~--~~~---~--~~
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: A question about models

2008-11-06 Thread Steve Holden

叮叮当当 wrote:
> I have a problem with model, describe as follow:
>
> suppose i have two models:
> class A:
>pass
> class B:
>pass
>
> for some reason, i must quote B in class A, and also, i must quote A
> in class B, how do i solve this question?
>
>   
Use the name of the class as a string.

regards
 Steve


--~--~-~--~~~---~--~~
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: apache and django

2008-11-10 Thread Steve Holden

If you read your httpd.conf file you will find at some point there is a
line that includes the configuration data from the sites-enabled
directory. This idea is to be able to switch sites on and off by adding
and removing symbolic links from sites-enabled.

Make sure you *always* edit the files in sites-available! If you edit in
site-enabled, some editors will replace the original symbolic link in
sites-enabled with an updated copy of the file itself, and then you will
lose you configuration data if you decide to switch the site off
temporarily ...

The configuration commands are exactly the same for a configuration
sub-file: it's exactly as though they had appeared in the main
configuration file at the point of inclusion, so once you understand the
relationship between the sites-available and sites-enabled directories
and your main configuration file you should be good to go.

You *could* put the configuration commands in http.conf itself, but this
goes against the Debian/Ubuntu organization scheme, and so probably
wouldn't be helpful long-term.

The Django setup instructions aren't bad, but there are so many
different ways that Apache is organized that the authors couldn't hope
to cover them all.

regards
 Steve
>
> On Nov 9, 10:33 pm, "DULMANDAKH Sukhbaatar" <[EMAIL PROTECTED]>
> wrote:
>   
>> Please follow instructions 
>> onhttp://docs.djangoproject.com/en/dev/howto/deployment/modpython/to
>> setup django and mod_python.
>>
>> And it's interesting that how do you know that mod_python is working?
>>
>> --
>> Regards
>> Dulmandakh
>> 
> >
>
>   



--~--~-~--~~~---~--~~
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: question(s) about django-registration, default user profiles and django-profiles

2008-11-11 Thread Steve Holden

Alex S. wrote:
> hi there,
>
> i want to use django-profiles to save some additional data for each
> user. so i created the needed profile model and set it in my settings
> file. after some looking over the standard user model i found fields
> for first- and lastname. i need that data in my profiles and really
> would not like to have that fields again in my custom profile model.
> i'd say the best way would be to display a form that saves the first-
> and the lastname in the standard user fields and the rest in the
> additional profile. is this possible? how would i implement such a
> form? just using the form_class parameter of django-profiles could
> work with such an approach?
>
> thanks in advance for any help! i know it's not a big problem but i'm
> always trying to do things in a way that just "feels good" - that's
> why i don't want to just implement the first- and lastname fields in
> the custom profile if they are already existing in another table (even
> if i would be able to get that working then). apart from that i think
> it would deepen my understanding on the way django works.
>   
See "Forms with 2 models":

http://groups.google.com/group/django-users/browse_thread/thread/655938b1c01d6dee/0e43647e09b557ba?show_docid=0e43647e09b557ba&pli=1
<http://groups.google.com/group/django-users/browse_thread/thread/655938b1c01d6dee/0e43647e09b557ba?show_docid=0e43647e09b557ba&pli=1>

regards
 Steve


--~--~-~--~~~---~--~~
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: Setting Up Django on Vista and Creating a Database

2008-11-11 Thread Steve Holden

John Antony wrote:
> I am currently using Vista OS
> I have installed Python in the path
> D:\Python26\
> and extracted the tarred file downloaded from www.djangoprojects.com
> ie "Django-1.0.tar.gz" in the path
> D:\Python26\Django-1.0\Django-1.0
> I am however unable to intall Django
> on typing the following command in command prompt I get this error:
> 
> D:\Python26\Django-1.0\Django-1.0>python setup.py install
> 'python' is not recognized as an internal or external command,
> operable program or batch file.

Sorry, I read the first half of your answer a little too quickly. Try

D:\Python26\python setup.py install

or just make sure that D:\Python26\ is added to your path (assuming
that's where you installed Python).

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Setting Up Django on Vista and Creating a Database

2008-11-11 Thread Steve Holden

John Antony wrote:
> I am currently using Vista OS
> I have installed Python in the path
> D:\Python26\
> and extracted the tarred file downloaded from www.djangoprojects.com
> ie "Django-1.0.tar.gz" in the path
> D:\Python26\Django-1.0\Django-1.0
> I am however unable to intall Django
> on typing the following command in command prompt I get this error:
> 
> D:\Python26\Django-1.0\Django-1.0>python setup.py install
> 'python' is not recognized as an internal or external command,
> operable program or batch file.
> 
> If I use the Python (command line) found in Start>All Programs>Python
> 2.6
> 
>>>> D:\Python26\Django-1.0\Django-1.0>python setup.py install
> File "", line 1
> 
> How do i install Django on my system..??
> 
It seems you are suffering from a little confusion about the command in
the installation instructions.

When you see

   D:\Python26\Django-1.0\Django-1.0>python setup.py install

in the instructions, the

   D:\Python26\Django-1.0\Django-1.0>

part is intended to indicate that you are running a Windows command
shell for which the default drive/directory combination is currently as
given (and the assumption is that you have unpacked the Django
distribution into that directory). It's the standard prompt for a
windows command shell window. The command you enter is

   python setup.py install

Since you obviously have Python installed already, you may benefit from
reading

   http://www.python.org/doc/faq/windows/

but bear in mind that Start>All Programs>Python 2.6

brings up a Python interpreter inside a Windows command shell, not a
bare Windows command shell (which is what you need).

> Also post intallation I wish to create a Database with username and
> password all with the same name ie "myforum"
> 
This is really dependent on the database platform you are planning to
use, and not specifically a Django-related question anyway, though it's
related enough that I am sure that others on this list will be happy to
give you advice once you enlighten us about your choice of database.

Good luck with Django!

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Recursive function

2008-11-12 Thread Steve Holden

By all means use your custom tag. Inside the code for the tag, use a
template to generate the HTML. That's all!

regards
 Steve

gontran wrote:
> Could you be more explicite because I don't understand everything and
> why not using my custom tag? (which works fine)
>
> On 12 nov, 14:43, bruno desthuilliers <[EMAIL PROTECTED]>
> wrote:
>   
>> On 12 nov, 14:25, gontran <[EMAIL PROTECTED]> wrote:> On 12 nov, 13:22, 
>> Steve Holden <[EMAIL PROTECTED]> wrote:
>>
>> 
>>>> gontran wrote:
>>>> 
>> (snip - about using templates instead of building html in python code)
>>
>> 
>>>>> -> I'm using this function in a custom tag to build a menu
>>>>>   
>>>> And is there a rule that says you can't do that using templates?
>>>> Hello Steve,
>>>> 
>>> Maybe I'm wrong but I want to display this menu in all pages of my
>>> site, so by using a custom tag, I can display my menu without having
>>> to import my model in my different views.
>>>   
>> This doesn't prevent you from using a template to do the html
>> rendering:
>>
>> class MyNode(Node):
>> def render(self, context):
>> template = get_template('path/to/mytemplate.html')
>> context.push()
>> try:
>> context['foo'] = 'bar'
>> return template.render(context)
>> finally:
>> context.pop()
>>
>> HTH
>> 
> >
>
>   



--~--~-~--~~~---~--~~
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: creating django middleware

2008-11-12 Thread Steve Holden

ershadul wrote:
> Dear all,
> please consider the following code-block:
>
> class SQLAlchemySessionMiddleware(object):
> """
> This class instantiates a sqlalchemy session and destroys
> """
> def process_request(self, request):
> request.db_session = session()
> return None
>
>   
The last statement in your method is completely redundant, and I'd
suggest you remove it.

How are you verifying that your middleware's "process_request()" method
is being called?
[...]

regards
 Steve


--~--~-~--~~~---~--~~
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: user-registration

2008-11-12 Thread Steve Holden

Maximus007 wrote:
> Hi guys,
> I am not able to change  any of the file
> ("views.py,""form.py,""models.py","urls.py") in user registration
> module which I have installed in Python's sitepackages.It is giving me
> permission denied msg.
> I have to use email id as an username instead of seprate username in
> my project.
> I have also downloaded some snippets from django site but I am not
> able to use them because i am not able to embed the code of user-
> registration im my project directly..
> Please help me..

Well you are either going to have to install registration somewhere you
can edit the files or get permission to edit them in the site-packages
directory.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Recursive function

2008-11-12 Thread Steve Holden

gontran wrote:
> Merci beaucoup!
> it works fine now.
> 
>> Now, and while this is none of my problems, I'd seriously question the
> decision of building html that way. This would be better done using
> templates IMVHO.
> 
> -> I'm using this function in a custom tag to build a menu

And is there a rule that says you can't do that using templates?

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: [Errno 13] Permission denied while using apache2

2008-11-12 Thread Steve Holden

laspal wrote:
> hi,
> I am trying to create folder.
> here is the code:
> if not os.path.isdir(str(_user.username)):
>  os.mkdir(str(_user.username) )
> filepathwithname = os.path.join(str(_user.username), file_name)
> if not os.path.isfile(filepathwithname):
> workbook.save(os.path.join(str(_user.username),
> file_name))
>
> The problem is I am getting permission denied error.
> It works fine when I am using  runserver. but getting error while
> using apache2
>
> Can anyone help me out.
>   
What's the current directory when that code runs under Apache? It's
likely not the same as when you run it under runserver ... so you will
either need to change its permissions or switch to a directory you *do*
have permissions on.

regards
 Steve


--~--~-~--~~~---~--~~
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: Performing an operation

2008-11-12 Thread Steve Holden

Just make sure when you *do* set your hosting up that you get shell
(command line) access of some kind so you can set up the cron jobs.

regards
 Steve

[EMAIL PROTECTED] wrote:
> Thanks for your help Daniel! I havent got hosting sorted yet so its
> something Ill have to set up later.
> I guess I can set up the custom command and do it manually for now.
> Phil
> 
> On Nov 12, 5:29 pm, Daniel Roseman <[EMAIL PROTECTED]>
> wrote:
>> On Nov 12, 5:02 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
>> wrote:
>>
>>
>>
>>> Hi all,
>>> Just building my first site with django and Ive hit my first snag that
>>> I cant find in the documentation.
>>> Just as an example scenario, suppose I have my model-
>>> class User(models.Model):
>>> signup_date =  models.DateTimeField()
>>> full_user_date = models.DateTimeField()
>>> full_user = models.BooleanField()
>>> I want to make it so that when we arrive at full_user_date django
>>> flicks full_user over to 1 and sends the user an email.
>>> I imagine I could do it in the views.py, but it would be dependant on
>>> someone visiting the page. I think it would be more effecient to just
>>> do a check once a day, thats all I need. How can i set it up so django
>>> does a check on the database after a set time?
>>> any ideas?
>>> Phil
>> You need some sort of job that runs periodically on the server. If
>> you're using Linux (or a Mac), cron is ideal for this. (I think
>> Windows has something like a Schedule Server for this job.)
>>
>> Just create a standalone script that imports the Django models just as
>> you would do in a view. Perhaps the best way of doing this is to
>> create a custom manage.py command - 
>> seehttp://docs.djangoproject.com/en/dev/howto/custom-management-commands...
>> for how this is done.
>>
>> You can then set cron to run manage.py your_command once a day to do
>> the update.
>> --
>> DR.
> > 
> 


-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: slow django builtin webserver

2008-11-12 Thread Steve Holden

Sven Richter wrote:
> 
> Hi all,
> 
> i recently reinstalled my workingstation. Nothing wild, just
> changed from single hdd to a raid system. However, scince
> that day my django server has a horrible response on
> the new system.
> Loading the server takes up to ca. 5 secs and requesting
> a site from it the same amount of time.
> 
> First i thought it was the mysql server which was running
> on ubuntu and where i upgraded to the new version (intrepid).
> So i installed a mysql server on my machine and adapted the
> settings, but that didnt help.
> 
> Same issue as before.
> 
> Now i am wondering where i can start to debug that.
> 
> My production machine runs on Arch linux which
> uses python 2.6 and django 1.0.
> 
> The same problem seems to appear when i try to
> connect via ssh to my other server. But that seems
> serverrelated cause it happens on other clients in my
> LAN too. I am a bit irritated, is suspect it to be
> some kind of dns problem.
> But what speaks against that is that internet requests
> are as fast as normal, and phpymadmin behaves
> normal too.
> 
This sounds a bit like a DNS problem to me, though that's only one of
many possible diagnoses.

Is "localhost" set in the /etc/hosts file?

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: creating django middleware

2008-11-13 Thread Steve Holden

ershadul wrote:
> Dear ,
> I dont know whether my process_request() is being called or not?
> Can you inform me please, how can i verify that my middleware's
> process_request() is called ?
> 
> On Nov 12, 4:42 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>> ershadul wrote:
>>> Dear all,
>>> please consider the following code-block:
>>> class SQLAlchemySessionMiddleware(object):
>>> """
>>> This class instantiates a sqlalchemy session and destroys
>>> """
>>> def process_request(self, request):
>>> request.db_session = session()
>>> return None
>> The last statement in your method is completely redundant, and I'd
>> suggest you remove it.
>>
>> How are you verifying that your middleware's "process_request()" method
>> is being called?
>> [...]

Try putting print statements in your code. Running the test server, of
course, so you will see any console output.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Simple date issue ...

2008-11-13 Thread Steve Holden

dbee wrote:
> I'm having a simple issue here trying to pull dates out of a database.
> I can only pull out double digit months eg. October, November,
> December but not single ...
> 
> Database: entry_date
> 
>   2008-10-12
>   2008-09-12
> 
> DB API:
> 
>   month_1_count = all_sign_up.filter(entry_date__month=9).filter
> (entry_date__year=2008).count()
> 
> That doesn't match and pull out the value but this works fine ...
> 
>   month_1_count = all_sign_up.filter(entry_date__month=10).filter
> (entry_date__year=2008).count()
> 
> I'm probably missing something really simple here ...

How are you declaring the dates in the model, and what database platform
are you running on?

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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-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: Read/Create Excel xls files using django

2008-11-13 Thread Steve Holden

Kurczak wrote:
> On 13 Lis, 20:45, dj <[EMAIL PROTECTED]> wrote:
>   
>> Hello All,
>>
>> I am trying to detemine if there is a way to read the data from an
>> Excel xls file into django. I also need to create an xls file. Does
>> anyone know how that would be done ?
>> 
> If you have windows hosting you could use COM interface from python
> win32 extensions.
>   
On any platform the xlrd module will allow you to read Excel
spreadsheets. Creating them is a little more problematic, but it looks
like the PyExcelerator module in SourceForge might work.

Do you *really* have to create an xls file? If your users just want to
get the data into Excel then creating a csv file is a much easier way of
managing that.

regards
 Steve


--~--~-~--~~~---~--~~
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: Templates - testing multiple things on IF line

2008-11-13 Thread Steve Holden

John M wrote:
> Does the IF tag allow for OR's or AND's?
>
>   
Yes. You can use one or the other, but not both, IIRC. [Checks
documentation]. Yes: "If you need to combine and and or to do advanced
logic, just use nested if tags."

regards
 Steve


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



  1   2   3   4   5   6   7   8   >