Re: New Project 403 Forbidden Error

2012-10-02 Thread John Yeukhon Wong
Just a quick question. Is is possible for you to manually setup this 
without bothering cpanel?
I mean u should have access to CentOS (ssh into it) right?

Then the setup should be very easy if you have that. I will use Nginx + 
gunicorn if you really have that option. I want to make sure you do without 
bothering these custom setup. Note that blog post is from 2008 and at the 
time there were very little tools usable for Django.

On Wednesday, September 26, 2012 2:14:01 PM UTC-4, Bestrafung wrote:
>
> I have been following these guides to setup Django on a CentOS cPanel 
> server: 
> http://forums.cpanel.net/f5/django-python-cpanel-71229-p2.html#post439009and 
> http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/.
>  
> After following those guides everything would appear to be working normally 
> except that when I visit the page I receive the Django 403 error specified 
> in the vhost.conf file. I have checked folder and file permissions and 
> everything appears to be correct. The guides said after following those 
> steps I should have a working Django install. Am I missing something? Any 
> help would;d be greatly appreciated.
>

-- 
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/-/Rwg4pXIG1_0J.
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: Web service development

2012-07-08 Thread John Yeukhon Wong
You run the development server right out of the box such as python 
manage.py runserver
But for real deployment you don't use the development servers. It doesn't 
support multiple requests. It will break. It's a toy, basically.

Watch some youtube videos on getting started with Django. Then look at 
Django's tutorials. Sometimes you want to have some "Graphical" tutorials 
before diving into textual tutorials.


On Sunday, July 8, 2012 4:20:52 AM UTC-4, stikic wrote:
>
> Hello,
>  
> How can I develop web service using django?
>  
> Is there edit and continue feature in django/python like Microsoft Visual 
> Studio/CSharp?
> Thank you.
>
> -- 
> SEYFULLAH TIKIÇ
>  

-- 
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/-/oN7T2Rarx3sJ.
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 use HTTPS with django

2012-07-08 Thread John Yeukhon Wong
I agree, but I think at the web server level is much better. Middlewares 
can break if Django core changes a lot, and since they are third-party hack 
code, so unless you are confident how to maintain it yourself, don't use 
them. Apache, Nginx configurations are widely used so they are easier to 
get help nowadays. That is not to say that many middlewares I've seen over 
the years are bad. I've used a few of those on snippets :) They are great.

And for many people, there is usually more than one Django site, or 
multiple applications deploy (custom backend, etc) which run as HTTP 
services too. So enabling SSL at server level is a lot easier to maintain.



On Sunday, July 8, 2012 5:47:01 AM UTC-4, Thomas Orozco wrote:
>
> This comes down to a simple middleware that intercepts http requests and 
> redirects them to https. This is very to do in django. 
>
> You can find plenty of such middleware on djangosnippets. 
>
> Now, if your app is running behind a reverse proxy (e.g. nginx + gunicorn) 
> ,  things get a little bit more complicated as your proxy needs to tell the 
> django app whether the request was originally https of http. 
>
> This is easy to do, but not very well documented in django. Look at the 
> settings reference for the appropriate ones. 
>
>
> Alternatively,  you could achieve the same thing at webserver level. But 
> having worked with both setups, using a middleware is a lot easier to 
> setup. 
>
> Now, you might find doing it at webserver level more appropriate, that's a 
> matter of personal preference. 
> Le 7 juil. 2012 11:26, "Timothy Makobu"  a 
> écrit :
>
>> I would think he would have areas that need to be logged in to all SSL. 
>> He already has the cert for SSL logins, and its prudent these days to have 
>> such apps all SSL, with tools making it straight forward to lift 
>> unencrypted traffic off a network.
>>
>> On Sat, Jul 7, 2012 at 11:28 AM, Melvyn Sopacua wrote:
>>
>>> On 7-7-2012 10:27, Timothy Makobu wrote:
>>> > " I want to know how to use HTTPS to securely login ..." which 
>>> satisfies
>>> > the first part of the question. This way it wont be possible to login
>>> > without HTTPS enabled for the project.
>>>
>>> What use is logging in if you're logged out the minute the connection
>>> becomes unencrypted?
>>>
>>> --
>>> Melvyn Sopacua
>>>
>>>
>>> --
>>> 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.
>>>
>>>
>>  -- 
>> 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.
>>
>

-- 
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/-/SLdmJ-KSqN8J.
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.



Adding a custom validation to Django's auth_user in admin

2012-07-08 Thread John Yeukhon Wong
 

Django has list_editable. I need to edit is_active flag. 

class MyUserAdminForm(ModelForm):
class Meta:
model = User

def clean_is_active(self):
# do something that validates your data
print ' I am here... '
print self.cleaned_data
print self

class MyUserAdmin(admin.ModelAdmin): 
  SOME CODE 
 form = MyUserAdminForm 


admin.site.unregister(User)
admin.site.register(User, MyUserAdmin) 

I put this in admin.py, and I've registered my admin.ModelAdmin code. The 
display is fine. 

The code above should fail because it doesn't return 
self.cleaned_data["is_active"]. But when I reload the development server, 
and changed the flag on some users, Django didn't complain, so this piece 
of code is not used.

My requirement is to check that the user under change is not a superuser. I 
have other things to do within that validation, but you get the idea.

Why is this?

Thanks.

-- 
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/-/GkbElmp44loJ.
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: Use Django to implement my GUI!

2012-05-13 Thread John Yeukhon Wong
Maybe pyjs?
Do the GUI part using Python (which renders into javascript), and you can 
connect it using Django as your backend.

