admin Exception Type: SuspiciousOperation ??
when I use django admin create a new book auther ( order the django book introduction ) but the "headshot" still is required and, if give any img the error as follows, Attempted access to '/tmp/avatar_005.jpeg' denied. Request Method: POST Request URL: http://127.0.0.1/admin/books/author/add/ Exception Type: SuspiciousOperation Exception Value: Attempted access to '/tmp/avatar_005.jpeg' denied. Exception Location: /usr/lib/python2.6/site-packages/django/core/files/storage.py in path, line 214 Python Executable: /usr/bin/python Python Version: 2.6.2 Python Path: ['/var/www/html', '/usr/lib/python26.zip', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/PIL'] Server time: Tue, 15 Dec 2009 03:04:14 +0800 google get an solution: change " headshot = models.ImageField(upload_to='/tmp') " to " headshot = models.ImageField(upload_to='tmp') " in models.pyheadshot = models.ImageField(upload_to='tmp') but grep 'headshot' /usr/lib/python2.6/site-packages/django/* -R will find nothing useful what's wrong with this problem ?? == Fedora 12 django 1.1 -- 小yú -- 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: Multi table inheritance and reverse lookup
We had to use a very similar solution as well in a project using multi- table inheritance. There's simply no good way to get to the actual type of the object. On Sep 23, 1:36 am, Torsten Brongerwrote: > Hallöchen! > > Jani Tiainen writes: > > [...] > > > Now it's trivial play with sub products and add spesific > > subproducts to orderproduct. > > > But, then, how to list all SubProducts that belongs to spesific > > order? > > > Specially thing stops at "Product", it doesn't know which one of > > those two subproducts it actually is. > > I had the same issue. Unfortunately, Django itself doesn't have a > built-in solution for that. I usedhttp://dpaste.com/97085/for > it. It's the same as you did but automatic. You simply call > > product.find_actual_instance() > > and you get the object of the true type (e.g. subproduct1). > > Tschö, > Torsten. > > -- > Torsten Bronger, aquisgrana, europa vetus > Jabber ID: torsten.bron...@jabber.rwth-aachen.de > orhttp://bronger-jmp.appspot.com --~--~-~--~~~---~--~~ 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: A simple use for multidb... is this possible yet?
thanks for the response Alex... you've most definitely saved me some time in digging around. I'm going to work on this today and I'll let you know how it goes. For the record, I think your work on multidb is great. This work is going to be what ultimately lets me begin to build apps that are more than just demos in our organization. On Jul 19, 3:44 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: > On Sun, Jul 19, 2009 at 3:29 PM, Jon Loyens<jonloy...@gmail.com> wrote: > > > Hi everyone (particularly those working on multidb), > > > I have a pretty simple use case that involves use of multidb support > > and I was wondering if the code base for multidb is far enough along > > to help me out on this. Basically, I have a legacy enterprise db that > > I've created working models for using inspectdb. The models work and > > are a big help in navigating and retrieving the data. > > > What I need to do now is transform some of the data and then store the > > data in a new set of models in a different database. Of course I > > could just open another connection using mysqldb and just write raw > > sql but what would be great is if I could use the django ORM to > > manipulate the data from the first database and then store it in the > > second. > > > My question is this: is there enough work done on multi-db already > > that maybe with maybe a little hack or two I could accomplish this? > > > JL > > Assuming that you're legacy DB doesn't use a custom Query class > (meaning it's not Oracle or one of the external backends), then > multi-db should easily be able to do what you want, check the docs the > multiple_database regression tests for a sense of the API. (Remember > to use the soc2009/multidb branch, not the old multi-db one). > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your > right to say it." -- Voltaire > "The people's good is the highest law." -- Cicero > "Code can always be simpler than you think, but never as simple as you > want" -- Me --~--~-~--~~~---~--~~ 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: syncdb is not doing anything
Given that you mention that you already have a lot of data in your db, I really recommend you check out South (http://south.aeracode.org/). South is an application that adds migrations to your Django application. When I develop new applications and the dataset is small, I'll usually just use a combination of fixtures and sqlreset to load up data. As applications get more mature and that gets to be a problem, I'll add in South which in my mind is far and away the most feature complete of the migration applications out there. Just to be clear though, here's the behavior of syncdb, sqlreset, etc.: syncdb - Scan models, create tables for any new models found in various models.py. Does not modify tables that already exist. reset - drop all existing applicaiton tables and recreate them as per syncdb. sql - generate but don't execute all the sql that would run as part of a syncdb command sqlreset - generate but don't execute all the sql that would run as part of the reset command If you're still concerned about the incorrect sql being generated (something I've never personally run into), could you please post your models and the code that it's generating to something like dpaste? Thanks. On Jul 6, 6:25 am, Philwrote: > Hi, > > you may want to try sqlreset keyword to get the right sql output for > your db and put it down into the db directly (copy\paste) > > something like this: > python manage.py sqlreset yourapp > > this will drop old tables and create all new ones. Though all data is > going to be lost. > syncdb doesn't change a thing if you run in after model changes, but > it does for the new models. > > Cheers, > Phil > > On Jul 6, 3:17 pm, chefsmart wrote: > > > > > Hi, > > > I have been working on an app for some time now. I have been using the > > Django svn trunk. > > > I have a lot of data in the database. Today I modified a couple of > > fields and added a couple of fields (date and char fields) to three of > > my models. No fields have been removed from the original model > > definitions. > > > When I do "python manage.py sql myapp" the output shows some > > inconsistent sql that is syntactically wrong. I thought this may > > simply be a jumbled string output problem, so I ran syncdb anyway. > > However, syncdb is not doing anything. I mean no messages, no error > > outputs, nothing. It just simply exits with a blank line output. I > > checked my database (mysql) and there were no changes made. So syncdb > > is not doing anything, even though the sqlall output shows it wants to > > do a lot of sql commands. > > > Moreover, the manage.py sql myapp command shows that syncdb wants to > > drop and reconstruct tables that I have not modified, and that are not > > related to the modified models in any way. > > > What could be going on? > > > Regards, > > CM --~--~-~--~~~---~--~~ 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: Easy display of table of data without a backing model
Another hack would be to make your data structure look 'enough' like a Django model such that the generic views would work for you. Remember that Python follows duck-typing principles so if your data structures looks enough like querysets and data models, then you could use the generic views. I doubt you'd be able to do enough to use admin but definitely the generic views. You could probably lift a lot of the Admin css too. On May 3, 4:12 am, Richard Davieswrote: > P.S. An obvious hack would be to save all my data from memory into a > Django model, then do the view based on the model. > > I'd like to avoid that if at all possible, both because it's ugly to > save data into the database just to pass it to a view and also because > I'd then get into all kinds of issues with keeping the data in the > database in sync with updates to the data in memory. --~--~-~--~~~---~--~~ 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: newbie: syncdb doesnt update schema after model change?
What you're trying to do is called "Schema migration" or "evolution" there's been a lot of talk of it in the past. I recommend the South project for evolution. Very very flexible. Check it out here: http://south.aeracode.org/ On Apr 17, 1:30 am, Rama Vadakattuwrote: > OR you can use django-evolutions which evolves the database schema in > sync with the models. > More details at :http://code.google.com/p/django-evolution/ > > On Apr 17, 10:29 am, zayatzz wrote: > > > > > If the tables of this app hold no info, then you can do python > > manage.py reset appname. This clears all tables of this app but the > > changes will hit database :) > > > Alan > > > On Apr 16, 7:11 pm, Aneesh wrote: > > > > This is by design. syncdb only checks to see if it needs to create > > > any new DB tables for any models; it does NOT alter existing model > > > tables. Seehttp://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb > > > for more info. > > > > If you don't have any valuable data in the table (ie, you're just > > > developing or playing around), the best thing to do is drop the whole > > > table from the DB entirely, and then syncdb will recreate it from > > > scratch with the new column included. You can also just issue an > > > ALTER TABLE to add the column manually with the proper name, and > > > Django will recognize it. > > > > Good luck, > > > Aneesh > > > > On Apr 16, 9:00 am, gry wrote: > > > > > [django: 1.1 beta 1 SVN-10407, python 2.5.2, ubuntu] > > > > My first django toy app. I've been working through the > > > > tutorialhttp://docs.djangoproject.com/en/dev/intro/tutorial02/. > > > > I've already done a few cycles of (change-model, ./manage.py syncdb) > > > > with success. > > > > I just added email and birthday fields to my Person model: > > > > > class Person(models.Model): > > > > name = models.CharField(max_length=200) > > > > def formalname(self): > > > > return 'Mr(Ms) ' + self.name > > > > phone = models.CharField(max_length=13) > > > > address = models.ForeignKey(Address) > > > > email = models.EmailField() > > > > birthday = models.DateField() > > > > def __unicode__(self): > > > > return self.name > > > > > I killed the server process(maybe not necessary). I did ./manage.py > > > > syncdb . > > > > Now "./manage.py sql phones" reports: > > > > CREATE TABLE "phones_person" ( > > > > "id" integer NOT NULL PRIMARY KEY, > > > > "name" varchar(200) NOT NULL, > > > > "phone" varchar(13) NOT NULL, > > > > "address_id" integer NOT NULL REFERENCES "phones_address" ("id"), > > > > "email" varchar(75) NOT NULL, > > > > "birthday" date NOT NULL > > > > ) > > > > but dbshell shows: > > > > CREATE TABLE "phones_person" ( > > > > "id" integer NOT NULL PRIMARY KEY, > > > > "name" varchar(200) NOT NULL, > > > > "phone" varchar(13) NOT NULL, > > > > "address_id" integer NOT NULL REFERENCES "phones_address" ("id") > > > > ); > > > > > I restart the server andhttp://127.0.0.1:8000/admin/phones/person/ > > > > gets me "Exception Value: > > > > no such column: phones_person.email". > > > > > Why is my change not making it into the DB? I even did "./manage.py > > > > flush" and it still fails on the email field. > > > > > -- George --~--~-~--~~~---~--~~ 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 do you retrieve a username that is not in the URL?
Also, you might want to make sure you have an authenticated user (by either decorating your view function with @login_required) or check that the user in the request is either authenticated or not the anonymous user (by including an if statement). On Apr 14, 8:36 pm, James Bennettwrote: > On Tue, Apr 14, 2009 at 5:12 PM, stkpoi wrote: > > if form.is_valid(): > > submission = Submission.objects.get_or_create( > > title=form['title'], > > link=form['link'], > > user=request.user.username > > ) > > And right there's your problem. The value to put into a ForeignKey is > the actual User object itself, not its id or username or some other > attribute. The error message you're seeing is a consequence of putting > the wrong value in there. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---