Re: How to access gmail
Assuming the question is: "How do I send mail using my gmail account?" ret = connection.send_messages([email]) https://github.com/CarlFK/veyepar/blob/master/dj/scripts/email_ab.py#L140 In my local_settings.py: EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER="c...@nextdayvideo.com" EMAIL_HOST_PASSWORD="mypassword" On Sun, Aug 27, 2023 at 1:23 PM 'Kasper Laudrup' via Django users wrote: > > On 26/08/2023 13.59, TASLIMA S wrote: > > > > Dear friends, > > I am developing an email signature web application. > > How to access gmail mails to my application. > > > > https://developers.google.com/gmail/api/guides > > Kind regards, > Kasper Laudrup > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/2e0feaab-2b9d-4901-9546-299a81e5ac3e%40stacktrace.dk. -- Carl K -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADmzSSg_exhigdMirFwJ1%3D%3DprXsoh%2B4L9Jn1RWbksFyNcqy%3Diw%40mail.gmail.com.
google auth and context
This works, mostly: https://github.com/CarlFK/veyepar/tree/master/dj/googauth when a person grants access, their browser is redirected back to the 2nd view. And all that stuff in the readme happens. but, If I wanted to save something to the db, even a "token received" flag, I don't have a reference to the IDs that kicked off the process. how can that view get the context? like what url (which includes client.id) kicked off the process? <https://matrix.to/#/!iYeMeXUCdNqEhdBhjX:libera.chat/$2qLUGJelAITtKfYOw6UU1RqNLb7DhCV_zlqz27yTXPA?via=libera.chat&via=matrix.org&via=tchncs.de> like it starts on https://veyepar.nextdayvideo.com/main/show_parameters/441/ 441 is the client.id - which would be handy to know when I get a token back. Carl Karsten -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e72b5312-f6cb-4e12-83c5-77cc28e039b4n%40googlegroups.com.
goog auth and context
I have this code that does google auth: https://github.com/CarlFK/veyepar/tree/master/dj/googauth when a person grants access, their browser is redirected back to the 2nd view. (good)... How can that view get the context? like what url (which includes client.id) kicked off the process? like it starts on https://veyepar.nextdayvideo.com/main/show_parameters/441/ 441 is the client.id - which would be handy to know when I get a token back. So I know what client this token is for. Carl Karsten -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/508514ad-6056-4c76-aec2-008c41c6fa88n%40googlegroups.com.
named admin url w filter
Is there a better way to do: {% url admin:main_episode_changelist %}?show__id__exact={{show.id}} I tried: {% url admin:main_episode_changelist show__id__exact=show.id %} Caught NoReverseMatch while rendering: Reverse for 'main_episode_changelist' with arguments '()' and keyword arguments '{'show__id__exact': 6}' not found. -- 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-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.
who owns djangocon.blip.tv?
http://djangocon.blip.tv/ has no posts, and no contact info. Anyone know who's it is? seems like a good place to put the djangocon videos. http://django.blip.tv/ is taken too, with some odd test vids. Maybe http://ponycon.blip.tv/ ? -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: offline population of django auth user table
On Sat, May 2, 2009 at 11:09 AM, Jeff wrote: > > I'm using Django's authentication. I would like to add several users > through a command-line script (not through code executed via the > website). Something like manage.py createsuperuser but for normal > users and not interactive. I want to be able to put code like this in > a script I can run offline like manage.py: > from django.contrib.auth.models import User User.objects.create_user('john', 'len...@thebeatles.com', 'johnpassword') > > ...but I don't know what needs to go above that code to set up the > environment to make it work. I've started looking into how manage.py > works, but I'm getting lost in Django internals. I'd rather not > fiddle with the database manually, since I'm not sure I know > everything I'd need to touch to keep it consistent. > > Any ideas? How do I set up the environment of a Django app offline, > in a simple command line script so that Users (or other parts of the > db) can be modified without running through a web server? > Here is some code from my mygrate.py program - it should be all you need, let me know (cc me, cuz I don't monitor this list) if you need more. # Create django Admin's def mkAdmin( name, pw ): print name, pw user = User.objects.create_user( name.lower(), 't...@example.com', pw ) # User.objects.create_user('john', 'len...@thebeatles.com', 'johnpassword') user.first_name=name user.is_superuser=True user.is_staff=True user.date_joined=datetime.datetime.today() user.last_login=datetime.datetime.today() profile = UserProfile.objects.create(user=user, datejoined=datetime.datetime(2008,1,1) ) user.save() profile.save() # bunch of accounts for the QA squad # mkAdmin('user1','pass1') # mkAdmin('user4','pass3') mkAdmin('Carl','foo') mkAdmin('Sheila','foo') mkAdmin('Tim','foo') # Create django Users # select MemberNumber, # Surname, `Given name`, `Familiar Name`, # `Email Address`, UserID, UserPassword, Telephone cSql=""" select * from RidgeMoorJonas.Member where UserID is not null and MemberNumber not in ( '271', '139', '139A', '287', '0558', '0185', '0319', '0599', '0754', '388' ) and `Date Joined` is not null limit 3000 """ cur.execute(cSql) # members = cur.fetchall() # for member in members: for member in cur: print member # for member in cur.fetchone(): email = member['Email Address'] or "buc...@ridgemoorcc.com" user = User.objects.create_user( member['UserID'], email, member['UserPassword<<>>'] ) user.last_login=datetime.datetime(2005,1,1,0,0,0) user.date_joined=datetime.datetime(2005,1,1,0,0,0) # flip some field names around maps = { 'first_name':'Given name', 'given_name':'Given name', 'givenname':'Given name', 'last_name':'Surname', 'familiarname':'Familiar Name', 'postalcode':'Postal Code', 'datejoined':'Date Joined' } # for map in maps: # member[map]=member[maps[map]] # now lower all the fids for f in member.keys(): # member[f.lower()]=member[f] maps[f.lower()]=f user.first_name=member['Given name'] user.last_name = member['Surname'] # if user.username=='LS0696': ## Make Larry staff so I can assign things to him :) #user.is_staff=True #print "Larry is staff!" #print user.id print member['Date Joined'] member['Date Joined'] = parse(member['Date Joined']) profile = UserProfile.objects.create(user=user, datejoined=member['Date Joined'] ) if member['Birthdate'] == datetime.datetime(1853, 5, 11, 0, 0): member['Birthdate'] = datetime.datetime(1953, 5, 11, 0, 0) if ' ' in member['Given name']: member['middlename']=member['Given name'].split(' ')[-1] for f in profile.__dict__: if f not in ['id','misc_info','user_id', 'nicname', 'middlename', 'picture' ]: # print f,maps[f], member[maps[f]] val= member[maps[f]] print f,maps[f],val if "date" not in f and val is None: val='' profile.__setattr__(f,val) # profile.append(member) # profile.phone_number=member['Telephone'] user.save() profile.save() -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
extending flatpages
I need to add some fields to flatpage model. (like header image) is there a clean way to do this? I saw it come up before, and one comment was "model subclassing is not supported." So now that it is supported... I am going to learn that it wont help me with this problem? 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 -~--~~~~--~~--~--~---
Re: blankiing an ImageField
Amit Ramon wrote: > * Carl Karsten <[EMAIL PROTECTED]> [2008-05-25 17:25 -0500]: >> In the admin UI, is there any way to blank out a foo = >> model.ImageField(...) ? >> >> Carl K > > > foo = model.ImageFields(..., editable=False) > No. (unless I am missing some unexpected use of editable) If I have set a value, (path/name of image file) and want to clear it (so empty, Null, '', whatever the default value is) 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 -~--~~~~--~~--~--~---
"intro to django" script -
I want to make a http://showmedo.com "Getting started with Django" I expect it to be about 5 min long. The goal is not show someone how to be productive, but how easy it is to get started. At most 1 min on install python, install django, make sure you can do python -c "import django" without error. Then some magic, python manage.py runserver, browse, “Welcome to Django” Then some more magic, syncdb, http://127.0.0.1:8000/admin/ "log in" Then define a model, view, html, url pattern. maybe even a public facing form. I am a bit fuzzy on what is considered 'best practices' for the 2 magic parts. I hear what the tutorial/book describes (django-admin.py startproject mysite; startapp myapp) isn't what the the pros do now, or at least what the pros would recommend. What I haven't heard is an alternative. I am tempted to show creating all the files by hand. (I can't do it all in 5 minutes, but some Julia Child moves and sped up video should make it faster than explaining what startproject and startapp do.) Any suggestions? Any writeups that cover this? 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 -~--~~~~--~~--~--~---
blankiing an ImageField
In the admin UI, is there any way to blank out a foo = model.ImageField(...) ? 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 -~--~~~~--~~--~--~---
Re: loaddata .. columns app_label, model are not unique
patch submitted: http://code.djangoproject.com/ticket/7254 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 -~--~~~~--~~--~--~---
Re: loaddata .. columns app_label, model are not unique
Russell Keith-Magee wrote: > On Fri, May 16, 2008 at 8:13 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Russell Keith-Magee wrote: > >>>> 2. should I leave in --debug? I really meant it for debugging, but I can >>>> see it >>>> being handy to debug the "list of items" and such. >>> No. That's what the verbosity option is for. >> what verbosity option? >> >> ./manage.py: error: no such option: --verbosity >> ./manage.py: error: no such option: --verbose >> >> Given that dumpdata dumps to stdout, any extra chars would 'corrupt' the >> dump, >> and the human readable 'status' chars would get lost in the dump. So I am >> not >> sure --verbose would be good here, given that --verbose generally runs the >> app. >> >> How about --dry-run? > > How about verbosity? > > Consistency is an important feature. The fact that verbosity isn't > currently available as an option to the dumpdata command doesn't > change the fact that it is available in many other locations as the > command to alter the amount of debug output. Inventing new option > names for the same feature just confuses the issue. > > As for corrupting the output - we can work around this by ensuring > that the default verbosity (usually 1, but there might be an argument > for the default to be 0 for dumpdata) can be used as-is. I can see the consistency point. I'll send the output to sdterr. speaking of consistency, any reason not to give all the make_option()'s single letter options? (like make_option('-v', '--verbosity') How does this look? Index: dumpdata.py === --- dumpdata.py (revision 7534) +++ dumpdata.py (working copy) @@ -2,13 +2,19 @@ from django.core import serializers from optparse import make_option +from sys import stderr class Command(BaseCommand): option_list = BaseCommand.option_list + ( -make_option('--format', default='json', dest='format', +make_option('--format', dest='format', default='json', help='Specifies the output serialization format for fixtures.'), -make_option('--indent', default=None, dest='indent', type='int', +make_option('--indent', dest='indent', type='int', default=None, help='Specifies the indent level to use when pretty-printing output'), +make_option('-e', '--exclude', dest='exclude',action='append', default=None, +help='App to exclude (use multiple --exclude to exclude multiple apps).'), +make_option('-v', '--verbosity', action='store', dest='verbosity', default='0', +type='choice', choices=['0', '1', '2'], +help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), ) help = 'Output the contents of the database as a fixture of the given format.' args = '[appname ...]' @@ -16,15 +22,34 @@ def handle(self, *app_labels, **options): from django.db.models import get_app, get_apps, get_models -format = options.get('format', 'json') -indent = options.get('indent', None) -show_traceback = options.get('traceback', False) +format = options.get('format') +indent = options.get('indent') +exclude = options.get('exclude') +verbosity = int(options.get('verbosity')) +show_traceback = options.get('traceback') +if verbosity >= 2: +print >>stderr, \ +"format %s\nindent %s\nexclude %s\nshow_traceback %s\n" % \ +(format, indent, exclude, show_traceback) +print >>stderr, "apps %s" % (app_labels) + if len(app_labels) == 0: app_list = get_apps() else: app_list = [get_app(app_label) for app_label in app_labels] +if exclude: +excl_apps = [get_app(app_label) for app_label in exclude] +for excl_app in excl_apps: +app_list.remove(excl_app) +if verbosity >= 2: +print >>stderr, "excluded: %s" % excl_app.__name__ + +if verbosity >= 2: +for app in app_list: +print >>stderr, "included: %s" % app.__name__ + # Check that the serialization format exists; this is a shortcut
Re: loaddata .. columns app_label, model are not unique
Russell Keith-Magee wrote: > On Fri, May 16, 2008 at 3:47 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Russell Keith-Magee wrote: >>> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote: >>>> Russell Keith-Magee wrote: >>>>> On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >>>> What are the chances of getting a dumpdata hack to exclude certain apps? >>>> >>>> I know it isn't too hard to figure out what apps I want to backup, but it >>>> sounds >>>> like the 'exclude' feature might be useful even once this issue is >>>> resolved. >>> It's a reasonable idea - one well worth suggesting as a feature >>> enhancement (I have a nagging feeling that there is something in there >>> already, but I could be getting confused). >>> >>> What are the chances such a fix will automagically materialize out of >>> the ether? Not high. What are the chances that a patch implementing >>> this feature would be added to trunk? Fairly good, conditional on the >>> quality of the patch. >> I am not submitting here, I just want to discuss it first. >> >> 1. what do you think of this syntax I invented: >> --option "list of items" >> >> I don't like it, but not sure how else to do it. > > I prefer the syntax from your other post. > >> 2. should I leave in --debug? I really meant it for debugging, but I can >> see it >> being handy to debug the "list of items" and such. > > No. That's what the verbosity option is for. what verbosity option? ./manage.py: error: no such option: --verbosity ./manage.py: error: no such option: --verbose Given that dumpdata dumps to stdout, any extra chars would 'corrupt' the dump, and the human readable 'status' chars would get lost in the dump. So I am not sure --verbose would be good here, given that --verbose generally runs the app. How about --dry-run? >> Why does the current code has 'json' listed in 2 places: >> make_option('--format', default='json' >> options.get('format', 'json') > > I can't think of an obvious reason off the top of my head. It's > possible that this is a hangover of some old code from the > pre-management refactor days, or an artefact of that refactor. I'll clean it up. Should the clean up be a separate patch? 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 -~--~~~~--~~--~--~---
Re: loaddata .. columns app_label, model are not unique
Just saving someone the trouble of telling me to spell multiple correctly. > make_option('-e', '--exclude', dest='exclude', action='append', > help='App to exclude (use mutiple --exclude to exclude mutiple apps).'), help='App to exclude (use multiple --exclude to exclude multiple apps).'), 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 -~--~~~~--~~--~--~---
Re: loaddata .. columns app_label, model are not unique
Carl Karsten wrote: > Russell Keith-Magee wrote: >> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote: >>> Russell Keith-Magee wrote: >>>> On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >>> What are the chances of getting a dumpdata hack to exclude certain apps? >>> >>> I know it isn't too hard to figure out what apps I want to backup, but it >>> sounds >>> like the 'exclude' feature might be useful even once this issue is resolved. >> It's a reasonable idea - one well worth suggesting as a feature >> enhancement (I have a nagging feeling that there is something in there >> already, but I could be getting confused). >> >> What are the chances such a fix will automagically materialize out of >> the ether? Not high. What are the chances that a patch implementing >> this feature would be added to trunk? Fairly good, conditional on the >> quality of the patch. > > I am not submitting here, I just want to discuss it first. > > 1. what do you think of this syntax I invented: > --option "list of items" > > I don't like it, but not sure how else to do it. I think I like this better: make_option('-e', '--exclude', dest='exclude', action='append', help='App to exclude (use mutiple --exclude to exclude mutiple apps).'), ./manage.py dumpdata -e core -e countries -e sessions -e sites previous way: ./manage.py dumpdata --exclude "core countries sessions sites" 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 -~--~~~~--~~--~--~---
Re: MySQL Boolean vs. PostgresQL Boolean
Szaijan wrote: > Hi, I developed my first Django app on my mapbook using PostgreSQL and > have recently moved it to a production site which uses MySQL. > PostgreSQL stores boolean values and True and False, just like Python > and JS, while MySQL uses 1 and 0. Where are you seeing this? I think you are confusing what gets stored on disk with a human readable version of the value. Good chance that both store a 0001 for true, and even that is a human readable version made up of 8 chars :) > > Is there some automated way to get the models to understand this and > present/save boolean values to and from views, or do I need to > override the save and get methods so that they translate 0 to False, 1 > to True, and vice versa? This seems to be a barrier to portability if > I have to hard code DB awareness into my models. I have flipped between sqlite, MySql and Postgresql with no such problems. 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 -~--~~~~--~~--~--~---
Re: loaddata .. columns app_label, model are not unique
Russell Keith-Magee wrote: > On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Russell Keith-Magee wrote: >>> On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> What are the chances of getting a dumpdata hack to exclude certain apps? >> >> I know it isn't too hard to figure out what apps I want to backup, but it >> sounds >> like the 'exclude' feature might be useful even once this issue is resolved. > > It's a reasonable idea - one well worth suggesting as a feature > enhancement (I have a nagging feeling that there is something in there > already, but I could be getting confused). > > What are the chances such a fix will automagically materialize out of > the ether? Not high. What are the chances that a patch implementing > this feature would be added to trunk? Fairly good, conditional on the > quality of the patch. I am not submitting here, I just want to discuss it first. 1. what do you think of this syntax I invented: --option "list of items" I don't like it, but not sure how else to do it. 2. should I leave in --debug? I really meant it for debugging, but I can see it being handy to debug the "list of items" and such. Why does the current code has 'json' listed in 2 places: make_option('--format', default='json' options.get('format', 'json') note: "default - Deprecated; use parser.set_defaults() instead. " http://docs.python.org/lib/optparse-option-attributes.html Index: dumpdata.py === --- dumpdata.py (revision 7534) +++ dumpdata.py (working copy) @@ -9,6 +9,10 @@ help='Specifies the output serialization format for fixtures.'), make_option('--indent', default=None, dest='indent', type='int', help='Specifies the indent level to use when pretty-printing output'), +make_option('--exclude', default=None, dest='exclude', +help='List of apps to exclude ("space seperated").'), +make_option('--debug', dest='debug', action='store_true', +help='Prints the list of apps excluded, to be processed, and exits.'), ) help = 'Output the contents of the database as a fixture of the given format.' args = '[appname ...]' @@ -18,6 +22,8 @@ format = options.get('format', 'json') indent = options.get('indent', None) +exclude = options.get('exclude') +debug = options.get('debug') show_traceback = options.get('traceback', False) if len(app_labels) == 0: @@ -25,6 +31,18 @@ else: app_list = [get_app(app_label) for app_label in app_labels] +if exclude: +excl_apps = [get_app(app_label) for app_label in exclude.split()] +for excl_app in excl_apps: +app_list.remove(excl_app) +if debug: +print "excluded: %s" % excl_app.__name__ + +if debug: +for app in app_list: +print "included: %s" % app.__name__ +return + # Check that the serialization format exists; this is a shortcut to # avoid collating all the objects and _then_ failing. if format not in serializers.get_public_serializer_formats(): 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 -~--~~~~--~~--~--~---
Re: loaddata .. columns app_label, model are not unique
Russell Keith-Magee wrote: > On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED]:~/dev/sites/ridgemoor$ ./manage.py loaddata rm.json >> Installing json fixture 'rm' from absolute path. >> Problem installing fixture 'rm.json': columns app_label, model are not >> unique >> >> How do I debug this? > > The error is telling you what is wrong - you are loading data into a > model that has a unique_together clause, but you are loading data that > is not unique together. > > However, I can go a little further in this specific case - you have > contenttypes in your fixture. > > Loading contenttypes by fixture is problematic because all the > contenttypes you will ever need are created automatically as part of > the syncdb. Consider the following sequence of events. > > 1. Create a project, populate INSTALLED_APPS, run syncdb. > 2. Generate a fixture > 3. Add a new application to INSTALLED APPS > 4. Flush the database, rerun syncdb. > 5. Attempt to load the fixture created in 2. > > Since you changed the applications in INSTALLED_APPS in (3), the order > of the contenttypes created in 4 can change (and in your case, _has_ > changed). As a result, the database IDs assigned to the content types > are not consistent, and when you load your fixture, you can end up > with two content type entries for the same content type. > > The simple solution - don't serialize content types. You don't need to > anyway, because they are automatically created by the syncdb process. What are the chances of getting a dumpdata hack to exclude certain apps? I know it isn't too hard to figure out what apps I want to backup, but it sounds like the 'exclude' feature might be useful even once this issue is resolved. > > The only catch on this is if you are using content types in some way, > and you need to serialize a reference to a content type. The most > likely reason for needing this is if you have a generic relation. In > this case, you are slightly stuck - you can't serialize the generic > relation without guaranteeing the IDs for the content types, but you > can't guarantee the IDs for the content types. This is a known issue, > http://code.djangoproject.com/ticket/7052. > > The only workaround in the meantime is to regenerate or manually tweak > your fixtures every time you modify INSTALLED_APPS. The order in which > contenttypes are created is consistent if you never modify > INSTALLED_APPS, so as long as you are willing to update your fixtures > whenever you modify INSTALLED_APPS, it is possible to live with this > problem. > if INSTALLED_APPS is the same on both boxes, shouldn't it work? (I have a feeling the answer is "maybe" given there might be a problem with the order apps were added or something.) Thanks for the in depth answer. 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 -~--~~~~--~~--~--~---
loaddata .. columns app_label, model are not unique
[EMAIL PROTECTED]:~/dev/sites/ridgemoor$ ./manage.py loaddata rm.json Installing json fixture 'rm' from absolute path. Problem installing fixture 'rm.json': columns app_label, model are not unique How do I debug this? 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 -~--~~~~--~~--~--~---
Re: [Django Code] #7101: ordering ForeignKey(self) =FieldError: Infinite loop caused by ordering.
Malcolm Tredinnick wrote: > > On Sun, 2008-04-27 at 23:19 -0500, Carl Karsten wrote: > [...] >> order_by('parent_id') doesn't do anything for the Admin UI, which is where I >> 'need' this. > > I made a typo. It should be 'parent__id' there (double underscore). > You're manually telling Django to order by one level, using the parent's > primary key. Bingo. And this does the trick: class Meta: ordering = ('parent__id', 'order',) Thanks, 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 -~--~~~~--~~--~--~---
Re: [Django Code] #7101: ordering ForeignKey(self) =FieldError: Infinite loop caused by ordering.
Django Code wrote: > #7101: ordering ForeignKey(self) =FieldError: Infinite loop caused by > ordering. > -+-- > Reporter: Carl Karsten <[EMAIL PROTECTED]> |Owner: > nobody > Status: closed |Component: > Core framework > Version: SVN| Resolution: > invalid >Keywords: |Stage: > Unreviewed > Has_patch: 0 | Needs_docs: > 0 > Needs_tests: 0 | Needs_better_patch: > 0 > -+-- > Changes (by mtredinnick): > > * status: new => closed > * needs_better_patch: => 0 > * resolution: => invalid > * needs_tests: => 0 > * needs_docs: => 0 > > Comment: > > That code was already broken, but you just hadn't noticed. Django is now > correctly reporting the error. If you order by the parent, then the > parents should be order by their parents and so on. Since that's > impossible to encode in SQL, previous versions of Django were returning > only a single level of ordering, which was very inconsistent. > > Either remove the infinite loop or use `order_by('parent_id')` if you want > a workaround to simulate the previous ambiguous behaviour. > order_by('parent_id') doesn't do anything for the Admin UI, which is where I 'need' this. I can probably live without it, but the previous behavior grouped siblings (child with same parent) together, and put the 'root nodes' (no parent) at the top. This was handy. I can now kinda get this behavior by using the list_filter = ('parent',) but so far I am finding that awkward. I think the nature of a site's menu is such that the previous was useful, but I can see that it wouldn't make any sense for a larger dataset. So, anyone have any suggestions on how to create something similar? 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 -~--~~~~--~~--~--~---
"duplicate key" loading dumpdata
same code on both boxes: [EMAIL PROTECTED]:~/ridgemoor$ ../django/bin/django-admin.py dumpdata >ridgemoor.json [EMAIL PROTECTED]:~/ridgemoor$ django-admin.py loaddata ridgemoor.json Installing json fixture 'ridgemoor' from absolute path. Problem installing fixture 'ridgemoor.json': ERROR: duplicate key violates unique constraint "django_content_type_app_label_key" UPDATE "django_content_type" SET "name"='Categories',"app_label"='eventcal',"model"='eventtype' WHERE "id"=11 um, how did this happen, and how do I fix it? 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 -~--~~~~--~~--~--~---
Re: allow user to update his record
Carl Karsten wrote: > Carl Karsten wrote: >> Is there a built in way for users to update their own user record? >> >> I currently have a page that displays user data to any other user. I was >> hoping >> to re-use that for allowing a user to edit his own. >> >> If it matters, I am useing a user_profile as described: >> http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ > > (12:35:22 AM) ubernostrum: CarlFK: http://code.google.com/p/django-profiles/ > (12:35:47 AM) ubernostrum: CarlFK: I wrote it so you won't have to :) How do I reference form and profile in my template? return render_to_response(template_name, { 'form': form, 'profile': profile_obj, },... http://code.google.com/p/django-profiles/source/browse/trunk/profiles/views.py#88 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 -~--~~~~--~~--~--~---
Re: allow user to update his record
Carl Karsten wrote: > Is there a built in way for users to update their own user record? > > I currently have a page that displays user data to any other user. I was > hoping > to re-use that for allowing a user to edit his own. > > If it matters, I am useing a user_profile as described: > http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ (12:35:22 AM) ubernostrum: CarlFK: http://code.google.com/p/django-profiles/ (12:35:47 AM) ubernostrum: CarlFK: I wrote it so you won't have to :) thanks uber. 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 -~--~~~~--~~--~--~---
allow user to update his record
Is there a built in way for users to update their own user record? I currently have a page that displays user data to any other user. I was hoping to re-use that for allowing a user to edit his own. If it matters, I am useing a user_profile as described: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ 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 -~--~~~~--~~--~--~---
Re: form for display, not edit
[EMAIL PROTECTED] wrote: > Using SVN you could SVN use modelforms, on .96 use the form_for > helpers. but modelforms still puts everything in tags, right? Carl K > > On Jan 31, 6:34 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: >> newforms is great for creating forms. I need something similar to generate a >> display form from a model. >> >> I looked at subclassing form, but what I would need to override is in the >> widgets. which is probably why my hope isn't a good one. but for what I >> need, >> I only am using char fields, so I don't have to worry about widgets. >> >> So, is there some way to render a form as just text? >> >> 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 -~--~~~~--~~--~--~---
form for display, not edit
newforms is great for creating forms. I need something similar to generate a display form from a model. I looked at subclassing form, but what I would need to override is in the widgets. which is probably why my hope isn't a good one. but for what I need, I only am using char fields, so I don't have to worry about widgets. So, is there some way to render a form as just text? 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 -~--~~~~--~~--~--~---
keep children from running away
OK, I think my data is going away because of my choice of blank and core. Ideally, I don't care if the record stays around even if it is 100% blank. either way, this is the only case I want it deleted. If there is any data in it, I do not want to loose it. but the way I have it currently the norm is to loose data. I do need to allow blanks in all the fields. So I figured if I set core=True, blank=True for all of them, it would do what I want. Apparently those 2 settings do not get along. Seems it causes SET myField="" to be ignored. here is my current model: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, edit_inline=models.STACKED, num_in_admin=1,min_num_in_admin=1, max_num_in_admin=1, num_extra_on_change=0 ) title = models.CharField("Title", max_length=80, core=True, blank=True) surname = models.CharField("Surname", max_length=65, core=True, blank=True ) 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 -~--~~~~--~~--~--~---
Re: why did admin delete my data?
James Bennett wrote: > On Jan 30, 2008 2:22 PM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> title = models.CharField("Title", core=True, max_length=80, blank=True, >> null=True) >> surname = models.CharField("Surname", max_length=65, core=True, >> blank=True, >> null=True) > > There's your culprit. > > Whenever you try to save a UserProfile that has NULL values in both of > these fields, the admin will not see that as "insert a NULL", it will > see it as "all the core fields are blank, delete the object." > Nope. There is data being displayed in those fields when I edit, and I type data into them when I add a new one. I just typed "abc" into title, hit save, hit history: "No fields changed." I am running devserver - where I can "print foo" to see when it has decided it needs to delete? 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 -~--~~~~--~~--~--~---
why did admin delete my data?
I did this: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ wrote a data migration.py to convert data. I browse to the django admin ui, and I can see the data. if I edit it, or not edit it, then hit Save, it deletes the User Profile record. I hit history, and is confirms: Changed last login and date joined. Deleted user profile "UserProfile object". If I add a new user, the user record gets saved, the Profile does not. (so I don't think we need to dig into migrate.py, but I will post it if someone thinks it will help. How can I find out why it is doing that? Here is my model and migrate.py class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, edit_inline=models.STACKED, num_in_admin=1,min_num_in_admin=1, max_num_in_admin=1, num_extra_on_change=0 ) title = models.CharField("Title", core=True, max_length=80, blank=True, null=True) surname = models.CharField("Surname", max_length=65, core=True, blank=True, null=True) 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 -~--~~~~--~~--~--~---
Re: Accessor clashes related field
Karen Tracey wrote: > On Jan 22, 2008 3:00 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: > >> # core/models.py >> from django.db import models >> from django.contrib.auth.models import User >> import ridgemoor.msg.models >> from time import strftime >> >> class Message(models.Model): >> to = models.ForeignKey(User, related_name = "messages_received") >> sender = models.ForeignKey(User, related_name = "messages_sent") >> subject = models.CharField(max_length=50, blank=False) >> sent = models.DateTimeField(auto_now_add=True) >> recieved = models.DateTimeField(null=True) >> body = models.TextField() >> status = models.CharField(max_length=1, blank=True, null=True) >> def __str__(self): >> return self.subject >> class Admin: >> list_display = ('sent', 'to', 'sender', 'subject') >> >> >> [EMAIL PROTECTED]:~/ridgemoor$ PYTHONPATH=$HOME ./manage.py syncdb >> Error: One or more models did not validate: >> core.message: Accessor for field 'to' clashes with related field >> 'User.messages_received'. Add a related_name argument to the definition >> for 'to'. >> >> Something broke my app. it is most likely the changes I have been making >> to get >> things working under apache, but this may be a change to trunk. >> >> It is telling me to add something that is already there. > > > The error is telling you that by the time the "to" field of Message is > processed, User already has a "messages_received" relation. Yes, the > message is a bit misleading, since you already have a related_name field, > but what it really means is you need to specify a related_name that doesn't > already exist for User. What is in ridgemoor.msg.models? I'd guess there's > another model with a ForeignKey to User specifying a related_name of > "messages_received". Do you really need two models with this relation? If > so you'll need to specify different related_names for the two. > Ah! bingo. fixed. in answer to your question: # msg/model.py class Message(models.Model): to = models.ForeignKey(User, related_name = "messages_received") sender = models.ForeignKey(User, related_name = "messages_sent") and for the last 6 months I had been using: class Message(msg.models.Model): status = models.CharField(max_length=1, blank=True, null=True) and in at least one: # class Meta: #db_table = 'message' I did this before I learned you shouldn't do it. It worked, might still work, but when I started bumping into problems I figured I better flatten it out. So I cut/pasted the attributes, changed the parent class to models.Model, and figured that would be all I needed. Didn't occur to me that relations create keys in other tables - now I see the copies are colliding. Thanks for helping me. 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 -~--~~~~--~~--~--~---
Re: differences between runserver and apache
Graham Dumpleton wrote: > On Jan 22, 6:18 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Carl Karsten wrote: >>> symlinks. I use them. I bet the default is for Apache not to follow them. >>> that >>> could be my problem. or at least one of them. >>> That is enough to start a wiki page. >>> I am going to divide it into rumors and confirmed rumors. Anyone have some >>> rumors for me to post? >> If so, please dump them here. >> >> http://code.djangoproject.com/wiki/devserver_and_apache_differences > > The differences have been dealt with before. See: > > > http://groups.google.com/group/django-users/browse_frm/thread/24deb095a2b2e450/f8e703bbb96e9e88?lnk=gst&q=Graham+setup_environ+PythonPath#f8e703bbb96e9e88 > > Your page is just making things more confusing. The dev server has > nothing to do with PythonPath, you probably mean sys.path, but it is whoops. right. I was thinking 'path' but wanted to make it clear it wasn't the OS $PATH path. > more complicated that you know as explained in referenced post. I'll read the links later today. have to go drive around in the snow. wish me luck :) Carl K > > Also, whether Apache follows symlinks has got nothing to do with it. > That aspect of Apache only comes into play when serving static files > or you have script files in the directories directly served by Apache, > neither of which apply to Django unless you so happen to have also > configured Apache to serve up the Django media files which your > configuration does not show you are doing. > > If you want a list of the things that can come up when using Apache, > you are better off reading: > > http://code.google.com/p/modwsgi/wiki/ApplicationIssues > > This is for mod_wsgi, but lots of the issues such as file access > permissions etc etc, also apply to mod_python. > > You may also want to read: > > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > which explicitly mentions the need to add both the site and site > parent directory to sys.path (through whatever means), if you > reference stuff not through the site name. > > Graham > > > > > --~--~-~--~~~---~--~~ 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: differences between runserver and apache
I never got it working back then. I was thinking of bringing up a test Apache box right from the start, but it seemed more important to get a prototype site functioning. Now I am ready to actually use Apache, so here we are. Thanks for your efforts - and like my page says: rumors. I will note that symlinks do not effect finding python files. Thanks. Carl K Graham Dumpleton wrote: > BTW, Carl. > > I note that you actually directly responded to that old thread I > referenced explaining the subtle differences, so you would have been > aware of how to set things up back then, so not sure why you are > having trouble now. ;-) > > Graham > > On Jan 22, 6:51 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: >> On Jan 22, 6:18 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: >> >>> Carl Karsten wrote: >>>> symlinks. I use them. I bet the default is for Apache not to follow them. >>>> that >>>> could be my problem. or at least one of them. >>>> That is enough to start a wiki page. >>>> I am going to divide it into rumors and confirmed rumors. Anyone have some >>>> rumors for me to post? >>> If so, please dump them here. >>> http://code.djangoproject.com/wiki/devserver_and_apache_differences >> The differences have been dealt with before. See: >> >> http://groups.google.com/group/django-users/browse_frm/thread/24deb09... >> >> Your page is just making things more confusing. The dev server has >> nothing to do with PythonPath, you probably mean sys.path, but it is >> more complicated that you know as explained in referenced post. >> >> Also, whether Apache follows symlinks has got nothing to do with it. >> That aspect of Apache only comes into play when serving static files >> or you have script files in the directories directly served by Apache, >> neither of which apply to Django unless you so happen to have also >> configured Apache to serve up the Django media files which your >> configuration does not show you are doing. >> >> If you want a list of the things that can come up when using Apache, >> you are better off reading: >> >> http://code.google.com/p/modwsgi/wiki/ApplicationIssues >> >> This is for mod_wsgi, but lots of the issues such as file access >> permissions etc etc, also apply to mod_python. >> >> You may also want to read: >> >> http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango >> >> which explicitly mentions the need to add both the site and site >> parent directory to sys.path (through whatever means), if you >> reference stuff not through the site name. >> >> Graham > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Accessor clashes related field
# core/models.py from django.db import models from django.contrib.auth.models import User import ridgemoor.msg.models from time import strftime class Message(models.Model): to = models.ForeignKey(User, related_name = "messages_received") sender = models.ForeignKey(User, related_name = "messages_sent") subject = models.CharField(max_length=50, blank=False) sent = models.DateTimeField(auto_now_add=True) recieved = models.DateTimeField(null=True) body = models.TextField() status = models.CharField(max_length=1, blank=True, null=True) def __str__(self): return self.subject class Admin: list_display = ('sent', 'to', 'sender', 'subject') [EMAIL PROTECTED]:~/ridgemoor$ PYTHONPATH=$HOME ./manage.py syncdb Error: One or more models did not validate: core.message: Accessor for field 'to' clashes with related field 'User.messages_received'. Add a related_name argument to the definition for 'to'. Something broke my app. it is most likely the changes I have been making to get things working under apache, but this may be a change to trunk. It is telling me to add something that is already there. 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 -~--~~~~--~~--~--~---
Re: differences between runserver and apache
Carl Karsten wrote: > symlinks. I use them. I bet the default is for Apache not to follow them. > that > could be my problem. or at least one of them. > > That is enough to start a wiki page. > > I am going to divide it into rumors and confirmed rumors. Anyone have some > rumors for me to post? If so, please dump them here. http://code.djangoproject.com/wiki/devserver_and_apache_differences 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 -~--~~~~--~~--~--~---
Re: differences between runserver and apache
whoops. svn co http://code.djangoproject.com/svn/django/trunk/django PythonPath "['/home/testrmcom'] + sys.path" That makes things simpler. But, I still had to change from core.models import Message to from ridgemoor.core.models import Message Well, that change seemed to make things better, but I am still getting errors when I hit the /admin UI. Current one: Could not import pre.views. Error was: No module named pre.views Environment: Request Method: GET Request URL: http://dhcp20/admin/ Django Version: 0.97-pre-SVN-7028 Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.databrowse', 'django.contrib.webdesign', 'ridgemoor.core', 'ridgemoor.eventcal', 'ridgemoor.pre'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware') Template error: In template /home/testrmcom/django/contrib/admin/templates/admin/base.html, error at line 28 Caught an exception while rendering: Could not import pre.views. Error was: No module named pre.views 18 : {% if not is_popup %} 19 : 20 : 21 : 22 : {% block branding %}{% endblock %} 23 : 24 : {% if user.is_authenticated and user.is_staff %} 25 : 26 : {% trans 'Welcome,' %} {% if user.first_name %}{{ user.first_name|escape }}{% else %}{{ user.username }}{% endif %}. 27 : {% block userlinks %} 28 : {% trans 'Documentation' %} 29 : / {% trans 'Change password' %} 30 : / {% trans 'Log out' %} 31 : {% endblock %} 32 : 33 : {% endif %} 34 : {% block nav-global %}{% endblock %} 35 : 36 : 37 : {% block breadcrumbs %}{% trans 'Home' %}{% if title %} › {{ title|escape }}{% endif %}{% endblock %} 38 : {% endif %} Traceback: File "/home/testrmcom/django/template/debug.py" in render_node 71. result = node.render(context) File "/home/testrmcom/django/template/defaulttags.py" in render 363. return reverse(self.view_name, args=args, kwargs=kwargs) File "/home/testrmcom/django/core/urlresolvers.py" in reverse 297. return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs)) File "/home/testrmcom/django/core/urlresolvers.py" in reverse 282. if lookup_view in self.reverse_dict: File "/home/testrmcom/django/core/urlresolvers.py" in _get_reverse_dict 218. for key, value in pattern.reverse_dict.iteritems(): File "/home/testrmcom/django/core/urlresolvers.py" in _get_reverse_dict 221. self._reverse_dict[pattern.callback] = (pattern,) File "/home/testrmcom/django/core/urlresolvers.py" in _get_callback 181. raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e)) Exception Type: ViewDoesNotExist at /admin/ Exception Value: Could not import pre.views. Error was: No module named pre.views Carl K Graham Dumpleton wrote: > You are not following the instructions. I would agree the instructions > aren't as clear as they could be, but it does describe what is needed. > Specifically the documentation says: > > """Remember: the parent directories of anything you import directly > must be on the Python path.""" > > You have not done this. > > You only have: > > PythonPath "['/home/testrmcom/django-svn/django', '/home/testrmcom/ > ridgemoor'] + sys.path" > > Because you are declaring DJANGO_SETTINGS_MODULE as: > > SetEnv DJANGO_SETTINGS_MODULE ridgemoor.settings > > then the parent directory of 'ridgemoor' must be added to PythonPath. > > PythonPath "['/home/testrmcom/django-svn/django', '/home/testrmcom', > '/home/testrmcom/ridgemoor'] + sys.path" > > Ie., to setup same path as inbuilt server, you need both the directory > the settings.py file is in and the parent of that directory. > > Graham > > On Jan 22, 1:43 am, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Graham Dumpleton wrote: >>> Post your Apache configuration snippet where you configuremod_python >>> for Django. >> &
Re: differences between runserver and apache
symlinks. I use them. I bet the default is for Apache not to follow them. that could be my problem. or at least one of them. That is enough to start a wiki page. I am going to divide it into rumors and confirmed rumors. Anyone have some rumors for me to post? Carl K jonasr wrote: > I'm having a similar issue. Last week after I moved from .95 to svn > and started having these problems. However, if I refresh the > 192.168.0.150/admin 4-5 times, the fifth refresh renders admin as if > nothing is wrong. > The records I add or update are added and saved, but after I restart > apache I'll get this error in the admin: > Tried update in module tswmls.notes.views. Error was: 'module' object > has no attribute 'update' > tswmls is my project name. > > I expect "update" must be an module in admin, because I have no class > named update in any of my projects. Another apache problem I ran into > when moving to svn is I had to locate the django svn directory in site- > packages. Just sym-linking from site-packages to my svn directory did > not work with mod_python and apache as before. Apache or mod_python > would not follow the sym-link, I'm not sure which causing this. No > method of PythonPath tweeking worked, django simply did not run until > I moved the files into site-packages. At the moment, django runs, but > every so often I get the admin errors you have. > > My Apache virtual server lines: > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE tswmls.settings > PythonPath "['/home/webs/djtsw'] + sys.path" > PythonDebug On > > > allow from all > Options +Indexes > > > SetHandler none > > > SetHandler none > > DocumentRoot /home/webs/djtsw/public_html > > > settings.py located at /home/web/djtsw/tswmls: > # Absolute path to the directory that holds media. > # Example: "/home/media/media.lawrence.com/" > MEDIA_ROOT = '/home/webs/djtsw/public_html/media' > > # URL that handles the media served from MEDIA_ROOT. > # Example: "http://media.lawrence.com"; > #MEDIA_URL = 'http://media.localhost' > MEDIA_URL = 'http://192.168.0.150/media' > > # URL prefix for admin media -- CSS, JavaScript and images. Make sure > to use a > # trailing slash. > # Examples: "http://foo.com/media/";, "/media/". > ADMIN_MEDIA_PREFIX = '/media/' > > # Make this unique, and don't share it with anybody. > SECRET_KEY = '40n7dnlrx#ty0no12c1*j$([EMAIL PROTECTED])&^u&eofcout_643wk4' > > # List of callables that know how to import templates from various > sources. > TEMPLATE_LOADERS = ( > 'django.template.loaders.filesystem.load_template_source', > 'django.template.loaders.app_directories.load_template_source', > # 'django.template.loaders.eggs.load_template_source', > ) > > MIDDLEWARE_CLASSES = ( > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.middleware.doc.XViewMiddleware', > ) > > ROOT_URLCONF = 'tswmls.urls' > > TEMPLATE_DIRS = ( > "/home/webs/djtsw/django_templates" > # Put strings here, like "/home/html/django_templates" or "C:/www/ > django/templates". > # Always use forward slashes, even on Windows. > # Don't forget to use absolute paths, not relative paths. > ) > > INSTALLED_APPS = ( > 'django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'django.contrib.admin', > 'tswmls.polls', > 'tswmls.notes', > 'tswmls.tsm', > 'tswmls.jobs', > 'tswmls.property', > 'tswmls.contacts', > 'tswmls.rental', > ) > > > On Jan 21, 8:26 am, Carl Karsten <[EMAIL PROTECTED]> wrote: >> James Bennett wrote: >>> On Jan 21, 2008 8:43 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >>>> Exception Type: ViewDoesNotExist at /admin/ >>>> Exception Value: Tried new_message in module ridgemoor.core.views. Error >>>> was: >>>> 'module' object has no attribute 'new_message' >>> Most likely is that something that's different between your Python >>> path under runserver and under Apache is causing something to fail >>> with an ImportError, which in turn causes reverse URL resolution to >>> fail, which in turn causes the "url" tag (which is used by the admin) >>> to fail. >> I heard runserver adds things to the path. which would explain why there is >> a >> difference. Is this correct? >> >> I am thinking maybe I am missing a 3rd party module? which wouldn't be on my >> path - is that what you mean? >> >> 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 -~--~~~~--~~--~--~---
Re: differences between runserver and apache
James Bennett wrote: > On Jan 21, 2008 8:43 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Exception Type: ViewDoesNotExist at /admin/ >> Exception Value: Tried new_message in module ridgemoor.core.views. Error was: >> 'module' object has no attribute 'new_message' > > Most likely is that something that's different between your Python > path under runserver and under Apache is causing something to fail > with an ImportError, which in turn causes reverse URL resolution to > fail, which in turn causes the "url" tag (which is used by the admin) > to fail. > I heard runserver adds things to the path. which would explain why there is a difference. Is this correct? I am thinking maybe I am missing a 3rd party module? which wouldn't be on my path - is that what you mean? 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 -~--~~~~--~~--~--~---
Re: differences between runserver and apache
Graham Dumpleton wrote: > Post your Apache configuration snippet where you configure mod_python > for Django. ServerAdmin [EMAIL PROTECTED] ServerName test ServerAlias test.ridgemoor.personnelware.com DocumentRoot /home/juser/public_html/ SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE ridgemoor.settings PythonDebug On PythonPath "['/home/testrmcom/django-svn/django', '/home/testrmcom/ridgemoor'] + sys.path" > > Post your full urls.py file. > [EMAIL PROTECTED]:~/ridgemoor$ cat urls.py # urls.py import os from django.conf.urls.defaults import * from django.conf import settings urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^logout/$', 'django.contrib.auth.views.logout', {'template_name':'logout.html'} ), (r'^eventcal/', include('eventcal.urls')), (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}), (r'^msg/', include('msg.urls')), (r'^core/', include('core.urls')), (r'^pre/', include('pre.urls')), (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.BASE_DIR+'/core/static/', 'show_indexes': True}), (r'', include('core.urls')), ) > Indicate the path to the directory containing the settings.py file so > we can see if it matches with what it is meant to be. [EMAIL PROTECTED]:~/ridgemoor$ pwd /home/juser/ridgemoor and here is the current error I am getting: Environment: Request Method: GET Request URL: http://test.ridgemoor.personnelware.com/admin/ Django Version: 0.97-pre-SVN-7027 Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.databrowse', 'django.contrib.webdesign', 'ridgemoor.core', 'ridgemoor.eventcal', 'ridgemoor.pre'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware') Template error: In template /home/testrmcom/django/contrib/admin/templates/admin/base.html, error at line 28 Caught an exception while rendering: Tried new_message in module ridgemoor.core.views. Error was: 'module' object has no attribute 'new_message' 18 : {% if not is_popup %} 19 : 20 : 21 : 22 : {% block branding %}{% endblock %} 23 : 24 : {% if user.is_authenticated and user.is_staff %} 25 : 26 : {% trans 'Welcome,' %} {% if user.first_name %}{{ user.first_name|escape }}{% else %}{{ user.username }}{% endif %}. 27 : {% block userlinks %} 28 : {% trans 'Documentation' %} 29 : / {% trans 'Change password' %} 30 : / {% trans 'Log out' %} 31 : {% endblock %} 32 : 33 : {% endif %} 34 : {% block nav-global %}{% endblock %} 35 : 36 : 37 : {% block breadcrumbs %}{% trans 'Home' %}{% if title %} › {{ title|escape }}{% endif %}{% endblock %} 38 : {% endif %} Traceback: File "/home/testrmcom/django/template/debug.py" in render_node 71. result = node.render(context) File "/home/testrmcom/django/template/defaulttags.py" in render 363. return reverse(self.view_name, args=args, kwargs=kwargs) File "/home/testrmcom/django/core/urlresolvers.py" in reverse 297. return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs)) File "/home/testrmcom/django/core/urlresolvers.py" in reverse 282. if lookup_view in self.reverse_dict: File "/home/testrmcom/django/core/urlresolvers.py" in _get_reverse_dict 218. for key, value in pattern.reverse_dict.iteritems(): File "/home/testrmcom/django/core/urlresolvers.py" in _get_reverse_dict 221. self._reverse_dict[pattern.callback] = (pattern,) File "/home/testrmcom/django/core/urlresolvers.py" in _get_callback 184. raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) Excepti
differences between runserver and apache
I developed a site using ./mmanage.py runserver for testing. I try to run it under apache and it errors. I hear runserver adds things to sys.path (installed apps) and when you run from apache that doesn't happen. sure enough, I can fix it by adding things to PythonPath. Now I am having 2 problems with (r'^admin/', include('django.contrib.admin.urls')), 1. if I browse to mysite.com/admin it misses that and gets caught by (r'', include('ridgemoor.core.urls')), 2, browse to mysite.com/admin/ get error: Tried new_message in module ridgemoor.core.views. Error was: 'module' object has no attribute 'new_message' I have a feeling this is more pathing problems, but now it doesn't work from runserver either, which makes me think I broke something trying to fix the path isues. So before I go 'fixing' more things, some sort of checklist describing what changes I need to make would be nice. Anything like this exist? Carl K ps http://us.pycon.org/2008/registration/ open for business. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
postgresql create db script
I am trying to write a shell script that do whatever needs to be done between sudo apt-get install postgresql python-psycopg and manage.py syncdb for MySql, I use this to generate somehting I can pipe into the CLI: print """ DROP DATABASE IF EXISTS %(db)s; CREATE DATABASE %(db)s; GRANT ALL ON %(db)s.* TO %(user)s IDENTIFIED BY '%(pw)s' with grant option; """ % { 'db':settings.DATABASE_NAME, 'user':settings.DATABASE_USER, 'pw':settings.DATABASE_PASSWORD } pipe that into the MySql CLI. I can't figure out how to do it with psql without it prompting me for input. I don't need it that fancy, just a script with everything hard coded would be fine. 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 -~--~~~~--~~--~--~---
static on separate what?
I this text, does "separate Web server" contingent on a 2nd box? If it is only one box, the same Apache instance would be preferred, right? http://www.djangoproject.com/documentation/modpython/ === quote === Django doesn’t serve media files itself; it leaves that job to whichever Web server you choose. We recommend using a separate Web server — i.e., one that’s not also running Django — for serving media. Here are some good choices: * lighttpd * TUX * A stripped-down version of Apache If, however, you have no option but to serve media files on the same Apache VirtualHost as Django, === end quote === 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 -~--~~~~--~~--~--~---
Re: design Q: where to put peoples names
Marty Alchin wrote: > My first question would be: Are you absolutely certain that none of > those 1000 other people will ever need a login? anything is possible. I would think at some point it isn't a good idea to use the User table. What if it was 1,000,000 names, like if I was publishing a phone book? > > Basically, if any of those users would ever need to be promoted to > login status, the User model is your best bet. As Samuel mentioned, > just set "is_active" to False and probably set the password field to > "!" since they wouldn't be expected to supply a password. As for > username, you can probably just make a slug out of their real name and > use that. > Can the username be Null? 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 -~--~~~~--~~--~--~---
design Q: where to put peoples names
The user table has first/last name. great. I need to manage about 1500 people, and only 500 will have any need for a site login. So where should I store the 1000 names that don't need to be a user record? I can think of: Everyone gets a User record. (given this is the easiest, what problems could it cause?) 2nd table for the extras. all code that needs to work with the super set will have to work with both tables. (yuck) 2nd table for all people. don't use the name fields in the User table. figure out how to use it to edit a User's Real Name (not the username) in the Admin UI. (This seems best. if you agree, how would I fix the Admin UI?) Thanks, Carl --~--~-~--~~~---~--~~ 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: query set from ModelMultipleChoice
Carl Karsten wrote: > This works, but there has to be a better way: > > class blastSettings(forms.Form): >users = forms.ModelMultipleChoiceField(queryset=User.objects.all() > > u=x.cleaned_data['users'] > users = User.objects.filter(id__in=[x.id for x in u]).values() > > body_template=Template(message.body) > for user in users: >c=Context(detail) >body = body_template.render(c) well, this is 'better': users = [x.__dict__ for x in u] and I goofed this line: >c=Context(detail) should be c=Context(users) 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 -~--~~~~--~~--~--~---
query set from ModelMultipleChoice
This works, but there has to be a better way: class blastSettings(forms.Form): users = forms.ModelMultipleChoiceField(queryset=User.objects.all() u=x.cleaned_data['users'] users = User.objects.filter(id__in=[x.id for x in u]).values() body_template=Template(message.body) for user in users: c=Context(detail) body = body_template.render(c) Carl Karsten --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
streaming status
A view has a loop - each iteration may take 3 seconds, and it will loop 20+ times, so 1 min of processing. Is there some way to dump stuff to the browser page each loop? Right now I am printing to the console, which is fine, but not cool. It's more for testing, wich will happen 100's of times, then the thing will get used in production once a year. 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 -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
birkin wrote: > This issue of how to best organize private and local django settings > came up at a recent hackfest I attended. Some googling revealed > postings by Adrian and others that essentially noted that it's > reasonable to assume that different programmers will choose to handle > this differently, and, as Malcolm noted above, "...it's a Python file, > so feel free to use the full power of the language as you wish." > > That last idea, though often noted in the documentation, is easy for > newbies like myself to forget. My thanks to the developers and others > on this list for repeating it. For me a lightbulb went on: "Oh, so I > can just import a settings_local.py file? Yes!" My issue isn't about limitations, it is about the defaults that are generated, which should conform to some level of "best practices." 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 -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
Malcolm Tredinnick wrote: > On Thu, 2007-11-01 at 23:02 -0500, Carl Karsten wrote: > [...] >> Support for the local_settings file is there, I just think it should be >> changed >> from an "If it exists" to assuming it exists, and seed it with the values >> that >> have been singled out as "secret." > > This is one of those cases where searching the archives will reveal that > we've already had this conversation a few times previously. Each time > the decision has been that the current very simple, single file setup > isn't going to change because it doesn't need a change. Except it isn't a simple, single file setup - it has #comments and references to other files. > That is your > settings file. Don't distribute it. There's one file you shouldn't > distribute. > It has things that need to be both version controlled in any environment, and distributed for Open Source code. > If you want something more complicated for your own setups, you are free > to do so. That's the other thing we've repeated over and over: it's a > Python file, so feel free to use the full power of the language as you > wish. all of django is python, so if we follow this logic, no more work needs to be done. > > Because of those two results -- it's hardly a snap decision and you have > full flexibility for doing whatever you want -- this really isn't a > decision we need to revisit. Let's move on. Then submit a bug report to have the "and don't share it with anybody." and "attempt to load a file called local_settings.py" removed. 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 -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
James Bennett wrote: > On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote: >> The generated settings.py contains things that are perfectly normal "source >> code" like things that should be treated as such. How does one only commit >> part >> of a file to svn? > > Why do you need to commit your project's settings file to a > publicly-viewable repository? Same reason I need to put urls.py and all the other files that are part of what makes things work. >> I think this kinda proves that the original design realized that there were 2 >> types of settings, but didn't bother to separate them. > > Yes, there are two types of settings: private settings and public > settings. And application-specific settings. Three! Three types of > settings: private settings, public settings, and application-specific > settings... and locale-specific settings. Four types of settings! > You are correct, but those cases are not addressed in the generated settings.py. like has been said, it is .py, so the developer can do what they want. I am just trying to make the starting point 'better' than it currently is, and it currently does address SECRET_KEY and local_settings. >> My point is to separate them into 2 groups. This separation would solve more >> than just the "keep secrets secret" problem, but also make it easier to >> manage >> the settings that are an integral part of the app. > > Er... no, it'd make settings more complicated. Actually, it would make it simpler. currently there is a comment and a try/except block of code. making the 2nd file standard would remove the need for both. > Right now you configure > Django by putting name/value pairs into a single location: the > settings module. Maybe you do, but I use the local_settings file too. > Your settings module is yours and yours alone, and > sharing it with someone you don't trust is a bad idea. Putting project > settings files into publicly-viewable places is, quite frankly, not > something Django ought to be encouraging. If that was true, then there doesn't need to be # ...and don't share it with anybody. and # this will attempt to load a file called local_settings.py ... They were put in deliberately, so I am pretty sure my thoughts are more inline with the original design than your "whole thing is private" thoughts. > >> (db type, name, user, password) are all derived from an external source that >> is >> going to be different for each installation So it doesn't make sense for >> them >> to be rolled into the set of files that is what gets installed. (where >> "installation" is a copy of the files on a machine for either development, >> testing or production. Even if multiple developers are working on a single >> production site, each developer will have their own installation.) > > If you don't trust your developers to keep a lid on things that ought > to be private, you need to get new developers. > You are missing my point there - it isn't a trust thing, it is a work flow thing. consider how often each of these cases happen: case 1: all developers are using a common db, user, password. one of those gets changed (like the pw changes every month), so one developer makes the change in settings.py, commits it, and the rest of the developers can pull down the change. case 2: not all developers use the same db, user, password, so if one changes settings.py, it will break other developers db connection. Case 1 will happen, but I think it will happen enough that it should be accounted for in the generated settings.py. >> I'm kinda confused by the resistance. Do we really need to start presenting >> concrete use cases for combined vs separate? > > You need to present a case for why it's so all-fired important for you > to be publicly posting full settings files, because to me that makes > no sense whatsoever; the settings file is not part of a Django-based > deliverable. I agree: you don't need to publicly post *full* settings files. exactly my point. Do I need to elaborate? 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 -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
James Bennett wrote: > On 11/1/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: >> View the whole settings file as something you don't just release >> casually and then only post the bits you feel safe doing so. That is >> absolutely normal configuration file practice. The generated settings.py contains things that are perfectly normal "source code" like things that should be treated as such. How does one only commit part of a file to svn? I think it is worth pointing out the comment that is put in the generated settings.py: # Make this unique, and don't share it with anybody. If we go with your view, that should be removed, because there is nothing special about SECRET_KEY. I think this kinda proves that the original design realized that there were 2 types of settings, but didn't bother to separate them. > > Apologies if I wasn't as clear as I could have been; this is really > what I was getting at by pointing out that settings files contain, > well, settings, and lots of them can be sensitive. My point is to separate them into 2 groups. This separation would solve more than just the "keep secrets secret" problem, but also make it easier to manage the settings that are an integral part of the app. (db type, name, user, password) are all derived from an external source that is going to be different for each installation So it doesn't make sense for them to be rolled into the set of files that is what gets installed. (where "installation" is a copy of the files on a machine for either development, testing or production. Even if multiple developers are working on a single production site, each developer will have their own installation.) Support for the local_settings file is there, I just think it should be changed from an "If it exists" to assuming it exists, and seed it with the values that have been singled out as "secret." > Django's debug > views go to moderate lengths to protect you (by hiding anything with > "PASSWORD" in its name), but not posting full settings files publicly > is really the only solution here. > Um, no. not the _only_ solution. I hardly call that a solution, it is hardly even a workaround. I'm kinda confused by the resistance. Do we really need to start presenting concrete use cases for combined vs separate? 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 -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
James Bennett wrote: > On 11/1/07, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Given that some settings.py files get shared/posted/uploaded to code.google, >> etc. it seems this should not be in there by default: >> >> # Make this unique, and don't share it with anybody. >> SECRET_KEY = 'foo!' > > By the same token, then, the database settings shouldn't be in the > settings file ;) > > (same goes for things like API keys, passwords for externally-accessed > services...) > Yeah, I sense an enhancement... When you run django-admin.py startproject mysite a settings.py gets created with lots of stuff. I am wondering if these should be pulled out: SECRET_KEY = 'foo!' DATABASE_ENGINE = '' DATABASE_NAME = '' DATABASE_USER = '' DATABASE_PASSWORD = '' DATABASE_HOST = '' DATABASE_PORT = '' and put in local_settings.py or something along these lines. # this will attempt to load a file called local_settings.py # which will override the information here. try: from local_settings import * except ImportError: pass I am even thinking it might be a good idea to store them in a /home/user/.mysite/local_settings.py or something that uses os.path.expanduser('~') So that it is kept separate from the stuff that is not 'private.' I can't really see a need to keep it version controlled, and hardly a point in other developers working on a project needing it to get automatically updated. (I can imagine a rare case, but I think the normal danger trump that convenience.) I do pull a copy to a fresh box for testing, and it will be a slight bother to have to manually move those settings around. but 1/2 the time I end up setting up a test DB/user anyway. I sure don't need to keep copies of passwords archived. So before I go hacking up a patch, any comments ? 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 -~--~~~~--~~--~--~---
Re: MS SQL and Django - Any current info?
Peter Bailey wrote: > Can anyone tell me if there is any current news about MS SQL support? > I am looking at frameworks for a client, and my preference is really > to go the Django route. The plan will be to migrate over time from an > asp environment with an MS SQL back end. So basically I am stuck > having to use MS SQL for a while, and no support for it in Django will > unfortunately be a show stopper. We will eventually migrate the > databases to an Open Source alternative, but that is not an option at > the start. > > I have successfully connected to MS SQL via TurboGears and Elixir/ > SQLAlchemy, so I know it is possible via python, and I realize that > most people here are not that interested in dealing with MS software. > I have also looked at the latest tickets, but they really don't say > anything definitive, although there appears to be some work being done > on it. > > I know this is an Open Source project, so it is hard to put schedules > and dates to specific things, but if anyone can give me a realistic > guess at when this support will be included (assuming it will be), I > would greatly appreciate it. > I am actually pretty sure it is actively supported, but given that support can come and go, here is how I can reassure you that it isn't a big mistake. I have worked with MS SQL using both http://www.freetds.org based pymssql and odbc based cdODBC. I have not worked with adodbapi which is what django uses, but given what I know about the things I have worked with, it A) can be done and B) probably has been done and C) I can do it if it hasn't. So my advice is run though the django tutorial using ado_mssql. If you run into problems, post here. If you don't get any response after a day or 2, forward it to me (above address) and I'll help you get through it. 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 -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
Todd O'Bryan wrote: > I then point to production_settings as my DJANGO_SETTINGS_MODULE for > mod_python and the production settings overwrite the settings that I > use for production. > > Of course, the last word should be "development," not "production." Good idea. What's funny is I do something similar for my db settings, but not for security, but to let one code base be used by 2 db's. not sure if they are checked in or not. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
keeping SECRET_KEY secret
Given that some settings.py files get shared/posted/uploaded to code.google, etc. it seems this should not be in there by default: # Make this unique, and don't share it with anybody. SECRET_KEY = 'foo!' I am sure there are already a dozen or so good solutions to this problem, plus mine: SECRET_KEY_file_name = os.path.expanduser('~/.secret') try: SECRET_KEY_file = open(SECRET_KEY_file_name,'r') SECRET_KEY = SECRET_KEY_file.read().strip() except IOError: # if the file doesn't exist, gen a key and save it to the file. from random import choice SECRET_KEY_file = open(SECRET_KEY_file_name,'w') SECRET_KEY = ''.join([choice('[EMAIL PROTECTED]&*(-_=+)') for i in range(50)]) SECRET_KEY_file.write( SECRET_KEY ) finally: SECRET_KEY_file.close() let the code war begin. 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 -~--~~~~--~~--~--~---
email example
I need to send email to a set of users. for now, let's assume all. What I have in mind: class MessageTemplate(models.Model): subject = models.CharField(maxlength=60, blank=False) body = models.TextField() User enters subject and body, hits "Save/Send" and some view code spins through the auth_user table sending to .email. Or anything close. I have sent email from other languages, never python/django. I have not really decided what the procedure will be, some of that is driven by what makes the code clean. I have a feeling the "Enter message" will be a separate step. Then there will be "send message X to users" with some way of specifying what message to send. and of course a log of who got sent what. and it won't be every user, it will be all users in a group, and all users listed in some other query, etc. Just found http://www.djangoproject.com/documentation/email which may be all I need, but some real examples and tips are always welcome. 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 -~--~~~~--~~--~--~---
Re: ImageField via admin
Grigory Fateyev wrote: > Hello Carl Karsten! > On Tue, 21 Aug 2007 10:21:06 -0500 you wrote: > >> Grigory Fateyev wrote: >>> Hello Carl Karsten! >>> On Mon, 20 Aug 2007 14:07:39 -0500 you wrote: >>> >>>>> settings.py:MEDIA_ROOT = BASE_DIR+'/media/' >>>>> settings.py:MEDIA_URL = '/site_media/' >>>>> urls.py:(r'^site_media/(?P.*)$', >>>>> 'django.views.static.serve', {'document_root': >>>>> settings.BASE_DIR+'/media/', 'show_indexes':True}), >>>>> >>>>> Revision: 5946 >>>>> >>>> I used your settings, no problem. >>>> >>>> Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) >>>> >>>> [EMAIL PROTECTED]:~/django/django_src$ svn up >>>> Updated to revision 5988. >>>> >>>> Carl K >>> That means you can add any object to Book class without problem? >>> >>> Thanks! >> yep. edit too. >> >> I suggest making a new site/project, add the model, make the few >> changes to settings and run the dev server. >> >> Carl K > > Very funny, but new project with the only class "Book" return the same > error: > > Traceback (most recent call last): > File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in > get_response 77. response = callback(request, *callback_args, > **callback_kwargs) File > "/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" > in _checklogin 51. if 'post_data' in request.POST: File > "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in > _get_post 136. self._load_post_and_files() File > "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in > _load_post_and_files 114. self._post, self._files = > http.parse_file_upload(self.environ['wsgi.input'], self.environ) File > "/usr/lib/python2.4/site-packages/django/http/__init__.py" in > parse_file_upload 71. raw_message = '\r\n'.join(['%s:%s' % pair for > pair in header_dict.items()]) > > AttributeError at /admin/books/book/add/ > '_fileobject' object has no attribute 'items' > do you have access to a python 25 box? Make sure django is up to date. 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 -~--~~~~--~~--~--~---
Re: ImageField via admin
Grigory Fateyev wrote: > Hello Carl Karsten! > On Mon, 20 Aug 2007 14:07:39 -0500 you wrote: > >>> settings.py:MEDIA_ROOT = BASE_DIR+'/media/' >>> settings.py:MEDIA_URL = '/site_media/' >>> urls.py:(r'^site_media/(?P.*)$', >>> 'django.views.static.serve', {'document_root': >>> settings.BASE_DIR+'/media/', 'show_indexes':True}), >>> >>> Revision: 5946 >>> >> I used your settings, no problem. >> >> Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) >> >> [EMAIL PROTECTED]:~/django/django_src$ svn up >> Updated to revision 5988. >> >> Carl K > > That means you can add any object to Book class without problem? > > Thanks! yep. edit too. I suggest making a new site/project, add the model, make the few changes to settings and run the dev server. 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 -~--~~~~--~~--~--~---
Re: ImageField via admin
Grigory Fateyev wrote: > Hello Carl Karsten! > On Sun, 19 Aug 2007 21:39:31 -0500 you wrote: > >> Grigory Fateyev wrote: >>> Hello! >>> >>> I have simple class with ImageField, but cann't add any object: >>> >>> class Book(models.Model): >>> name = models.CharField(_('Book Title'), maxlength=200) >>> book_number = models.IntegerField() >>> image = models.ImageField(upload_to='%Y/%m/%d/', core=True, >>> blank=True) >>> comment = models.TextField(_('Book Comment'), blank=True, >>>null=True) >>> author = models.CharField(_('Author'), maxlength=100, >>> blank=True) >>> year_rate = models.IntegerField() >>> >>> class Meta: >>> verbose_name = _('Book') >>> verbose_name_plural = _('Books') >>> >>> class Admin: >>> list_display = ('book_number', 'name', 'year_rate') >>> >>> def __unicode__(self): >>> return u"%s %s %s" % (self.book_number, self.name, >>> self.year_rate) >>> >>> the error: >>> >>> Traceback (most recent call last): >>> File >>> "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in >>> get_response 77. response = callback(request, *callback_args, >>> **callback_kwargs) File >>> "/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" >>> in _checklogin 51. if 'post_data' in request.POST: File >>> "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in >>> _get_post 135. self._load_post_and_files() >>> File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in >>> _load_post_and_files 113. self._post, self._files = >>> http.parse_file_upload(self.environ['wsgi.input'], self.environ) >>> File "/usr/lib/python2.4/site-packages/django/http/__init__.py" in >>> parse_file_upload 71. raw_message = '\r\n'.join(['%s:%s' % pair for >>> pair in header_dict.items()]) >>> >>> AttributeError at /admin/books/book/add/ >>> '_fileobject' object has no attribute 'items' >>> >>> What the problem it can be? >>> >> I just made a project with just that model. works for me. >> I would start by looking at these lines: >> >> [EMAIL PROTECTED]:~/django/foo/foot$ grep static * >> settings.py:# settings.py:MEDIA_ROOT = BASE_DIR+'/static/' >> settings.py:MEDIA_URL = '/static/' >> urls.py:(r'^static/(?P.*)$', 'django.views.static.serve', >> {'document_root': settings.BASE_DIR+'/static/', 'show_indexes': >> True}), >> >> What version of django? I am using current svn. >> >> Carl K >> > > settings.py:MEDIA_ROOT = BASE_DIR+'/media/' > settings.py:MEDIA_URL = '/site_media/' > urls.py:(r'^site_media/(?P.*)$', 'django.views.static.serve', > {'document_root': settings.BASE_DIR+'/media/', 'show_indexes':True}), > > Revision: 5946 > I used your settings, no problem. Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [EMAIL PROTECTED]:~/django/django_src$ svn up Updated to revision 5988. 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 -~--~~~~--~~--~--~---
Re: ImageField via admin
Grigory Fateyev wrote: > Hello! > > I have simple class with ImageField, but cann't add any object: > > class Book(models.Model): > name = models.CharField(_('Book Title'), maxlength=200) > book_number = models.IntegerField() > image = models.ImageField(upload_to='%Y/%m/%d/', core=True, > blank=True) > comment = models.TextField(_('Book Comment'), blank=True, >null=True) > author = models.CharField(_('Author'), maxlength=100, > blank=True) > year_rate = models.IntegerField() > > class Meta: > verbose_name = _('Book') > verbose_name_plural = _('Books') > > class Admin: > list_display = ('book_number', 'name', 'year_rate') > > def __unicode__(self): > return u"%s %s %s" % (self.book_number, self.name, > self.year_rate) > > the error: > > Traceback (most recent call last): > File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in > get_response 77. response = callback(request, *callback_args, > **callback_kwargs) File > "/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" > in _checklogin 51. if 'post_data' in request.POST: File > "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in > _get_post 135. self._load_post_and_files() File > "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in > _load_post_and_files 113. self._post, self._files = > http.parse_file_upload(self.environ['wsgi.input'], self.environ) File > "/usr/lib/python2.4/site-packages/django/http/__init__.py" in > parse_file_upload 71. raw_message = '\r\n'.join(['%s:%s' % pair for > pair in header_dict.items()]) > > AttributeError at /admin/books/book/add/ > '_fileobject' object has no attribute 'items' > > What the problem it can be? > I just made a project with just that model. works for me. I would start by looking at these lines: [EMAIL PROTECTED]:~/django/foo/foot$ grep static * settings.py:# settings.py:MEDIA_ROOT = BASE_DIR+'/static/' settings.py:MEDIA_URL = '/static/' urls.py:(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.BASE_DIR+'/static/', 'show_indexes': True}), What version of django? I am using current svn. 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 -~--~~~~--~~--~--~---
wiki design
I am trying do design a iddy biddy site that will replace a site that is only about 8 static pages. I want to make it wiki-ish, so the 'site admin' can tweak things now and then, and it needs pictures. so sort of a hybrid between a wiki and a gallery. I figure I need models.FileField() but not really sure what it would do other than provide a way for the user (admin) to upload jpg's which I could probably do with a simple upload form, but having the admin UI seems like it might add something. anyone seen anything like this, or have any ideas? 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 -~--~~~~--~~--~--~---
Re: Filter on related model problem...
Collin Grady wrote: > Regroup generates a list of dicts with two keys - grouper (the value > of the field you're grouping by) and list (the list of objects that > match that) > > So in this case, you get entries like {'grouper': , > 'list': [, , ...]} :) > > why is it call regroup and not just group? The original data set does not need to be sorted/grouped, right? 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 -~--~~~~--~~--~--~---
Re: Access db module
Tim Chase wrote: >> Someone wants to create a browser UI for an access db. can't change the db, >> even though A) access can talk to other engines via odbc and B) it will cost >> someone else more. >> >> python does odbc, there is already a MsSql_oledb for django module, so all I >> need to do is make one for access. I'm a db guy, and access is a db, so it >> shouldn't be too hard, right? > > I'll toss a couple caveats on the table and let you evaluate them > against your needs :) > > There seem to be a couple warts on the ado_mssql > driver/backend--mostly due to some brain-damaged decisions on the > MS end of things. > > One I noticed was slicing, as MSSQL and Access (ADB) don't > support the LIMIT syntax, but do support TOP which means that > instead of doing > >SELECT * FROM app_model LIMIT 10 OFFSET 20; > > you're stuck with something like > >SELECT TOP 10 * FROM app_model; -- no OFFSET ability > > This makes pagination a drag. 'cuz yeah...I really want to pull > back N+M records when all I asked for was M records. I am hoping the whole db file is about 50 mb, so don't care if I have to pull everything. I can't imagine the db is over 500. but that is all just hunch. > > It might be feasible to do some sort of "(top M of ((top N+M) > reverse-sorted)) reverse-sorted again" which is an obcene hack. > One worthy of a 100-year sentence being stuck doing > data-conversions for clients that don't know what . > > Random ordering (using "?" as your order) is also broken as the > Rand() function is only evaluated once (not per-row). Thus, if > you try to order by it, it does nothing. It would be like > ordering by a constant-valued column. hope I dont have to care about that. > > I believe MSSQL/ADB are generally case-insensitive (you can > switch MSSQL to be case sensitive, but it makes all sorts of > things very fragile, as this is deviance from the norm). > > I've also had ADB fall over on me for no good reason in complex > queries. For some reason it usually has to do with a simple > ORDER BY clause on a complex query; yet simply wrapping the whole > thing in "SELECT * FROM () ORDER BY order>" solves the problem for me. If I remove the ORDER BY from > the original query, it works just fine. Go figure. > > Those are my ADB & MSSQL frustrations that come to me off the top > of my head. I'm sure there are more, but that should be enough > to make you use sqlite and hoodwink the party that thinks ADB is > ${DIETY}'s gift to databases ;) > >> Anyone know where I am going to get screwed? > > heh, it wouldn't be polite to say in mixed company ]:-D > Thanks for the tips. I won't be so optimistic now. 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 -~--~~~~--~~--~--~---
Re: Access db module
swell. I am hoping I can use the MsSql_OLEDB code. Carl K Graham Hagger wrote: > Carl, > > Your question triggered some horrible access memories - but also > intrigued me. A quick googling brought me this link which might help > you out somewhat. > > http://www.markcarter.me.uk/computing/python/ado.html > > Graham > > Carl Karsten wrote: >> Someone wants to create a browser UI for an access db. can't change the db, >> even though A) access can talk to other engines via odbc and B) it will cost >> someone else more. >> >> python does odbc, there is already a MsSql_oledb for django module, so all I >> need to do is make one for access. I'm a db guy, and access is a db, so it >> shouldn't be too hard, right? Anyone know where I am going to get screwed? >> >> 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 -~--~~~~--~~--~--~---
Access db module
Someone wants to create a browser UI for an access db. can't change the db, even though A) access can talk to other engines via odbc and B) it will cost someone else more. python does odbc, there is already a MsSql_oledb for django module, so all I need to do is make one for access. I'm a db guy, and access is a db, so it shouldn't be too hard, right? Anyone know where I am going to get screwed? 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 -~--~~~~--~~--~--~---
Re: Filter on related model problem...
Collin Grady wrote: > view: > > poems = > Poem.objects.filter(approved=True).select_related().order_by('auth_user.username') > > template: > > {% regroup poems by user as grouped %} > {% for group in grouped %} > {{ group.grouper }} > {% for poem in group.list %} > {{ poem.title }} > {% endfor %} > {% endfor %} > Can you explain how regroup works? This is probably the solution to my problem i posted a few days ago: subject: grouping, replies: 0. 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 -~--~~~~--~~--~--~---
Re: SQL problem : how to use id thats autoincremented in statement
[EMAIL PROTECTED] wrote: > hi all, > > i have a problem with the current project i am working on.actual thr's > a table X with a field ID(autoincrement) and a field named HASH.which > is md5 of the id.now should i have to make two queries ..first one to > find out whats going to be next id and then insert the hash of it ..or > there is anotherway to do it.In SQL it world fine if i execute > following statement : > > SET @max_id=(SELECT max(ID) from table_X);insert into table_X(HASH) > values(md5(@max_id+1)); > > so please tell me a good solution ..i don't want to query two time.btw > i am using mysql as database backend. A good solution is somewhat dependent on understanding the problem. Why do you need to store an md5 of the ID? a shot in the dark solution is: create a db trigger SET hash = md5(id) (not sure exactly the trigger syntax, but mysql does have an md5: http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html#function_md5 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 -~--~~~~--~~--~--~---
Re: Proper way to extend contrib.auth
Grégoire wrote: > Hello, > > I would like to extend some functionnalities of contrib.auth, > especially in the User model. > > The objective is to do something clean without hacking django's source > code. My first idea was to create a new auth application (e.g. myauth) > and create a new User class in there extending the > contrib.auth.models.User class. Unfortunately, it doesn't work at all: > django does not find the other models obviously. I added them by hand, > then added the relationships to have all the tables and finally > realized that it doesn't work with the admin interface :( > > So, what's the good way to add some fields to the User model and > change some validators? Maybe the only solution is to copy the code > from contrib.auth and contrib.admin into new applications and start > from it... > > Thanks in advance for any advices ! > > Grégoire http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model 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 -~--~~~~--~~--~--~---
grouping
'Attached' is how I have implemented grouping items. Problem: it shows group headings when there are no items for that group. And I don't like the fact that the inner loop spins through all the items for every outer loop. doesn't scale well. What I am used to is something like: today_events = list of detail, order by eventtype.sequence, event.eventdate eventtype='' for event in today_events if event,eventtype !# eventtype # new group print event,eventtype.description eventtype=event,eventtype print event.title What is a good way to implement this? Carl K # models.py class EventType(models.Model): code=models.CharField(maxlength=10) # used in code, so don't change. description=models.CharField(maxlength=20) class Meta: ordering = ('sequence',) class Event(models.Model): title = models.CharField(maxlength=47) eventdate = models.DateField() detail = models.TextField(blank=True) eventtype=models.ForeignKey(EventType, null=True) # views.py event_types = EventType.objects.all() today_events = Event.objects.filter( show_on_main=True, eventdate = cur_day ) # welcome.html {% for event_type in event_types %} {{event_type.description }} {% for event in today_events %} {% ifequal event.eventtype event_type %} {{ event.title }} {% endifequal %} {% endfor %} {% endfor %} --~--~-~--~~~---~--~~ 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: Best Practices to Make your Apps Portable
Sebastian Macias wrote: > Thanks a lot for the feedback everyone. > > I have come up a perfect setup and folder structure (at least > perfect for my needs) that will allow me to work on generic apps and > project specific apps efficiently and just wanted to share it with > everyone in case it can save a anyone a headache. > > > *Folder structure for a django project* > > /var/django_root/my_project_name/ > urls.py > settings.py > apps/ > my_project_specific_app_1/ > my_project_specific_app_2/ > my_project_specific_app_3/ > > *Folder structure for generic/portable apps* > > /var/django_root/shared/ > my_generic_portable_app_1/ > my_generic_portable_app_2/ > my_generic_portable_registration_app/ > > > *Development Setup* > > I added the following to the top of my_project_name/settings.py so it > appends the portable/generic apps folder to the python path. > > DEVELOPMENT = True > > if DEVELOPMENT: > import sys > sys.path.append('/var/django_root/shared') > > For extended convenience I symlinked my portable/generic apps folder > to my django project so I can quickly make changes to my generic apps > without having to go outside my django project folder structure > > ln -s `pwd`/var/django_root/shared /var/django_root/my_project_name/ > shared > > > *Production Setup* > > My Apache conf file: > > > ServerName championsound.local > ServerAlias *.championsound.local > SetHandler python-program > PythonPath "['/var/django_root', '/var/django_root/shared'] + > sys.path" > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE championsound.settings > PythonDebug On > > > Note how '/var/django_root' and '/var/django_root/shared' are added to > the PythonPath > > Enjoy it! > > Sebastian Macias Can you post this to the wiki? or tell me to. one of us should. :) 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 -~--~~~~--~~--~--~---
Re: There's got to be a better way
Tim Chase wrote: >> In my view, I have: >> future_events = Event.objects.filter(start_date__gte=now) >> pacific_events = future_events.filter(club__region='Pacific') >> rocky_mountain_events = future_events.filter(club__region='Rocky >> Mountain') >> southwest_events = future_events.filter(club__region='Southwest') >> midwest_events = future_events.filter(club__region='Midwest') >> central_events = future_events.filter(club__region='Central') >> northeast_events = >> future_events.filter(club__region='Northeast') >> southeast_events = >> future_events.filter(club__region='Southeast') >> >> return render_to_response('clubs/events.html', {' >> 'pacific_events': pacific_events, >> 'rocky_mountain_events':rocky_mountain_events, >> 'southwest_events':southwest_events, >> 'midwest_events':midwest_events, >> 'central_events':central_events, >> 'northeast_events':northeast_events, >> 'southeast_events':southeast_events, >> }) >> >> And then in the view, I spit out: >> {% if pacific_events %} >> do stuff >> {% endif %} >> >> For each event type, ad nauseum. > > Sounds like you want to do something like > > future_events = Event.objects.filter(start_date__gte=now) > regions = ( > 'Pacific', > 'Midwest', > # ... or load from your Region table > ) > return render_to-response('clubs/events.html'), {'events': [ > (region, future_events.filter(club__region=region) > for region in regions > ]) > 'other_context_field': whatever, > }) > > and then in your template, you'd have something like > >{% for region in events %} > Happenings in the {{ region.0 }} region > >{% for event in region.1 %} > {{ event.description }} >{% endfor %} > >{% endfor %} > > Hope this helps, > > -tim tim, I have a similar task, and this looks like what I need to do. few minor questions: missing ) [(region, future_events.filter(club__region=region) for region in regions] guessing the missing ) goes here: [(region, future_events.filter(club__region=region)) for region in regions] What happens if there are no events in one of the regions? Does that cause a hit to the DB for each region? 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 -~--~~~~--~~--~--~---
Re: from settings import *, non-django python script Error
johnny wrote: > import re > from BeautifulSoup import BeautifulSoup > import urllib2 > from os import environ > #from settings import * > > def myfunction() : > > environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings" > from settings import * > > I get an error: > myscript.py:22: SyntaxWarning: import * only allowed at module level. right. import creates a namespace (like a var name) which wouldn't be well defined there. > > I have tried placing "from settings import *" above the "def > myfunction()", then I get an error: > raise EnvironmentError, "Could not import settings '%s' (Is it on > sys.path? > Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) > EnvironmentError: Could not import settings 'mysite.settings' (Is it > on sys.path > ? Does it have syntax errors?): No module named mysite.settings > > If I don't do import *, what do I need to import in order to use > django model in a python script? Is it (settings.py) on sys.path ? (be sure to answer this question if you are still having problems.) > Import only the followings: > > DATABASE_ENGINE > DATABASE_NAME > DATABASE_USER > DATABASE_PASSWORD > DATABASE_HOST > DATABASE_PORT > you probably want something like this: # nifty trick to get ../settings import os, sys os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' BASE_DIR = os.path.dirname(os.path.abspath(__file__)) apppath=os.path.abspath(BASE_DIR+'/../') sys.path.insert(0, apppath ) import settings "like" being a key word, cuz that code works for me, it expects settings.py to be in a dir above it. 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 -~--~~~~--~~--~--~---
Re: share users across django projects?
hotani wrote: > I'm about to build a new project using django that will have the same > users as a previous project. I would like to avoid duplicating the > existing user table. Is there a way to authenticate into the new > project with the current user list? The users are in the db. Unless you want to get on the multi-db bus, you will need to use the same db for both projects, witch is starting to sound like all one project. Why not just make another app in the same project? 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 -~--~~~~--~~--~--~---
Re: Advertisement Management
Steve wrote: > Does anybody know about a publicly available ad management program > written using Django that I could easily drop into my project? If > there isn't one, I could always write my own, but if there's one > already started I'd rather not reinvent the wheel. > The "drop into my project" concept is not easily implemented. you should probably bring this up on http://groups.google.com/group/django-hotclub 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 -~--~~~~--~~--~--~---
Re: i18n on win 32 : make_message.py doesn't find anything to translate
olivier wrote: > Hi Carl, > > Actually, it seems like the header stripping on line 122 of make- > message.py is too aggressive and removes all lines of the output of > xgettext. > > I replaced : > > msgs = '\n'.join(dropwhile(len, > msgs.split('\n'))) > > by: > > lines = msgs.split("\n") > msg, write = [], False > for line in lines: > if not line.strip(): > write = True > if write: > msg.append(line) > msgs = "\n".join(msg) > > > (space formatting will probably get messed up by google group) > > and everything goes fine. > I'll fill a ticket when I can. > > Olivier > > How is it any different?I tried various values of X in the code below, and they all came up Equal: True Guessing it is either a windows/unix newline thing, or unicode. Carl K from itertools import dropwhile def f1(msgs): msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) return msgs def f2(msgs): lines = msgs.split("\n") msg, write = [], False for line in lines: if not line.strip(): write = True if write: msg.append(line) msgs = "\n".join(msg) return msgs def dump(m): print len(m), [ hex(ord(x)) for x in m ] # test parameter x='\n \na\nbc\n\n\nd\n\ne\n' dump(x) y1=f1(x) y2=f2(x) # examine results dump(y1) dump(y2) print "Equal: %s" % (y1==y2) --~--~-~--~~~---~--~~ 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: i18n on win 32 : make_message.py doesn't find anything to translate
olivier wrote: > Hi group, > > I'm running Windows XP, django from the trunk, pyhon 2.5.1. > As recommended here [1], I run gettext natively (not Cygwin), using > gettext for win32 [2]. > My templates, my python source files and my settings are all made by > the book. > > Nevertheless, make_message doesn't find any string to translate, > without raising any error or warning. > > Has someone any clue about what's going on ? > Are there any issues with i18n on win32 ? > run the unit tests for win and sqlite as described: http://code.djangoproject.com/wiki/TestingDjango (let me how that page could be improved.) I am guessing you will get 3 errors, which has something to do with setup.py. 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 -~--~~~~--~~--~--~---
Re: Can Django call cscript.exe to run vbscripts
You might want to describe the current problem you need to solve. good chance it will be easier to solve using a few lines of python/django than trying to run your existing vbscript. Carl K braveheart wrote: > Anyone else have other solution ? > > On Jul 20, 8:54 pm, Dennis Allison <[EMAIL PROTECTED]> > wrote: >> actually, look at module subprocess rather than os as the subprocess >> module contains the current best practice solution. (Check the Python >> 3000 docs to see what will be going away and avoid using them. :-) ) >> >> BUT, the vbscript GUI will not be available throught the web, at least not >> easily. >> >> On Fri, 20 Jul 2007, Andrey Khavryuchenko wrote: >> >>> b> I'm an Windows System Administrator and for my job i often use >>> b> vbscripts to automate my tasks. I was wondering if Django can call >>> b> cscript.exe to execute a vbscript file (Offcourse django is assumed to >>> b> run under Windows)? I know that i can also script wmi with python but >>> b> i'm allready mastering vbscript and have a huge library of function >>> b> vbscripts. >>> b> Can someone help me pls ? >>> Django app is a plain python script. So check python doc for starting >>> external applications (module os). >> -- > > > > > --~--~-~--~~~---~--~~ 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: 4 beginner's questions
Stefan Matthias Aust wrote: > Carl, Jeremy, > > Thanks for your answers. > > Carl wrote: > >> I just made this. it should answer most of 1 and 2. >> http://code.djangoproject.com/wiki/DatabaseReset > > Somehow, it seems to me that there should be a standard utility > function to initialize the system for command line tools. I saw your > "nifty trick" twice and I used a similar approach. I vote for ./manage.py -runscript myscript.py which apparently has been shot down in the past. > > Your migrate.py script seems to be very specific to your > mysql-specific use case. yes, but only for reading. The writes into django db are all via the django db api. The page is boarder line wiki worthy, but I got tired of pasting the same 3 files into dpaste.com :) 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 -~--~~~~--~~--~--~---
Re: 4 beginner's questions
Stefan Matthias Aust wrote: > Hi, > > Coming from a Java background, I introduced Django in my company for a > new web application. So far, we made great progress and web > development suddenly was fun again. Unfortunately, it feels like all > time I save because of Django, is spent on searching for an IDE (I > still haven't found something really usable), reading the doc and > solving trivial Python problems. I hope this will get better once I > have more experience with Python. > > I've a few questions regarding Django I'd like to ask in this and future > mails. > > 1) It is important for me to recreate my environment from scratch > (that is, from the VCS). I'd like to have a working application after > calling "syncdb". For my own application, I've create an initial_data > fixture. But I'd like to recreate users and permissions, too. > > Is this possible? > > I looked into django/core/management.py and it seems that "load_data" > simple enumerates the installed application so if I want to create a > fixture for "auth", the initial_data file must be located inside the > django installation. This isn't an option. Furthermore, it seems that > "syncdb" always asks for an admin account on the console. Can I > somehow suppress that question? Instead, I'd like to load some saved > fixture. > > 2) I'd like to run batch application against our database > (periodically using cron). Of course, I'd like to use the same > database abstraction as Django uses, so I tried to find a way to > initialize the system. > > What's the recommended way to access models from outside of views? > > I came up with these lines (conveniently located inside the project folder): > > #!/usr/bin/env python > ... > if __name__ == '__main__': >from django.core.management import setup_environ >import settings >PROJECT_DIRECTORY = setup_environ(settings) > >from demo.models import Demo >d = Demo.objects.get(...) >... >d.save() > I just made this. it should answer most of 1 and 2. http://code.djangoproject.com/wiki/DatabaseReset > 3) I need to create an object with a unique random id - and I would > prefer not to use the database specific SQL layer. What's the best way > to do it? My naive approach is to declare the id field unique and > simply try to insert objects until I get no error. The documentation > says [unique] "is enforced at the database level" but it unfortunately > does not describe what happens if the constraint is violated. Will > this always raise an IntegrityError? > Why a unique _random_ id. seems odd. knowing the use case might help. > 4) I'd like to specify the file name of an uploaded file. Right now, > the original filename is kept and I think, this could cause problems > if two people upload a file with the same name at the same time. > > I tried to understand the file upload process in the Django source but > there was too much meta magic for my brain. However, it seems that the > current documentation doesn't tell the whole story. It seems, that > there is a save_FOO_file() in addition to the documentation tree > get_FOO_xxx methods... My guess is that manipulators.py is responsible > for saving the uploaded file. ... Wait, I think, _save_FIELD_file() > will eventually save the file and yes, that while loop is obviously > not threadsafe! So I need to set the filename myself. But how? > good Q hopfully someone can answer it. :) 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 -~--~~~~--~~--~--~---
Re: Menu implementation
Lic. José M. Rodriguez Bacallao wrote: > Have anybody implemented a tree with django, for example, a menu? > tree = ui or data structurer? (guessing the answer is yes to both) 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 -~--~~~~--~~--~--~---
Re: model managers of base classes
Thanks - I think I bumped into that yesterday and got distracted trying to setup a test on a win box (yay) I was getting a 500, you too right? Carl K omat wrote: > As I further test the pythonic inheritance for models, I figure out > that some django model magic does not work. For example, instead of > "get_object_or_404" you should do: > try: > object = ObjectClass.objects.get(pk=1) > except: > raise Http404 > > > > On 17 Temmuz, 18:01, omat <[EMAIL PROTECTED]> wrote: >> Sorry for the terminological confusion. The "model" is the >> django.db.models.Model() class, the "manager" is the >> django.db.models.Manager() class. >> >> Yes Nis, the behaviors you listed are the most important ones. It >> would be nice to have Meta, Admin, etc. inherited as well but, it is >> not a priority. I think, with that requirements, pure pythonic class >> inheritance is just fine. It gives a single table for each model, >> which sounds quite natural. >> >> For the side effect, as Carl has pointed out, as long as you don't put >> "ortho" in the settings.INSTALLED_APPS, it is not recognized by >> syncdb. >> >> Yours, >> oMat >> >> On 17 Temmuz, 17:14, Carl Karsten <[EMAIL PROTECTED]> wrote: >> >>> Nis Jørgensen wrote: >>>> omat skrev: >>>>> Thanks for the pointer, Nis. >>>>> Model inheritance made my models so much DRYer that it will be hard to >>>>> give up, at least psychologically... >>>>> And, except for the managers, it worked just as I would expect, and >>>>> for the managers, it was easy to patch. >>>> Just to make sure I understand, your expected behavior is >>>> - Each model gets a db table which include fields from its ancestors >>>> - Managers and (other) methods are inherited as if they were defined on >>>> the subclass >>>> - There is no common interface for subclasses of a model class. >>>> Correct? >>>> I would perhaps call this "class templating" rather than "subclassing", >>>> but I can definitely see its usefulness. >>> I think the name problem stems from "model" not being well defined, or notr >>> properly used. Is the model the class, the persistence implemented in the >>> db, >>> the shape of the data...? >>> I agree that what is bing described here is very different than some of the >>> other discussions that use the same terms. which makes it very confusing. >>> (the >>> other discussions seem to focus around a separate table for each level of >>> subclass.) >>> I am currently trying out what is discussed in this thread, and figured out >>> the >>> same hack: db_table = 'message' - Some time this week I hope to have things >>> working well enough to post the whole app >>> inhttp://groups.google.com/group/django-hotclub >>>> Note that you get the probably undesired sideeffect of defining the >>>> Ortho class as a model - which may cause some confusion if people use >>>> syncdb and friends, and probably in other cases as well. >>> So far syncdb has not found my abstract class. I have it in a separate dir >>> not >>> referenced by INSTALLED_APPS. guessing that is the trick, but I am not 100% >>> sure how syncdb finds classes. >>> 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 -~--~~~~--~~--~--~---
Re: model managers of base classes
Nis Jørgensen wrote: > omat skrev: >> Thanks for the pointer, Nis. >> >> Model inheritance made my models so much DRYer that it will be hard to >> give up, at least psychologically... >> >> And, except for the managers, it worked just as I would expect, and >> for the managers, it was easy to patch. >> > > Just to make sure I understand, your expected behavior is > - Each model gets a db table which include fields from its ancestors > - Managers and (other) methods are inherited as if they were defined on > the subclass > - There is no common interface for subclasses of a model class. > > Correct? > > I would perhaps call this "class templating" rather than "subclassing", > but I can definitely see its usefulness. I think the name problem stems from "model" not being well defined, or notr properly used. Is the model the class, the persistence implemented in the db, the shape of the data...? I agree that what is bing described here is very different than some of the other discussions that use the same terms. which makes it very confusing. (the other discussions seem to focus around a separate table for each level of subclass.) I am currently trying out what is discussed in this thread, and figured out the same hack: db_table = 'message' - Some time this week I hope to have things working well enough to post the whole app in http://groups.google.com/group/django-hotclub > > Note that you get the probably undesired sideeffect of defining the > Ortho class as a model - which may cause some confusion if people use > syncdb and friends, and probably in other cases as well. So far syncdb has not found my abstract class. I have it in a separate dir not referenced by INSTALLED_APPS. guessing that is the trick, but I am not 100% sure how syncdb finds classes. 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 -~--~~~~--~~--~--~---
win install problem
ING': '', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': '', 'REQUEST_METHOD': 'GET', 'RUN_MAIN': 'true', 'SCRIPT_NAME': '', 'SERVER_NAME': 'testxp.DEV.JASSING.COM', 'SERVER_PORT': '8000', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.5.1', 'SESSIONNAME': 'Console', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\\DOCUME~1\\test\\LOCALS~1\\Temp', 'TMP': 'C:\\DOCUME~1\\test\\LOCALS~1\\Temp', 'USERDOMAIN': 'TESTXP', 'USERNAME': 'test', 'USERPROFILE': 'C:\\Documents and Settings\\test', 'WINDIR': 'C:\\WINDOWS', 'wsgi.errors': ', mode 'w' at 0x0096F0B0>, 'wsgi.file_wrapper': , 'wsgi.input': , 'wsgi.multiprocess': False, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}> self url u'4' C:\Python25\Lib\site-packages\django\shortcuts\__init__.py in render_to_response # for convenience's sake. from django.template import loader from django.http import HttpResponse, Http404 from django.db.models.manager import Manager def render_to_response(*args, **kwargs): return HttpResponse(loader.render_to_string(*args, **kwargs)) ... load_and_render = render_to_response # For backwards compatibility. def get_object_or_404(klass, *args, **kwargs): if isinstance(klass, Manager): manager = klass klass = manager.model ▶ Local vars Variable Value args ('databrowse/object_detail.html', {'object': , 'root_url': u'/eventcal/databrowse/'}) kwargs {} C:\Python25\Lib\site-packages\django\template\loader.py in render_to_string get_template, or it may be a tuple to use select_template to find one of the templates in the list. Returns a string. """ dictionary = dictionary or {} if isinstance(template_name, (list, tuple)): t = select_template(template_name) else: t = get_template(template_name) ... if context_instance: context_instance.update(dictionary) else: context_instance = Context(dictionary) return t.render(context_instance) ▶ Local vars Variable Value context_instance None dictionary {'object': , 'root_url': u'/eventcal/databrowse/'} template_name u'databrowse/object_detail.html' C:\Python25\Lib\site-packages\django\template\loader.py in get_template raise TemplateDoesNotExist, name def get_template(template_name): """ Returns a compiled Template object for the given template name, handling template inheritance recursively. """ source, origin = find_template_source(template_name) ... template = get_template_from_string(source, origin, template_name) return template def get_template_from_string(source, origin=None, name=None): """ Returns a compiled Template object for the given template code, ▶ Local vars Variable Value template_name u'databrowse/object_detail.html' C:\Python25\Lib\site-packages\django\template\loader.py in find_template_source template_source_loaders.append(func) for loader in template_source_loaders: try: source, display_name = loader(name, dirs) return (source, make_origin(display_name, loader, name, dirs)) except TemplateDoesNotExist: pass raise TemplateDoesNotExist, name ... def get_template(template_name): """ Returns a compiled Template object for the given template name, handling template inheritance recursively. """ ▶ Local vars Variable Value dirs None loader name u'databrowse/object_detail.html' Traceback (most recent call last): File "C:\Python25\Lib\site-pac
Re: method as view
Forest Bond wrote: > On Sun, Jul 15, 2007 at 02:59:57PM -0500, Carl Karsten wrote: >> How can I use a method as a view? (so that I can subclass and extend later.) >> >> foo works, the other 2 give errors: >> >> # msg/urls.py >> from django.conf.urls.defaults import * >> urlpatterns = patterns('msg.views', >> (r'^detail/(?P[-\w]+)/$', 'foo'), >> (r'^detail/x/(?P[-\w]+)/$', 'MsgViews.message_detail'), >> (r'^detail/y/(?P[-\w]+)/$', MsgViews.message_detail), >> ) > > Try this: > > > from django.conf.urls.defaults import * > > msg_views = MsgViews() > > urlpatterns = patterns('msg.views', > (r'^detail/(?P[-\w]+)/$', 'foo'), > (r'^detail/x/(?P[-\w]+)/$', msg_views.message_detail), > (r'^detail/y/(?P[-\w]+)/$', msg_views.message_detail), > ) That works, Thanks. > > > Alternatively, you can make message_detail a static method: > > > class MsgViews(object): > > @static_method > def message_detail(request, object_id=None): > m=get_object_or_404(Message, pk=object_id) > return render_to_response('message_detail.html', {'message': m}) > > > I'm not even sure if this sort of thing is possible, but it might be: > > > class MsgViews(object): > > @static_method > def __call__(request, object_id=None): > m=get_object_or_404(Message, pk=object_id) > return render_to_response('message_detail.html', {'message': m}) > > error: name 'static_method' is not defined > The only reason I can think of for doing that is that you wouldn't have to > import MsgViews in your urls.py, you could just specify a string. > > Now, after all that, I'm still a little confused as to why you would want to > do > all of this? You say so that you can extend your view functions, but classes > are extensible because their methods can be replaced, and you already _can_ > replace plain view functions... Classes also can call self.other method, and the code they are extending. Hmm, now that I think about it, you may have a point. I'll leave it as is for now, but if I have any more problems I will probably go back to module.function. My overall goal is to figure out how to make components that can be moved between django apps/sites. I kinda have models working, but im gonna burn for using the same name for both parent and subclass. # msg/model.py from django.db import models from django.contrib.auth.models import User class Message(models.Model): to = models.ForeignKey(User, related_name = "messages_received") sender = models.ForeignKey(User, related_name = "messages_sent") subject = models.CharField(maxlength=50) sent = models.DateTimeField(auto_now_add=True) recieved = models.DateTimeField(null=True) read = models.BooleanField(default=False) body = models.TextField() def __str__(self): return self.subject #class Admin: #list_display = ('sent', 'to', 'sender', 'subject') class Meta: db_table = 'message' # core/models.py import msg.models class Message(msg.models.Message): status = models.CharField(maxlength=1, blank=True) class Admin: list_display = ('sent', 'to', 'sender', 'subject') 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 -~--~~~~--~~--~--~---
method as view
How can I use a method as a view? (so that I can subclass and extend later.) foo works, the other 2 give errors: # msg/urls.py from django.conf.urls.defaults import * urlpatterns = patterns('msg.views', (r'^detail/(?P[-\w]+)/$', 'foo'), (r'^detail/x/(?P[-\w]+)/$', 'MsgViews.message_detail'), (r'^detail/y/(?P[-\w]+)/$', MsgViews.message_detail), ) # msg/views.py from django.shortcuts import render_to_response, get_object_or_404 from core.models import Message class MsgViews(object): def message_detail(self, request, object_id=None): m=get_object_or_404(Message, pk=object_id) return render_to_response('message_detail.html', {'message': m}) def foo(request, object_id=None): mv=msgviews() return mv.message_detail(request, object_id) 'MsgViews.message_detail': Could not import msg.views.MsgViews. Error was: No module named MsgViews MsgViews.message_detail: unbound method message_detail() must be called with MsgViews instance as first argument (got WSGIRequest instance instead) I was given this in #django mattmcc: You can make a class into a callable object to use in urlconfs. Which sounds familiar, but I don't know how to do. 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 -~--~~~~--~~--~--~---
Re: is there any host servers that supports Django based sites?
Michael wrote: > > > On 15 יולי, 17:18, Michael <[EMAIL PROTECTED]> wrote: >> .: >> Webfaction django hosting rocks. >> can I get a link to Webfaction? > > ok, I think I found it by myself > http://www.webfaction.com/shared_hosting > > so, as I understand, the best strategy is to host the clients product > on my own server > then to show the final product to the client, he likes it, and then I > can convince him to use other hosting service (ie - webfraction) > right? > > It's a good idea, but the problem is that I'm kinda out of money > paying every month to some hosting service would be a pain :) > so, someone interested to share with me his hosting service? > I can pay him AFTER I sell the product > > think about that- it may be easy money for you, I'm doing all the > development on my comp, once the product is done, I upload it to your > host, just for 1-2 days, - if the client is happy, he pays me and I > pay you, just for 1-2 days of hosting :) > As much as I would like the easy money, I have to recommend you do it yourself, just change what it is you are trying to do. first thoughts: show the client on your computer. the one you developed on. or, use the client's computer. I do recommend installing apache or whatever you plan on using at the final location (webfraction) Not sure I would recommend installing apache on your client's computer, but that is between you and them. This isn't as cool as having a domain name and a "live on the Net" site, but you and your client need to realize that isn't anything different than a local site. I don't think it will be worth the hassle, risks or money to do what you are asking. 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 -~--~~~~--~~--~--~---
Re: model subclassing
Malcolm Tredinnick wrote: > On Fri, 2007-07-13 at 21:31 -0500, Carl Karsten wrote: >> I am experimenting with subclassing a model. The parent class will be an >> abstract class that does not get 'managed' by django. Only the subclass >> will, >> and the table the subclass works with will have all the fields. >> >> syncdb was able to create the table I expected, the admin let me add and >> save >> it, but then when I went to view it, error: >> >> ProgrammingError at /admin/core/message/1/ >> (1146, "Table 'djangodb.msg_abmessage' doesn't exist") >> >> (full details below) >> >> So is this just a small bug in the Admin, or is this totally unsupported and >> I >> should give up now? > > Currently unsupported. Work in progress at the moment and will be > available before 1.0. > I think what I am trying to do is getting tangled up in a big ball of problem, and what I am looking for might be a simple fix. (or even working except for a bug in the admin UI.) What follows is an attempt to isolate my problem from a bigger problem, which will also help with the bigger problem. I just read over http://code.djangoproject.com/wiki/ModelInheritance and http://groups.google.com/group/django-developers/browse_thread/thread/1bc01ee32cfb7374/84b64c625cd1b402?tvc=2&q=Model+Inheritance#84b64c625cd1b402 I see a design methodology problem: there are at least 3 problems (or features) trying to be addressed and I think they are separate enough problems to have separate solutions. I see more than one reasonable solution proposed. Each has something to offer the developer, not mutually exclusive, and can even work in conjunction. I think breaking ModelInheritance into well defined parts is important. looking at my problem: class abMessage(models.Model): to = models.ForeignKey(User, related_name = "messages_received") body = models.TextField() class message(msg.models.abMessage): status = models.CharField(maxlength=1) The problem/solution I am looking for: abstract base, concrete subclass, subclass is persisted in one table in the db. Yet this is the one case that was listed as "I am not implementing the "everything in one table" storage model." seems to me this should be one of the first things done, given how easy it is compared to the other solutions discussed. "(1) What notation to use to declare a class as abstract?" I think one of the problems trying to be solved here is: how do we keep django's syncdb, Admin UI and such from 'finding' such a class and trying to create a persistence for it. This problem may exist in non ModelInheritance situations too, making it part of the ModelInheritance problem may limit the usefulness of the solution. --~--~-~--~~~---~--~~ 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: Database setup
surfwizz wrote: > I'm trying to do the django tutorial at > http://www.djangoproject.com/documentation/tutorial01/, > but I don't know how to set up a database. I do not have a dedicated > server or web hosting at this time, and I want to do some work on > setting up a website with database systems before I get web hosting. > Can I make a database stored locally? if yes, how? # settings.py ... DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. DATABASE_NAME = 'foo' ... That is all you need (for DATABASE settings) syncdb will create the database for you (called 'foo' in your project dir. which is fine for now.) All that other stuff postdd is correct, but probably over your head at this point, so don't worry about it if you didn't understand. 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 -~--~~~~--~~--~--~---
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 -~--~~~~--~~--~--~---
Re: installation issues
Ok, getting somewhere. That is the dir that needs to know about django. Next we need to know where django is, and 'install' that into the site-packages dir. 'install' is just a link, .pth file or putting django directly in that dir. I recommend the link. more details are here: http://www.djangoproject.com/documentation/install/#install-the-django-code if you still have problems, post the following: 1. What version of django you want (official release, or development version.) 2. Where the django code is 3. what django references are currently in your site-packages dir. For #3, do ls -ld django* in your site-packages dir, like this: [EMAIL PROTECTED]:~$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" /usr/lib/python2.5/site-packages [EMAIL PROTECTED]:~$ cd /usr/lib/python2.5/site-packages [EMAIL PROTECTED]:/usr/lib/python2.5/site-packages$ ls -ld django* lrwxrwxrwx 1 root root 36 2007-06-25 23:30 django -> /home/carl/django/django-src/django/ Carl K surfwizz wrote: > Sorry about that. Thanks for the tip on using copy/paste. Here's the > result for that: > new-host-3:~ wdavis$ python -c "from distutils.sysconfig import > get_python_lib; print get_python_lib()" > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- > packages > > > On Jul 13, 6:49 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: >> you missed the -c >> >> guessing you need to figure out how to cut/paste into your terminal. I >> think it >> is action-v for paste, where action is the cloverleaf. >> >> Carl K >> >> surfwizz wrote: >>> Here's what that looks like: >>> new-host-3:~ wdavis$ python "from distutils.sysconfig import >>> get_python_lib; print get_python_lib()" >>> /Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/ >>> Contents/MacOS/Python: can't open file 'from distutils.sysconfig >>> import get_python_lib; print get_python_lib()': [Errno 2] No such file >>> or directory >>> new-host-3:~ wdavis$ >>> On Jul 13, 6:16 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: >>>> run this command, show us what you get: >>>> python -c "from distutils.sysconfig import get_python_lib; print >>>> get_python_lib()" >>>> So like this: >>>> [EMAIL PROTECTED]:~$ python -c "from distutils.sysconfig import >>>> get_python_lib; print >>>> get_python_lib()" >>>> /usr/lib/python2.5/site-packages >>>> Carl K >>>> surfwizz wrote: >>>>> I could not find any folders at the lib location. To clarify how the >>>>> IDLE thing went, I tried running sudo python setup.py, but it didn't >>>>> work, so I opened setup.py in IDLE, Then went to 'run', in the >>>>> menubar, and clicked 'run module'. It prompted me to save it, so I >>>>> did. that was the whole python IDLE thing with this. >>>>> On Jul 13, 3:40 am, "Dirk van Oosterbosch, IR labs" >>>>> <[EMAIL PROTECTED]> wrote: >>>>>> On 13-jul-2007, at 5:42, surfwizz wrote: >>>>>>> I installed python fromwww.python.org, so the command prompt opens it >>>>>>> into 2.5.1. That's what I tried to install django into. >>>>>> Can you confirm that django is installed at this location? >>>>>> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- >>>>>> packages/django/ >>>>>> (try 'locate django' in the Terminal to find out where all of django is) >>>>>>> [...] so I just ran setup.py in IDLE as a module. Is there a way >>>>>>> to fix this, or get this install running properly? >>>>>> What do you mean 'in IDLE as a module'? AFAIK the correct way to >>>>>> install python packages is to run 'sudo python setup.py' from the >>>>>> normal command line. Or did you do that? >>>>>> best >>>>>> dirk > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
model subclassing
db 15. 16. def execute(self, sql, params=()): 17. start = time() 18. try: 19. return self.cursor.execute(sql, params) ... 20. finally: 21. stop = time() 22. self.db.queries.append({ 23. 'sql': smart_unicode(sql) % convert_args(params), 24. 'time': "%.3f" % (stop - start), 25. }) ? Local vars Variable Value params [u'1'] self sql u'SELECT `msg_abmessage`.`id`,`msg_abmessage`.`to_id`,`msg_abmessage`.`sender_id`,`msg_abmessage`.`subject`,`msg_abmessage`.`sent`,`msg_abmessage`.`recieved`,`msg_abmessage`.`read`,`msg_abmessage`.`message` FROM `msg_abmessage` WHERE (`msg_abmessage`.`id` = %s)' start 1184379386.960124 stop 1184379386.960449 * /usr/lib/python2.5/site-packages/MySQLdb/cursors.py in execute 157. else: 158. self.messages.append((TypeError, m)) 159. self.errorhandler(self, TypeError, m) 160. except: 161. exc, value, tb = exc_info() 162. del tb 163. self.messages.append((exc, value)) 164. self.errorhandler(self, exc, value) ... 165. self._executed = query 166. self._warning_check() 167. return r 168. 169. def executemany(self, query, args): 170. ? Local vars Variable Value ListType TupleType UnicodeType args [u'1'] charset u'utf8' db exc exc_info query u"SELECT `msg_abmessage`.`id`,`msg_abmessage`.`to_id`,`msg_abmessage`.`sender_id`,`msg_abmessage`.`subject`,`msg_abmessage`.`sent`,`msg_abmessage`.`recieved`,`msg_abmessage`.`read`,`msg_abmessage`.`message` FROM `msg_abmessage` WHERE (`msg_abmessage`.`id` = '1')" self value ProgrammingError(1146, "Table 'djangodb.msg_abmessage' doesn't exist") * /usr/lib/python2.5/site-packages/MySQLdb/connections.py in defaulterrorhandler 28. error = errorclass, errorvalue 29. if cursor: 30. cursor.messages.append(error) 31. else: 32. connection.messages.append(error) 33. del cursor 34. del connection 35. raise errorclass, errorvalue ... 36. 37. 38. class Connection(_mysql.connection): 39. 40. """MySQL Database Connection Object""" 41. ? Local vars Variable Value error (, ProgrammingError(1146, "Table 'djangodb.msg_abmessage' doesn't exist")) errorclass errorvalue ProgrammingError(1146, "Table 'djangodb.msg_abmessage' doesn't exist") Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "/usr/lib/python2.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 39. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in change_stage 322. manipulator = model.ChangeManipulator(object_id) File "/usr/lib/python2.5/site-packages/django/db/models/manipulators.py" in __init__ 261. self.original_object = self.manager.get(pk=obj_key) File "/usr/lib/python2.5/site-packages/django/db/models/manager.py" in get 73. return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in get 260. obj_list = list(clone) File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in __iter__ 113. return iter(self._get_data()) File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in _get_data 480. self._result_cache = list(self.iterator()) File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in iterator 188. cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File "/usr/lib/python2.5/site-packages/django/db/backends/util.py" in execute 19. return self.cursor.execute(sql, params) File "/usr/lib/python2.5/site-packages/MySQLdb/cursors.py" in execute 164. self.errorhandler(self, exc, value) File "/usr/lib/python2.5/site-p
Re: installation issues
you missed the -c guessing you need to figure out how to cut/paste into your terminal. I think it is action-v for paste, where action is the cloverleaf. Carl K surfwizz wrote: > Here's what that looks like: > new-host-3:~ wdavis$ python "from distutils.sysconfig import > get_python_lib; print get_python_lib()" > /Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/ > Contents/MacOS/Python: can't open file 'from distutils.sysconfig > import get_python_lib; print get_python_lib()': [Errno 2] No such file > or directory > new-host-3:~ wdavis$ > > > On Jul 13, 6:16 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: >> run this command, show us what you get: >> python -c "from distutils.sysconfig import get_python_lib; print >> get_python_lib()" >> >> So like this: >> >> [EMAIL PROTECTED]:~$ python -c "from distutils.sysconfig import >> get_python_lib; print >> get_python_lib()" >> /usr/lib/python2.5/site-packages >> >> Carl K >> >> surfwizz wrote: >>> I could not find any folders at the lib location. To clarify how the >>> IDLE thing went, I tried running sudo python setup.py, but it didn't >>> work, so I opened setup.py in IDLE, Then went to 'run', in the >>> menubar, and clicked 'run module'. It prompted me to save it, so I >>> did. that was the whole python IDLE thing with this. >>> On Jul 13, 3:40 am, "Dirk van Oosterbosch, IR labs" >>> <[EMAIL PROTECTED]> wrote: >>>> On 13-jul-2007, at 5:42, surfwizz wrote: >>>>> I installed python fromwww.python.org, so the command prompt opens it >>>>> into 2.5.1. That's what I tried to install django into. >>>> Can you confirm that django is installed at this location? >>>> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- >>>> packages/django/ >>>> (try 'locate django' in the Terminal to find out where all of django is) >>>>> [...] so I just ran setup.py in IDLE as a module. Is there a way >>>>> to fix this, or get this install running properly? >>>> What do you mean 'in IDLE as a module'? AFAIK the correct way to >>>> install python packages is to run 'sudo python setup.py' from the >>>> normal command line. Or did you do that? >>>> best >>>> dirk > > > > > --~--~-~--~~~---~--~~ 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: installation issues
run this command, show us what you get: python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" So like this: [EMAIL PROTECTED]:~$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" /usr/lib/python2.5/site-packages Carl K surfwizz wrote: > I could not find any folders at the lib location. To clarify how the > IDLE thing went, I tried running sudo python setup.py, but it didn't > work, so I opened setup.py in IDLE, Then went to 'run', in the > menubar, and clicked 'run module'. It prompted me to save it, so I > did. that was the whole python IDLE thing with this. > > On Jul 13, 3:40 am, "Dirk van Oosterbosch, IR labs" > <[EMAIL PROTECTED]> wrote: >> On 13-jul-2007, at 5:42, surfwizz wrote: >> >>> I installed python fromwww.python.org, so the command prompt opens it >>> into 2.5.1. That's what I tried to install django into. >> Can you confirm that django is installed at this location? >> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- >> packages/django/ >> (try 'locate django' in the Terminal to find out where all of django is) >> >>> [...] so I just ran setup.py in IDLE as a module. Is there a way >>> to fix this, or get this install running properly? >> What do you mean 'in IDLE as a module'? AFAIK the correct way to >> install python packages is to run 'sudo python setup.py' from the >> normal command line. Or did you do that? >> >> best >> dirk > > > > > --~--~-~--~~~---~--~~ 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: new django site: PotterPredictions.com
Kai Kuehne wrote: > Well, I meant without to register myself on the site. in case it isn't crystal clear: http://www.codinghorror.com/blog/archives/000881.html "Removing The Login Barrier" 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 -~--~~~~--~~--~--~---
Re: avoiding 'matching query not exist'
James Bennett wrote: > On 7/11/07, Carl Karsten <[EMAIL PROTECTED]> wrote: >> How can I do something similar with: >> coursestatus = Event.objects.filter( >>eventtype__eventcode='corsecond', >>eventdate__lt = datetime.now() >>).latest('eventdate') >> >> Currently I get " Event matching query does not exist. " > > As you should -- when there is no object matching the parameters > you've passed, 'latest()' raises ObjectDoesNotExist (specifically in > this case, the subclass Event.DoesNotExist). > > What you want is to wrap a try/except block around that, like so: > > try: > coursestatus = Event.objects.filter(...your params...).latest() > except Event.DoesNotExist: > coursestatus = None > Huh. I would have expected this case would have been provided for. Thanks for giving me the exception to catch, I would have just left it open thinking I would figure it out someday, and that day would only come when I am going nuts trying to figure out why some error is being suppressed. 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 -~--~~~~--~~--~--~---
avoiding 'matching query not exist'
This deals with empty sets: dinner_special = Event.objects.filter( eventtype__eventcode='restspec', eventdate = datetime.now() ) Today's Dinner Secials: {% if dinner_special %} {{ dinner_special.0.title }}{{ dinner_special.0.description }} {% else %} Sorry, nothing posted for today. {% endif %} How can I do something similar with: coursestatus = Event.objects.filter( eventtype__eventcode='corsecond', eventdate__lt = datetime.now() ).latest('eventdate') Currently I get " Event matching query does not exist. " 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 -~--~~~~--~~--~--~---
Re: installation issues
surfwizz wrote: > I am having trouble installing Django on Mac OSX 10.4.10. Any help > would be welcome. Thanks! > > Im gona take a shot: Can you run python and get a >>> prompt? If yes, what version is it? and what happens when you >>> import django 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 -~--~~~~--~~--~--~---
Re: ForeignKey(User, list_display=full?
Russell Keith-Magee wrote: > On 7/11/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > >> I am hoping to do something like >> contact = models.ForeignKey(User, list_display = ('first_name', 'last_name') >> ) > > A big -1 on this idea. This mixes the data representation with the > display representation. One of the major reasons for the > newforms-admin rewrite is to avoid mixes like this. > Personally, I think this is an appropriate place to do what I am doing. it is a central place where an aspect of my app is defined, and that definition can include both the schema and the UI. the UI can be overridden at the instance level, but if there are more than one place this 'default' UI is to be used, this seems like the place to define it. now that I have said all that, I should go look at the newforms-admin thing. so don't get too worked up over my "common place to define everything" desire. > If you want to affect the display of a foreign key, you can (and > should) do it on the form. The default display will be __str__, but > you can easily replace the display list. > Only interested in the admin interface. I am not very far into coding my app, I have been using SVN. sounds like I should start using the newforms-admin? (im quite ok developing with beta code. by the time I am ready to deploy I will know that either my stuff works, or what bugs are pending and then fix them. or something like that.) 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 -~--~~~~--~~--~--~---
ForeignKey(User, list_display=full?
I am using the django User like so: # models.py from django.contrib.auth.models import User class Event(models.Model): title = models.CharField(maxlength=47) eventdate = models.DateField() contact = models.ForeignKey(User, null=True, blank=True ) right now I get this in admin: - user1 user2 I get the user1,user2 username because "If the field is a ForeignKey, Django will display the __str__() of the related object." http://www.djangoproject.com/documentation/model-api/ (should now say __unicode__ - traced.) class User(models.Model): def __unicode__(self): return self.username I am hoping to do something like contact = models.ForeignKey(User, list_display = ('first_name', 'last_name') ) But that throws ridgemoor.eventcal: __init__() got an unexpected keyword argument 'list_display' --~--~-~--~~~---~--~~ 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: effective dates
Tim Chase wrote: >> status.effectivedate is when a status 'starts', (like closed for repairs.) >> How do I get the 'current status based on current date' ? >> >> so if the following 3 records are in the table: >> status >> effective date, description >> 1/1/2007 - open for business >> 3/24/2007 - closed for remodeling >> 5/1/2007 - open with a new look. >> 11/14/2007 - closed for Christmas >> 1/1/2008 - open - happy new year. >> >> So right now, the status is "open with a new look." when it is 11/14, the >> current status will be "closed for Christmas." >> >> The SQL is a big ugly, hoping the ORM will make it for me. > > IIUC, you want the most recent status with a date earler than > now, which should be doable via something like > > from datetime import datetime > status = Status.objects.filter( > effectivedate__lt = datetime.now() > ).latest('effectivedate') > nice. > > I'm not sure the SQL is all that ugly either, as it would be > something like > >SELECT * >FROM app_status >WHERE effectivedate < NOW() >ORDER BY effectivedate DESC >LIMIT 1 Also nice. never seen it done with LIMIT. SELECT * FROM app_status WHERE effectivedate in (select max(effectivedate) from app_status where effectivedate<=NOW() ) and good luck augmenting that with WHERE someID=foo, cuz you have to add that into both WHERE's. > > but it's nice to have it abstracted in the ORM to avoid backend > peculiarities regarding the NOW function and the syntax for > limiting to one row. ("now()" vs. "curdate"; "LIMIT" vs. "TOP") > once I get something working (probably with the filter you suggested) I'll post a trac about a more ... elegant? version. > As a side note, if you work someplace that closes for Christmas > on 11/14, I want to work there! :) yeah, cuz that place is gonna be in business for a while. 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 -~--~~~~--~~--~--~---