Re: Admin page: How to add a column for user that added an item
On Oct 28, 2:47 pm, Robert Dailey <[EMAIL PROTECTED]> wrote: > On Oct 28, 11:17 am, Steve Holden <[EMAIL PROTECTED]> wrote: > > > > > Robert Dailey wrote: > > > On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote: > > > >> Robert Dailey wrote: > > > >>> Hi, > > > >>> I currently have the following model: > > > >>> class Note( models.Model ): > > >>> content = models.TextField() > > > >>> I've setup the admin page to allow users to add "notes", which > > >>> basically lets them fill in the content variable. However, on the > > >>> admin page I want to add a column to show the user that added that > > >>> note. This would be the username in the admin page that they logged in > > >>> with. I hope that I can do this without adding any information to my > > >>> Note class, but if I must then I don't mind. > > > >>> So column 1 should be the user that added that note, and Column 2 > > >>> should be the note itself. > > > >> The usual way to do this is to establish a relationship between User and > > >> Note. Since each note will only be created by a single user, and each > > >> user can (presumably) issue many notes the sensible thing to do would be > > >> to add a foreign key to Note to express which user created it. > > > >> OK, assuming you can import your User model into the module that defines > > >> your Note model, you would just need to add > > > >> user = models.ForeignKey(User) > > > >> to the Note model. > > > > Thanks for your help. I tried the following: > > > > from django.db import models > > > from django.contrib.auth.models import User > > > > # Create your models here. > > > class Note( models.Model ): > > > content = models.TextField() > > > user = models.ForeignKey( User ) > > > > However, now when I visit the page that lists my notes, I get the > > > following error: > > > > OperationalError at /admin/core/note/ > > > (1054, "Unknown column 'core_note.user_id' in 'field list'") > > > > Any idea what is going on? > > > You'll need to add the corresponding field to your database. If you > > don't have any data worth keeping on the Note table (it will be called > > YourappnameNote in the database) then the easiest thing to do is delete > > the whole table then run > > > python manage.py syncdb > > > to re-create the table with the additional field. > > Awesome, thank you! > > I'm have some more questions for you if you don't mind. When I add a > note, now there is a combo box with a list of users to choose from. I > would like for this combo box to not be visible and for it to > automatically choose the user submitting the note (The user currently > logged in). Is there a way to do this? Bump Any ideas on this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin page: How to add a column for user that added an item
On Oct 28, 11:17 am, Steve Holden <[EMAIL PROTECTED]> wrote: > Robert Dailey wrote: > > On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote: > > >> Robert Dailey wrote: > > >>> Hi, > > >>> I currently have the following model: > > >>> class Note( models.Model ): > >>> content = models.TextField() > > >>> I've setup the admin page to allow users to add "notes", which > >>> basically lets them fill in the content variable. However, on the > >>> admin page I want to add a column to show the user that added that > >>> note. This would be the username in the admin page that they logged in > >>> with. I hope that I can do this without adding any information to my > >>> Note class, but if I must then I don't mind. > > >>> So column 1 should be the user that added that note, and Column 2 > >>> should be the note itself. > > >> The usual way to do this is to establish a relationship between User and > >> Note. Since each note will only be created by a single user, and each > >> user can (presumably) issue many notes the sensible thing to do would be > >> to add a foreign key to Note to express which user created it. > > >> OK, assuming you can import your User model into the module that defines > >> your Note model, you would just need to add > > >> user = models.ForeignKey(User) > > >> to the Note model. > > > Thanks for your help. I tried the following: > > > from django.db import models > > from django.contrib.auth.models import User > > > # Create your models here. > > class Note( models.Model ): > > content = models.TextField() > > user = models.ForeignKey( User ) > > > However, now when I visit the page that lists my notes, I get the > > following error: > > > OperationalError at /admin/core/note/ > > (1054, "Unknown column 'core_note.user_id' in 'field list'") > > > Any idea what is going on? > > You'll need to add the corresponding field to your database. If you > don't have any data worth keeping on the Note table (it will be called > YourappnameNote in the database) then the easiest thing to do is delete > the whole table then run > > python manage.py syncdb > > to re-create the table with the additional field. Awesome, thank you! I'm have some more questions for you if you don't mind. When I add a note, now there is a combo box with a list of users to choose from. I would like for this combo box to not be visible and for it to automatically choose the user submitting the note (The user currently logged in). Is there a way to do this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin page: How to add a column for user that added an item
On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote: > Robert Dailey wrote: > > Hi, > > > I currently have the following model: > > > class Note( models.Model ): > > content = models.TextField() > > > I've setup the admin page to allow users to add "notes", which > > basically lets them fill in the content variable. However, on the > > admin page I want to add a column to show the user that added that > > note. This would be the username in the admin page that they logged in > > with. I hope that I can do this without adding any information to my > > Note class, but if I must then I don't mind. > > > So column 1 should be the user that added that note, and Column 2 > > should be the note itself. > > The usual way to do this is to establish a relationship between User and > Note. Since each note will only be created by a single user, and each > user can (presumably) issue many notes the sensible thing to do would be > to add a foreign key to Note to express which user created it. > > OK, assuming you can import your User model into the module that defines > your Note model, you would just need to add > > user = models.ForeignKey(User) > > to the Note model. Thanks for your help. I tried the following: from django.db import models from django.contrib.auth.models import User # Create your models here. class Note( models.Model ): content = models.TextField() user = models.ForeignKey( User ) However, now when I visit the page that lists my notes, I get the following error: OperationalError at /admin/core/note/ (1054, "Unknown column 'core_note.user_id' in 'field list'") Any idea what is going on? --~--~-~--~~~---~--~~ You 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 -~--~~~~--~~--~--~---
Admin page: How to add a column for user that added an item
Hi, I currently have the following model: class Note( models.Model ): content = models.TextField() I've setup the admin page to allow users to add "notes", which basically lets them fill in the content variable. However, on the admin page I want to add a column to show the user that added that note. This would be the username in the admin page that they logged in with. I hope that I can do this without adding any information to my Note class, but if I must then I don't mind. So column 1 should be the user that added that note, and Column 2 should be the note itself. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static files?
On Sep 1, 1:32 am, Davor Lučić <[EMAIL PROTECTED]> wrote: > If you are using Apache you can use mod_rewrite. > > http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html > > On Aug 31, 10:08 pm, Robert <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I just got done reading through the 4 django tutorials and they were > > very helpful. However, I did not find out through the tutorials alone > > how to serve CSS files along with my HTML. I was told in IRC that > > these are not directly handled by django. > > > Basically, my main concern is keeping my website source code > > centralized. At the moment, I keep my django project & respective apps > > in Subversion, and I want my static files (CSS) to be in there with > > the rest of the django files. > > > Having said this, I'm not sure how to configure apache to look for > > those CSS files. Say my django project is in /srv/django/myproject, > > and my document root is in /srv/http, what must be done? If this is > > covered in the documentation, I apologize for wasting the community's > > time and would appreciate a direct link to the materials I need to > > read. > > > Thanks in advance. Thanks for the help guys. I'm guessing javascript files are also considered static, since they're referenced by the HTML as well? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Developing django on windows
On Sep 4, 3:39 pm, Robert Dailey <[EMAIL PROTECTED]> wrote: > Hi, > > I plan to host my production copy of my django project on a linux/ > apache setup, however for my development I want to do a checkout > through subversion and work exclusively on windows as I develop. This > means I want to be able to run just the test server for django on > windows while I develop to test my changes. Is there a quick installer > somewhere for the testing functionality of django? This might entail > installing the entire django API, but the searching I've done so far > has involved a lot of work just to get django working in windows. > > Thanks in advance. I guess this also means I'd have to expose my MySQL database to the LAN... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Developing django on windows
Hi, I plan to host my production copy of my django project on a linux/ apache setup, however for my development I want to do a checkout through subversion and work exclusively on windows as I develop. This means I want to be able to run just the test server for django on windows while I develop to test my changes. Is there a quick installer somewhere for the testing functionality of django? This might entail installing the entire django API, but the searching I've done so far has involved a lot of work just to get django working in windows. Thanks 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-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 -~--~~~~--~~--~--~---
Need suggestions on subversion structure for project
Hi, First, let me start by explaining what my goals are: - Have a django project & its apps in version control - Have all of the templates the apps will use in the same version control - Have all static content (images, css, etc) in the same version control. So far, this is the directory structure I've come up with: django/ my_project/ app1/ app2/ templates/ static/ images/ styles/ Is this a good structure? Using this structure, I can work on everything involved in making my website through a single working copy in Subversion. Do you guys have any better suggestions? My main concern with the structure I presented above is how I will configure Apache2 to handle serving static content. Also, the fact that Django requires an absolute path for the templates directory makes this more of a management nightmare. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---