On Sunday, May 13, 2012 6:14:36 AM UTC-4, Eugene NGONTANG wrote:
>
> Hi! 
>
> I'm a python developper, but new in django. 
>
> I'm devolopping a multi clients-server application. 
>
> The server and the clients are communicating via sockets, The server 
> receive somme states from clients, and display them in the User 
> interface. 
> In the other hand, the server has to send a message(packet) to the 
> client when an event  occurs in the GUI, and data are stored in a 
> database. 
>
> Then I choose to make a web interface where data could be viewed and 
> manipulated. And I discovered Django, which fit all my needs. I tested 
> and liked the framework. 
>
> My questions are: 
> - Can I override the djando admin methods so that i can not only 
> customized my views and html page, but also manipulate objects in 
> database, so that i can do another action when catching an  event in 
> the GUi. 
> For example, taking the django admin tutorial, I would like to do and 
> action like sending a message the user choose "add a poll". How can I 
> do those things? Cause I noticed that method that alter data in data 
> base are part of django admin module and cannot be overriden 
>
> - To achieve what I want, i would like to run my server engine and my 
> django admin in two separated threads. How do i run my admin module in 
> a thread? Cause till now i'm using the command line "python manage.py 
> runserver" 
>
> - I also tried to overide tables name, and foreign keys names. Could 
> you guys provide me a true life example? 
>
> - And now in the production step, I would like you guys to tell me 
> what to choose for serving files. I would like to with your experience 
> what's better between running a unicorn server or apache with mod_wsgi 
>
> I don't know if i'm clear, but i hope. In brief I'd like to use the 
> django framework features to design my Gui like i want, customize 
> interactions between the gui and the backend, and choose a good web 
> server for the production. 
>
> Thank you for advance

-- 
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/-/6hGVZIFjm6QJ.
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: Any tool to validate django templates?

2012-04-16 Thread John Yeukhon Wong
Would this help?
http://stackoverflow.com/questions/3086637/how-should-i-validate-html-in-django-templates-during-the-development-process

I quite like the not-accepted-as-answer. Just go through your urls. 
Essentially, you have two types of possible template errors:

1. human errors (missing a close tag / mispell)
2. logic error

For logic error, you are dealing with mostly logic tags  such as url tags 
or custom tags rendering problem. For example, does your {% url my_view id 
username %} actually works? are the variables passing to / from view are 
good for these tags? THis kind of error is not possible checked with going 
through all urls because u can't test possibility like that. THat has to be 
handled by unit test and integration (system) test.


Good luck. 

On Sunday, April 15, 2012 12:42:14 PM UTC-4, Marcin wrote:
>
> Hi all,
>
> I've got a template that isn't parsing, but the error is the 
> nondescript: TemplateSyntaxError: Could not parse the remainder: '"{%' from 
> '"{%'
>
> Is there a tool that can help locate the source of the error?
>
> Marcin
>
> -- 
> Marcin Tustin
> Tel: 07773 787 105
>
>  

-- 
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/-/Ml-zdg0y4WEJ.
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: Is it a good practice to delegate views based on GET / POST?

2012-04-11 Thread John Yeukhon Wong
Thanks to both of you. Kevin, how would I do a regex mask for views?

Thanks.

