Re: verbose field names in admin

2010-03-03 Thread Adam Yee
Ok, take a look at this link...
http://docs.djangoproject.com/en/dev/topics/db/models/#verbose-field-names

If that isn't what you're looking for, then you can change it at the
form level...
http://docs.djangoproject.com/en/1.1/ref/forms/fields/#label

Again, the more detail you give will help (ie. some example code of
how you are actually doing this), and the more likely you are to get
help.

Adam

On Mar 1, 4:12 pm, pixelcowboy <pixelcowbo...@gmail.com> wrote:
> Im not trying to change the verbose name for the model class, but for
> individual fields in the model, by the way.
>
> On Mar 1, 2:45 pm, Adam Yee <adamj...@gmail.com> wrote:
>
>
>
> > When in doubt, always refer to the docs 
> > -http://docs.djangoproject.com/en/dev/ref/models/options/
> > There may be something small overlooked.
>
> > You shouldn't have to re-sync the database to use verbose_name.  It's
> > just a hook to be used for example, in the model's meta options.  Give
> > us more detail about your model for further help.
>
> > On Mar 1, 7:20 am, pixelcowboy <pixelcowbo...@gmail.com> wrote:
>
> > > Hi, I have added verbose names for each of my field names, with the
> > > purpose of getting a pretty admin display. However, I have reset my
> > > database and the admin still shows the field name only, not the
> > > verbose name. Do I need to do anything else?

-- 
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: verbose field names in admin

2010-03-01 Thread Adam Yee
When in doubt, always refer to the docs - 
http://docs.djangoproject.com/en/dev/ref/models/options/
There may be something small overlooked.

You shouldn't have to re-sync the database to use verbose_name.  It's
just a hook to be used for example, in the model's meta options.  Give
us more detail about your model for further help.

On Mar 1, 7:20 am, pixelcowboy  wrote:
> Hi, I have added verbose names for each of my field names, with the
> purpose of getting a pretty admin display. However, I have reset my
> database and the admin still shows the field name only, not the
> verbose name. Do I need to do anything else?

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



Can't explain this ImportError

2010-02-24 Thread Adam Yee
Just started using haystack.  I've created an extended search form of
SearchForm and have it located at /mysite/search/search_forms.py

The import error happens in haystack.urls

Traceback:
File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-packages/
django/core/handlers/base.py" in get_response
  92. request.path_info)
File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-packages/
django/core/urlresolvers.py" in resolve
  222. sub_match = pattern.resolve(new_path)
File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-packages/
django/core/urlresolvers.py" in resolve
  220. for pattern in self.url_patterns:
File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-packages/
django/core/urlresolvers.py" in _get_url_patterns
  249. patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-packages/
django/core/urlresolvers.py" in _get_urlconf_module
  244. self._urlconf_module =
import_module(self.urlconf_name)
File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-packages/
django/utils/importlib.py" in import_module
  35. __import__(name)
File "/home/adam/stldata-djangosvn-2.6/mysite/haystack/urls.py" in

  3. from mysite.search.search_forms import CustomerSearchForm

Exception Type: ImportError at /search/serviceorder/
Exception Value: No module named search.search_forms

Here is mysite.haystack.urls:

from django.conf.urls.defaults import *
from haystack.views import SearchView
from mysite.search.search_forms import CustomerSearchForm # <---

urlpatterns = patterns('haystack.views',
url(r'^serviceorder/$', SearchView(), name='haystack_search'),
)

It should be working.  All that's been added is the directory 'search'
containing 'search_forms.py'.
Permissions shouldn't be an issue either.  It's all in my Python
path...I have no clue.

-- 
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: Template links when Django not domain root

2009-07-31 Thread Adam Yee

On Jul 30, 7:29 pm, Graham Dumpleton 
wrote:
> If you are using mod_wsgi then you definitely do not need
> FORCE_SCRIPT_NAME as mod_wsgi does the correct think in respect of
> setting up SCRIPT_NAME/PATH_INFO. The only time it might not be right
> with mod_wsgi is if you used WSGIScriptAliasMatch to map the
> application and you didn't set up the directive properly. This can
> happen because how you set up pattern and target for that directive
> will control how SCRIPT_NAME is calculated. WSGIScriptAliasMatch
> should only be used if absolutely required.
>
> So, post how you configured mod_wsgi to mount your application just to
> eliminate that as possibility. Verify that FORCE_SCRIPT_NAME isn't set
> in settings.py or if it is that it is set to None.
>
> Someone with more Django knowledge would then need to tell you if you
> are specifying urls.py correctly, whether any other settings you need
> to check and whether how URL references are generated are correct. All
> I can tell you is that if mod_wsgi is set up properly, you should
> never need FORCE_SCRIPT_NAME with mod_wsgi.
>
> You may need to explain better what is meant by 'This is causing all
> my template links to break'. Ie., what errors are you getting, what
> are the URLs it is generating and what they should be etc.
>
> Graham
>
> On Jul 31, 12:09 pm, Streamweaver  wrote:
>
>
>
> > I'm not actually using {% url %} at this time.  I am setup for
> > mod_wsgi and don't know how to go about configuring links in the
> > templates when the sites root is on a subdirectory.  There isn't much
> > in the way of examples on FORCE_SCRIPT_NAME I can find and I'm not
> > really an apache admin so I'm a bit out of my depth here.
>
> > Is this the avenue I should be pursuing or is there some way to set
> > this up better.  the url filter seems to violate DRY methodology.
>
> > Thanks again.
>
> > On Jul 30, 9:52 pm, Graham Dumpleton 
> > wrote:
>
> > > Using FORCE_SCRIPT_NAME is only appropriate for certain WSGI hosting
> > > mechanisms. Using it may simply hide the fact that the OPs application
> > > code is wrong to begin with.
>
> > > OP should indicate how they are hosting their application for real
> > > site. Ie., mod_python, mod_wsgi, fastcgi or other.
>
> > > Graham
>

