About django's ImageField type
Hi All, I found ImageField is hard to understand for me. Anyone can give me a example and some explanation on it? Thanks. ImageField Like FileField, but validates that the uploaded object is a valid image. Has two extra optional arguments, height_field and width_field, which, if set, will be auto-populated with the height and width of the image each time a model instance is saved. In addition to the special get_FOO_* methods that are available for FileField, an ImageField also has get_FOO_height() and get_FOO_width() methods. These are documented elsewhere. Requires the Python Imaging Library. When should we define the filed as ImageField? Best wishes, Nick --~--~-~--~~~---~--~~ 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: mod_python problem?
Hi Hames, I am not sure about your request,but I suggest you to update your http.conf SetHandler python-program PythonPath "['/var/www/django/'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On If you used mysite, mysite should always in your urls, the mod_python will not found the right view if you did not add mysite in the urls. Best wishes, Nick - Original Message - From: James McManus To: django-users@googlegroups.com Sent: Monday, July 23, 2007 12:35 PM Subject: mod_python problem? I am having two problems using django on an Apache server, with mod_python. The first problem I found a solution, but it may be causing other problems. In mysite/urls.py I am not able to use the ^ in: (r^'polls/', include(' mysite.polls.urls')), It causes a 404 error. I do not have this problem when I use the django server. If I remove ^ in: (r'polls/', include('mysite.polls.urls')), I do not get the error. In the mysite/polls/urls.py I use the ^ in: (r'^(?P\d+)/vote/$', 'vote'), and I do not get the 404 error. My mod_python setting in httpd are: SetHandler python-program PythonPath "['/var/www/django/'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On These setting appear to work, except for the one variation in mysite/urls.py. All functions in admin are working, and I am able to get to the point of voting in polls. However, that is where the second problem occurs. When I vote using the django server the url changes from: http://localhost:8080/mysite/polls/8/ to http://localhost:8080/polls/8/results/ and I get the expected results. If I vote without making a selection, the following url appears: http://localhost:8080/polls/8/vote/ and the page produces the expected message: You didn't select a choice. However, if I try voting using the mod_python server I get the vote url, without mysite: http://www.aratasystems.com/polls/8/vote/ and the message: The requested URL /polls/8/vote/ was not found on this server. Also when I use the django server I am able to drop mysite and use urls: http://localhost:8080/polls/ http://localhost:8080/admin/ But if drop mysite when using the mod_python server, I get the "requested URL" message. I have attempted to modify the mod_python setting in httpd, but in all cases it ends up producing errors in both the django and mod_python servers. Is there a way I can modify my httpd setting to prevent these problems? Or can I deal with this by changing code in mysite? Thanks Jim --~--~-~--~~~---~--~~ 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: About create a database table dynamicly
Hi Carl, Thank you, I have resended the mail again, thanks . best wishes, nick - Original Message - From: "Carl Karsten" <[EMAIL PROTECTED]> To: <django-users@googlegroups.com> Sent: Sunday, July 15, 2007 12:33 AM Subject: Re: About create a database table dynamicly > > > nick feng wrote: >> Hi, >> >> I had to create a table in the database according to the users' input >> imformation. >> Django seems has no topic about this, anyone has any idea on it?Thank you > > im guessing you hit reply and changed the subenct, which buried your question > in > someone else's. aka hijacking a thread. > > you may want to post again, but use the > To post to this group, send email to django-users@googlegroups.com > that is at the bottom of all messages. > > Carl K > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
About create a database table dynamicly
Hi, I had to create a table in the database according to the users' input imformation. Django seems has no topic about this, anyone has any idea on it?Thank you Best wishes, Nick --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
About create a database table dynamicly
Hi, I had to create a table in the database according to the users' input imformation. Django seems has no topic about this, anyone has any idea on it?Thank you Best wishes, Nick --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Which database is better for django, PostgreSQL or MYSQL?
Which database is better for django, PostgreSQL or MYSQL? --~--~-~--~~~---~--~~ 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: No module named _md5
It' seems that the md5 is not a middleware, but you have write it in the setting.py file's middleware setting part. - Original Message - From: "e-gor" <[EMAIL PROTECTED]> To: "Django users"Sent: Friday, July 06, 2007 2:59 AM Subject: No module named _md5 > > > I have python 2.5.1, django report errors: > > Mod_python error: "PythonHandler django.core.handlers.modpython" > > Traceback (most recent call last): > > File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py", > line 193, in Dispatch >result = object(req) > > File "/usr/local/lib/python2.5/site-packages/django/core/handlers/ > modpython.py", line 177, in handler >return ModPythonHandler()(req) > > File "/usr/local/lib/python2.5/site-packages/django/core/handlers/ > modpython.py", line 145, in __call__ >self.load_middleware() > > File "/usr/local/lib/python2.5/site-packages/django/core/handlers/ > base.py", line 31, in load_middleware >raise exceptions.ImproperlyConfigured, 'Error importing middleware > %s: "%s"' % (mw_module, e) > > ImproperlyConfigured: Error importing middleware > django.middleware.common: "No module named _md5" > > When i write import md5 from python command prompt i have no errors. > > > > > --~--~-~--~~~---~--~~ 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: An idea on DB migration
The django has already provided the way to use SQL, I don't think this is needed. - Original Message - From: "Noam" <[EMAIL PROTECTED]> To: "Django users"Sent: Thursday, July 05, 2007 2:40 AM Subject: An idea on DB migration > > > Hello, > > I have an idea on how DB migration can work in Django. It's very > simple, it will allow the programmer to do anything he wants in the > migration, and he will have to learn almost nothing in order to > migrate the DB. The drawback is that it's not very efficient, which > means that it will probably work only for small to medium databases - > but I think that most Django sites are like this. If you have a bigger > site, you will have to use SQL. > > My idea is this: create a tool which will create a script which will > migrate the DB. The user will then edit the script as he likes, and > run it to create a new DB with the migrated data. If the result is not > what he wanted, he will edit the script again and run it again. > > For example, say that I have a directory with the old site (and old > models) and a directory with the new site. The only difference between > them is that I renamed the field store.Book.name to > store.Book.book_name. I will run "django-admin.py migrate oldsitedir > newsitedir". This will create a file which will look like this: > > = > #!/usr/bin/env python > > from django.db import ... > > class old_settings: >DATABASE_ENGINE = 'mysql' >DATABASE_NAME = 'store_3' >... > > class new_settings: >DATABASE_ENGINE = 'mysql' >DATABASE_NAME = 'store_4' >... > > old_connection = make_connection_from_settings(old_settings) > new_connection = make_connection_from_settings(new_settings) > > # Old models > > class old: >class auth: >class User(models.Model): >_connection = old_connection # or whatever will be needed > >username = models.CharField(unique=True, maxlength=30) >... > >class store: >class Book(models.Model): >_connection = old_connection > >name = models.CharField() >... > > # New models > > class new: >... >class store: >class Book(models.Model): >_connection = old_connection > >book_name = models.CharField() >... > > # Migration function > > def migrate(): >drop_tables_in_new_db_and_sync_it() > ># Migrate auth.User >for o in old.auth.User.objects.all(): >n = new.auth.User() >n.id = o.id >n.username = o.username >... >n.save() > ># Migrate store.Book >for o in old.store.Book.objects.all(): >n = new.store.Book() >n.id = o.id ># TODO: ># Removed fields: name ># Added fields: book_name >n.save() >... > > if __name__ == '__main__': >migrate() > > = > > Then, to migrate the DB, I will edit the file, search for "TODO" > comments, and replace the comment in the file with "n.book_name = > o.name". I will create a new empty DB with the name "store_4". > > Then I will run "./migrate.py", and the database will be migrated. I > will run the new version of my site, and if everything works I can > delete the DB "store_3". > > Another thing: the migrate command will work also with only one given > site directory. In that case the old db definition and the new db > definition will be identical, and the user will be able to edit them > manually in the generated file. This feature will also help in > migrating between different types of databases - in that case, the > user will only change the settings on the top of migrate.py. > > To summarize: the programmer won't have to learn commands which add > new fields, delete fields, rename fields, modify fields, etc. The > programmer will just have to slightly modify a generated file, to > create the new version of the DB as he likes. > > I hope I managed to explain my idea. What do you think about it? > > Have a good day, > Noam > > > > > --~--~-~--~~~---~--~~ 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: newbie having difficulty with sqlite
I think you should create the books file by yourself, the sqlite3 may not have the ability to create the file in your file system. - Original Message - From: "walterbyrd" <[EMAIL PROTECTED]> To: "Django users"Sent: Thursday, July 05, 2007 2:25 AM Subject: newbie having difficulty with sqlite > > > My settings.py file looks like this: > > DATABASE_ENGINE = 'sqlite3'# 'postgresql_psycopg2', 'postgresql', > 'mysql', 'sqlite3' or 'ado_mssql'. > DATABASE_NAME = '/usr/bin/scripts/mysite/books' # Or path to database > file if using sqlite3. > DATABASE_USER = '' # Not used with sqlite3. > DATABASE_PASSWORD = '' # Not used with sqlite3. > DATABASE_HOST = '' # Set to empty string for localhost. > Not used with sqlite3. > DATABASE_PORT = '' # Set to empty string for default. Not > used with sqlite3. > > I do not have a database file yet. I am just setting this up. > > I ran the interactive shell with: python manage.py shell. Then > entered: > > In [1]: from django.db import connection > In [2]: cursor = connection.cursor() > > Here is where it bombed: > > ---> 58 self.connection = Database.connect(**kwargs) > > This is the error message: > > OperationalError: unable to open database file > > Am I supposed to already have a database file? I have been trying to > follow the examples given in djangobook.com, and I don't see where I > was supposed to create a file before running those commands. > DATABASE_NAME is set to where I want the file to go. > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Could you please share your django-based website source code with me?
Hi All, I plan to build a django-based website for open-sourcing these days, I have read the django-book. Since my limited knowledge of web developing(this is my first time to develop website), I find it's still hard to start now. Will anybody share your django-based website source code with me ? Thank you very much! I promise that your codes is only used for my studying django. Best wishes, Nick --~--~-~--~~~---~--~~ 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: about newforms
Hi Christian, Have you read the www.djangobook.com? I think it's better for you to read www.djangoproject.com/documentation/ It's will help you with every case of your project. Best Wishes, Nick - Original Message - From: "Christian Hoppner" <[EMAIL PROTECTED]> To:Sent: Tuesday, April 10, 2007 1:03 AM Subject: about newforms > > > Hi there. > > I have noticed that the newforms documentation really lacks a lot so far. Not > to say it's useless, but it's not enough to teach me how to use it. > > I have already decided to manually generate the two forms I'll need for my > current project. So that's not the question. > > Now, what should I do? Learn about the old forms, then "convert" to newforms, > or better wait for the documentation to get written? > > My python knowledge is not as big as to learn from the unit test. > > Thanks everyone! > -- > Chris M. Hoeppner > Web designer, developer & consultant > Faithful Standartista > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---