On Wednesday, April 11, 2012 2:05:27 AM UTC-4, Kevin wrote:
>
> Separating GET and POST is normally used for RESTful web programming.  
> Which is becoming a very common practice is popular competing frameworks, 
> such as Rails.
>
> Personally I would prefer a more "native" way in Django to separate 
> GET/POST views.  I guess this could be done via a decorator or something.
>
> Another reason you may want to separate GET/POST is for security.  For 
> example, only letting some views accept POST requests, and basically shove 
> a big 403 message to users who attempt to POST to a view which otherwise 
> shouldn't accept a POST.  I normally limit this using the web server, so 
> POST requests will not even reach the web application if the component 
> doesn't even accept it.  I always have a mind set that the Internet is 
> never safe, and everybody is a hacker.  It's better to be safe, than sorry 
> that a malicious POST body reached your application.  An easy way to do 
> this on the server is to use a regex mask for views which will accept a 
> POST body, such as having an extension of ".do" or ".action".  If the view 
> doesn't have this special extension, then only allow GET requests to pass 
> through to WSGI.  You can also filter out headers and such on the server to 
> further protect your WSGI application from the outside world.  If you don't 
> have access to the server's configuration, well, then I'm sure the cloud 
> service you deployed to is "safe enough".
>
> On Tuesday, 10 April 2012 18:21:15 UTC-5, John Yeukhon Wong wrote:
>>
>> 3/4 down the page
>> http://www.djangobook.com/en/2.0/chapter08/
>>
>> urlpatterns = patterns('', # ... (r'^somepage/$', views.method_splitter, 
>> {'GET': views.some_page_get, 'POST': views.some_page_post}), # ... )
>>
>>
>> Is this a good practice at all? If I use the method splitter, my urls 
>> will look ugly. Or should I just separate based on the length of certain 
>> views? (If it's too long, break it into two, or use the delegator)
>>
>

-- 
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/-/AdCV-UuVdKIJ.
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.



Is it a good practice to delegate views based on GET / POST?

2012-04-10 Thread John Yeukhon Wong
3/4 down the page
http://www.djangobook.com/en/2.0/chapter08/

urlpatterns = patterns('', # ... (r'^somepage/$', views.method_splitter, 
{'GET': views.some_page_get, 'POST': views.some_page_post}), # ... )


Is this a good practice at all? If I use the method splitter, my urls will 
look ugly. Or should I just separate based on the length of certain views? 
(If it's too long, break it into two, or use the delegator)

-- 
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/-/AzISlKRiq0UJ.
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 I always provide a return value when writing my test using mock library?

2012-04-10 Thread John Yeukhon Wong
I am Cc this to testing-in-python mailing list. Hope this makes sense.

Suppose I have a function called "render_reverse" which takes two 
arguments: function name, and args list, and it returns "reverse(f, *args)"

If I called render_reverse('happy_birthday', {'args': [username]}), I would 
get this:   /greeting/birthday/username/

I am going to patch the `reverse` function that's local to render_reverse, 
and inside the test, should I always provide a return value like this?

with patch('myproject.myapps.mylibrary.reverse') as mock_reverse:
 mock_f = MagicMock(name='f')
 mock_kwargs = MagicMock(name='kwargs')
 mock_reverse.return_value = ' /greeting/birthday/johnsmith/'
 response = mock_reverse(mock_f, mock_kwargs)

self.assert..


What is the best practice in general? How do I determine whether I want to 
provide a return value or not? In almost any cases, how do I know things go 
well? Sometimes I can't differentiate unittest from integration / system 
test (I want to see other codes ikn the same function execute and throw 
back the right result)

Thanks! 

-- 
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/-/4QJSDMT5qLoJ.
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.



Can anyone please explain the following settings?

2012-02-08 Thread John Yeukhon Wong
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, "site_media", "media")

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com;, "http://example.com/media/;
MEDIA_URL = "/site_media/media/"

# Absolute path to the directory that holds static files like app
media.
# Example: "/home/media/media.lawrence.com/apps/"
STATIC_ROOT = os.path.join(PROJECT_ROOT, "site_media", "static")

# URL that handles the static files like app media.
# Example: "http://media.lawrence.com;
STATIC_URL = "/site_media/static/"

I am kinda new with site_media settings. THis is a legacy code.
Right now I have two directories under the site_root

/media/  and /site_media/ (which contains site_media/static/*.*)  The
latter one is where all the css, js comes from. But I have the same
exact copies in /media/.

I just don't understand what each of the options above mean Can
someone please explain them?  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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



site_media and media

2012-02-08 Thread John Yeukhon Wong
I am working on someone's legacy code. We do testings on virtual
machine (like virtulabox). The virtual machine image contains a
working version of our project, and under the directory we have this:

project
  - media/
  - site_media
   - static

-- 
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: what is the best IDE to use for Python / Django

2012-01-21 Thread John Yeukhon Wong

While it has been asked a trillion times already, let me say TRY UT
YOURSELF. Sometimes even doing on console such as vim is not bad.
However if you are working on a huge project an IDE can help you.
Pycharm is very good. The problem is still very new but its
development. Maturity is outstanding. I love its database auto
complete. But version control is still e
On Jan 19, 9:14 am, Andre Terra  wrote:
> *** Everyone, please DO NOT reply to this thread. ***
>
> Krondaj, feel free to search the archives for similar threads. This
> question has been asked an answered at least a dozen times.
>
> Cheers,
> André Terra
>
>
>
> On Thu, Jan 19, 2012 at 12:08 PM, Krondaj  wrote:
> > Hi,
>
> > I was wondering what the best IDE to use for Python / Django would
> > be?
>
> > I am currently using Geany, but i'm sure there is a better (hopefully
> > free) one out there!?!
>
> > Regards,
>
> > Chris
>
> > --
> > 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.

-- 
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 get the time from date-based generic views

2011-02-25 Thread John Yeukhon Wong
OHHH this is really impressive. I didn't really think of that.

Thanks! Now I have another concept loaded under my belt. Hhaha

THank!

On Feb 26, 12:18 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Sat, Feb 26, 2011 at 1:09 PM, John Yeukhon Wong
>
> <gokoproj...@gmail.com> wrote:
> > Suppose we have a django page using
> > django.views.generic.date_based.object_detail (or even archive_index..
> > actually doesn't really matter...)
>
> > In the model class I saved the datetime.datetime.now which suppose to
> > include the day, month, year, and time.
>
> > But I have no idea how to access the time part when i am using this
> > generic views
>
> > What I want is Feb 26, 2011,  01:12:04 AM
> > I can get the calendar part by {{ object.pub_date}}
>
> > How do I get the time part?
>
> The answer doesn't really have anything to do with class based views
> -- it's a templating issue.
>
> Your model has a field that contains a datetime field -- a single
> field, called pub_date, that contains a date component and a time
> component. When you output {{ object.pub_date }}, it's outputting the
> entire date-time content. If you want to only show the time component,
> you have two options:
>
> 2) Call the time() method on the pub_date attribute.
>
> {{ object.pub_date.time }}
>
> This is possible because all datetime objects (whichs is what
> object.pub_date is returning) have a built-in method called time()
> that returns the time component, and Django's template engine will
> traverse (and invoke) built-in methods as part of the dot-notation
> syntax.
>
> 1) Use the |date filter to only print time-related components.
>
> {{ object.pub_date|date:"P" }}
>
> would output "1:12 AM". This is ultimately the most flexible approach,
> because you can determine exactly how dates are displayed. See the
> docs on the date filter [1] for other formatting options.
>
> [1]http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#date
>
> Yours
> Russ Magee %-)

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



how to get the time from date-based generic views

2011-02-25 Thread John Yeukhon Wong
Suppose we have a django page using
django.views.generic.date_based.object_detail (or even archive_index..
actually doesn't really matter...)

In the model class I saved the datetime.datetime.now which suppose to
include the day, month, year, and time.

But I have no idea how to access the time part when i am using this
generic views

What I want is Feb 26, 2011,  01:12:04 AM
I can get the calendar part by {{ object.pub_date}}

How do I get the time part?


For example, in urls.py

entry_info_dict = {
'queryset': Entry.publish.all(),
'date_field': 'pub_date',
}

Here's the doc for quick access
http://docs.djangoproject.com/en/dev/ref/class-based-views/#date-based-views

Thank you guys.

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



label when customize django form

2011-01-24 Thread John Yeukhon Wong
In forms,py, we can simple do this
e_mail = forms.EmailField(label='Your e-mail address')

this will work and be use if we use {{ form.as_table}} for example.

But if we instead use our own customization, because it's too
restricted to use the auto form render,  when it comes to labels, we
have to manually specify it
Your e-mail address

But this may looks ugly. Is there a way to load the label from
forms.py even if we are not using form.as_ ??

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



[beginner] extra_context in generic views

2011-01-19 Thread John Yeukhon Wong
http://docs.djangoproject.com/en/dev/topics/generic-views/#adding-extra-context
I am confused by the model scenario.

"For example, think of showing a list of all the books on each
publisher detail page. The object_detail generic view provides the
publisher to the context, but it seems there's no way to get
additional information in that template."
So, say below the detail of a publisher (first name, last name, books
published, phone, address, logo...etc), we might want to display a
list of other publisher.

"This would populate a {{ book_list }} variable in the template
context. This pattern can be used to pass any information down into
the template for the generic view. It's very handy."

So why do we create extra_context anyway?

A section above, the urlpatterns was
"urlpatterns = patterns('',
(r'^publishers/$', list_detail.object_list, publisher_info)
)"

I am confused. Can anyone explain what's going on if I have the
extra_context, and how do I exactly used that? 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



'str' object not callable

2010-10-26 Thread John Yeukhon Wong
This is part of my views

[[[code]]]  from mysite.views

def site_root(request):
return HttpResponse("This is the site root")
def hello(request):
return HttpResponse("Hello World")

[[endcode]]

My URLConf
[[code]]
from django.conf.urls.defaults import *

urlpatterns = patterns('mysite.views',
(r'^$', 'site_root'),
(r'^hello/$', 'hello'),
(r'^now/plus/(\d{1,2})/$',
'offset_time'),
)
[[/code]]

I am actually following the book "The Definitive Guide to Django (2)""
chapter 8 advacne URLConf and views.
The sample code was

[[code]]
from django.conf.urls.defaults import *
urlpatterns = patterns('mysite.views',
(r'^hello/$', 'hello'),
(r'^time/$', 'current_datetime'),
(r'^time/plus/(\d{1,2})/$', 'hours_ahead'),
)
[[//code]]

What is wrong with my url?
I am calling the root right now, localhost, and root view is the first
one to be called. That gives me the error, and thus any url thereafter
gives the same error.

Any input is appreicated. Thanks

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



Re: too many options error when launching sqlite3 dbshell

2010-10-23 Thread John Yeukhon Wong
Problem solved. SQLite will chop the path of the sqlite.db... so
instead moved to "C:\\sqlite.db" will solve the problem.

On Oct 22, 9:47 pm, John Yeukhon Wong <gokoproj...@gmail.com> wrote:
> I have django 1.2.3.0 Final
>
> In my setting, I have 'sqlite3' filled for the DATABASE_ENGINE.
> I am able to work with the sqlite3 until I am told that I need to
> access python manage.py dbshell
>
> At first I got the error "sqlite3 is not recongized"
> Then I read threads and I found that this can be solved by downloading
> the exe file and set the environment variable path on Windows (I am on
> XP Pro)
>
>  I used this approach 
> insteadhttp://groups.google.com/group/django-users/msg/cf0665c227030ae2?
>
> Now when I access python manage.py dbshell, I am getting
>
> [[[
> C:\Documents and Settings\JohnWong\workspace\mysite\mysite>python
> manage.py dbsh
> ell
> sqlite3: Error: too many options: "Settings\JohnWong\workspace\mysite
> \sqlite.db"
>
> Use -help for a list of options.
> ]]]
> I tried with --database=name_of_my_db and still no luck
>
> Any input is appreciated.
> Thanks

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



too many options error when launching sqlite3 dbshell

2010-10-22 Thread John Yeukhon Wong
I have django 1.2.3.0 Final

In my setting, I have 'sqlite3' filled for the DATABASE_ENGINE.
I am able to work with the sqlite3 until I am told that I need to
access python manage.py dbshell

At first I got the error "sqlite3 is not recongized"
Then I read threads and I found that this can be solved by downloading
the exe file and set the environment variable path on Windows (I am on
XP Pro)

 I used this approach instead
http://groups.google.com/group/django-users/msg/cf0665c227030ae2?

Now when I access python manage.py dbshell, I am getting

[[[
C:\Documents and Settings\JohnWong\workspace\mysite\mysite>python
manage.py dbsh
ell
sqlite3: Error: too many options: "Settings\JohnWong\workspace\mysite
\sqlite.db"

Use -help for a list of options.
]]]
I tried with --database=name_of_my_db and still no luck

Any input is appreciated.
Thanks

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



multiple views function in a single URL specification

2010-10-17 Thread John Yeukhon Wong
I asked this somewhere else but it seems like the responder hasn't
reply the latest comment I made.
http://stackoverflow.com/questions/3951758/how-do-you-iterate-over-a-...

Nevertheless, I think I should be welcome to make one here.

Let's keep thing short.

Say I have a very simple list to iterate

[--code--]
def link(request):
c = Context()
c['title']  = ['Home Page', 'Current Time', '10 hours later']
return render_to_response('time.html', c)
[--code--]

Now say I also have another view called current_time

In my html I had, for example
[--code--]
{% for item in title %}
{{item}}
{% if not forloop.last %} | {% endif %}
{% endfor %}

{% if hour <= 1 %}
do something...
{% endif %}

[--code--]

For the template, I tried loop through "in c.title, in c, in title"
and still doesn't work

As you can guess, I use two view functions in a single html file.

The problem is that I received   'function' object is not iterable

So the guy said I probably had a problem with the URL
my URL -->   (r'^now/$', current_time, link),

So he recommended me doing this
(r'^articles/(?P\(?P)/$',
'project_name.views.link'), #the second tuple element is the view
function

Something similar to Django URL Dispatcher (from the dispatcher
chapter).. I think...
I think he meant to capture then. But what I want to do is really
just, say,   localhost/now/  and load the page

I can definitely integrate two views functions into one single
function, which works fine.

The question is, how can I assign multiple views function in a single
URL???

Thank you for any input in advance!!!

-- 
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: multiple views function in a single URL specification

2010-10-17 Thread John Yeukhon Wong
I think for the link view function, I need to do something like this
instead. Sorry.

[--code--]
def link(request):
c = Context()
c['title']  = ['Home Page', 'Current Time', '10 hours later']
return render_to_response('time.html', c)
[--code--]

On Oct 17, 1:06 pm, John Yeukhon Wong <gokoproj...@gmail.com> wrote:
> I asked this somewhere else but it seems like the responder hasn't
> reply the latest comment I 
> made.http://stackoverflow.com/questions/3951758/how-do-you-iterate-over-a-...
>
> Nevertheless, I think I should be welcome to make one here.
>
> Let's keep thing short.
>
> Say I have a very simple list to iterate
>
> [--code--]
> def link(request):
>     title  = ['Home Page', 'Current Time', '10 hours later']
>     return render_to_response('time.html', title)
> [--code--]
>
> Now say I also have another view called current_time
>
> In my html I had, for example
> [--code--]
> {% for item in title %}
>     {{item}}
>     {% if not forloop.last %} | {% endif %}
> {% endfor %}
>
> {% if hour <= 1 %}
> do something...
> {% endif %}
>
> [--code--]
>
> As you can guess, I use two view functions in a single html file.
>
> The problem is that I received   'function' object is not iterable
>
> So the guy said I probably had a problem with the URL
> my URL -->   (r'^now/$', current_time, link),
>
> So he recommended me doing this
> (r'^articles/(?P\(?P)/$',
> 'project_name.views.link'), #the second tuple element is the view
> function
>
> Something similar to Django URL Dispatcher (from the dispatcher
> chapter).. I think...
> I think he meant to capture then. But what I want to do is really
> just, say,   localhost/now/  and load the page
>
> I can definitely integrate two views functions into one single
> function, which works fine.
>
> The question is, how can I assign multiple views function in a single
> URL???
>
> Thank you for any input in advance!!!

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



multiple views function in a single URL specification

2010-10-17 Thread John Yeukhon Wong
I asked this somewhere else but it seems like the responder hasn't
reply the latest comment I made.
http://stackoverflow.com/questions/3951758/how-do-you-iterate-over-a-list-in-django/3951775#3951775

Nevertheless, I think I should be welcome to make one here.

Let's keep thing short.

Say I have a very simple list to iterate

[--code--]
def link(request):
title  = ['Home Page', 'Current Time', '10 hours later']
return render_to_response('time.html', title)
[--code--]

Now say I also have another view called current_time

In my html I had, for example
[--code--]
{% for item in title %}
{{item}}
{% if not forloop.last %} | {% endif %}
{% endfor %}

{% if hour <= 1 %}
do something...
{% endif %}

[--code--]

As you can guess, I use two view functions in a single html file.

The problem is that I received   'function' object is not iterable

So the guy said I probably had a problem with the URL
my URL -->   (r'^now/$', current_time, link),

So he recommended me doing this
(r'^articles/(?P\(?P)/$',
'project_name.views.link'), #the second tuple element is the view
function


Something similar to Django URL Dispatcher (from the dispatcher
chapter).. I think...
I think he meant to capture then. But what I want to do is really
just, say,   localhost/now/  and load the page

I can definitely integrate two views functions into one single
function, which works fine.

The question is, how can I assign multiple views function in a single
URL???

Thank you for any input in advance!!!

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



the structure of a registration app

2010-08-23 Thread John Yeukhon Wong
I want to understand something...
Let say I want to do a low-level registration handling myself, using
the User class that comes with Django.

I started an app called accounts in my project

So what should I put in model? Some examples would create an
additional file called forms.py to put the registration class


How do I determine what I put in the model? I know model is what we
generate in the DB...
But in this case, what would I put

Thanks

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



help with understanding tag cloud code

2010-08-22 Thread John Yeukhon Wong
Hi, I am confused with this piece of code. This is a code responsible
for building a tag cloud. It lives in the views.py

The part I don't understand is

# Calculate tag, min and max counts.
min_count = max_count = tags[0].bookmarks.count()

I never had used this 3 assignments in Python before. I also don't get
why it's tags[0]

According to the book, it is iterating through the tag lists.
I really can't follow the logic there, and this also prevents me from
understanding the rest of the for loop

Thank you for any input!

//code begins

def tag_cloud_page(request):
MAX_WEIGHT = 5
tags = Tag.objects.order_by('name')
# Calculate tag, min and max counts.
min_count = max_count = tags[0].bookmarks.count()
for tag in tags:
tag.count = tag.bookmarks.count()
if tag.count < min_count:
 min_count = tag.count
if max_count < tag.count:
max_count = tag.count
# Calculate count range. Avoid dividing by zero.
range = float(max_count - min_count)
if range == 0.0:
range = 1.0
# Calculate tag weights.
for tag in tags:
tag.weight = int( MAX_WEIGHT * (tag.count - min_count) /
range)
variables = RequestContext(request, { 'tags': tags })
return render_to_response('tag_cloud_page.html', variables)

// code ends

-- 
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: check email duplication at registration

2010-08-22 Thread John Yeukhon Wong
Hi, thank you for pointing out the problem!
Solved! 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-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: check email duplication at registration

2010-08-21 Thread John Yeukhon Wong
Hi, sorry for the problem.

Well, this is used in registration. As stated in the title, this is
used to prevent "duplication".
Let say an existing user in db, whose username is abc, and email is
1...@acb.com
After testing, I can still register an account with the existing email
address, which means that the code does not work properly

Full source code



/code begins




import re
from django import forms
from django.contrib.auth.models import User

class RegistrationForm(forms.Form):
username = forms.CharField(label=u'Username', max_length=30)
email = forms.EmailField(label=u'Email')
password1 = forms.CharField(
label=u'Password',
widget=forms.PasswordInput()
)
password2 = forms.CharField(
label=u'Password (Again)',
widget=forms.PasswordInput()
)

def clean_password2(self):
if 'password1' in self.cleaned_data:
password1 = self.cleaned_data['password1']
password2 = self.cleaned_data['password2']
if password1 == password2:
return password2
raise forms.ValidationError('Passwords do not match.')

def clean_username(self):
username = self.cleaned_data['username']
if not re.search(r'^\w+$', username):
raise forms.ValidationError('Username can only contain
''alphanumeric characters and the underscore.')
try:
User.objects.get(username=username)
except User.DoesNotExist:
return username
raise forms.ValidationError('Username is already taken.')

def clean_email(self):
email = self.cleaned_data['email']
try:
User.objects.get(email=email)
except User.DoesNotExist:
return email
raise forms.ValidationError('This email address has been
registered with an existing user.')







/// code ends

On Aug 21, 10:05 pm, Steve Holden <holden...@gmail.com> wrote:
> On 8/21/2010 7:23 PM, John Yeukhon Wong wrote:> I don't think this code is 
> working properly
>
> That isn't a very helpful description. For better answers, please
> describe what it is doing that it should not (or what it is not doing
> that it should).
>
>
>
> > from django import forms
> > from django.contrib.auth.models import User
>
> > def clean_email(self):
> >     email = self.cleaned_data['email']
> >     try:
> >         User.objects.get(email=email)
> >     except User.DoesNotExist:
> >         return email
> >     raise forms.ValidationError('This email address has been
> > registered with an existing user.')
>
> > How should I rewrite it properly? Thanks!!
>
> Shouldn't clean_email() be a method of the form it's a part of? You
> appear to have written it as a stand-alone function, so it probably
> isn't being called at all.
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9http://djangocon.us/

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



check email duplication at registration

2010-08-21 Thread John Yeukhon Wong
I don't think this code is working properly

from django import forms
from django.contrib.auth.models import User

def clean_email(self):
email = self.cleaned_data['email']
try:
User.objects.get(email=email)
except User.DoesNotExist:
return email
raise forms.ValidationError('This email address has been
registered with an existing user.')



How should I rewrite it properly? Thanks!!

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



Re: mod_wsgi and first django app

2010-08-16 Thread John Yeukhon Wong
I added the wsgi scripts and incluced that in my views.py
It works...

I know that for every project there is only one views can exist... so
is that the really way???

I want to have some guides here, thank you, and I am sorry for being
stupid if I sound like one

On Aug 16, 9:39 pm, John Yeukhon Wong <gokoproj...@gmail.com> wrote:
> I have the book "The definitive Guide to DJango: Web Development Done
> Right".
> Both editions use mod_python, and not mod_wsgi.
>
> I have the setup correctly.
>
> The first program was display the current datetime
>
> 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)
>
> The urls.py
>
> from django.conf.urls.defaults import *
> from mysite.views import current_datetime
>
> urlpatterns = patterns('',
>
>         (r'^time/$', current_datetime),
> )
>
> I am getting nothing but again, the blue page withhttp://domain/time/
>
> As a beginner, I can't find a book that use mod_wsgi
>
> So how do I set up this, and for the future (as there are multiple
> pages in the future...)
>
> 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-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.



mod_wsgi and first django app

2010-08-16 Thread John Yeukhon Wong
I have the book "The definitive Guide to DJango: Web Development Done
Right".
Both editions use mod_python, and not mod_wsgi.

I have the setup correctly.

The first program was display the current datetime

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)


The urls.py

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

urlpatterns = patterns('',

(r'^time/$', current_datetime),
)



I am getting nothing but again, the blue page with http://domain/time/

As a beginner, I can't find a book that use mod_wsgi

So how do I set up this, and for the future (as there are multiple
pages in the future...)

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



which python does django takes (two python exists)

2010-08-16 Thread John Yeukhon Wong
I am running Debian Lenny, and I have 2.5.25 and 2.7 co-exists
Which one would I get for django?

Notice the last response from this link
http://stackoverflow.com/questions/142764/how-do-i-upgrade-python-2-5-2-to-python-2-6rc2-on-ubuntu-linux-8-04

This is the method that I used...

-- 
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: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
Hi, Graham

I looked at the error log and I fully understood the problem.

I spent an hour trying different ways to understand the whole thing.
Here is the result.

f:/public/testproject/apache/django.wsgi

//code begins here
import os, sys
sys.path.append("f:/public")

os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

//code ends here


if I add your hello world code in this file, and restarted the apache,
I will have hello world.
I created a hello.wsgi (and hello.py). For each, I had to manually set
up an alias
For example this works
WSGIScriptAlias /hello "f:/public/testproject/apache/hello.wsgi"

I noticed that if I have two of them co-exist simultaneously
WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
WSGIScriptAlias /testproject "f:/public/testproject/apache/hello.wsgi"

I will get nothing but the same default blue page. I looked the error
log, nothing showed up. The access log, however, is interesting, but I
couldn't get any information from the web.

// portion of the log
127.0.0.1 - - [14/Aug/2010:00:48:45 -0400] "GET / HTTP/1.1" 200 12
127.0.0.1 - - [14/Aug/2010:00:48:46 -0400] "GET / HTTP/1.1" 200 12
127.0.0.1 - - [14/Aug/2010:00:49:02 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:17 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:18 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:19 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:25 -0400] "GET /testproject/ HTTP/
1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:26 -0400] "GET /testproject/ HTTP/
1.1" 200 2061


The one with 200 12 happened long before 200 2061 did. The 200 12 was
the access record of only having one alias (either one, and not both).
The 200 2061 is when both exist, and I reqest to access them. There is
no error, but this 2061 code probably suggest something. Do you know
by any chance?

Anyway. These tests conclude that I have my mod_wsgi working
correctly.


I understand that there are a few disadvantage of working on a MS, for
example: lack of daemon mode, and a bit more complicated to handle
users and file permission than on a UNIX.

I do plan to deploy the project on a UNIX server in the future, and I
still do want to follow up with the previous discussion:

So in general,

1. When I write a django project, for each project I need a different /
apache/ and the content within? I know mod_wgics is a module we use to
allow apache to run python but I am not clear how we actually use
it.


2. If I am going to work on a UNIX, let say a linux distro, if I
create a wsgi folder outside /home/ (now i am clear which one you are
referring to...), where do you prefer? How do I link it again? I am
not very clear from the video because I am raised in United States,
and your Australian accent troubled me a little...I am sorry...

Thank you.

John

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
According to this post
http://www.rkblog.rk.edu.pl/w/p/mod_wsgi/

I used the similar approach, and had localhost/hello.py and worked.

But what about the WSCI way that you showed us in the video?

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-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: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
Hi, Graham.

I watched the video and your pdf up until the point you ran the wsgi
successfully.

I restarted the apache and bottom of the apache monitor said "Apache/
2.2.16(Win32) mod_wsgi/3.3Python/2.7", and also I could see localhost
again. I can see the blue page.

I am sorry if I sound too stupid, but I am pretty new...

1. Don't put the hello.wsgi and any wsgi app under the home directory.
Is it F:/public (where my django project testproject is located)? So I
should create a folder outside public right?
2. If so, do I add this following code to the wsgi conf file ?

Order deny,allow
Allow from all


3. I try to access to localhost/hello.wsgi but it's still giving me
the same blue django default page

Thank you for the help






On Aug 13, 10:01 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> On Aug 14, 11:26 am, John Yeukhon Wong <gokoproj...@gmail.com> wrote:
>
>
>
> > Hi, I know most of you work on Linux, but I do need this to be done on
> > Windows for a very personal reason.
>
> > I mainly followed this tutorial here, except that I use mod_wsgi over
> > mod_python.http://wiki.thinkhole.org/howto:django_on_windows
>
> > I had my python 2.7, apache, mod_wsgi and postreg all installed under
> > my F drive.
> > This is the folder:  F:/public, and I created a project called
> > testproject, so I have F:/public/testproject
>
> > I am stuck at configuration Django with Apache (and mod_wsgi).
> > I spent 5 hours searching and reading the documentation and still
> > can't figure out how to do it right.
>
> > I read thishttp://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
> > I created two files:  apache_django_wsgi.conf and django.wsgi under F:/
> > public/testproject/apache, where apache is a manual created folder.
> > The actual Apache is installed under F:/Apache Software Foundation/
> > Apache2.2
>
> > I did these for Apache2.2/conf/httpd.conf
>
> > LoadModule wsgi_module modules/mod_wsgi.so
> > Include "f:/public/testproject/apache/apache_django_wsgi.conf"
>
> > So good so far. No error after restart ApACHE.
>
> > Now, I have to setup those two files.
>
> > I had this for the conf (I just copied it from the google doc)
>
> > # Code begin here
> > Alias /media/ f:/public/testproject/media/
>
> > 
> > Order deny,allow
> > Allow from all
> > 
>
> > WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
>
> > 
> > Order deny,allow
> > Allow from all
> > 
> > #Code ends here
>
> > However, I was suspecting something bad to happen...
>
> > OKay. For django.wsgi
>
> > // code begins here
> > import os, sys
> > sys.path.append("f:/public")
>
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > // code ends here
>
> > This one is better - I know the info is good and correct.
>
> > Now I restarted the apache again, no error.
>
> > But when I try to access to my localhost or localhost/testproject I
> > received this message
>
> > Forbidden:   You don't have permission to access /testproject/ on this
> > server.
>
> > I was denied, I don't know why we need that script anyway...
>
> > How should I set it up? How do I test if everything is working well?
>
> Did you try and walk before you ran? ;-)
>
> That is, did you try getting a WSGI hello world program working before
> you decided to try and get Django site to work?
>
> Anyway, you need to look at the Apache error logs to find out the
> actual reason why Apache has given you a 403 error.
>
> I suggest you also go watch my mod_wsgi talk where it references
> exactly why you get some of these problems, including Forbidden
> errors, with examples of the errors you will see in Apache error log.
> Links to talk at:
>
>  http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_...
>
> Graham

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
Hi, I know most of you work on Linux, but I do need this to be done on
Windows for a very personal reason.

I mainly followed this tutorial here, except that I use mod_wsgi over
mod_python.
http://wiki.thinkhole.org/howto:django_on_windows

I had my python 2.7, apache, mod_wsgi and postreg all installed under
my F drive.
This is the folder:  F:/public, and I created a project called
testproject, so I have F:/public/testproject

I am stuck at configuration Django with Apache (and mod_wsgi).
I spent 5 hours searching and reading the documentation and still
can't figure out how to do it right.

I read this
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

I created two files:  apache_django_wsgi.conf and django.wsgi under F:/
public/testproject/apache, where apache is a manual created folder.
The actual Apache is installed under F:/Apache Software Foundation/
Apache2.2

I did these for Apache2.2/conf/httpd.conf

LoadModule wsgi_module modules/mod_wsgi.so
Include "f:/public/testproject/apache/apache_django_wsgi.conf"

So good so far. No error after restart ApACHE.

Now, I have to setup those two files.

I had this for the conf (I just copied it from the google doc)

# Code begin here
Alias /media/ f:/public/testproject/media/


Order deny,allow
Allow from all


WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"


Order deny,allow
Allow from all

#Code ends here

However, I was suspecting something bad to happen...

OKay. For django.wsgi

// code begins here
import os, sys
sys.path.append("f:/public")

os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

// code ends here

This one is better - I know the info is good and correct.


Now I restarted the apache again, no error.

But when I try to access to my localhost or localhost/testproject I
received this message

Forbidden:   You don't have permission to access /testproject/ on this
server.

I was denied, I don't know why we need that script anyway...

How should I set it up? How do I test if everything is working well?


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



Re: Django external access [Windows]

2010-06-06 Thread John Yeukhon Wong
Good news. Weird thing happened.
I am okay with the access.

It seems like even with the DNS service such as no-ip.org still
requires the users to access via  abc.no-ip.org:8000 instead of abc.no-
ip.org.

But I thought I had tried abc.no-ip.org:8000 already yesterday.

Thank you, Sam.

On Jun 6, 1:19 am, Sam Lai <samuel@gmail.com> wrote:
> Does it work from another machine on the same local network?
>
> This is definitely possible though; I've done it before.
>
> On 6 June 2010 14:35, John Yeukhon Wong <gokoproj...@gmail.com> wrote:
>
> > I just disabled the FW, but no luck with any trials.
>
> > Yeah. Security isn't my concern because only a few people (including
> > myself) will learn about this project. They will only see the
> > interfaces at certain stages when I give out notifications.
> > I am sure in Linux there isn't any problem with overriding the
> > restriction.
> > It's so weird with XP.
>
> > Hahaha
>
> > Thanks
>
> > On Jun 5, 11:55 pm, Sam Lai <samuel@gmail.com> wrote:
> >> Oops. Seems like you've tried that already.
>
> >> Have you checked your Windows firewall settings?
>
> >> On 6 June 2010 13:53, Sam Lai <samuel@gmail.com> wrote:
>
> >> > By default, the Django development server does not allow hosts to
> >> > connect unless it is localhost (127.0.0.1) or a local IP
> >> > (192.168.1.101 in your case).
>
> >> > Doing this is a *bad idea*, as indicated by the docs -
> >> >http://docs.djangoproject.com/en/1.2/ref/django-admin/#djadmin-runserver
>
> >> > If you really do want to override it, start the server like this -
>
> >> > python manage.py runserver 0.0.0.0:8000
>
> >> > That tells the dev server to accept any IP.
>
> >> > If I were you, I'd just set up IIS/Apache. There's no advantage of
> >> > accessing your dev server from elsewhere anyway, because you can't see
> >> > the debug messages.
>
> >> > On 6 June 2010 10:32, John Yeukhon Wong <gokoproj...@gmail.com> wrote:
> >> >> For my home purpose, currently I am running Windows XP.
>
> >> >> I have everything ready. Django, Python are all good.
>
> >> >> If I let the runserver (I am using the django-development server) to
> >> >> be 127.0.0.1:8000 or 192.168.1.101:8000 they all worked.
>
> >> >> Let say abc.no-ip.org is a FREE DNS service I use to access
> >> >> externally.
>
> >> >> In the past when I did this in debian or ubuntu, there was no access
> >> >> issue except the fact that I enabled either multi-cast or NET
> >> >> Redirection in my router firewall setting.
>
> >> >> I checked my router setting so many times and nothing suspicious.
>
> >> >> I even tried like  192.168.1.101:8080  0.0.0.0:8080  in the runserver
> >> >> command and no luck.
>
> >> >> I still cannot access to abc.no-ip.org
>
> >> >> How come?
>
> >> >> Thanks.
>
> >> >> --
> >> >> You received this message because you are subscribed to the Google 
> >> >> Groups "Django users" group.
> >> >> To post to this group, send email to django-us...@googlegroups.com.
> >> >> To unsubscribe from this group, send email to 
> >> >> django-users+unsubscr...@googlegroups.com.
> >> >> For more options, visit this group 
> >> >> 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.



Re: Django external access [Windows]

2010-06-05 Thread John Yeukhon Wong
I just disabled the FW, but no luck with any trials.

Yeah. Security isn't my concern because only a few people (including
myself) will learn about this project. They will only see the
interfaces at certain stages when I give out notifications.
I am sure in Linux there isn't any problem with overriding the
restriction.
It's so weird with XP.

Hahaha

Thanks

On Jun 5, 11:55 pm, Sam Lai <samuel@gmail.com> wrote:
> Oops. Seems like you've tried that already.
>
> Have you checked your Windows firewall settings?
>
> On 6 June 2010 13:53, Sam Lai <samuel@gmail.com> wrote:
>
> > By default, the Django development server does not allow hosts to
> > connect unless it is localhost (127.0.0.1) or a local IP
> > (192.168.1.101 in your case).
>
> > Doing this is a *bad idea*, as indicated by the docs -
> >http://docs.djangoproject.com/en/1.2/ref/django-admin/#djadmin-runserver
>
> > If you really do want to override it, start the server like this -
>
> > python manage.py runserver 0.0.0.0:8000
>
> > That tells the dev server to accept any IP.
>
> > If I were you, I'd just set up IIS/Apache. There's no advantage of
> > accessing your dev server from elsewhere anyway, because you can't see
> > the debug messages.
>
> > On 6 June 2010 10:32, John Yeukhon Wong <gokoproj...@gmail.com> wrote:
> >> For my home purpose, currently I am running Windows XP.
>
> >> I have everything ready. Django, Python are all good.
>
> >> If I let the runserver (I am using the django-development server) to
> >> be 127.0.0.1:8000 or 192.168.1.101:8000 they all worked.
>
> >> Let say abc.no-ip.org is a FREE DNS service I use to access
> >> externally.
>
> >> In the past when I did this in debian or ubuntu, there was no access
> >> issue except the fact that I enabled either multi-cast or NET
> >> Redirection in my router firewall setting.
>
> >> I checked my router setting so many times and nothing suspicious.
>
> >> I even tried like  192.168.1.101:8080  0.0.0.0:8080  in the runserver
> >> command and no luck.
>
> >> I still cannot access to abc.no-ip.org
>
> >> How come?
>
> >> Thanks.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Django users" group.
> >> To post to this group, send email to django-us...@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> 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.



Django external access [Windows]

2010-06-05 Thread John Yeukhon Wong
For my home purpose, currently I am running Windows XP.

I have everything ready. Django, Python are all good.

If I let the runserver (I am using the django-development server) to
be 127.0.0.1:8000 or 192.168.1.101:8000 they all worked.

Let say abc.no-ip.org is a FREE DNS service I use to access
externally.

In the past when I did this in debian or ubuntu, there was no access
issue except the fact that I enabled either multi-cast or NET
Redirection in my router firewall setting.

I checked my router setting so many times and nothing suspicious.

I even tried like  192.168.1.101:8080  0.0.0.0:8080  in the runserver
command and no luck.

I still cannot access to abc.no-ip.org

How come?

Thanks.

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