Graham is right about needing to mount your site correctly.  Post your
Apache config at http://groups.google.com/group/modwsgi?hl=en and they
can help with that.  I've not had to use FORCE_SCRIPT_NAME when using
mod_wsgi.  What I found that works is passing the script_name in each
view context.  This is violating DRY, but I haven't worried about that
too much.  This is a way to make apps portable.  If you still need or
want to use the {% url %} tag, you just need to preceed it by a
{{ script_name }} (I'm mostly sure, correct me if wrong).  You can
give script_name to your context with request.META['SCRIPT_NAME'] if
it exists.

hope this helps,
Adam

> > > On Jul 31, 6:04 am, Alex Koshelev  wrote:
>
> > > > If you are using `{% url %}` template tag or `reverse` function you can 
> > > > set
> > > > FORCE_SCRIPT_NAME [1] settings variable specified for your deployment
> > > > project root. Or working with right web-server in front of django 
> > > > project
> > > > force it to tell proper SCRIPT_NAME himself.
>
> > > > [1]:http://docs.djangoproject.com/en/dev/ref/settings/#force-script-name
>
> > > > ---
> > > > Alex Koshelev
>
> > > > On Thu, Jul 30, 2009 at 10:55 PM, Streamweaver 
> > > > wrote:
>
> > > > > I have a django project that has worked just fine in development but
> > > > > I'm trying to move it to a demo site and the application is not on a
> > > > > root domain or sub-domain.
>
> > > > > Instead the site root URL is suppose to be something like
> > > > >https://site.domain.com/appname/
>
> > > > > This is causing all my template links to break.  The {% url %} tag
> > > > > seems to work only for the site root and doesn't bring in the
> > > > > subdirectory name.
>
> > > > > What's the Django way of handling this?  I'm surprised I haven't been
> > > > > able to find something about this.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Submitting a form

2009-07-29 Thread Adam Yee

Use the model's verbose field name 
http://docs.djangoproject.com/en/dev/topics/db/models/#id2

On Jul 29, 3:55 pm, When ideas fail  wrote:
> Is there a way i can change the label for a field in the model form?
>
> On 29 July, 21:44, When ideas fail  wrote:
>
>
>
> > Ok thanks seems to work now.
>
> > On 29 July, 21:27, Daniel Roseman  wrote:
>
> > > On Jul 29, 9:17 pm, When ideas fail  wrote:
>
> > > > I've created a model form and I was wondering what the correct way to
> > > > save this was. I've tried adapting the view from the standard django
> > > > forms docs but maybe it should be different?
>
> > > > This is what i have in my view (it says contact form but its a form
> > > > that should save contacts in a db):
>
> > > > class ContactForm(ModelForm):
> > > >     class Meta:
> > > >         model = Contact
>
> > > > def contact_view(request):
> > > >     if request.method == 'Post':
> > > >         form = ContactForm(request.POST)
> > > >         if form.is_valid():
> > > >             contact= form.save()
> > > >             return HttpResponseRedirect('/thanks/')
> > > >        else: return HttpResponseRedirect('/error/')
>
> > > >     else:
> > > >         form = ContactForm()
> > > >         tags = Tag.objects.all()
> > > >     return render_to_response('Site/contact.html', locals(),
> > > > context_instance=RequestContext(request))
>
> > > > And my template is like this:
>
> > > > 
> > > >                                         {{ form.as_p }}
> > > >                                          > > > value="Submit" />
>
> > > > My understanding is that with this setup it should go to thanks/ if
> > > > the form is valid and error/ if it is not and it doesn't do either,
> > > > and it doesn't save or come back with any errors either . could
> > > > someone help me please?
>
> > > > Thanks
>
> > > There are two problems, but the main one is in the first line of your
> > > view. request.method == 'Post' will *never* be true, because the
> > > method (as in shown in your template) is all upper case.
> > > request.method == 'POST' should work.
>
> > > Secondly, don't redirect to /error/. Drop that else clause altogether,
> > > and let the view fall through to the final render_to_response. This
> > > will redisplay the form with any errors.
> > > --
> > > DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Dynamic Form - polls

2009-04-19 Thread Adam Yee

On Apr 18, 3:23 pm, google torp  wrote:
> Hi.
> Normally, what you are doing would work, initializing the form
> with request.POST. However the way you have constructed
> your form, you need have a poll object as well. Not only that
> but it should of cause be the poll that the post data is associated
> to.
> Then you could do it like this
> form = PollForm(the_right_poll, request.POST)
>
> ~Jakob

Thanks for pointing me in the right direction Jakob.  I've changed my
view adding in 'the_right_poll'.  Works well, but I still have some
improvements to make. Thank you.

#views.py
def do_the_poll(request):
if request.method == "POST":
polls = get_list_or_404(Poll)
for poll in polls:
form = PollForm(poll, request.POST)
if form.is_valid():
choice = form.cleaned_data[poll.question]
choice.votes += 1
choice.save()
return redirect('/mediapoll/')
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Dynamic Form - polls

2009-04-18 Thread Adam Yee

I've been struggling with dynamically creating and validating forms.
So far I've been able to create the forms using a ModelChoiceField.

see below - models, forms, views, template
http://dpaste.com/hold/35292/

After submitting the votes, in the if request.method=="POST" hook, I
can't figure out how to properly fill the form with the request.POST
data.  Right now I'm getting this error

AttributeError at /mediapoll/do_the_poll/
'QueryDict' object has no attribute 'choice_set'

I understand why this is happening, but I can't see if there is
something subtle that I'm missing in creating the form, or how I'm
populating the form with the post data.  I'm still fairly new to
Django.  Help please, thank you.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RadioSelect widget not rendering

2009-04-15 Thread Adam Yee

Can't get the forms.RadioSelect widget to render.  I'm using svn
10559, I've looked over forms/widgets.py, but I don't know...  I'm
able to use forms.CheckboxSelect just fine.

Is it Firefox giving me issues?  What's going on here?

#forms.py
class PollForm(forms.Form):
def make_fields(self, poll):
for c in poll.choice_set.iterator():
self.fields[c.choice] = forms.CharField
(widget=forms.RadioSelect, label=c.choice)

#template

{{ form.as_p }}



#source output from Firefox (missing fields)

Cable: 

Satelite: 

Regular TV: 




--~--~-~--~~~---~--~~
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: Having trouble authenticating/validating

2009-03-26 Thread Adam Yee

On Mar 25, 6:27 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Tue, Mar 24, 2009 at 2:11 PM, Adam Yee <adamj...@gmail.com> wrote:
> > So, I now pass the bound form, but still no validation error messages
> > show up.  More importantly, is_valid is still returning false even
> > when I try logging in as a super user.  I also removed checking for
> > is_active since the AuthenticationForm's clean should take care of
> > that and raise the correct validation error if the user isn't active.
> > Now with the error() func removed:
>
> How are you rendering the form in the template?  If is_valid returns false
> then there should be errors noted in the errors dictionary, if you are not
> seeing these it sounds like youare rendering the form in some way that
> bypasses outputting the form errors.  Fixing that would be a step towards
> figuring out what is causing the problem, since you'd know specifically what
> is wrong instead of trying to guess what might be going wrong.
>
> Karen

{{ error }}

{{ form.as_p }}



Guessing is sometimes all one can do after analyzing to their limit.
Or they can be lazy without any personal effort and post to a group
like this one (which I don't recommend).  I spent as much time allowed
figuring out what I could, then came to you.  I strive to lessen the
amount of guessing I do and develop the skills needed to figure out
problems...but that takes time.

I've been reading up on validating since I feel the problem lies in
the is_valid part.  Again, I understand this is a guess, I just need
to direction in figuring out the problem.  I'm not merely looking for
the quick and easy solution.

What I do know is that rendering a template is a separate action from
validating.  Validation should take place before rendering.  If I
can't validate properly, it won't show in the template properly,
right?  Thanks Karen.
--~--~-~--~~~---~--~~
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: Having trouble authenticating/validating

2009-03-25 Thread Adam Yee

On Mar 23, 8:30 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Mon, Mar 23, 2009 at 4:45 PM, Adam Yee <adamj...@gmail.com> wrote:
>
> > I'm using Django's builtin AuthenticationForm
>
> > Here's my login view:http://dpaste.com/18110/
>
> > Form submittal (not empty or empty fields) takes me back to the login
> > page with 'Did not login'.  My debugging print statement isn't showing
> > up in the terminal, so is_valid is somehow returning false.
>
> > If I submit with empty fields, I don't get the default 'This field is
> > required' type of error messages that I would expect.  I'm not sure
> > how clean() is working with the AuthenticationForm...  Am I validating
> > correctly? Or is something happening in the authentication process?
> > Thanks.
>
> Your error() function is creating a brand-new blank AuthenticationForm that
> is passed in the context to the template, so the specific error message
> associated with whatever caused is_valid() to fail (which has been added to
> the original form's error_list) is being thrown away.  If instead you pass
> back the form you called is_valid() on, then the template would be able to
> report the specific error that is causing the validation failure.
>
> Karen

Do I need to set a test cookie in the view before using
AuthenticationForm()?  I'm new to sessions and cookies.  Anyone out
there use this builtin form, AuthenticationForm()?
--~--~-~--~~~---~--~~
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: Having trouble authenticating/validating

2009-03-24 Thread Adam Yee



On Mar 23, 8:30 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Mon, Mar 23, 2009 at 4:45 PM, Adam Yee <adamj...@gmail.com> wrote:
>
> > I'm using Django's builtin AuthenticationForm
>
> > Here's my login view:http://dpaste.com/18110/
>
> > Form submittal (not empty or empty fields) takes me back to the login
> > page with 'Did not login'.  My debugging print statement isn't showing
> > up in the terminal, so is_valid is somehow returning false.
>
> > If I submit with empty fields, I don't get the default 'This field is
> > required' type of error messages that I would expect.  I'm not sure
> > how clean() is working with the AuthenticationForm...  Am I validating
> > correctly? Or is something happening in the authentication process?
> > Thanks.
>
> Your error() function is creating a brand-new blank AuthenticationForm that
> is passed in the context to the template, so the specific error message
> associated with whatever caused is_valid() to fail (which has been added to
> the original form's error_list) is being thrown away.  If instead you pass
> back the form you called is_valid() on, then the template would be able to
> report the specific error that is causing the validation failure.
>
> Karen

Thanks Karen for that tip.  The brand-new unbound form is removed.

So, I now pass the bound form, but still no validation error messages
show up.  More importantly, is_valid is still returning false even
when I try logging in as a super user.  I also removed checking for
is_active since the AuthenticationForm's clean should take care of
that and raise the correct validation error if the user isn't active.
Now with the error() func removed:

def stl_login(request):
if request.method == "POST":
form = AuthenticationForm(request.POST)
if form.is_valid(): # authenticate() should get called here from
form's clean()
print 'form is valid'
user = form.get_user()
print request.user
login(request, user)
return HttpResponseRedirect(reverse
('stlhome.views.stl_user_home'))
return render_to_response('stl_home.html', {
'script_name': request.META['SCRIPT_NAME'],
'form': form,
'error': 'Did not login'}
)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Having trouble authenticating/validating

2009-03-23 Thread Adam Yee

I'm using Django's builtin AuthenticationForm

Here's my login view: http://dpaste.com/18110/

Form submittal (not empty or empty fields) takes me back to the login
page with 'Did not login'.  My debugging print statement isn't showing
up in the terminal, so is_valid is somehow returning false.

If I submit with empty fields, I don't get the default 'This field is
required' type of error messages that I would expect.  I'm not sure
how clean() is working with the AuthenticationForm...  Am I validating
correctly? Or is something happening in the authentication process?
Thanks.


# django.contrib.auth.forms.py
# AuthenticationForm's clean()
...
def clean(self):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')

if username and password:
self.user_cache = authenticate(username=username,
password=password)
if self.user_cache is None:
raise forms.ValidationError(_("Please enter a correct
username and password. Note that both fields are case-sensitive."))
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is
inactive."))

# TODO: determine whether this should move to its own method.
if self.request:
if not self.request.session.test_cookie_worked():
raise forms.ValidationError(_("Your Web browser
doesn't appear to have cookies enabled. Cookies are required for
logging in."))

return self.cleaned_data
...
--~--~-~--~~~---~--~~
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: Deploying Django tutorial part 4, redirecting problem, apache error

2009-03-12 Thread Adam Yee

On Feb 10, 5:27 am, "a...@amos-site.org.uk"
<david.john.a...@googlemail.com> wrote:
> Where exactly do you put this I'm guessing in the file, but a bit of
> context would be appreciated.

#django.views.generic.list_detail.py
...
...
def object_detail(request, ... ...
...
...
c = RequestContext(request, {
template_object_name: obj,
'script_name': request.META['SCRIPT_NAME'],  # <---
}, context_processors)
for key, value in extra_context.items():
if callable(value):
c[key] = value()
else:
c[key] = value
response = HttpResponse(t.render(c), mimetype=mimetype)
populate_xheaders(request, response, model, getattr(obj,
obj._meta.pk.name))
return response


>
> On Jan 19, 7:17 am, Adam Yee <adamj...@gmail.com> wrote:
>
>
>
> > Success.  I added
>
> > 'script_name': request.META['SCRIPT_NAME']
>
> > into the context of object_detail() in django's generic views
> > list_detail.py.  Here's the modified form tag to the polls_detail.html
> > template:
>
> >  > method="post">
>
> > Note removing the / before {{ script_name }}
>
> > Just to reiterate what Preston said, please share other solutions.
>
> > On Jan 18, 8:13 pm, Adam Yee <adamj...@gmail.com> wrote:
>
> > > On Jan 18, 7:39 am, ptone <pres...@ptone.com> wrote:
>
> > > > In thetutorial, the form action in the poll_detail template is
> > > > hardcoded to "/polls/..."
>
> > > > So the browser is doing what's been explicitly asked of it, despite
> > > > Django doing its best to deal gracefully with your mounting the app
> > > > at /mysite.
>
> > > > In my own newcomer approach, the way I found to work around this is to
> > > > pass in the script name into the context that goes to the template in
> > > > the render_to_response line of the view
>
> > > > 'script_name':request.META['SCRIPT_NAME']
>
> > > > and then use that in the form action URL:
>
> > > >  > > > method="post">
>
> > > Preston, thanks for pointing this out.  You're right about the url
> > > being hardcoded and the prefix not being passed.  I played around with
> > > your request.META['SCRIPT_NAME'] suggestion.  I can't figure out how
> > > to pass the initial 'script_name' to the poll_detail before trying to
> > > vote.  In other words, it seems like I would need to include
> > > 'script_name' in the context passed to the generic view
> > > (object_detail) before it can properly be used in the form.
>
> > > If I add an {% if script_name %} in the poll_detail template or just a
> > > {{ script_name }}, it would need to be rendered before accessing the
> > > vote view.  Maybe you can ellaborate on your method of getting django
> > > to recognize the prefix.  Portability is looking difficult at this
> > > point.  Thanks to all for your help.
>
> > > > This proobably means a // in the URL if you mount your site at /, but
> > > > I think most browsers and servers won't care about that extra /
>
> > > > I welcome anyone pointing out a better way to make the form action
> > > > more "portable" in projects...
>
> > > > -Preston
>
> > > > On Jan 17, 7:53 pm, Adam Yee <adamj...@gmail.com> wrote:
>
> > > > > It was a slam dunk for completing thetutorialin the development
> > > > > server, but I can't figure out this issue I'm having with the generic
> > > > > views while using myapacheserver.  I'm unable to get the vote view
> > > > > toredirectcorrectly.
>
> > > > > Myapacheerror seen here with both urls.py and views.py.  Theapache
> > > > > config is at the bottom.
>
> > > > >http://dpaste.com/110275/
>
> > > > > Voting (hiting the vote button) with or without a radio button
> > > > > selected is redirecting me tohttp://127.0.0.1/polls/1/vote/which
> > > > > gives me a 404 (and not in django's debug format) instead of 
> > > > > ...mysite/
> > > > > polls/1/vote/.
>
> > > > > However, going in the backdoor way and manually typing 
> > > > > inhttp://127.0.0.1/mysite/polls/1/vote/takesmethroughthevote view
> > > > > KeyError exception saying "You didn't select a choice" and displays
> > > > > the page.  I'm also able to access the results URL manually.  So I'm
> > > > > thinking the problem lies in either the views.py, my urlconfs or
> > > > > something with my wsgiapacheconfig.
>
> > > > > Can anyone see what I'm missing?- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Recent admin redirect url error?

2009-02-04 Thread Adam Yee

Using Django version 1.1 pre-alpha SVN-9805

On Feb 4, 4:44 pm, Adam Yee <adamj...@gmail.com> wrote:
> I'm experiencing Change password / Logout redirect errors while trying
> to logout or change the password.
>
> The 404 messages show below:
> Request Method:         GET
> Request URL:    http://127.0.0.1/admin/admin/logout/
>
> It's adding in an extra ^admin/
>
> Same for Change password:
> Request URL:    http://127.0.0.1/admin/admin/password_change/
>
> Is anyone else experiencing this?  Where in the auth.views can I find
> the issue?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Recent admin redirect url error?

2009-02-04 Thread Adam Yee

I'm experiencing Change password / Logout redirect errors while trying
to logout or change the password.

The 404 messages show below:
Request Method: GET
Request URL:http://127.0.0.1/admin/admin/logout/

It's adding in an extra ^admin/

Same for Change password:
Request URL:http://127.0.0.1/admin/admin/password_change/

Is anyone else experiencing this?  Where in the auth.views can I find
the issue?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Strange "problem" with tutorial

2009-02-03 Thread Adam Yee



On Feb 3, 9:49 am, Joshua Russo  wrote:
> I'm working through the tutorials and have encountered a strange
> problem. So far everything works but Python doesn't acknowledge my
> base site as a package. So everywhere that you see a reference like
> "mysite.poll" I need to use only "poll". I think that my problems stem
> from the following section that starts on line 263 of tutorial01.txt:

Make sure you're not mispelling 'polls'.  You've typed 'poll' above.
If you're talking about the settings, yes you don't need to specify
mysite.polls since the settings.py file is already in the mysite
directory.  You could just put 'polls' into installed apps.

>
> To create your app, make sure you're in the :file:`mysite` directory
> and type
> this command:
>
> .. code-block:: bash
>
>     python manage.py startapp polls
>
> I ran the above command from my MySite directory that holds the
> manage.py file. Is that correct? Anyone have any ideas why I can't
> reference my base package? (I think I'm using the term package
> correctly here.)
>
> Thanks
> Josh

As far as I see your doing it correctly.  For technical purposes, the
way that I see it (and the way django defines it):
mysite = project
polls = app
I'm not quite sure what you're referring to as base package.  Hope
this helps.
--~--~-~--~~~---~--~~
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: Deploying Django tutorial part 4, redirecting problem, apache error

2009-01-18 Thread Adam Yee

Success.  I added

'script_name': request.META['SCRIPT_NAME']

into the context of object_detail() in django's generic views
list_detail.py.  Here's the modified form tag to the polls_detail.html
template:



Note removing the / before {{ script_name }}

Just to reiterate what Preston said, please share other solutions.

On Jan 18, 8:13 pm, Adam Yee <adamj...@gmail.com> wrote:
> On Jan 18, 7:39 am, ptone <pres...@ptone.com> wrote:
>
>
>
>
>
> > In the tutorial, the form action in the poll_detail template is
> > hardcoded to "/polls/..."
>
> > So the browser is doing what's been explicitly asked of it, despite
> > Django doing its best to deal gracefully with your mounting the app
> > at /mysite.
>
> > In my own newcomer approach, the way I found to work around this is to
> > pass in the script name into the context that goes to the template in
> > the render_to_response line of the view
>
> > 'script_name':request.META['SCRIPT_NAME']
>
> > and then use that in the form action URL:
>
> >  > method="post">
>
> Preston, thanks for pointing this out.  You're right about the url
> being hardcoded and the prefix not being passed.  I played around with
> your request.META['SCRIPT_NAME'] suggestion.  I can't figure out how
> to pass the initial 'script_name' to the poll_detail before trying to
> vote.  In other words, it seems like I would need to include
> 'script_name' in the context passed to the generic view
> (object_detail) before it can properly be used in the form.
>
> If I add an {% if script_name %} in the poll_detail template or just a
> {{ script_name }}, it would need to be rendered before accessing the
> vote view.  Maybe you can ellaborate on your method of getting django
> to recognize the prefix.  Portability is looking difficult at this
> point.  Thanks to all for your help.
>
>
>
>
>
> > This proobably means a // in the URL if you mount your site at /, but
> > I think most browsers and servers won't care about that extra /
>
> > I welcome anyone pointing out a better way to make the form action
> > more "portable" in projects...
>
> > -Preston
>
> > On Jan 17, 7:53 pm, Adam Yee <adamj...@gmail.com> wrote:
>
> > > It was a slam dunk for completing the tutorial in the development
> > > server, but I can't figure out this issue I'm having with the generic
> > > views while using my apache server.  I'm unable to get the vote view
> > > to redirect correctly.
>
> > > My apache error seen here with both urls.py and views.py.  The apache
> > > config is at the bottom.
>
> > >http://dpaste.com/110275/
>
> > > Voting (hiting the vote button) with or without a radio button
> > > selected is redirecting me tohttp://127.0.0.1/polls/1/vote/which
> > > gives me a 404 (and not in django's debug format) instead of ...mysite/
> > > polls/1/vote/.
>
> > > However, going in the backdoor way and manually typing 
> > > inhttp://127.0.0.1/mysite/polls/1/vote/takesmethrough the vote view
> > > KeyError exception saying "You didn't select a choice" and displays
> > > the page.  I'm also able to access the results URL manually.  So I'm
> > > thinking the problem lies in either the views.py, my urlconfs or
> > > something with my wsgi apache config.
>
> > > Can anyone see what I'm missing?- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Deploying Django tutorial part 4, redirecting problem, apache error

2009-01-18 Thread Adam Yee

On Jan 18, 7:39 am, ptone <pres...@ptone.com> wrote:
> In the tutorial, the form action in the poll_detail template is
> hardcoded to "/polls/..."
>
> So the browser is doing what's been explicitly asked of it, despite
> Django doing its best to deal gracefully with your mounting the app
> at /mysite.
>
> In my own newcomer approach, the way I found to work around this is to
> pass in the script name into the context that goes to the template in
> the render_to_response line of the view
>
> 'script_name':request.META['SCRIPT_NAME']
>
> and then use that in the form action URL:
>
>  method="post">

Preston, thanks for pointing this out.  You're right about the url
being hardcoded and the prefix not being passed.  I played around with
your request.META['SCRIPT_NAME'] suggestion.  I can't figure out how
to pass the initial 'script_name' to the poll_detail before trying to
vote.  In other words, it seems like I would need to include
'script_name' in the context passed to the generic view
(object_detail) before it can properly be used in the form.

If I add an {% if script_name %} in the poll_detail template or just a
{{ script_name }}, it would need to be rendered before accessing the
vote view.  Maybe you can ellaborate on your method of getting django
to recognize the prefix.  Portability is looking difficult at this
point.  Thanks to all for your help.

>
> This proobably means a // in the URL if you mount your site at /, but
> I think most browsers and servers won't care about that extra /
>
> I welcome anyone pointing out a better way to make the form action
> more "portable" in projects...
>
> -Preston
>
> On Jan 17, 7:53 pm, Adam Yee <adamj...@gmail.com> wrote:
>
>
>
> > It was a slam dunk for completing the tutorial in the development
> > server, but I can't figure out this issue I'm having with the generic
> > views while using my apache server.  I'm unable to get the vote view
> > to redirect correctly.
>
> > My apache error seen here with both urls.py and views.py.  The apache
> > config is at the bottom.
>
> >http://dpaste.com/110275/
>
> > Voting (hiting the vote button) with or without a radio button
> > selected is redirecting me tohttp://127.0.0.1/polls/1/vote/which
> > gives me a 404 (and not in django's debug format) instead of ...mysite/
> > polls/1/vote/.
>
> > However, going in the backdoor way and manually typing 
> > inhttp://127.0.0.1/mysite/polls/1/vote/takesme through the vote view
> > KeyError exception saying "You didn't select a choice" and displays
> > the page.  I'm also able to access the results URL manually.  So I'm
> > thinking the problem lies in either the views.py, my urlconfs or
> > something with my wsgi apache config.
>
> > Can anyone see what I'm missing?- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Deploying Django tutorial part 4, redirecting problem, apache error

2009-01-18 Thread Adam Yee

On Jan 18, 3:44 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> On Jan 18, 8:46 pm, Adam Yee <adamj...@gmail.com> wrote:
>
>
>
>
>
> > On Jan 17, 8:36 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
> > wrote:
>
> > > On Jan 18, 2:53 pm, Adam Yee <adamj...@gmail.com> wrote:
>
> > > > It was a slam dunk for completing the tutorial in the development
> > > > server, but I can't figure out this issue I'm having with the generic
> > > > views while using my apache server.  I'm unable to get the vote view
> > > > to redirect correctly.
>
> > > > My apache error seen here with both urls.py and views.py.  The apache
> > > > config is at the bottom.
>
> > > >http://dpaste.com/110275/
>
> > > I'm in the middle of something else at the moment and my internet
> > > connection is dodgy, so I can't reliably look this up, however, one
> > > wild guess: Since the error you're seeing suggests that the '/mysite'
> > > portion is being stripped, this is possibly one of the cases where the
> > > Alias (or WSGIAlias in this case) has to end with a trailing slash.
> > > You've written the WSGIAlias as "/mysite", try "/mysite/" instead.
>
> > > Again, this may be complete rubbish, but it's a common enough error
> > > with Alias commands, although I can't remember how it works with
> > > trailing script specifications (like /django.wsgi). Still, it will
> > > only take 30 seconds to test and if I'm wrong, you're no worse off.
>
> > > Regards,
> > > Malcolm
>
> > Adding the trailing slash to /mysite/ resulted in getting 404s on all
> > views.  Read over Apache's docs
>
> >http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias
>
> > and it says something about the URL not being aliased if you add the
> > trailing /.  I don't quite fully understand it.
>
> > However, removing 'mysite' and leaving just the / has fixed the
> > response/redirect problem.  The index generic view is now 
> > athttp://127.0.0.1/polls/andall the rest follows as instructed in the
> > tutorial.
>
> > I'm still very puzzled by not being able to use '/mysite'.  I agree
> > with you that somewhere '/mysite' is being stripped or just not being
> > accessed at all.  My guess is somewhere in the generic views and/or
> > how they are set up in the urlconfs.  It seems because the vote view
> > isn't a generic view, it's unable to redirect to a generic view.
> > Feels like something is missing.  Does that make any sense?
>
> What version of Django are you using?
>
> What is in your WSGI script file?
>
> You aren't using Django 1.0 by chance, but have used the workaround
> described in mod_wsgi wiki documentation related to mounting at sub
> URL which should only be used for Django prior to 1.0. Using that
> workaround would cause strange problems with Django 1.0.
>
> Graham- Hide quoted text -
>
> - Show quoted text -

Graham, using version 2.3

import os, sys
sys.path.append('C:/web/django')
sys.path.append('C:/web/django/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

--~--~-~--~~~---~--~~
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: Deploying Django tutorial part 4, redirecting problem, apache error

2009-01-18 Thread Adam Yee



On Jan 17, 8:36 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Jan 18, 2:53 pm, Adam Yee <adamj...@gmail.com> wrote:
>
> > It was a slam dunk for completing the tutorial in the development
> > server, but I can't figure out this issue I'm having with the generic
> > views while using my apache server.  I'm unable to get the vote view
> > to redirect correctly.
>
> > My apache error seen here with both urls.py and views.py.  The apache
> > config is at the bottom.
>
> >http://dpaste.com/110275/
>
> I'm in the middle of something else at the moment and my internet
> connection is dodgy, so I can't reliably look this up, however, one
> wild guess: Since the error you're seeing suggests that the '/mysite'
> portion is being stripped, this is possibly one of the cases where the
> Alias (or WSGIAlias in this case) has to end with a trailing slash.
> You've written the WSGIAlias as "/mysite", try "/mysite/" instead.
>
> Again, this may be complete rubbish, but it's a common enough error
> with Alias commands, although I can't remember how it works with
> trailing script specifications (like /django.wsgi). Still, it will
> only take 30 seconds to test and if I'm wrong, you're no worse off.
>
> Regards,
> Malcolm

Adding the trailing slash to /mysite/ resulted in getting 404s on all
views.  Read over Apache's docs

http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias

and it says something about the URL not being aliased if you add the
trailing /.  I don't quite fully understand it.

However, removing 'mysite' and leaving just the / has fixed the
response/redirect problem.  The index generic view is now at
http://127.0.0.1/polls/ and all the rest follows as instructed in the
tutorial.

I'm still very puzzled by not being able to use '/mysite'.  I agree
with you that somewhere '/mysite' is being stripped or just not being
accessed at all.  My guess is somewhere in the generic views and/or
how they are set up in the urlconfs.  It seems because the vote view
isn't a generic view, it's unable to redirect to a generic view.
Feels like something is missing.  Does that make any sense?

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



Deploying Django tutorial part 4, redirecting problem, apache error

2009-01-17 Thread Adam Yee

It was a slam dunk for completing the tutorial in the development
server, but I can't figure out this issue I'm having with the generic
views while using my apache server.  I'm unable to get the vote view
to redirect correctly.

My apache error seen here with both urls.py and views.py.  The apache
config is at the bottom.

http://dpaste.com/110275/

Voting (hiting the vote button) with or without a radio button
selected is redirecting me to http://127.0.0.1/polls/1/vote/ which
gives me a 404 (and not in django's debug format) instead of ...mysite/
polls/1/vote/.

However, going in the backdoor way and manually typing in
http://127.0.0.1/mysite/polls/1/vote/ takes me through the vote view
KeyError exception saying "You didn't select a choice" and displays
the page.  I'm also able to access the results URL manually.  So I'm
thinking the problem lies in either the views.py, my urlconfs or
something with my wsgi apache config.

Can anyone see what I'm missing?


--~--~-~--~~~---~--~~
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: How to obtain an intermediate ManyToMany object?

2009-01-15 Thread Adam Yee

Maybe try a all(), filter(stuff) or get(thing)?

lightbox.lightboxphotograph_set.all()

Does that yield anything?

On Jan 15, 10:51 am, JonUK  wrote:
> lightbox.lightboxphotograph_set yields:
>
> TypeError: "'RelatedManager' object is not iterable"
>
> :(
--~--~-~--~~~---~--~~
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: very basic beginners question

2009-01-08 Thread Adam Yee


On Jan 8, 7:49 am, Evan  wrote:
> This is probably the most basic question in the history of the group.
> Still, I googled the error message both in this group and in google at
> large and went through the first 5 pages, and didn't see anything.
>
> i installed django a few weeks ago.  i'm pretty sure it's installed
> correctly.   i start on the first step of 
> thehttp://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01
> Django tutorial.   after typing django import into the command prompt,
> it tells me to type django-admin.py startproject mysite.   when i do
> that, i get this error message.
>
> File "", line 1
>
> i'm running this in Vista, btw.

It might not seem very clear in their wording, but they are telling
you to type in "django-admin.py startproject mysite" from the command
line prompt and not the Python IDE interpreter.  If it doesn't work,
the cmd line prompt will complain about the file not existing or batch
file thingy.  Something to that effect.  Read through carefully and
follow directions.  Make sure that you have django-admin.py in the
directory where you plan to make your project.  Or depending on if you
installed django with "python setup.py" you should have django-
admin.py on the system path.  Hph.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



change/edit list not showing in admin interface

2008-12-03 Thread Adam Yee

Hi,

Going through chapter 6 in the djangobook.  Using 1.1 SVN-9368.  I
think this chapter might be missing a step or two, or there's
something I'm overlooking.

In both the django development server and my apache server I can't
seem to show the created models 'Publiser, Author and Books'.  All
models have

 class Admin:
   pass

Everything else is visible and working, Auth and Site pages both, log
in - log out, what have you.  But no database models are showing.
Could I be missing something in my urls.py or settings.py?

currently in those files:

# urls.py
from django.conf.urls.defaults import *
from django.contrib import admin
from testproject.views import current_datetime, hours_ahead

admin.autodiscover()

urlpatterns = patterns('',
(r'^time/$', current_datetime),
(r'^time/plus/(\d{1,2})/$', hours_ahead),
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

(r'^admin/doc/', include('django.contrib.admindocs.urls')),

(r'^admin/(.*)', admin.site.root),
)


#settings.py
...
...
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'testproject.urls'

TEMPLATE_DIRS = (
'C:/web/django/testproject/templates',
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admindocs',
'django.contrib.admin',
'testproject.books',
)

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: djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Adam Yee

You were right, Django didn't see any URLs in the URLconf file because
I wasn't using the right one.  I had another site also called
'testproject' in a different directory (deleted now).  So I was using
views.py and settings.py in the /web/django directory, but the urls.py
from a totally different one.  It was subtle, and I'm glad I caught it
sooner than later.  All is working fine now with this urls.py when
accessing http://localhost:8080/testproject/time

from django.conf.urls.defaults import *
from testproject.views import current_datetime

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

urlpatterns = patterns('',
(r'^time/$', current_datetime),
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

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

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)

Thanks again.

On Nov 16, 6:31 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-11-16 at 17:41 -0800, Adam Yee wrote:
>
> [...]
>
> Good debugging info snipped.
>
> > When enteringhttp://localhost:8080/testproject/timeI'm reading this
> > in the Apache error log:
>
> > [Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
> > interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
> > [Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
> > (pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
> > testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.
>
> >http://localhost:8080/testproject/timejust brings up 'It worked!'
>
> So the good news is that this means Django is handling the request and
> not exploding, since "it worked" is produced by Django. Which means your
> webserver configuration is correct (or at least very close to correct).
> You're not seeing an error saying something like "Apache doesn't know
> anything about Django".
>
> > Notice how it shows the process as just /testproject and not /
> > testproject/time.
>
> That's correct. The web server hands everything off to what you've
> called "testproject" and Django handles the rest of the stuff.
>
> What's interesting here is that it doesn't redirect to testproject/time/
> (with a trailing slash). Which means Django thinks your URL Conf file is
> empty. Did you just change it and save it without telling Apache to
> reload/restart, so it hasn't picked up the changes, perhaps?
>
> I can't immediately see anything wrong with the setup information you've
> posted, so it's something subtle (or I'm going blind in my old age,
> which is also a candidate).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Adam Yee

I'm a new user to Django, hi everyone.

My system:
Windows XP
Python 2.5
Apache 2.2
>>configured for mod_wsgi
MySQL, MySQLdb   #Irrelevant at this point

My issue:
Having trouble getting the through the first example.  Basically, when
directing the browser to '.../time/' I'm still at the 'It worked!'
beginning page.  I haven't been able to bring up the view with
current_datetime.

Some things you might ask to know:
- For Apache:

WSGIScriptAlias /testproject "C:/web/django/apache/django.wsgi"

Order allow,deny
Allow from all


- For my app:
## django.wsgi
import os, sys
sys.path.append('C:/web/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

## views.py
from django.http import HttpResponse
import datetime

def current_datetime(request):
now = datetime.datetime.now()
html = "It is now %s." % now
return HttpResponse(html)

## urls.py
from django.conf.urls.defaults import *
from testproject.views import current_datetime

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

urlpatterns = patterns('',
(r'^testproject/time/$', current_datetime),
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

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

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)

When entering http://localhost:8080/testproject/time I'm reading this
in the Apache error log:

[Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
[Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
(pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.

http://localhost:8080/testproject/time just brings up 'It worked!'

Notice how it shows the process as just /testproject and not /
testproject/time.  Is this supposed to be that way?  Is there
something I'm missing in the 'testproject.settings.py' that is
preventing me from seeing the /time URL?  I think everything is setup
correctly.  I've spent a little time looking for an issue related to
this, but couldn't find a post.  Does anybody have any suggestions?
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
-~--~~~~--~~--~--~---