2009-7-5
| 22:08 | davidcramer | might not be the best approach, but i couldnt find any examples (or even a way) to extend it how I wanted to |
| 22:08 | davidcramer | and i think it will work well :) |
| 22:09 | mib_mib | what about feedjack? |
| 22:09 | mib_mib | not what you wanted? |
| 22:11 | davidcramer | let me look |
| 22:11 | davidcramer | oh no i dont want something that does stuff |
| 22:11 | davidcramer | i just want a feed parser :D |
| 22:11 | davidcramer | and it uses the "excellent" feedparser ;) |
| 22:14 | chrishartim | what might be the right sytax to find the path of any module that's on sys.path? |
| 22:27 | ironi | hi |
| 22:37 | kanzure | My django app needs to have custom configuration. Where should I put this? |
| 22:39 | [530] | kanzure: settings.py |
| 22:40 | kanzure | [530]: I added a variable to settings.py and it doesn't seem to be globally accessible throughout my project. |
| 22:40 | kanzure | [530]: what do I do? |
| 22:41 | sjl | kanzure: "from settings import your_var" doesn't work? |
| 22:41 | [530] | kanzure: um, globally how? |
| 22:41 | kanzure | sjl: okay, nevermind :) |
| 22:41 | kanzure | I'll do that from now on. |
| 22:41 | [530] | from django.conf import settings |
| 22:42 | SmileyChris | sjl: yeah, you shouldn't be accessing settings like that |
| 22:42 | sjl | SmileyChris: Why's that? |
| 22:42 | SmileyChris | sjl: if it's project level setting, you should be using the method [530] showed above |
| 22:43 | sjl | SmileyChris: That's what I figured you meant, but why? |
| 22:43 | SmileyChris | sjl: because who's to say the project is using that settings module? |
| 22:43 | SmileyChris | sjl: if you use from django.conf import settings, it's decoupled |
| 22:44 | sjl | SmileyChris: If I built the project, me, but I can see how a reusable app would want to use the other method |
| 22:45 | SmileyChris | sjl: you really shouldn't have your project's modules directly on the python path anyway, it makes for a messy namespace |
| 22:46 | SmileyChris | sjl: but yes, you are more than welcome to use whatever method you like - it's good to recommend best practices though ;) |
| 22:46 | sjl | So the default structure as recommended in the tutorial, etc is not the best one? |
| 22:46 | SmileyChris | sjl: the imports there use the project name |
| 22:47 | sjl | they don't have to -- "from myapp.models import whatever" always seems to work for me, which means that myapp is on the path |
| 22:48 | SmileyChris | that's because runserver does stupid things |
| 22:48 | SmileyChris | and it's not good |
| 22:48 | SmileyChris | and you're importing a separate copy of the module |
| 22:48 | kylef | SmileyChris: are you saying all app's should be INSIDE a project? |
| 22:48 | SmileyChris | kylef: no, if you're making generic apps then place them on the python path |
| 22:48 | sjl | And any other third-party apps should be copied/symlinked INSIDE a project and imported that way? |
| 22:49 | SmileyChris | i don't place them in the project module at all |
| 22:49 | SmileyChris | there should only be one way to import the module |
| 22:49 | kylef | neither do I, prefer to seperate everything. No linking to a project. |
| 22:50 | kylef | I made the mistake when I was learning python/django and had to go through bunch of files renaming stuff when I wanted to use the app on another project |
| 22:50 | sjl | so for some applications (third party/generic) you have them outside the project and import one way, and for other applications you have them inside and import another way? |
| 22:50 | SmileyChris | kylef: depends on the project - if the apps are one-off I'll usually keep them inside project.appname - unless i'm "virtualenv"ing, my repository normally contains src/ which gets added to the pythonpath (and contains the project and any standalone apps) |
| 22:51 | SmileyChris | sjl: yep, see above |
| 22:52 | sjl | so if you think an app is tied to a project then realize it's really more generic than you thought and you want to decouple it you get to go through and edit all the import statements inside? |
| 22:52 | SmileyChris | yes - find and replace is easy |
| 22:53 | [530] | sed to the rescue |
| 22:53 | SmileyChris | or ctrl-h in eclipse :) |
| 22:53 | SmileyChris | then you don't have to remember weird syntaxes |
| 22:54 | SmileyChris closes the can'o'worms lid | |
| 22:55 | [530] | find . -name \*.py -exec sed -i pye -e "s/project\.appname/appname/" {} \; :P |
| 22:57 | m1chael | how would i integrate jcrop in to the admin? |
| 22:58 | SmileyChris | m1chael: add the relevant js to the Media class of your form/modeladmin |
| 22:58 | SmileyChris | but really, i don't know what jcrop is |
| 22:59 | m1chael | |
| 23:00 | SmileyChris | m1chael: looking at what it is, seems like you'd be better making a custom view for your admin |
| 23:01 | m1chael | okay ive never done that before... ive done cgi type things before.. im still pretty new with all of this |
| 23:02 | davidcramer | Any canadians here who can tell me about pricing for a US citizen to go to a community college in Toronto area? :) |
| 23:05 | interstar | hi |
| 23:07 | interstar | can anyone explain what an error : ImportError('Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.',) means ? It's appeared when I try to import another file into my settings.py and that file imports django models. |
| 23:09 | ubernostrum | interstar: before you can make use of some components of Django (ORM, templates, etc.) settings must already be available. |
| 23:09 | ubernostrum | interstar: so trying to import something in settings which requires something which requires settings won't work. |
| 23:10 | interstar | ubernostrum so are you saying that I can't do anything with models in something imported into settings.py? |
| 23:13 | ubernostrum | interstar: I'm saying that if you need to import something in your settings file, it can't directly or indirectly make use of anything which requires settings to already be defined. |
| 23:14 | interstar | ubernostrum ok. thanks |
| 23:27 | jimi_hendrix | what may cause this error: invalid literal for int() with base 10: 'test' in get_db_prep_value |
| 23:29 | SmileyChris | jimi_hendrix: most likely, you're trying get a model where the field is an integer (usually the pk) using a string value |
| 23:29 | jimi_hendrix | pk? |
| 23:32 | jimi_hendrix | oo i see |
| 23:41 | pilgrim | Is the app django-profile ( http://bitbucket.org/ubernostrum/django-profile... ) same as this in the docs ( http://docs.djangoproject.com/en/dev/topics/aut... ). In other words, do I need to install django-profile ( http://bitbucket.org/ubernostrum/django-profile... ) or is in the django install? |
| 23:45 | pilgrim_ | Is the app django-profile ( http://bitbucket.org/ubernostrum/django-profile... ) same as this in the docs ( http://docs.djangoproject.com/en/dev/topics/aut... ). In other words, do I need to install django-profile ( http://bitbucket.org/ubernostrum/django-profile... ) or is in the django install? |
| 23:46 | kylef | pilgrim_: I belive they are two seperate things, I think django-profile takes care of views and urls for the profile auth module |
| 23:47 | pilgrim_ | kylef: k thanks |
| 23:47 | mattmcc | It adds functionality for using profiles. |
| 23:54 | polydektes | is there a way to build models.py around an already existing database? |
| 23:54 | mattmcc | inspectdb |
| 23:54 | mattmcc | It can guess, but you'll need to edit the result. |
| 23:55 | jimi_hendrix | is there something like get that returns a list of 0 or more objects |
| 23:56 | mattmcc | That would be filter. |
| 23:56 | mattmcc | Or any of a half dozen other queryset methods. |
| 23:57 | jimi_hendrix | if i did Model.objects.filter(username='foo') wouldnt that return foobar aswell |
| 23:57 | mattmcc | No, why would it? |
| 23:57 | jimi_hendrix | someone told me it would |
| 23:58 | mattmcc | You'd have to use a lookup filter such as contains or startswith for that. |
| 23:58 | mattmcc | filter(username__contains='foo') |
Page 11 of 11
← Previous
(1,085 total)