Re: Admin issues
In your urls. py make sure you have: from django.contrib import admin admin.autodiscover() and that you've uncommented the (r'^admin/', include(admin.site.urls)), in the tuple: urlpatterns = patterns. On Apr 9, 2010, at 8:44 AM, Sheena wrote: > Hey hey. I'm a little new to Django so I've been following through the > Django Book v2 and I'm having trouble adding my models to the admin > site. I'm pretty sure I've followed instructions correctly, I've also > tried following some random advice I found to no avail. Any help would > be greatly appreciated. Below are some code snippets: > > from models.py: > class Publisher(models.Model): >name = models.CharField(max_length=30) >address = models.CharField(max_length=50) >city = models.CharField(max_length=60) >state_province = models.CharField(max_length=30) >country = models.CharField(max_length=50) >website = models.URLField() > >def __unicode__(self): >return self.name > >class admin: >pass > the last two lines don't seem to change anything. > > form settings.py > INSTALLED_APPS = ( >'django.contrib.auth', >'django.contrib.contenttypes', >#'django.contrib.sessions', >'django.contrib.admin', >#'django.contrib.comments', >#'django.contrib.sites', >'newProj.books', > ) > MIDDLEWARE_CLASSES = ( >'django.middleware.common.CommonMiddleware', >'django.contrib.sessions.middleware.SessionMiddleware', >'django.contrib.auth.middleware.AuthenticationMiddleware', > ) > > DATABASE_ENGINE = 'sqlite3' > DATABASE_NAME = > os.path.join(os.path.dirname(__file__),'testDB').replace('\\','/') > DATABASE_USER = '' # Not used with sqlite3. > DATABASE_PASSWORD = '' # Not used with sqlite3. > DATABASE_HOST = '' # Not used with sqlite3. > DATABASE_PORT = '' # Set to empty string for default. Not > used > > And finally from admin.py > class AuthorAdmin(admin.ModelAdmin): >pass > admin.site.register(Author, AuthorAdmin) > admin.site.register(Publisher) > admin.site.register(Book) > > Any help would be greatly appreciated > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin issues
@Sheena, sorry -- I didnt read all of your email -- I think if you've got it all in admin.py make sure you're importing admin from django.contrib. To activate the admin interface though you need to do: 1. Add 'django.contrib.admin' to the INSTALLED_APPS setting (which you did) 2. Make sure INSTALLED_APPS contains 'django.contrib.auth, contettypes, and sessions (I see sessions is commented out on yours. 3. Middle ware classes needs to contain 'django.middleware.common.CommomMiddleware, 'django.contrib.sessions.middlewarae.SessionMiddleWare, and django.contrib.auth.middleware.AuthenticationMiddleware. run python manage.py syncdb then make sure that you have this in urls.py file: from django.contrib import admin admin.autodiscover() #include this URLPattern... urlpatterns = patterns(' ', # ... (r'^admin/', include(admin.site.urls)), # ... ) Hope this helps! but you will still need to make sure that you have On Apr 9, 2010, at 9:13 AM, Steven Elliott Jr wrote: > In your urls. py make sure you have: > > from django.contrib import admin > admin.autodiscover() > > and > > that you've uncommented the (r'^admin/', include(admin.site.urls)), > > in the tuple: urlpatterns = patterns. > > On Apr 9, 2010, at 8:44 AM, Sheena wrote: > >> Hey hey. I'm a little new to Django so I've been following through the >> Django Book v2 and I'm having trouble adding my models to the admin >> site. I'm pretty sure I've followed instructions correctly, I've also >> tried following some random advice I found to no avail. Any help would >> be greatly appreciated. Below are some code snippets: >> >> from models.py: >> class Publisher(models.Model): >>name = models.CharField(max_length=30) >>address = models.CharField(max_length=50) >>city = models.CharField(max_length=60) >>state_province = models.CharField(max_length=30) >>country = models.CharField(max_length=50) >>website = models.URLField() >> >>def __unicode__(self): >>return self.name >> >>class admin: >>pass >> the last two lines don't seem to change anything. >> >> form settings.py >> INSTALLED_APPS = ( >>'django.contrib.auth', >>'django.contrib.contenttypes', >>#'django.contrib.sessions', >>'django.contrib.admin', >>#'django.contrib.comments', >>#'django.contrib.sites', >>'newProj.books', >> ) >> MIDDLEWARE_CLASSES = ( >>'django.middleware.common.CommonMiddleware', >>'django.contrib.sessions.middleware.SessionMiddleware', >>'django.contrib.auth.middleware.AuthenticationMiddleware', >> ) >> >> DATABASE_ENGINE = 'sqlite3' >> DATABASE_NAME = >> os.path.join(os.path.dirname(__file__),'testDB').replace('\\','/') >> DATABASE_USER = '' # Not used with sqlite3. >> DATABASE_PASSWORD = '' # Not used with sqlite3. >> DATABASE_HOST = '' # Not used with sqlite3. >> DATABASE_PORT = '' # Set to empty string for default. Not >> used >> >> And finally from admin.py >> class AuthorAdmin(admin.ModelAdmin): >>pass >> admin.site.register(Author, AuthorAdmin) >> admin.site.register(Publisher) >> admin.site.register(Book) >> >> Any help would be greatly appreciated >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- 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: Admin issues
What you have looks about right. What result are you getting? An error message? --Stuart On Apr 9, 7:44 am, Sheena wrote: > Hey hey. I'm a little new to Django so I've been following through the > Django Book v2 and I'm having trouble adding my models to the admin > site. I'm pretty sure I've followed instructions correctly, I've also > tried following some random advice I found to no avail. Any help would > be greatly appreciated. Below are some code snippets: > > from models.py: > class Publisher(models.Model): > name = models.CharField(max_length=30) > address = models.CharField(max_length=50) > city = models.CharField(max_length=60) > state_province = models.CharField(max_length=30) > country = models.CharField(max_length=50) > website = models.URLField() > > def __unicode__(self): > return self.name > > class admin: > pass > the last two lines don't seem to change anything. > > form settings.py > INSTALLED_APPS = ( > 'django.contrib.auth', > 'django.contrib.contenttypes', > #'django.contrib.sessions', > 'django.contrib.admin', > #'django.contrib.comments', > #'django.contrib.sites', > 'newProj.books', > ) > MIDDLEWARE_CLASSES = ( > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > ) > > DATABASE_ENGINE = 'sqlite3' > DATABASE_NAME = > os.path.join(os.path.dirname(__file__),'testDB').replace('\\','/') > DATABASE_USER = '' # Not used with sqlite3. > DATABASE_PASSWORD = '' # Not used with sqlite3. > DATABASE_HOST = '' # Not used with sqlite3. > DATABASE_PORT = '' # Set to empty string for default. Not > used > > And finally from admin.py > class AuthorAdmin(admin.ModelAdmin): > pass > admin.site.register(Author, AuthorAdmin) > admin.site.register(Publisher) > admin.site.register(Book) > > Any help would be greatly appreciated -- 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: Admin issues
Uncomment: #'django.contrib.sessions', make sure to import admin from django.contrib and turn admin.autodiscover() and yes, error messages would be helpful... if any. On Apr 9, 2010, at 10:32 AM, Stuart wrote: > What you have looks about right. What result are you getting? An error > message? > > > --Stuart > > On Apr 9, 7:44 am, Sheena wrote: >> Hey hey. I'm a little new to Django so I've been following through the >> Django Book v2 and I'm having trouble adding my models to the admin >> site. I'm pretty sure I've followed instructions correctly, I've also >> tried following some random advice I found to no avail. Any help would >> be greatly appreciated. Below are some code snippets: >> >> from models.py: >> class Publisher(models.Model): >> name = models.CharField(max_length=30) >> address = models.CharField(max_length=50) >> city = models.CharField(max_length=60) >> state_province = models.CharField(max_length=30) >> country = models.CharField(max_length=50) >> website = models.URLField() >> >> def __unicode__(self): >> return self.name >> >> class admin: >> pass >> the last two lines don't seem to change anything. >> >> form settings.py >> INSTALLED_APPS = ( >> 'django.contrib.auth', >> 'django.contrib.contenttypes', >> #'django.contrib.sessions', >> 'django.contrib.admin', >> #'django.contrib.comments', >> #'django.contrib.sites', >> 'newProj.books', >> ) >> MIDDLEWARE_CLASSES = ( >> 'django.middleware.common.CommonMiddleware', >> 'django.contrib.sessions.middleware.SessionMiddleware', >> 'django.contrib.auth.middleware.AuthenticationMiddleware', >> ) >> >> DATABASE_ENGINE = 'sqlite3' >> DATABASE_NAME = >> os.path.join(os.path.dirname(__file__),'testDB').replace('\\','/') >> DATABASE_USER = '' # Not used with sqlite3. >> DATABASE_PASSWORD = '' # Not used with sqlite3. >> DATABASE_HOST = '' # Not used with sqlite3. >> DATABASE_PORT = '' # Set to empty string for default. Not >> used >> >> And finally from admin.py >> class AuthorAdmin(admin.ModelAdmin): >> pass >> admin.site.register(Author, AuthorAdmin) >> admin.site.register(Publisher) >> admin.site.register(Book) >> >> Any help would be greatly appreciated > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin issues
I uncommented 'django.contrib.sessions' to no avail, and everything else is correct. I'm not getting any error messages at all, I'm just not given the option to do anything with my tables from the admin site. I've gone through three different tutorials on it and they all say the same thing so it doesn't look like I've left anything out. I'm not sure if this is a stoopid question or not but could Windows XP be screwing with it? I was warned by an aquaintance that it does strange things to Django but I wasn't given any specifics and everything has been behaving beautifully until now. I'm using Djanga v1.1.1 -- 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: Admin issues
On Fri, Apr 9, 2010 at 1:23 PM, Sheena wrote: > I uncommented 'django.contrib.sessions' to no avail, and everything > else is correct. > Did you run manage.py syncdb after uncommenting sessions? > I'm not getting any error messages at all, I'm just not given the > option to do anything with my tables from the admin site. > So what, exactly, do you get? A blank page? A page saying you don't have permission to edit anything? > I've gone > through three different tutorials on it and they all say the same > thing so it doesn't look like I've left anything out. I'm not sure if > this is a stoopid question or not but could Windows XP be screwing > with it? I was warned by an aquaintance that it does strange things to > Django but I wasn't given any specifics and everything has been > behaving beautifully until now. I'm using Djanga v1.1.1 > No, Django runs fine on Windows XP. In your original note you mention having a "class admin" in your models -- that's an extremely old (and no longer functional) way of enabling admin. As you note, it has no effect when using Django 1.1.1. But the fact that something prompted you to even add it makes me think that you may be running into trouble due to working off of doc for a mixture of different versions. What I'd suggest is starting fresh by working through the tutorial: http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01 (Note you want to stick with the one that matches the version you have installed.) Perhaps by working through a fresh project and successfully getting the admin working there it will become clear to you what piece is missing/different in your own project. 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-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: Admin issues
This may be bad advice. But, since I'm a newbie myself running in a non-production environment, what I do is restart Apache after making changes to my model.py or settings.py. It might be worth restarting your web server, if you can. I figure there's a better approach. I just haven't gotten far enough along in my learning to be concerned with finding a better way, yet. On Fri, Apr 9, 2010 at 7:44 AM, Sheena wrote: > Hey hey. I'm a little new to Django so I've been following through the > Django Book v2 and I'm having trouble adding my models to the admin > site. I'm pretty sure I've followed instructions correctly, I've also > tried following some random advice I found to no avail. Any help would > be greatly appreciated. Below are some code snippets: > > from models.py: > class Publisher(models.Model): >name = models.CharField(max_length=30) >address = models.CharField(max_length=50) >city = models.CharField(max_length=60) >state_province = models.CharField(max_length=30) >country = models.CharField(max_length=50) >website = models.URLField() > >def __unicode__(self): >return self.name > >class admin: >pass > the last two lines don't seem to change anything. > > form settings.py > INSTALLED_APPS = ( >'django.contrib.auth', >'django.contrib.contenttypes', >#'django.contrib.sessions', >'django.contrib.admin', >#'django.contrib.comments', >#'django.contrib.sites', >'newProj.books', > ) > MIDDLEWARE_CLASSES = ( >'django.middleware.common.CommonMiddleware', >'django.contrib.sessions.middleware.SessionMiddleware', >'django.contrib.auth.middleware.AuthenticationMiddleware', > ) > > DATABASE_ENGINE = 'sqlite3' > DATABASE_NAME = > os.path.join(os.path.dirname(__file__),'testDB').replace('\\','/') > DATABASE_USER = '' # Not used with sqlite3. > DATABASE_PASSWORD = '' # Not used with sqlite3. > DATABASE_HOST = '' # Not used with sqlite3. > DATABASE_PORT = '' # Set to empty string for default. Not > used > > And finally from admin.py > class AuthorAdmin(admin.ModelAdmin): >pass > admin.site.register(Author, AuthorAdmin) > admin.site.register(Publisher) > admin.site.register(Book) > > Any help would be greatly appreciated > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin issues
Have you looked at your db? are the tables there that you wrote in your models. Did you run python manage.py syncdb and did you see verification that your tables were created? If you want to see that the sql is being created run python manage.py sqlall app_name to make sure its generating the sql you want. If everything is correct the only explanation is that you don't actually have any tables set up in the database. On Apr 9, 2010, at 1:23 PM, Sheena wrote: > I uncommented 'django.contrib.sessions' to no avail, and everything > else is correct. > > I'm not getting any error messages at all, I'm just not given the > option to do anything with my tables from the admin site. I've gone > through three different tutorials on it and they all say the same > thing so it doesn't look like I've left anything out. I'm not sure if > this is a stoopid question or not but could Windows XP be screwing > with it? I was warned by an aquaintance that it does strange things to > Django but I wasn't given any specifics and everything has been > behaving beautifully until now. I'm using Djanga v1.1.1 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin issues
Still no luck... I've run syncdb and I can talk to my db through the interpreter easily so I don't think there's a problem with that. When i log in i get add and change options for Groups, Users, Comments and Sites but not for anything relating to my application (as created in chapter 5 of the Django Book 2, it looks to me like there should be an option to add and change stuff in my little database. I included the class admin stuff as a last ditch effort to get the thing to work, I found it on an older tutorial, just thought I'd see if it changed anything. Besides that, I'm using runserver when looking at my sites and i always restart it whenever i make changes that could alter my admin site. -- 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: Admin issues
On Mon, Apr 12, 2010 at 4:41 AM, Sheena wrote: > Still no luck... > I've run syncdb and I can talk to my db through the interpreter easily > so I don't think there's a problem with that. > When i log in i get add and change options for Groups, Users, Comments > and Sites but not for anything relating to my application (as created > in chapter 5 of the Django Book 2, it looks to me like there should be > an option to add and change stuff in my little database. > I included the class admin stuff as a last ditch effort to get the > thing to work, I found it on an older tutorial, just thought I'd see > if it changed anything. > Besides that, I'm using runserver when looking at my sites and i > always restart it whenever i make changes that could alter my admin > site. > So it sounds like the issue has something to do with your admin.py file -- that is where the admin registration calls for your own models are, and that appears to be the only thing that isn't working. It is in your application directory alongside models.py, right, not anywhere else? That is where it needs to be in order to be found by the admin.autodiscover() in urls.py. You might try putting some prints into it and seeing if it is getting loaded at all. 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-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: Admin issues
> Do I Have to use a custom manipulator? > > Thanks in advance. > Picio > Sorry I want to say CUSTOM MANAGER :( Picio --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---