Django Tutorial part 2... Admin Site won't work...
I'm going through the django tutorial and I'm having difficulties at the beginning of the second part... It tells me to create the admin site, and browse to 127.0.0.1:8000/admin to log in to the admin site I just created... But when I do that, I get the python server telling me that the site is not found -- it's not the usual apache web-server 404 error, it's definitely coming from the python server, so I know that's running properly. Searching through some of the other posts, I came across one responder who asked someone with this same problem to find their site ID in their settings.py file. Mine says the site ID is 1. So, armed with that information, I go to the python shell, and type the following: >>> from django.contrib.sites.models import Site >>> Site.objects.get(id=1) And I get the following in response: Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 131, in get return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 366, in get % self.model._meta.object_name) DoesNotExist: Site matching query does not exist. So, it seems that the entire site doesn't exist? I've followed every step in the tutorial exactly, with no problems so far... Can anyone help me with this? Thanks, Laurence MacNeill Mableton, Georgia, USA -- 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/-/Aq18U3mxM1MJ. 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 do I get django working without having to manually run the server?
Ok... I'm still learning this stuff here, and I'm confused about one thing... Well, many things, actually, but only one thing that I'll ask about here. During the tutorial I have to type "python manage.py runserver" in order to see my django pages in a web-browser. Obviously, I don't want to do this for anything but the tutorial... In fact, I don't even want to do this for the tutorial -- I have apache and mod_wsgi already running on this machine, so why won't those things just automatically serve up these django pages I'm creating? What more do I need to do to get apache and mod_wsgi to server my django pages? Thanks, Laurence MacNeill Mableton, Georgia, USA -- 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/-/XyTCXN8L3FIJ. 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.
Where are my posts?
How do I get privileges to post in this group? I've posted two questions, and have not seen them pop up yet... Who do I need to contact to get posting privileges? I really was hoping to get these questions answered soon. Thanks, Laurence MacNeill Mableton, Georgia, USA -- 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/-/ckfvboIGvPoJ. 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: Django Tutorial part 2... Admin Site won't work...
I'm using 1.4 I finally figured out that if I just create the site manually, everything works fine... I don't know why it wasn't being created when syncdb was run... L. On Sunday, June 17, 2012 2:17:35 AM UTC-4, Xavier Ordoquy wrote: > > Hi, > > The site entry is usually created when the syncdb is run. > What Django version are you using ? If you're using the development > version, please remove it and install a stable version. > > Regards, > Xavier Ordoquy, > Linovia. > > Le 16 juin 2012 à 23:16, Laurence MacNeill a écrit : > > I'm going through the django tutorial and I'm having difficulties at the > beginning of the second part... > > It tells me to create the admin site, and browse to 127.0.0.1:8000/adminto > log in to the admin site I just created... But when I do that, I get > the python server telling me that the site is not found -- it's not the > usual apache web-server 404 error, it's definitely coming from the python > server, so I know that's running properly. > > Searching through some of the other posts, I came across one responder who > asked someone with this same problem to find their site ID in their > settings.py file. Mine says the site ID is 1. So, armed with that > information, I go to the python shell, and type the following: > >>> from django.contrib.sites.models import Site > >>> Site.objects.get(id=1) > > And I get the following in response: > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", > line 131, in get > return self.get_query_set().get(*args, **kwargs) > File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line > 366, in get > % self.model._meta.object_name) > DoesNotExist: Site matching query does not exist. > > So, it seems that the entire site doesn't exist? I've followed every step > in the tutorial exactly, with no problems so far... Can anyone help me > with this? > > Thanks, > Laurence MacNeill > Mableton, Georgia, USA > > > -- > 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/-/Aq18U3mxM1MJ. > 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/-/FA-ss7hNR50J. 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.
Trying to find something in multiple databases... Confused...
Ok, I'm a total django noob here, so I am probably doing this wrong... But here goes... When someone comes to my django app's root (index), I need to verify their user-name (which is stored in a Linux environment variable). Based on where (or if) I find their user-name, I want to send them to one of three different pages -- if I don't find them in any database, I want to add them to a given database, then send them to a page. So here's what I have in my views.py file: def index(request) current_username = os.environ['REMOTE_USER'] -- 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/-/89ghQfC_J0IJ. 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: Trying to find something in multiple databases... Confused...
well -- I hit the wrong key and posted that before I was finished typing... here's what's in my views.py file: def index(request) current_username = os.environ['REMOTE_USER'] This should provide me with their username (yes I do have 'import os' at the top of the file)... Now, after I get their username I want to do something like this (but I'm not sure how to write in django -- so I've put ## around the pseudo-code) try: student = Student.objects.get(student_name=current_username) except (#can't find it in Student database, but I don't know what code to put here#) try: instructor = Instructor.objects.get(instructor_name=current_username) except (#can't find it in Instructor database, but I don't know what code to put here#) try: administrator = Administrator.objects.get(administrator_name=current_username) except (#fail condition - can't find current_username in Administrator database, but I don't know what code to put here#) #because we failed to find it in any database, we assume it's a student and add it student = Student(student_name=current_username) student.save #here's where I'm not sure how to continue -- I want to do something like this# #if student is defined# return render_to_response('ta/student.html', student) #else if instructor is defined# return render_to_response('ta/instructor.html', instructor) #else if administrator is defined# return render_to_response('ta/administrator.html', administrator) #end of my code# So -- can someone please help me fill in the missing code above? I've been searching for hours, but I just can't seem to hit on the correct search-terms to get done what I want here... Thanks, Laurence MacNeill Mableton, Georgia, USA On Monday, June 18, 2012 3:40:53 AM UTC-4, Laurence MacNeill wrote: > > Ok, I'm a total django noob here, so I am probably doing this wrong... > But here goes... > > When someone comes to my django app's root (index), I need to verify their > user-name (which is stored in a Linux environment variable). Based on > where (or if) I find their user-name, I want to send them to one of three > different pages -- if I don't find them in any database, I want to add them > to a given database, then send them to a page. > > So here's what I have in my views.py file: > def index(request) > current_username = os.environ['REMOTE_USER'] > > -- 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/-/rVfs691Nk0AJ. 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: Trying to find something in multiple databases... Confused...
On Monday, June 18, 2012, Melvyn Sopacua wrote: > On 18-6-2012 9:52, Laurence MacNeill wrote: > > well -- I hit the wrong key and posted that before I was finished > typing... > > > > here's what's in my views.py file: > > def index(request) > > current_username = os.environ['REMOTE_USER'] > > And you're sure this works? Try: > return django.shortcuts.render_to_response(current_username) > > here to verify it's coming through. Normally, the authenticated username > would be part of the request dictionary. Yeah, it's not working... How do I get the user-name from the request dictionary? request.REMOTE_USER or somthing like that? It's not using Django for the user-validation, though... When someone logs into the site, they get redirected to a page that validates them. This is controled by the Apache web-server itself -- if they try to access any document served by Apache, and they don't have a cookie on their computer, they're redirected to a different page where they enter their user ID and password, then are sent back to the original page. The user-id is then stored in a linux environment variable called REMOTE_USER. So I figured the only way to access it was via the os.environ method. > > Almost correct: > if student is not None : > # the student.html template will now have a variable named student > # which is the student object you fetched > return render_to_response('ta/student.html', student=student) > elif instructor is not None : > #etc Ahh, ok -- that makes sense... Thanks... L. -- 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: Trying to find something in multiple databases... Confused...
Right -- different tables in the same database, of course... Thanks. L. On Monday, June 18, 2012, Daniel Roseman wrote: > On Monday, 18 June 2012 08:40:53 UTC+1, Laurence MacNeill wrote: >> >> Ok, I'm a total django noob here, so I am probably doing this wrong... >> But here goes... >> >> When someone comes to my django app's root (index), I need to verify >> their user-name (which is stored in a Linux environment variable). Based >> on where (or if) I find their user-name, I want to send them to one of >> three different pages -- if I don't find them in any database, I want to >> add them to a given database, then send them to a page. >> >> So here's what I have in my views.py file: >> def index(request) >> current_username = os.environ['REMOTE_USER'] >> >> > So Melvyn has answered your question, but a quick note on terminology: > what you've got there are separate *database tables*, or separate *Django > models* -- not separate databases. Multiple databases is a whole different > question, which you really don't want to get into as a newbie (or, indeed, > at all if possible). > -- > DR. > > -- > 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/-/jSuHg6H4amoJ. > To post to this group, send email to > django-users@googlegroups.com 'django-users@googlegroups.com');> > . > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com 'django-users%2bunsubscr...@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.