Problem serving files from media directory
Hello, I've deployed a new website to my staging and production servers but for some reason the images in the media directory are displaying 404 errors. The path to the image is correct and the image is located at that path: ls -la ~/.virtualenvs/website/project/media/projects/hair/2012/test-1 total 144 drwxr-x--- 2 username username 4096 Aug 27 16:43 . drwxr-x--- 3 username username 4096 Aug 27 16:43 .. -rwxrwxr-x 1 username username 131719 Aug 27 16:43 13221803.jpg settings.py: MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') MEDIA_URL = '/media/' Am I having problems because the image file is nested within other directories? Files are being served from the static directory just fine, any ideas? Thanks, Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Kk3KOw-L4RQJ. 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.
Problem serving files from media directory
Hello, I've deployed a new website to my staging and production servers but for some reason the images in the media directory are displaying 404 errors. The path to the image is correct and the image is located at that path: ls -la ~/.virtualenvs/website/project/media/projects/hair/2012/test-1 total 144 drwxr-x--- 2 leahbc leahbc 4096 Aug 27 16:43 . drwxr-x--- 3 leahbc leahbc 4096 Aug 27 16:43 .. -rwxrwxr-x 1 leahbc leahbc 131719 Aug 27 16:43 13221803.jpg settings.py: MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') MEDIA_URL = '/media/' Am I having problems because the image file is nested within other directories? Files are being served from the static directory just fine, any ideas? Thanks, Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/bPRXOIJRoPAJ. 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: 404 only in Chrome
I think it might be related to a jquery plugin i'm using. It appears that the plugin is not finding an attribute on an image, and is therefore appending the undefined status to the url in developer tools. If I comment out the plugin the error is gone. On Dec 10, 7:36 am, Tomasz Zielińskiwrote: > Can it be a browser caching > issue:http://www.google.pl/support/forum/p/Chrome/thread?tid=3bb0a94bfb0637... > ? > > Best, > Tomasz Zielinski -- 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: 404 only in Chrome
Thanks for the reply but that didn't help. On Dec 9, 5:41 pm, Furbee <furbeena...@gmail.com> wrote: > In urls.py: > > Change: > (r'^portfolio/', include('project.urls.web')), > > To: > (r'^portfolio/$', include('project.urls.web')), > > The dollar sign makes it the end of the regular expression string. Without > it, /portfolio/ will match with /portfolio/funstuff, > /portfolio/?my_hax_rock, etc. See if that helps. > > Furbee > > > > > > > > On Fri, Dec 9, 2011 at 5:33 PM, neridaj <neri...@gmail.com> wrote: > > Hello, > > > For some reason I'm getting a 404 in google chrome when I visit / > > portfolio/. The url entered is /portfolio/ but it returns as a 404 at / > > portfolio/undefined/ in the chrome developer tools window. I read a > > post about some issues with chrome handling errors and to resolve it > > by unchecking "Use a web service to help resolve navigation errors" > > but this didn't help with my problem. I'm not sure why undefined is > > being appended to the url, any ideas? > > > urls.py: > > > (r'^portfolio/', include('project.urls.web')), > > > project/urls/web.py: > > > urlpatterns = patterns('django.views.generic.list_detail', > > (r'^$', 'object_list', web_project_info_dict, > > 'project_web_archive_index'), > > (r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict), > > ) > > > If it was a real 404 why isn't my error page displayed i.e., when I > > visit /portfolio/non-existent-slug, I get the proper 404 page. > > > >>> django.VERSION > > (1, 2, 0, 'alpha', 0) > > > Thanks for any help! > > > -- > > 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. -- 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.
404 only in Chrome
Hello, For some reason I'm getting a 404 in google chrome when I visit / portfolio/. The url entered is /portfolio/ but it returns as a 404 at / portfolio/undefined/ in the chrome developer tools window. I read a post about some issues with chrome handling errors and to resolve it by unchecking "Use a web service to help resolve navigation errors" but this didn't help with my problem. I'm not sure why undefined is being appended to the url, any ideas? urls.py: (r'^portfolio/', include('project.urls.web')), project/urls/web.py: urlpatterns = patterns('django.views.generic.list_detail', (r'^$', 'object_list', web_project_info_dict, 'project_web_archive_index'), (r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict), ) If it was a real 404 why isn't my error page displayed i.e., when I visit /portfolio/non-existent-slug, I get the proper 404 page. >>> django.VERSION (1, 2, 0, 'alpha', 0) Thanks for any help! -- 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: Serving static files weirdness
Got it working by changing the following: STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( # Put strings here, like "/home/html/static" or "C:/www/django/ static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. os.path.join(PROJECT_ROOT, 'static'), ) On Jul 8, 2:47 pm, neridaj <neri...@gmail.com> wrote: > I'm using Django version 1.3 and the Django devserver. My admin media > is the default: ADMIN_MEDIA_PREFIX = '/static/admin/' > > On Jul 8, 1:49 am, bruno desthuilliers <bruno.desthuilli...@gmail.com> > wrote: > > > > > > > > > On Jul 8, 4:40 am, neridaj <neri...@gmail.com> wrote: > > > > I had mystaticfiles being served form media i.e., the tree looked > > > like this: > > > > media/ > > > /css > > > /js > > > /images > > > > with this in my url conf: > > > if settings.SERVE_MEDIA_FROM_DJANGO: > > > urlpatterns += patterns('', > > > (r'^media/(?P.*)$', 'django.views.static.serve', > > > {'document_root': r'media'}), > > > (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', > > > { 'document_root': r'media/js/tiny_mc' }), > > > ) > > > > I then switched it to this: > > > >static/ > > > /css > > > /js > > > /images > > > > with this in my url conf: > > > if settings.SERVE_MEDIA_FROM_DJANGO: > > > urlpatterns += patterns('', > > > (r'^static/(?P.*)$', 'django.views.static.serve', > > > {'document_root': r'static'}), > > > (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', > > > { 'document_root': r'static/js/tiny_mc' }), > > > ) > > > > I don't understand why changing media tostatichas stopped django > > > fromservingstaticfiles, any ideas? > > > settings.MEDIA_URL and MEDIA_ROOT ? -- 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: Serving static files weirdness
I'm using Django version 1.3 and the Django devserver. My admin media is the default: ADMIN_MEDIA_PREFIX = '/static/admin/' On Jul 8, 1:49 am, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On Jul 8, 4:40 am, neridaj <neri...@gmail.com> wrote: > > > > > > > > > > > I had mystaticfiles being served form media i.e., the tree looked > > like this: > > > media/ > > /css > > /js > > /images > > > with this in my url conf: > > if settings.SERVE_MEDIA_FROM_DJANGO: > > urlpatterns += patterns('', > > (r'^media/(?P.*)$', 'django.views.static.serve', > > {'document_root': r'media'}), > > (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', > > { 'document_root': r'media/js/tiny_mc' }), > > ) > > > I then switched it to this: > > >static/ > > /css > > /js > > /images > > > with this in my url conf: > > if settings.SERVE_MEDIA_FROM_DJANGO: > > urlpatterns += patterns('', > > (r'^static/(?P.*)$', 'django.views.static.serve', > > {'document_root': r'static'}), > > (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', > > { 'document_root': r'static/js/tiny_mc' }), > > ) > > > I don't understand why changing media tostatichas stopped django > > fromservingstaticfiles, any ideas? > > settings.MEDIA_URL and MEDIA_ROOT ? -- 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.
Serving static files weirdness
I had my static files being served form media i.e., the tree looked like this: media/ /css /js /images with this in my url conf: if settings.SERVE_MEDIA_FROM_DJANGO: urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': r'media'}), (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', { 'document_root': r'media/js/tiny_mc' }), ) I then switched it to this: static/ /css /js /images with this in my url conf: if settings.SERVE_MEDIA_FROM_DJANGO: urlpatterns += patterns('', (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': r'static'}), (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', { 'document_root': r'static/js/tiny_mc' }), ) I don't understand why changing media to static has stopped django from serving static files, any ideas? Cheers, J -- 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.
Work around restarting server on image uploads?
Hello, Is there a way to get uploaded images to render without having to restart the server? Whenever I add a new image via the admin interface I have to restart apache in order for the images to render. Thanks, Jason -- 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.
mysql -> sqlite3 migration error
I'm trying migrate some tables for the first time and I'm not sure how to resolve this error. It looks like things fail when this file is called: films:0006_migrate_country, which in turn is failing to create the films_filmdistribution table. Any thought on how to resolve this? Thanks for any help. Not synced (use migrations): - quiz - accounts - purchasedstreams - django_facebook - gifts - films - mediadb - store - subscription - testimonials - majorfest - juries - members - streamevents - splash - box (use ./manage.py migrate to migrate these) Exception TypeError: "'NoneType' object is not callable" in > ignored (project_name)jason-neridas-macbook-4:project_name username$ ./ manage.py migrate --settings=stages.dev.settings /Users/username/project_name/project/project_name/dependencies/ django_jsonapi/models.py:4: DeprecationWarning: the sha module is deprecated; use the hashlib module instead import sha, time Running migrations for quiz: - Migrating forwards to 0001_initial. > quiz:0001_initial - Loading initial data for quiz. No fixtures found. Running migrations for accounts: - Migrating forwards to 0002_add_postal_and_country. > accounts:0001_initial > accounts:0002_add_postal_and_country - Loading initial data for accounts. No fixtures found. Running migrations for purchasedstreams: - Migrating forwards to 0002_import_from_films. > purchasedstreams:0001_initial > films:0001_initial > purchasedstreams:0002_import_from_films - Loading initial data for purchasedstreams. No fixtures found. Running migrations for django_facebook: - Migrating forwards to 0004_bigger_tokens. > django_facebook:0001_initial > django_facebook:0002_add_permissions_request > django_facebook:0003_update_permissions_request > django_facebook:0004_bigger_tokens - Loading initial data for django_facebook. No fixtures found. Running migrations for gifts: - Migrating forwards to 0007_add_code_pools. > gifts:0001_initial > gifts:0002_modify_urls_to_noverify > gifts:0003_add_code_pools > gifts:0004_allow_blanks_in_codes > gifts:0005_allow_blanks_in_coupon_desc > gifts:0006_add_code_pools > gifts:0007_add_code_pools - Loading initial data for gifts. No fixtures found. Running migrations for films: - Migrating forwards to 0013_drop_old_distributions. > splash:0001_initial > splash:0002_import_slides_from_films > streamevents:0001_initial > streamevents:0002_transfer_from_films > films:0002_drop_streamlog > films:0003_drop_stream > films:0004_delete_slides > films:0005_add_country > films:0006_migrate_country Traceback (most recent call last): File "./manage.py", line 12, in execute_manager(settings) File "/Users/username/project_name/project/django/core/management/ __init__.py", line 438, in execute_manager utility.execute() File "/Users/username/project_name/project/django/core/management/ __init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/username/project_name/project/django/core/management/ base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/Users/username/project_name/project/django/core/management/ base.py", line 218, in execute output = self.handle(*args, **options) File "/Users/username/src/south/south/management/commands/ migrate.py", line 105, in handle ignore_ghosts = ignore_ghosts, File "/Users/username/src/south/south/migration/__init__.py", line 191, in migrate_app success = migrator.migrate_many(target, workplan, database) File "/Users/username/src/south/south/migration/migrators.py", line 221, in migrate_many result = migrator.__class__.migrate_many(migrator, target, migrations, database) File "/Users/username/src/south/south/migration/migrators.py", line 292, in migrate_many result = self.migrate(migration, database) File "/Users/username/src/south/south/migration/migrators.py", line 125, in migrate result = self.run(migration) File "/Users/username/src/south/south/migration/migrators.py", line 99, in run return self.run_migration(migration) File "/Users/username/src/south/south/migration/migrators.py", line 81, in run_migration migration_function() File "/Users/username/src/south/south/migration/migrators.py", line 57, in return (lambda: direction(orm)) File "/Users/username/project_name/project/django/db/ transaction.py", line 299, in _commit_on_success res = func(*args, **kw) File "/Users/username/project_name/project/project_name/modules/ films/migrations/0006_migrate_country.py", line 17, in forwards for film in Film.objects.select_related('contact').all(): File "/Users/username/project_name/project/django/db/models/ query.py", line 106, in _result_iter self._fill_cache() File "/Users/username/project_name/project/django/db/models/ query.py", line 760, in _fill_cache self._result_cache.append(self._iter.next()) File "/Users/username/project_name/project/django/db/models/
Re: ProgrammingError: relation "project_webproject" does not exist
I restarted my server and the images now display. I don't understand why I need to do that for the images to show up. On Mar 17, 12:30 pm, neridaj <neri...@gmail.com> wrote: > Hello, > > I've been working on a portfolio website that includes an app called > projects. Within this app are the models WebProject and ScreenShot for > project info and related screenshots for display on the portfolio > page. Everything has been working fine up until now, when I try to add > another project. I'm able to add the project and related screenshots > without error but the images for the new project are not being found > when the page is displayed, while the two previous projects display > fine. > > When I view the postgresql db tables all the info is there, however, > when I query the tables from within the django interactive shell I'm > getting errors when I try to do a simple select. I tried running > syncdb but that didn't help. I don't have a ton of data in the db yet > so I've been considering dumping the tables but what if this happens a > year down the road, any ideas? > > >>> wp = WebProject.objects.get(id=1) > > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py", > line 120, in get > return self.get_query_set().get(*args, **kwargs) > File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", > line 300, in get > num = len(clone) > File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", > line 81, in __len__ > self._result_cache = list(self.iterator()) > File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", > line 238, in iterator > for row in self.query.results_iter(): > File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ > query.py", line 287, in results_iter > for rows in self.execute_sql(MULTI): > File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ > query.py", line 2369, in execute_sql > cursor.execute(sql, params) > File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", > line 19, in execute > return self.cursor.execute(sql, params) > ProgrammingError: relation "project_webproject" does not exist > > or... > > >>> e = Entry.objects.get(id=1) > > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py", > line 120, in get > return self.get_query_set().get(*args, **kwargs) > File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", > line 300, in get > num = len(clone) > File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", > line 81, in __len__ > self._result_cache = list(self.iterator()) > File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", > line 238, in iterator > for row in self.query.results_iter(): > File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ > query.py", line 287, in results_iter > for rows in self.execute_sql(MULTI): > File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ > query.py", line 2369, in execute_sql > cursor.execute(sql, params) > File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", > line 19, in execute > return self.cursor.execute(sql, params) > InternalError: current transaction is aborted, commands ignored until > end of transaction block -- 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.
ProgrammingError: relation "project_webproject" does not exist
Hello, I've been working on a portfolio website that includes an app called projects. Within this app are the models WebProject and ScreenShot for project info and related screenshots for display on the portfolio page. Everything has been working fine up until now, when I try to add another project. I'm able to add the project and related screenshots without error but the images for the new project are not being found when the page is displayed, while the two previous projects display fine. When I view the postgresql db tables all the info is there, however, when I query the tables from within the django interactive shell I'm getting errors when I try to do a simple select. I tried running syncdb but that didn't help. I don't have a ton of data in the db yet so I've been considering dumping the tables but what if this happens a year down the road, any ideas? >>> wp = WebProject.objects.get(id=1) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py", line 120, in get return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 300, in get num = len(clone) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 81, in __len__ self._result_cache = list(self.iterator()) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 238, in iterator for row in self.query.results_iter(): File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ query.py", line 287, in results_iter for rows in self.execute_sql(MULTI): File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ query.py", line 2369, in execute_sql cursor.execute(sql, params) File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) ProgrammingError: relation "project_webproject" does not exist or... >>> e = Entry.objects.get(id=1) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py", line 120, in get return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 300, in get num = len(clone) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 81, in __len__ self._result_cache = list(self.iterator()) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 238, in iterator for row in self.query.results_iter(): File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ query.py", line 287, in results_iter for rows in self.execute_sql(MULTI): File "/usr/lib/python2.6/dist-packages/django/db/models/sql/ query.py", line 2369, in execute_sql cursor.execute(sql, params) File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) InternalError: current transaction is aborted, commands ignored until end of transaction block -- 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.
generic view confusion
I don't understand why my template_object_name is empty in a generic object_list view. I'm trying to grab all the category names and urls from my Category model but it's turning up empty, at least {{ category_list|length }} yields 0. I'm trying to add this info to the sidebar of a generic object_list view for art projects, so I'm giving the view the template_name and the template_object_name to avoid confusion with the generic view it will be included in - already using the default object_list and app/model_list.html for the main content. Thanks for any help. # URL # from django.conf.urls.defaults import * from project.models import Category project_info_dict = { 'queryset': Category.objects.all(), 'template_name': 'portfolioproject_list.html', 'template_object_name': 'category', } urlpatterns = patterns('', (r'^$', 'django.views.generic.list_detail.object_list', project_info_dict, 'category_list'), (r'^(?P[-\w]+)/$', 'project.views.category_detail', {}, 'category_detail'), ) # TEMPLATE # {% block sidebar %} Categories {% for category in category_list %} {{ category }} {% endfor %} {% endblock %} -- 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.
Problems with PIL after upgrading to OSX 10.6.2
I'm having problems with PIL after upgrading to OSX 10.6.2 and was wondering if anyone else had similar issues or found a fix. I'm getting the error: The _imaging C module is not installed, so I tried reinstalling PIL which resulted in the following error: lipo: can't figure out the architecture type of: /var/folders/Sc/ScD +ointGXqPrmBQ19Uc2k+++TI/-Tmp-//ccrzTUKs.out error: command 'gcc' failed with exit status 1 If any other mac users have had this problem I would appreciate any input. Thanks, Jason -- 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.
how to define DJANGO_SETTINGS_MODULE for multiple sites.
I'm trying to setup my first cron job and I think the reason my script is not running is because I don't have DJANGO_SETTINGS_MODULE defined for my environment i.e., .profile script. I'm using mod_wsgi so my DJANGO_SETTINGS_MODULE is defined in the respective wsgi file for each site, so my question is how do I setup a crontab that imports the correct settings module? I tried this but no luck: * * * * * django-admin.py shell --settings=sitename.settings /home/ username/cron/syncr.py >> /home/username/croninfo.txt Thanks, Jason -- 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.
DJANGO_SETTINGS_MODULE is undefined
I'm getting this error even though my DJANGO_SETTINGS_MODULE is defined in my wsgi file: import os, sys sys.path.append('/home/username/public_html/mysite.com') sys.path.append('/home/username/public_html/mysite.com/mysite') os.environ['PYTHON_EGG_CACHE'] = '/home/username/public_html/ mysite.com/.python-eggs' os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() def application(environ, start_response): environ['wsgi.url_scheme'] = environ.get('HTTP_X_URL_SCHEME', 'http') return _application(environ, start_response) ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. -- 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.
Practical Django Projects blog app admin not showing entries with draft status
I'm following along James Bennett's tutorials and when I save an entry as a draft it doesn't show up in the admin interface for further editing. When I log in with psql I can see the draft in the database but the admin doesn't show the draft in the entries, however the draft is listed in the Tagged Items table. HOw do I get the draft to show up in the entries, do I need to add something to the admin.py file for the blog app? class EntryAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('title',)} Thanks for any help, Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: contrib.comments get_absolute_url raising 404 only on remote server
Thanks, man, that was it. On Jan 12, 3:39 am, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On 12 jan, 03:32, neridaj <neri...@gmail.com> wrote: > > > I've been testing my site locally and figured I should commit some of > > my changes. I'm using django.contrib.comments and for some reason the > > comment.get_absolute_url is resulting in a broken link on the live > > server. When I mouse over the link the status bar reads the link > > correctly i.e.,http://mysite.com/comments/cr/12/1/#c5butwhen I > > click the link the result > > ishttp://example.com/blog/2010/jan/11/test-title-1/#c5 > > resulting in: The requested URL /blog/2010/jan/11/test-title-1/ was > > not found on this server. If I manually type in my domain instead of > > example.com it works as it should, I just don't understand why it's > > not resolving with mysite.com. > > > Thanks, > > Wild guess : you have the Site app activated, and didn't edit the site > record that Comment is using to build the absolute_url. > > My 2 cents... > > > Jason > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Updated to revision 12207, now CSRF verification failed. Request aborted.
I guess I had to add the middleware even though I'm using django.contrib.comments and generic views? On Jan 11, 7:12 pm, neridaj <neri...@gmail.com> wrote: > what's up with this now. I'm suing contrib apps and generic views > i.e., no middleware needed, and I've added {% csrf_token %} to my POST > forms but can't get rid of this. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Updated to revision 12207, now CSRF verification failed. Request aborted.
what's up with this now. I'm suing contrib apps and generic views i.e., no middleware needed, and I've added {% csrf_token %} to my POST forms but can't get rid of this. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
contrib.comments get_absolute_url raising 404 only on remote server
I've been testing my site locally and figured I should commit some of my changes. I'm using django.contrib.comments and for some reason the comment.get_absolute_url is resulting in a broken link on the live server. When I mouse over the link the status bar reads the link correctly i.e., http://mysite.com/comments/cr/12/1/#c5 but when I click the link the result is http://example.com/blog/2010/jan/11/test-title-1/#c5 resulting in: The requested URL /blog/2010/jan/11/test-title-1/ was not found on this server. If I manually type in my domain instead of example.com it works as it should, I just don't understand why it's not resolving with mysite.com. Thanks, Jason -- 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.
context processor var empty
I'm trying to use a context processor to make all of my blog entry titles available for an ajax autocomplete search box but for some reason the var returned from the context processor is empty. from blog.models import Entry # search/context_processors.py def search(request): data = Entry.objects.all() return { 'data': data } # settings.py TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "search.context_processors.search", ) # base.html $(document).ready(function(){ var data = "{{ data }}".split(":"); $("#id_q").autocomplete(data); }); # base.html rendered $(document).ready(function(){ var data = "".split(":"); $("#id_q").autocomplete(data); }); -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: why does if statement fail with
Template error: In template /Users/username/django-sites/username.com/public/templates/ tagging/tag_list.html, error at line 17 'if' statement improperly formatted 7 : {{ object.name }} 8 : 9 : 10 : {% endfor %} 11 : 12 : 13 : {% if page_obj.has_previous %} 14 : previous 15 : {% endif %} 16 : 17 : {% if page_obj.number < paginator.count %} 18 : 19 : {% endif %} 20 : 21 : {{ paginator.count }} 22 : 23 : 24 : Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. 25 : 26 : 27 : {% if page_obj.has_next %} Traceback: File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/views/generic/list_detail.py" in object_list 100. t = template_loader.get_template(template_name) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/loader.py" in get_template 82. template = get_template_from_string(source, origin, template_name) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/loader.py" in get_template_from_string 90. return Template(source, origin, name) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/__init__.py" in __init__ 168. self.nodelist = compile_string(template_string, origin) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/__init__.py" in compile_string 189. return parser.parse() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/__init__.py" in parse 285. compiled_result = compile_func(self, token) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/loader_tags.py" in do_extends 169. nodelist = parser.parse() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/__init__.py" in parse 285. compiled_result = compile_func(self, token) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/loader_tags.py" in do_block 147. nodelist = parser.parse(('endblock', 'endblock %s' % block_name)) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/__init__.py" in parse 285. compiled_result = compile_func(self, token) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/template/defaulttags.py" in do_if 822. raise TemplateSyntaxError, "'if' statement improperly formatted" Exception Type: TemplateSyntaxError at /tags/page1/ Exception Value: 'if' statement improperly formatted On Jan 8, 5:52 pm, Justin Stewardwrote: > On Fri, Jan 8, 2010 at 1:25 PM, Biju Varghese wrote: > > if statement in template language checks only whether the variable is > > empty or not... > > comparison can be done with other variants of if such as ifequals > > ifnotequal etc... > > OP is using django > 1.2.http://docs.djangoproject.com/en/dev/releases/1.2-alpha-1/#smart-if-tag > > ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: why does if statement fail with
Yeah, I guess an error would help, oops. I just get 'if' statement improperly formatted. This is the only if statement that has failed. On Jan 7, 9:13 pm, Russell Keith-Magee <freakboy3...@gmail.com> wrote: > On Fri, Jan 8, 2010 at 1:10 PM, neridaj <neri...@gmail.com> wrote: > > I'm using 1.2: > > >>>> django.VERSION > > (1, 2, 0, 'alpha', 0) > > In which case you're going to need to give us some debug information. > "It doesn't work" isn't especially helpful. Django has a very healthy > test suite, if comparisons are covered by that test suite, and the > test suite is currently passing, so as far as we are aware, > comparisons are working fine. > > What error are you seeing? Do if comparisons fail all the time, or > just on that statement? > > We can't help you unless you help us help you. > > Yours, > Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: why does if statement fail with
I'm using 1.2: >>> django.VERSION (1, 2, 0, 'alpha', 0) On Jan 7, 8:54 pm, Russell Keith-Magee <freakboy3...@gmail.com> wrote: > On Fri, Jan 8, 2010 at 12:50 PM, Eric Abrahamsen <gir...@gmail.com> wrote: > > > On Jan 8, 2010, at 12:28 PM, neridaj wrote: > > >> Can anyone tell me why this less than symbol is causing this if > >> statement to fail? > > >> {% if page_obj.number|add:"4" < paginator.count %} > > >> {% endif %} > > > Because the if tag doesn't accept comparison operators. If you're trying to > > make a more complex pagination mechanism, you'll probably want to set it up > > in the view, or use a custom template tag… > > ... unless, of course, you're using the 1.2 alpha or trunk version of > Django. Django 1.2 will include support for comparison operators in if > tags. > > Yours, > Russ Magee %-) -- 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.
why does if statement fail with
Can anyone tell me why this less than symbol is causing this if statement to fail? {% if page_obj.number|add:"4" < paginator.count %} {% endif %} Cheers, J -- 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.
Totally confused on categorized feeds
I've been following along James Bennett's Practical Django Projects and I'm confused on how to render a template with the correct url that maps to the urlconf for categorized feeds. I understand that the url needs to be in the form feeds/categories/audio but how do I build this url in the template without hard coding it? I've tried the following: urlconf: feeds = { 'entries': LatestEntriesFeed, 'links': LatestLinksFeed, 'categories': CategoryFeed, 'tweets': LatestTweetsFeed } (r'^feeds/categories/(?P.*)/$', 'django.contrib.syndication.views.feed', { 'feed_dict': feeds }, 'category_feed'), in the template: {{ category.title }} which yields: Slug u'audio' isn't registered. -- because categories needs to be passed in to ...and (r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed', { 'feed_dict': feeds }, 'category_feed'), which results in a malformed url: /feeds//categories/audio// Thanks for any help, J -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: local variable 'delta' referenced before assignment
I guess I was mixing tabs and spaces, thanks guys. On Dec 29, 3:38 pm, Ramiro Morales <cra...@gmail.com> wrote: > On Tue, Dec 29, 2009 at 8:31 PM, neridaj <neri...@gmail.com> wrote: > > File "/Users/jasonnerida/django-apps/blog/models.py" in > > moderate_comment > > 142. if delta.days > 30: > > I suspect you have the above line badly indented, > e.g. at the same level of the > > if not instance.id: > > line because it appears to have eight spaces in the traceback, > assuming you use 4 space tab-stops. That would explain > the problem you are seeing. > > Maybe you are mixing tabs and spaces and you aren't > seeing them in you editor? > > PS: You will need to stat posting thin kind of questions to > your favorite friendly Python mailing list/IRC channel. > > -- > Ramiro Morales | http://rmorales.net -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: local variable 'delta' referenced before assignment
Traceback: File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/views/decorators/http.py" in inner 37. return func(request, *args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/contrib/comments/views/comments.py" in post_comment 110. comment.save() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/contrib/comments/models.py" in save 85. super(Comment, self).save(force_insert, force_update) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/db/models/base.py" in save 410. self.save_base(force_insert=force_insert, force_update=force_update) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/db/models/base.py" in save_base 432. signals.pre_save.send(sender=origin, instance=self, raw=raw) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ site-packages/django/dispatch/dispatcher.py" in send 166. response = receiver(signal=self, sender=sender, **named) File "/Users/jasonnerida/django-apps/blog/models.py" in moderate_comment 142. if delta.days > 30: Exception Type: UnboundLocalError at /comments/post/ Exception Value: local variable 'delta' referenced before assignment On Dec 29, 3:29 pm, Chris Withers <ch...@simplistix.co.uk> wrote: > neridaj wrote: > > I don't see why this error is happening, the var is assigned. > > > def moderate_comment(sender, **kwargs): > > instance = kwargs['instance'] > > if not instance.id: > > content = instance.content_object > > if isinstance(content, Tweet): > > delta = datetime.datetime.now() - content.pub_time > > else: > > delta = datetime.datetime.now() - content.pub_date > > if delta.days > 30: #failure > > > local variable 'delta' referenced before assignment > > Please post a full traceback. > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > -http://www.simplistix.co.uk -- 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.
local variable 'delta' referenced before assignment
I don't see why this error is happening, the var is assigned. def moderate_comment(sender, **kwargs): instance = kwargs['instance'] if not instance.id: content = instance.content_object if isinstance(content, Tweet): delta = datetime.datetime.now() - content.pub_time else: delta = datetime.datetime.now() - content.pub_date if delta.days > 30: #failure local variable 'delta' referenced before assignment Thanks, Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: don't understand why isinstance returns false
fixed. On Dec 29, 1:38 pm, neridaj <neri...@gmail.com> wrote: > def moderate_comment(sender, **kwargs): > instance = kwargs['instance'] > if not instance.id: > content = instance.content_object > if isinstance(content, Tweet): > delta = datetime.datetime.now() - content.pub_time > delta = datetime.datetime.now() - content.pub_date > > Exception Value: > > 'Tweet' object has no attribute 'pub_date' -- 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.
don't understand why isinstance returns false
def moderate_comment(sender, **kwargs): instance = kwargs['instance'] if not instance.id: content = instance.content_object if isinstance(content, Tweet): delta = datetime.datetime.now() - content.pub_time delta = datetime.datetime.now() - content.pub_date Exception Value: 'Tweet' object has no attribute 'pub_date' -- 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.
mapping url to feed
I'm trying to retrieve blog entries for a specific category and I'm not sure how to generate the correct url in my template. here is what I have: {{ category.title }} feeds = { 'entries': LatestEntriesFeed, 'links': LatestLinksFeed, 'categories': CategoryFeed, 'tweets': LatestTweetsFeed } (r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed', { 'feed_dict': feeds }, 'category_feed'), I think I need to have "categories/category.title" to correctly map to "feeds/categories/category.title" but I'm not sure how/if I should do that in the template. Thanks for any help, J -- 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.
mapping url to feed
I'm trying to retrieve blog entries for a specific category and I'm not sure how to generate the correct url in my template. here is what I have: {{ category.title }} feeds = { 'entries': LatestEntriesFeed, 'links': LatestLinksFeed, 'categories': CategoryFeed, 'tweets': LatestTweetsFeed } (r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed', { 'feed_dict': feeds }, 'category_feed'), I think I need to have "categories/category.title" to correctly map to "feeds/categories/category.title" but I'm not sure how/if I should do that in the template. Thanks for any help, J -- 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.
get_absolute_url not recognized
I'm trying to add a get_absolute_url method to a Tweet model from django-syncr and do not understand why the method is not recognized. class Tweet(models.Model): pub_time= models.DateTimeField() twitter_id = models.PositiveIntegerField() text= models.TextField() user= models.ForeignKey('TwitterUser') def __unicode__(self): return u'%s %s' % (self.user.screen_name, self.pub_time) def url(self): return u'http://twitter.com/%s/statuses/%s' % (self.user.screen_name, self.twitter_id) @models.permalink def get_absolute_url(self): return ('blog_tweet_detail', (), { 'year': self.pub_time.strftime ("%Y"), 'month': self.pub_time.strftime("%b").lower(), 'day': self.pub_time.strftime("%d"), 'slug': self.tweet.twitter_id }) >>> from syncr.twitter.models import Tweet >>> t = Tweet.objects.get(pk=1) >>> t >>> t.url > >>> t.get_absolute_url Traceback (most recent call last): File "", line 1, in AttributeError: 'Tweet' object has no attribute 'get_absolute_url' -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Hosting for django?
I was on Dreamhost for a while but once I needed to install 3rd party modules I ran into problems. I've since switched to Slicehost VPS - http://www.slicehost.com/ and would definitely recommend them. If I was going with shared hosting I would probably use Webfaction - http://www.webfaction.com/ On Dec 22, 11:08 am, Victor Loureiro Limawrote: > Amazon's Cloud Computing is wonderful, its currently hosting our django > website. > Media Temple is also a good option. > > att, > victor lima > > 2009/12/22 yummy_droid > > > Hi, > > > Has anyone had good experiences with hosting companies that I can use > > for production django apps, with backups, etc.? > > > I would also want to add some extensions etc. as well (e.g. > > matplotlib, reportlab, etc.). > > > Anyone use godaddy? > > > Thanks. > > > -- > > > 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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: stringformat in {% url %}
nevermind, I'm doing this a different way. On Dec 15, 1:46 pm, neridaj <neri...@gmail.com> wrote: > Hello, > > I'm trying to format a variable inside a {% url %} tag with > stringformat but I can't get it right. All I want to do is concatenate > a pound sign (#) to an id i.e., "#123456789", here is what I have: > > > > Thanks for any help, > > J -- 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.
stringformat in {% url %}
Hello, I'm trying to format a variable inside a {% url %} tag with stringformat but I can't get it right. All I want to do is concatenate a pound sign (#) to an id i.e., "#123456789", here is what I have: Thanks for any help, J -- 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.
ImportError: cannot import name Decimal
I'm using nginx, apache2/wsgi and if anyone can help me out I would appreciate it. The site in question was running fine until I added another vhost to my config. Now, the new site is down, though the other domain is fine, and I get the Decimal ImportError, here is the Traceback: Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/usr/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 439, in execute_manager utility.execute() File "/usr/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 380, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 257, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 67, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/usr/lib/python2.6/dist-packages/satchmo_store/shop/ management/ commands/satchmo_check.py", line 4, in from decimal import Decimal File "/usr/lib/python2.6/decimal.py", line 138, in import numbers as _numbers File "/home/neridaj/src/satchmo-trunk/satchmo/apps/satchmo_utils/ numbers.py", line 1, in from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, InvalidOperation, getcontext ImportError: cannot import name Decimal I made some adjustments to my vhost config and here is that file: ServerName mysite.com ServerAdmin supp...@mysite.com ServerAlias www.mysite.com WSGIScriptAlias / /home/username/public_html/mysite.com/mysite.wsgi WSGIDaemonProcess mysite.com threads=5 display-name=%{GROUP} python- path=/usr/lib/python2.6/dist-packages WSGIProcessGroup mysite.com # Custom log file locations LogLevel warn ErrorLog /home/username/public_html/mysite.com/logs/error.log CustomLog /home/username/public_html/mysite.com/logs/access.log combined XSendFile on XSendFileAllowAbove on RPAFenable On RPAFsethostname On RPAFproxy_ips 127.0.0.1 Thanks for any help, J -- 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.
django-tagging - how to retrieve individual tags for specific models without duplicates
Hello, I can't figure out how to retrieve tags for specific models i.e., I would like to show tags for entries if I'm on a blog/entry page, tags for links if I'm on a blog/links page, etc. If I use {{ entry.tags }} in the templates I get duplicate tags and if an entry has more than one tag those tags wind up on the same line e.g., audio, audiodev, audiotrack, audio, audiodev, audio, I've been trying to query the TaggedItems model in order to get the related content_type i.e., entry, link, etc. in order to get the related tags individually but I don't understand how to a) get the tags, and b) remove duplicates. Essentially I want this TaggedItem.objects.filter(content_type='entry') and then to be able to remove duplicates. TaggedItems has these relationships: tag = models.ForeignKey(Tag, verbose_name=_('tag'), related_name='items') content_type = models.ForeignKey(ContentType, verbose_name=_ ('content type')) object_id= models.PositiveIntegerField(_('object id'), db_index=True) object = generic.GenericForeignKey('content_type', 'object_id') Thanks for any help, Jason -- 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.
django-syncr - twitter.User.profile_image_url - deprecated attribute?
Hello, I'm just curious if anyone else has run into this problem using the twitter app in django-syncr. I looked on the twitter API docs but didn't find anything. t.syncTwitterUserTweets('twitteruser') Traceback (most recent call last): File "", line 1, in File "/Users/user/django-apps/syncr/app/tweet.py", line 111, in syncTwitterUserTweets self._syncTwitterStatus(status) File "/Users/user/django-apps/syncr/app/tweet.py", line 81, in _syncTwitterStatus user = self._syncTwitterUser(status.user) File "/Users/user/django-apps/syncr/app/tweet.py", line 55, in _syncTwitterUser 'thumbnail_url': user.profile_image_url, AttributeError: 'User' object has no attribute 'profile_image_url' Thanks, Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: page_obj not in template
nevermind, I figured it out. On Dec 3, 4:06 pm, neridaj <neri...@gmail.com> wrote: > Hello, > > I'm trying to display {{ page_obj }} in a template but for some reason > it is empty. Is there something wrong with my code: > > from django.conf.urls.defaults import * > from django.views.generic.list_detail import object_list, > object_detail > from coderepos.models import Snippet > > snippet_info = { 'queryset': Snippet.objects.all() } > > urlpatterns = patterns('', > url(r'^$', object_list, dict(snippet_info, paginate_by=20), > name='coderepos_snippet_list'), > url(r'^(?P\d+)/$', object_detail, snippet_info, > name='coderepos_snippet_detail'), > ) > > {% extends "base.html" %} > > {{ page_obj }}; > {% if page_obj.has_previous %} > Previous page > {% endif %} > {% if page_obj.has_next_page %} > Next page > {% endif %} -- 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.
page_obj not in template
Hello, I'm trying to display {{ page_obj }} in a template but for some reason it is empty. Is there something wrong with my code: from django.conf.urls.defaults import * from django.views.generic.list_detail import object_list, object_detail from coderepos.models import Snippet snippet_info = { 'queryset': Snippet.objects.all() } urlpatterns = patterns('', url(r'^$', object_list, dict(snippet_info, paginate_by=20), name='coderepos_snippet_list'), url(r'^(?P\d+)/$', object_detail, snippet_info, name='coderepos_snippet_detail'), ) {% extends "base.html" %} {{ page_obj }}; {% if page_obj.has_previous %} Previous page {% endif %} {% if page_obj.has_next_page %} Next page {% endif %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django not finding modules on pythonpath
I have a few novice user questions: 1. If I installed apache2 with prefork do I need to uninstall in order to change to worker? 2. If I add the following lines to my vhost definition does this make mod_wsgi run in daemon mode? WSGIDaemonProcess mysite.com processes=1 threads=5 display-name=% {GROUP} WSGIProcessGroup mysite.com 3. What is the syntax for adding the value of PYTHONPATH to the python- path= option? 4. What is the syntax for adding the python-path option to apache2.conf? Thanks for all your help so far, J On Dec 1, 5:22 pm, Graham Dumpleton <graham.dumple...@gmail.com> wrote: > On Dec 2, 12:02 pm, neridaj <neri...@gmail.com> wrote: > > > During development I had my project apps in the same directory that > > django-admin.py startproject mysite created. I would now like to have > > my apps in a global directory, django-apps, to be used in other > > projects. I thought this was what the PYTHONPATH environment variable > > was for, do I need to add every PYTHONPATH module directory > > from .profile to mysite.wsgi? > > Any directories listed in PYTHONPATH environment variable of user when > running django-admin.py, must be individually added to 'sys.path' in > the WSGI script file. > > Alternatively, take what you have in PYTHONPATH and use that same > value to define WSGIPythonPath directive if using mod_wsgi embedded > mode, or the python-path option to WSGIDaemonProcess if using mod_wsgi > daemon mode. For information about the latter two directives see: > > http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPyt... > http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDae... > > Do note that by doing it in WSGI script file, only applies to that > Django instance. If done in Apache configuration, applies to all > Django instances running in embedded mode or that daemon mode process > group, as appropriate for way configured. > > As such, setting these in WSGI script file is better if they relate > only to a specific Django instance. > > Graham > > > On Dec 1, 3:03 pm, Graham Dumpleton <graham.dumple...@gmail.com> > > wrote: > > > > Have a read of: > > > >http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > > > In particular where it says: > > > > """ > > > If you have been using the Django development server and have made use > > > of the fact that it is possible when doing explicit imports, or when > > > referencing modules in 'urls.py', to leave out the name of the site > > > and use a relative module path, you will also need to add to sys.path > > > the path to the site package directory itself. > > > > sys.path.append('/usr/local/django') > > > sys.path.append('/usr/local/django/mysite') > > > > In other words, you would have the path to the directory containing > > > the 'settings.py' file created by 'django-admin.py startproject', as > > > well as the parent directory of that directory, as originally added > > > above. > > > > Note that it is not recommended to be setting 'DJANGO_SETTINGS_MODULE' > > > to be 'settings' and only listing the path to the directory containing > > > the 'settings.py' file. This is because such a setup will not mirror > > > properly how the Django development server works and everything may > > > not work as expected. > > > """ > > > > You have only added the path to the parent directory and not the path > > > of the directory containing the settings.py file. Your use of relative > > > modules references within the site package may therefore be a problem. > > > > Graham > > > > On Dec 2, 9:43 am, neridaj <neri...@gmail.com> wrote: > > > > > I'm using the same setup I have for another django site running on the > > > > same server. I haven't had to use the python-path arg to WDP before so > > > > I'm not sure how to do that. I'm still pretty new to this so any help > > > > would be much appreciated. I'm using the same wsgi script that works > > > > for the other site so I don't see any problem but here it is if you > > > > want to have a look: > > > > > import os, sys > > > > > path = '/home/username/public_html/mysite.com/' > > > > if path not in sys.path: > > > > sys.path.append(path) > > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' > > > > > import django.core.handlers.wsgi > > > > > _application = django.core.handlers.wsgi.WSGIHandler() > > > > > def application(envir
Re: django not finding modules on pythonpath
During development I had my project apps in the same directory that django-admin.py startproject mysite created. I would now like to have my apps in a global directory, django-apps, to be used in other projects. I thought this was what the PYTHONPATH environment variable was for, do I need to add every PYTHONPATH module directory from .profile to mysite.wsgi? On Dec 1, 3:03 pm, Graham Dumpleton <graham.dumple...@gmail.com> wrote: > Have a read of: > > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > In particular where it says: > > """ > If you have been using the Django development server and have made use > of the fact that it is possible when doing explicit imports, or when > referencing modules in 'urls.py', to leave out the name of the site > and use a relative module path, you will also need to add to sys.path > the path to the site package directory itself. > > sys.path.append('/usr/local/django') > sys.path.append('/usr/local/django/mysite') > > In other words, you would have the path to the directory containing > the 'settings.py' file created by 'django-admin.py startproject', as > well as the parent directory of that directory, as originally added > above. > > Note that it is not recommended to be setting 'DJANGO_SETTINGS_MODULE' > to be 'settings' and only listing the path to the directory containing > the 'settings.py' file. This is because such a setup will not mirror > properly how the Django development server works and everything may > not work as expected. > """ > > You have only added the path to the parent directory and not the path > of the directory containing the settings.py file. Your use of relative > modules references within the site package may therefore be a problem. > > Graham > > On Dec 2, 9:43 am, neridaj <neri...@gmail.com> wrote: > > > I'm using the same setup I have for another django site running on the > > same server. I haven't had to use the python-path arg to WDP before so > > I'm not sure how to do that. I'm still pretty new to this so any help > > would be much appreciated. I'm using the same wsgi script that works > > for the other site so I don't see any problem but here it is if you > > want to have a look: > > > import os, sys > > > path = '/home/username/public_html/mysite.com/' > > if path not in sys.path: > > sys.path.append(path) > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' > > > import django.core.handlers.wsgi > > > _application = django.core.handlers.wsgi.WSGIHandler() > > > def application(environ, start_response): > > environ['wsgi.url_scheme'] = environ.get('HTTP_X_URL_SCHEME', > > 'http') > > return _application(environ, start_response) > > > On Dec 1, 1:53 pm, Skylar Saveland <skylar.savel...@gmail.com> wrote: > > > > Are you using python-path arg to WDP? Also, you might do some > > > sys.path hacking in the .wsgi script. > > > > neridaj wrote: > > > > Hello, > > > > > I'm trying to deploy my project to my server and I don't understand > > > > why django isn't finding modules I've added to my pythonpath. When I > > > > try to access my site I get 500 errors and after looking at the server > > > > log I see a traceback with this: > > > > > [error] [client 174.xxx.xxx.xxx] ImportError: No module named blog > > > > > However, when I run python I am able to import the modules. I'm using > > > > nginx as a proxy to apache2/mod_wsgi on Ubuntu 9.04. > > > > > Thanks, > > > > > J -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django not finding modules on pythonpath
I'm using the same setup I have for another django site running on the same server. I haven't had to use the python-path arg to WDP before so I'm not sure how to do that. I'm still pretty new to this so any help would be much appreciated. I'm using the same wsgi script that works for the other site so I don't see any problem but here it is if you want to have a look: import os, sys path = '/home/username/public_html/mysite.com/' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() def application(environ, start_response): environ['wsgi.url_scheme'] = environ.get('HTTP_X_URL_SCHEME', 'http') return _application(environ, start_response) On Dec 1, 1:53 pm, Skylar Saveland <skylar.savel...@gmail.com> wrote: > Are you using python-path arg to WDP? Also, you might do some > sys.path hacking in the .wsgi script. > > neridaj wrote: > > Hello, > > > I'm trying to deploy my project to my server and I don't understand > > why django isn't finding modules I've added to my pythonpath. When I > > try to access my site I get 500 errors and after looking at the server > > log I see a traceback with this: > > > [error] [client 174.xxx.xxx.xxx] ImportError: No module named blog > > > However, when I run python I am able to import the modules. I'm using > > nginx as a proxy to apache2/mod_wsgi on Ubuntu 9.04. > > > Thanks, > > > J -- 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.
django not finding modules on pythonpath
Hello, I'm trying to deploy my project to my server and I don't understand why django isn't finding modules I've added to my pythonpath. When I try to access my site I get 500 errors and after looking at the server log I see a traceback with this: [error] [client 174.xxx.xxx.xxx] ImportError: No module named blog However, when I run python I am able to import the modules. I'm using nginx as a proxy to apache2/mod_wsgi on Ubuntu 9.04. Thanks, J -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-tagging module not found
I'm running django on ubuntu jaunty-9.04, apache2/mod_wsgi, and nginx. I'm having problems with both of my vhosts resolving to the same document root, as well as 500 errors with one of the domains. my first domain works fine i.e., the url resolves to the correct document root, but when I look up the other vhost I have problems. I think the second vhost might be having problems because it is defined second in the order in the apache vhosts. If I look up the second vhost without www prepended to the url I get 500 errors with the following in the server log: [client 174.xxx.xxx.xxx] ImportError: No module named tagging when I import the tagging module from python it imports with no errors. My vhost for the domain in question is as follows: /etc/apache2/sites-available/mysite.com: ServerName mysite.com ServerAdmin supp...@mysite.com ServerAlias *mysite.com WSGIScriptAlias / /home/username/public_html/mysite.com/mysite.wsgi # Custom log file locations LogLevel warn ErrorLog /home/username/public_html/mysite.com/logs/error.log CustomLog /home/username/public_html/mysite.com/logs/access.log combined RPAFenable On RPAFsethostname On RPAFproxy_ips 127.0.0.1 /etc/nginx/sites-available: server { listen 80; server_name mysite.com; # ex: www.mysite.com location / { proxy_pass http://mysite.com:8081; include /etc/nginx/proxy.conf; } # Static files location, requires that you create this folder separately location /site_media/ { root /home/username/public_html/mysite.com/; } # Admin templates location location /admin_media/ { root /home/username/public_html/mysite.com/; } } Public_html/mysite.com/mysite.wsgi: import os, sys path = '/home/username/public_html/mysite.com/' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() def application(environ, start_response): environ['wsgi.url_scheme'] = environ.get('HTTP_X_URL_SCHEME', 'http') return _application(environ, start_response) On Nov 30, 9:23 pm, neridaj <neri...@gmail.com> wrote: > Hello, > > I'm trying to deploy my simple app and I've mirrored the project as it > was on my local dev machine. For some reason, when I try to browse to > the url I get a 500 error and the error log says ImportError: No > module named tagging. I've added PYTHONPATH env vars as follows: > > export PYTHONPATH=/home/username/public_html/mysite.com/:$PYTHONPATH > export PYTHONPATH=/home/username/public_html/mysite.com/mysite: > $PYTHONPATH > export PYTHONPATH=/home/username/public_html/mysite.com/mysite/blog: > $PYTHONPATH > export PYTHONPATH=/home/username/public_html/mysite.com/mysite/project: > $PYTHONPATH > export PYTHONPATH=/home/username/public_html/mysite.com/mysite/search: > $PYTHONPATH > export PYTHONPATH=/home/username/public_html/mysite.com/mysite/akismet: > $PYTHONPATH > export PYTHONPATH=/home/username/src/akismet-0.2.0:$PYTHONPATH > export PYTHONPATH=/home/username/src/django-tagging-0.3:$PYTHONPATH > export PYTHONPATH=/home/username/src/Markdown-2.0.3:$PYTHONPATH > export PYTHONPATH=/home/username/src/pydelicious > +tools-0.5.3:$PYTHONPATH > export DJANGO_SETTINGS_MODULE=mysite.settings > > when I print sys.path tagging is on the path and when I import tagging > from python I get no errors. I've been doing dev on osx, is there some > different syntax to properly add to PYTHONPATH on ubuntu? > > Thanks, > > J -- 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.
django-tagging module not found
Hello, I'm trying to deploy my simple app and I've mirrored the project as it was on my local dev machine. For some reason, when I try to browse to the url I get a 500 error and the error log says ImportError: No module named tagging. I've added PYTHONPATH env vars as follows: export PYTHONPATH=/home/username/public_html/mysite.com/:$PYTHONPATH export PYTHONPATH=/home/username/public_html/mysite.com/mysite: $PYTHONPATH export PYTHONPATH=/home/username/public_html/mysite.com/mysite/blog: $PYTHONPATH export PYTHONPATH=/home/username/public_html/mysite.com/mysite/project: $PYTHONPATH export PYTHONPATH=/home/username/public_html/mysite.com/mysite/search: $PYTHONPATH export PYTHONPATH=/home/username/public_html/mysite.com/mysite/akismet: $PYTHONPATH export PYTHONPATH=/home/username/src/akismet-0.2.0:$PYTHONPATH export PYTHONPATH=/home/username/src/django-tagging-0.3:$PYTHONPATH export PYTHONPATH=/home/username/src/Markdown-2.0.3:$PYTHONPATH export PYTHONPATH=/home/username/src/pydelicious +tools-0.5.3:$PYTHONPATH export DJANGO_SETTINGS_MODULE=mysite.settings when I print sys.path tagging is on the path and when I import tagging from python I get no errors. I've been doing dev on osx, is there some different syntax to properly add to PYTHONPATH on ubuntu? Thanks, J -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Accessing model instance on pre_save signal
Thanks Tim. That's funny you just posted that because I just got done doing that and was going to post it as solved. Cheers, J On Nov 25, 1:48 pm, Tim Valenta <tonightslasts...@gmail.com> wrote: > I know how messed up this all seems, so I sympathize. I totally want > to store items according to a related object's name or id or whatever. > > However, I'm using upload_to in a more straightforward manner, and it > seems to work out alright. Tell me if you've already tried it this > way: > > class ScreenShot(models.Model): > def _image_location(instance, filename): > return ''.join("web_projects/%Y/", instance.project.slug, > "/", filename) > # ... > image = models.ImageField(upload_to=_image_location) > > The thing you pass to your field's "upload_to" value can be a > callable, which takes two arguments: the instance of `ScreenShot` > being altered, and the filename of the original file that was > uploaded. You then just return a string of the path to save in, > including the filename. > > It's all described here, which it looks like you've already > read:http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mod... > > Does that not work for you? I do exactly the same thing for various > fields on some of my models. I could see how it might complicate > things if you were doing it on an inline. I admit that I haven't > tried that one out, as luck would have it. If the main model already > exists, it should work, though. > > Just brainstorming to find a simpler solution. Have you already tried > it that way? > > Tim > > On Nov 25, 12:08 pm, neridaj <neri...@gmail.com> wrote: > > > I'm trying to access the current instance of ScreenShot related to the > > current instance of WebProject, in order to get the slug field of > > WebProject to use as a upload directory but I don't think I can > > because there's no primary key in the db yet. I need to call > > change_upload_to when the instance of WebProject tries to save because > > it saves before the instance of ScreenShot i.e., before slug is > > obtained to append to the upload_to directory. Are you suggesting I > > should just add the ImageField to the WebProject class? I don't want > > to have a fixed number of ImageFields for WebProject, if there's a way > > to do that without using another class that would work. Can I access > > the save method of ScreenShot from WebProject? Should I just add > > another slug field to ScreenShot? > > > class ScreenShotInline(admin.StackedInline): > > model = ScreenShot > > extra = 3 > > > class WebProjectAdmin(admin.ModelAdmin): > > prepopulated_fields = {'slug': ('title',)} > > inlines = [ScreenShotInline] > > > On Nov 25, 9:46 am, Preston Holmes <pres...@ptone.com> wrote: > > > > I'm a bit confused on a few points here. The upload_to field > > > attribute should be atomic to the imagefield - it doesn't rely on > > > related models. > > > > your change_upload_to creates a new screenshot - but doesn't connect > > > it to the current WebProject instance. Is that what you are trying to > > > do? > > > > s = ScreenShot(project=instance) > > > > Is there a reason your WebProject is not defined when you create a > > > screenshot in your view? > > > > Something about this seems like it is making it more complicated than > > > it needs to be. but details are lacking t > > > > -Preston > > > > On Nov 24, 5:52 pm, neridaj <neri...@gmail.com> wrote: > > > > > Hello, > > > > > I'm trying to change the upload_to attribute of an ImageField so that > > > > it is in the format "web_projects/year/slug/". The problem I am having > > > > is that the ForeignKey model is getting saved before the related > > > > ScreenShot model is able to call it's save method to change upload_to. > > > > I'm trying to use a pre_save signal to reverse the order of saving but > > > > I'm not sure how to access the current instance of the ScreenShot > > > > model to call it's save method. Thanks for any suggestions. > > > > > class ScreenShot(models.Model): > > > > project = models.ForeignKey(WebProject) > > > > image = models.ImageField(upload_to="web_projects/%Y/") > > > > page_title = models.CharField(max_length=250, > > > > help_text="Maximum 250 > > > > characters.") > > > > > def __un
Re: Accessing model instance on pre_save signal
I'm trying to access the current instance of ScreenShot related to the current instance of WebProject, in order to get the slug field of WebProject to use as a upload directory but I don't think I can because there's no primary key in the db yet. I need to call change_upload_to when the instance of WebProject tries to save because it saves before the instance of ScreenShot i.e., before slug is obtained to append to the upload_to directory. Are you suggesting I should just add the ImageField to the WebProject class? I don't want to have a fixed number of ImageFields for WebProject, if there's a way to do that without using another class that would work. Can I access the save method of ScreenShot from WebProject? Should I just add another slug field to ScreenShot? class ScreenShotInline(admin.StackedInline): model = ScreenShot extra = 3 class WebProjectAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('title',)} inlines = [ScreenShotInline] On Nov 25, 9:46 am, Preston Holmes <pres...@ptone.com> wrote: > I'm a bit confused on a few points here. The upload_to field > attribute should be atomic to the imagefield - it doesn't rely on > related models. > > your change_upload_to creates a new screenshot - but doesn't connect > it to the current WebProject instance. Is that what you are trying to > do? > > s = ScreenShot(project=instance) > > Is there a reason your WebProject is not defined when you create a > screenshot in your view? > > Something about this seems like it is making it more complicated than > it needs to be. but details are lacking t > > -Preston > > On Nov 24, 5:52 pm, neridaj <neri...@gmail.com> wrote: > > > Hello, > > > I'm trying to change the upload_to attribute of an ImageField so that > > it is in the format "web_projects/year/slug/". The problem I am having > > is that the ForeignKey model is getting saved before the related > > ScreenShot model is able to call it's save method to change upload_to. > > I'm trying to use a pre_save signal to reverse the order of saving but > > I'm not sure how to access the current instance of the ScreenShot > > model to call it's save method. Thanks for any suggestions. > > > class ScreenShot(models.Model): > > project = models.ForeignKey(WebProject) > > image = models.ImageField(upload_to="web_projects/%Y/") > > page_title = models.CharField(max_length=250, help_text="Maximum 250 > > characters.") > > > def __unicode__(self): > > return self.page_title > > > def save(self): > > self.image.upload_to="web_projects/%Y/"+self.project.slug > > super(ScreenShot, self).save() > > > def change_upload_to(sender, **kwargs): > > s = ScreenShot() # not sure how to access current instance > > s.save() > > > pre_save.connect(change_upload_to, sender=WebProject) -- 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.
Accessing model instance on pre_save signal
Hello, I'm trying to change the upload_to attribute of an ImageField so that it is in the format "web_projects/year/slug/". The problem I am having is that the ForeignKey model is getting saved before the related ScreenShot model is able to call it's save method to change upload_to. I'm trying to use a pre_save signal to reverse the order of saving but I'm not sure how to access the current instance of the ScreenShot model to call it's save method. Thanks for any suggestions. class ScreenShot(models.Model): project = models.ForeignKey(WebProject) image = models.ImageField(upload_to="web_projects/%Y/") page_title = models.CharField(max_length=250, help_text="Maximum 250 characters.") def __unicode__(self): return self.page_title def save(self): self.image.upload_to="web_projects/%Y/"+self.project.slug super(ScreenShot, self).save() def change_upload_to(sender, **kwargs): s = ScreenShot() # not sure how to access current instance s.save() pre_save.connect(change_upload_to, sender=WebProject) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: url import causing strange errors
I recreated the app manually instead of startapp and it works now, any idea why that is? On Nov 23, 10:16 pm, neridaj <neri...@gmail.com> wrote: > I changed my app name, model names, and url names to the following and > still get the error: > > project/ > __init__.py > admin.py > models.py > views.py > urls/ > __init__.py > web.py > > mysite/ > urls.py > > (r'^sites/', include('project.urls.web')), > > project/ > urls/ > web.py > > from django.conf.urls.defaults import * > from project.models import WebProject > > web_project_info_dict = { > 'queryset': WebProject.objects.all(), > > } > > urlpatterns = patterns('django.views.generic.list_detail', > (r'^$', 'object_list', web_project_info_dict), > (r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict), > ) > > On Nov 23, 5:32 pm, Karen Tracey <kmtra...@gmail.com> wrote: > > > On Mon, Nov 23, 2009 at 8:21 PM, neridaj <neri...@gmail.com> wrote: > > > I don't see the difference between how the urls are setup for my blog > > > app and my projects app: > > > > blog/ > > > __init__.py > > > admin.py > > > feeds.py > > > models.py > > > views.py > > > urls/ > > > __init__.py > > > categories.py > > > entries.py > > > links.py > > > tags.py > > > I don't see a file blog/urls/blog.py in which there is a "from blog.models > > import something" > > > > projects/ > > > __init__.py > > > admin.py > > > models.py > > > tests.py > > > urls/ > > > __init__.py > > > projects.py > > > The problem is the duplicate projects in projects/urls/projects.py combined > > with trying, in projects.py "from projects.models import something". "from > > projects", inside projects.py, is going to look inside projects.py to > > satisfy the import. > > > Karen > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: url import causing strange errors
I changed my app name, model names, and url names to the following and still get the error: project/ __init__.py admin.py models.py views.py urls/ __init__.py web.py mysite/ urls.py (r'^sites/', include('project.urls.web')), project/ urls/ web.py from django.conf.urls.defaults import * from project.models import WebProject web_project_info_dict = { 'queryset': WebProject.objects.all(), } urlpatterns = patterns('django.views.generic.list_detail', (r'^$', 'object_list', web_project_info_dict), (r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict), ) On Nov 23, 5:32 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Mon, Nov 23, 2009 at 8:21 PM, neridaj <neri...@gmail.com> wrote: > > I don't see the difference between how the urls are setup for my blog > > app and my projects app: > > > blog/ > > __init__.py > > admin.py > > feeds.py > > models.py > > views.py > > urls/ > > __init__.py > > categories.py > > entries.py > > links.py > > tags.py > > I don't see a file blog/urls/blog.py in which there is a "from blog.models > import something" > > > projects/ > > __init__.py > > admin.py > > models.py > > tests.py > > urls/ > > __init__.py > > projects.py > > The problem is the duplicate projects in projects/urls/projects.py combined > with trying, in projects.py "from projects.models import something". "from > projects", inside projects.py, is going to look inside projects.py to > satisfy the import. > > Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: url import causing strange errors
I don't see the difference between how the urls are setup for my blog app and my projects app: blog/ __init__.py admin.py feeds.py models.py views.py urls/ __init__.py categories.py entries.py links.py tags.py projects/ __init__.py admin.py models.py tests.py urls/ __init__.py projects.py On Nov 23, 1:38 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Mon, Nov 23, 2009 at 2:46 PM, neridaj <neri...@gmail.com> wrote: > > I've noticed that sometimes errors in my url conf will cause strange > > unrelated errors that have sent me down paths that don't need to be > > followed because it's a simple typo. I can't seem to find it here but > > maybe I need another set of eyes on it. > > > (r'^projects/', include('projects.urls.projects')), > > > # projects/urls/projects.py > > > from django.conf.urls.defaults import * > > from projects.models import Project > > Your projects module (that contains urls and models and whatever) is hidden, > for code inside projects.py by the projects.py module itself. THAT projects > module does not have a submodule named models, so the import here will fail. > > Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: url import causing strange errors
I keep getting these errors but the module is right where it should be. Exception Type: ImportError Exception Value:No module named models Exception Location: /Users/username/django-projects/mysite.com/mysite/ projects/urls/projects.py in , line 2 On Nov 23, 11:46 am, neridaj <neri...@gmail.com> wrote: > I've noticed that sometimes errors in my url conf will cause strange > unrelated errors that have sent me down paths that don't need to be > followed because it's a simple typo. I can't seem to find it here but > maybe I need another set of eyes on it. > > (r'^projects/', include('projects.urls.projects')), > > # projects/urls/projects.py > > from django.conf.urls.defaults import * > from projects.models import Project > > project_info_dict = { > 'queryset': Project.objects.all(), > > } > > urlpatterns = patterns('django.views.generic.list_detail', > (r'^$', 'object_list', project_info_dict), > (r'^(?P[-\w]+)/$', 'object_detail', project_info_dict), > ) > > Thanks, > > J -- 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=.
url import causing strange errors
I've noticed that sometimes errors in my url conf will cause strange unrelated errors that have sent me down paths that don't need to be followed because it's a simple typo. I can't seem to find it here but maybe I need another set of eyes on it. (r'^projects/', include('projects.urls.projects')), # projects/urls/projects.py from django.conf.urls.defaults import * from projects.models import Project project_info_dict = { 'queryset': Project.objects.all(), } urlpatterns = patterns('django.views.generic.list_detail', (r'^$', 'object_list', project_info_dict), (r'^(?P[-\w]+)/$', 'object_detail', project_info_dict), ) Thanks, J -- 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=.
Re: passing vars to filters?
Thanks Karen. On Nov 19, 4:56 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Thu, Nov 19, 2009 at 7:25 PM, neridaj <neri...@gmail.com> wrote: > > Is it possible to pass vars to filters rather than hard coding the > > field name, something like this: > > > def search(request): > > query = request.GET.get('q', '') > > bits = request.GET.get('models', '').partition('.') > > model_name = bits[0] > > field_name = bits[2] > > model_type = ContentType.objects.get(app_label="blog", > > model=model_name) > > model_class = model_type.model_class() > > results = [] > > if query: > > results = model_class.objects.filter > > (field_name__icontains=query) > > return render_to_response('search/search.html', > > { 'query': query, 'results': > > results }) > > Create a dictionary of keyword arguments and pass that. For example: > > results = model_class.objects.filter(**{field_name+'__icontains': query}) > > Karen -- 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=.
passing vars to filters?
Is it possible to pass vars to filters rather than hard coding the field name, something like this: def search(request): query = request.GET.get('q', '') bits = request.GET.get('models', '').partition('.') model_name = bits[0] field_name = bits[2] model_type = ContentType.objects.get(app_label="blog", model=model_name) model_class = model_type.model_class() results = [] if query: results = model_class.objects.filter (field_name__icontains=query) return render_to_response('search/search.html', { 'query': query, 'results': results }) Thanks, J -- 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=.
Re: casting unicode to model
I just found out that get() returns only one object. On Nov 19, 2:30 pm, neridaj <neri...@gmail.com> wrote: > Thanks for the help. Is get_object_for_this_type() not made to handle > multiple objects? If more than one object is returned I get this > error: get() returned more than one Entry. > > On Nov 19, 4:10 am, David De La Harpe Golden > > <david.delaharpe.gol...@ichec.ie> wrote: > > Karen Tracey wrote: > > > Undocumented internal routine, but unlikely to change: > > > Just to note the contenttypes framework has a documented > > way:http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#method... > > > from django.contrib.contenttypes.models import ContentType > > model_type = ContentType.objects.get(app_label=app_name, model=model_name) > > model_class = model_type.model_class() -- 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=.
Re: casting unicode to model
Thanks for the help. Is get_object_for_this_type() not made to handle multiple objects? If more than one object is returned I get this error: get() returned more than one Entry. On Nov 19, 4:10 am, David De La Harpe Goldenwrote: > Karen Tracey wrote: > > Undocumented internal routine, but unlikely to change: > > Just to note the contenttypes framework has a documented > way:http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#method... > > from django.contrib.contenttypes.models import ContentType > model_type = ContentType.objects.get(app_label=app_name, model=model_name) > model_class = model_type.model_class() -- 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=.
Re: casting unicode to model
Thanks Karen but I'm just getting a 'NoneType' object has no attribute 'objects' with this code: def search(request): query = request.GET.get('q', '') model = request.GET.get('models', '') model_class = get_model(blog, model) results = [] if query: results = model_class.objects.filter(content__icontains=query) return render_to_response('search/search.html', { 'query': query, 'results': results }) On Nov 18, 6:29 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Wed, Nov 18, 2009 at 9:09 PM, neridaj <neri...@gmail.com> wrote: > > Hello, > > > I have a select menu which I would like to use as a model selector in > > a view but I keep getting 'unicode' object has no attribute 'objects' > > because I need to cast this to type Model or something similar. How do > > I go about doing that. > > Undocumented internal routine, but unlikely to change: > > from django.db.models import get_model > model_class = get_model(app_name, model_name) > > Karen -- 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=.
casting unicode to model
Hello, I have a select menu which I would like to use as a model selector in a view but I keep getting 'unicode' object has no attribute 'objects' because I need to cast this to type Model or something similar. How do I go about doing that. Thanks, J -- 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=.
problems accessing markdown comments
I can't figure out why my comment vars aren't available in my template. I'm using django.contrib.markup and when I try to preview the comments nothing is displayed, however, the comment var is available in {{ comment|linebreaks }} but not in {{ comment.submit_date|date:"F j, Y" }}, {{ comment.person_name }} or {{ comment.comment|markdown:"safe" }}. Does anyone see what I'm doing wrong? code for preview.html: {% load comments %} {% if next %} {% endif %} {% if form.errors %} {% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %} {% else %} {% trans "Preview your comment" %} {{ comment|linebreaks }} {% load markup %} Post a comment Here's how your comment will look: On {{ comment.submit_date|date:"F j, Y" }}, {{ comment.person_name }} said: {{ comment.comment|markdown:"safe" }} Thanks, J -- 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=.
no such column: blog_link.slug
I'm getting this error even though I have added slug field for this model - Link. I ran syncdb a few times and I still get the error. Any suggestions? class Link(models.Model): # Metadata. slug = models.SlugField(unique_for_date='pub_date', help_text="Must be unique for the publication.") -- 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=.
Re: django-tagging causing str error
Thanks Karen. On Nov 14, 8:28 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Fri, Nov 13, 2009 at 11:42 PM, neridaj <neri...@gmail.com> wrote: > > I'm using django-tagging and I think it's causing an error when I try > > to access the admin page. If I comment out the urls that reference > > django-tagging views the error goes away. > > > from django.conf.urls.defaults import * > > from blog.models import Entry, Link > > from tagging.models import Tag > > > urlpatterns = patterns('' > > You are missing a comma on the end of this line. > > Karen -- 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=.
Re: django-tagging causing str error
Oops, sorry about that. Here is the error: TemplateSyntaxError at /admin/ Caught an exception while rendering: 'str' object is not callable admin/base.html, error at line 30 30 {% url django-admindocs-docroot as docsroot %} On Nov 14, 1:47 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Nov 14, 4:42 am, neridaj <neri...@gmail.com> wrote: > > > > > I'm using django-tagging and I think it's causing an error when I try > > to access the admin page. If I comment out the urls that reference > > django-tagging views the error goes away. > > > from django.conf.urls.defaults import * > > from blog.models import Entry, Link > > from tagging.models import Tag > > > urlpatterns = patterns('' > > (r'^$', 'django.views.generic.list_detail.object_list', > > { 'queryset': Tag.objects.all() }), > > (r'^entries/(?P[-\w]+)/$', > > 'tagging.views.tagged_object_list', { 'queryset_or_model': Entry, > > 'template_name': 'blog/entries_by_tag.html' }), > > (r'^links/(?P[-\w]+)/$', 'tagging.views.tagged_object_list', > > { 'queryset_or_model': Link, 'template_name': 'blog/ > > links_by_tag.html' }), > > ) > > > Thanks for any suggestions, > > > Jason > > And are we supposed to guess what the error is? > -- > DR. -- 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=.
django-tagging causing str error
I'm using django-tagging and I think it's causing an error when I try to access the admin page. If I comment out the urls that reference django-tagging views the error goes away. from django.conf.urls.defaults import * from blog.models import Entry, Link from tagging.models import Tag urlpatterns = patterns('' (r'^$', 'django.views.generic.list_detail.object_list', { 'queryset': Tag.objects.all() }), (r'^entries/(?P[-\w]+)/$', 'tagging.views.tagged_object_list', { 'queryset_or_model': Entry, 'template_name': 'blog/entries_by_tag.html' }), (r'^links/(?P[-\w]+)/$', 'tagging.views.tagged_object_list', { 'queryset_or_model': Link, 'template_name': 'blog/ links_by_tag.html' }), ) Thanks for any suggestions, Jason -- 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=.
Re: admin.site.register() - help
Thanks Matt, that did it. On Nov 11, 11:07 pm, Matt Schinckel <matt.schinc...@gmail.com> wrote: > On Nov 12, 4:18 pm, neridaj <neri...@gmail.com> wrote: > > > since FlatPage is already registered how do I properly register an > > InlineModelAdmin object? > > You can use: > > admin.site.unregister(FlatPage) > > and then re-register with your FlatPageAdmin class: > > admin.site.register(FlatPage, MyFlatPageAdmin) -- 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=.
Re: admin.site.register() - help
since FlatPage is already registered how do I properly register an InlineModelAdmin object? On Nov 11, 9:51 pm, neridaj <neri...@gmail.com> wrote: > Hey Karen, > > I realized that I shouldn't have been using a generic.StackedInline > and fixed the indentation. I left the FlatPage out of register because > I was getting 'The model FlatPage is already registered'. > > On Nov 11, 9:09 pm, Karen Tracey <kmtra...@gmail.com> wrote: > > > On Wed, Nov 11, 2009 at 10:40 PM, neridaj <neri...@gmail.com> wrote: > > > I'm doing something wrong when I try to register models for the admin > > > interface and I'm not sure what it is. I have everything in my > > > installed apps, is there something wrong with these files? > > > > [snip] > > > from django.db import models > > > from django.contrib import admin > > > from django.contrib.flatpages.models import FlatPage > > > > class SearchKeyword(models.Model): > > > keyword = models.CharField(max_length=50) > > > page = models.ForeignKey(FlatPage) > > > > def __unicode__(self): > > > return self.keyword > > > As someone else already mentioned, this __unicode__ method is not indented > > properly. It needs to be indented at the same level as the field > > definitions for the model. The effect of having it the way it is will be > > that SearchKeywords will display using the default unicode() method for a > > model instead of your customized one. > > > > search/admin.py > > > > from testproject.search.models import SearchKeyword > > > from django.contrib.flatpages.models import FlatPage > > > from django.contrib import admin > > > from django.contrib.contenttypes import generic > > > > class KeywordInline(generic.GenericStackedInline): > > > model = SearchKeyword > > > Why are you using a GenericStackedInline here? You do not have a > > GenericForeignKey in the SearchKeyword model, just a regular ForeignKey. > > admin.StackedInline is what you want for a regular ForeignKey. (You aren't > > getting far enough to see a problem resulting from this, but you will when > > you fix the error you are hitting, unless you are really using a > > GenericForeignKey in SearchKeyword.) > > > > class PageAdmin(admin.ModelAdmin): > > > inlines = [ > > > KeywordInline, > > > ] > > > > admin.site.register(PageAdmin) > > > The first positional argument to admin.site.register is a model (or a > > sequence of models). You've not specified the model, only the ModelAdmin. > > You need to add a first argument here to specify the model you are > > registering (I'd guess FlatPage, since that is what your inlines have a > > ForeignKey pointing to.) > > > Karen -- 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=.
Re: admin.site.register() - help
Hey Karen, I realized that I shouldn't have been using a generic.StackedInline and fixed the indentation. I left the FlatPage out of register because I was getting 'The model FlatPage is already registered'. On Nov 11, 9:09 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Wed, Nov 11, 2009 at 10:40 PM, neridaj <neri...@gmail.com> wrote: > > I'm doing something wrong when I try to register models for the admin > > interface and I'm not sure what it is. I have everything in my > > installed apps, is there something wrong with these files? > > > [snip] > > from django.db import models > > from django.contrib import admin > > from django.contrib.flatpages.models import FlatPage > > > class SearchKeyword(models.Model): > > keyword = models.CharField(max_length=50) > > page = models.ForeignKey(FlatPage) > > > def __unicode__(self): > > return self.keyword > > As someone else already mentioned, this __unicode__ method is not indented > properly. It needs to be indented at the same level as the field > definitions for the model. The effect of having it the way it is will be > that SearchKeywords will display using the default unicode() method for a > model instead of your customized one. > > > > > search/admin.py > > > from testproject.search.models import SearchKeyword > > from django.contrib.flatpages.models import FlatPage > > from django.contrib import admin > > from django.contrib.contenttypes import generic > > > class KeywordInline(generic.GenericStackedInline): > > model = SearchKeyword > > Why are you using a GenericStackedInline here? You do not have a > GenericForeignKey in the SearchKeyword model, just a regular ForeignKey. > admin.StackedInline is what you want for a regular ForeignKey. (You aren't > getting far enough to see a problem resulting from this, but you will when > you fix the error you are hitting, unless you are really using a > GenericForeignKey in SearchKeyword.) > > > class PageAdmin(admin.ModelAdmin): > > inlines = [ > > KeywordInline, > > ] > > > admin.site.register(PageAdmin) > > The first positional argument to admin.site.register is a model (or a > sequence of models). You've not specified the model, only the ModelAdmin. > You need to add a first argument here to specify the model you are > registering (I'd guess FlatPage, since that is what your inlines have a > ForeignKey pointing to.) > > Karen -- 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=.
Re: admin.site.register() - help
it looks like the admin.AdminModel object is causing the error in this inline definition class PageAdmin(admin.ModelAdmin): inlines = [ KeywordInline, ] admin.site.register(PageAdmin) 'MediaDefiningClass' object is not iterable when I comment that out the blog.Categories class is available in the admin. On Nov 11, 8:09 pm, Kenneth Gonsalveswrote: > On Thursday 12 Nov 2009 9:36:11 am Zeynel wrote: > > > Sorry, I am a beginner but I noticed that in my models the indent of > > unicode is indented like this: > > > class SearchKeyword(models.Model): > > keyword = models.CharField(max_length=50) > > page = models.ForeignKey(FlatPage) > > def __unicode__(self): > > return self.keyword > > > I have no idea if this will cause an error, though. > > does this post have anything to do with the subject of the previous post? if > not, it is a good idea to start a new thread with a proper subject line. I do > not see any error in indentation, but the best way to check is to press > 'compile' on your ide and see if any errors show - indentation errors will > show. > -- > regards > Kenneth Gonsalves > Senior Project Officer > NRC-FOSShttp://nrcfosshelpline.in/web/ -- 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=.
Re: admin.site.register() - help
I don't get an error, the models just aren't showing up in the admin. On Nov 11, 7:56 pm, Kenneth Gonsalves <law...@au-kbc.org> wrote: > On Thursday 12 Nov 2009 9:10:04 am neridaj wrote: > > > I'm doing something wrong when I try to register models for the admin > > interface and I'm not sure what it is. I have everything in my > > installed apps, is there something wrong with these files? > > it would be a good idea also to mention what error you are getting > -- > regards > Kenneth Gonsalves > Senior Project Officer > NRC-FOSShttp://nrcfosshelpline.in/web/ -- 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=.
admin.site.register() - help
I'm doing something wrong when I try to register models for the admin interface and I'm not sure what it is. I have everything in my installed apps, is there something wrong with these files? INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.flatpages', 'django.contrib.admindocs', 'testproject.search', 'blog', ) search/models.py from django.db import models from django.contrib import admin from django.contrib.flatpages.models import FlatPage class SearchKeyword(models.Model): keyword = models.CharField(max_length=50) page = models.ForeignKey(FlatPage) def __unicode__(self): return self.keyword search/admin.py from testproject.search.models import SearchKeyword from django.contrib.flatpages.models import FlatPage from django.contrib import admin from django.contrib.contenttypes import generic class KeywordInline(generic.GenericStackedInline): model = SearchKeyword class PageAdmin(admin.ModelAdmin): inlines = [ KeywordInline, ] admin.site.register(PageAdmin) blog/models.py from django.db import models class Category(models.Model): title = models.CharField(max_length=250) slug = models.SlugField(unique=True) description = models.TextField() def __unicode__(self): return self.title blog/admin.py from django.contrib import admin from blog.models import Category admin.site.register(Category) -- 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=.
Re: problems registering models in admin
The model is on my python path and I didn't get an import error so I don't think that's the problem, thanks though. On Nov 11, 6:01 pm, Zeynel <azeyn...@gmail.com> wrote: > My models.py was in the path, C:/sw1/wkw/models.py > > I had to include sw1: > > from sw1.wkw1.models import Lawyer > > I don't if this is true in your case as well. > > On Nov 11, 8:19 pm, neridaj <neri...@gmail.com> wrote: > > > I'm working on a standalone app and when I try to add it to the admin > > index it does not show up using: > > > from django.contrib import admin > > from blog.models import Category > > > admin.site.register(Category) > > > Thanks, > > > J -- 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=.
Re: problems registering models in admin
yeah, that's installed and I've added other models to the admin. On Nov 11, 5:54 pm, Preston Holmes <pres...@ptone.com> wrote: > Is the admin in your installed apps in settings.py? > > http://docs.djangoproject.com/en/1.1/intro/tutorial02/#activate-the-a... > Add "django.contrib.admin" to your INSTALLED_APPS setting. > > -Preston > > On Nov 11, 5:19 pm, neridaj <neri...@gmail.com> wrote: > > > I'm working on a standalone app and when I try to add it to the admin > > index it does not show up using: > > > from django.contrib import admin > > from blog.models import Category > > > admin.site.register(Category) > > > Thanks, > > > J -- 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=.
problems registering models in admin
I'm working on a standalone app and when I try to add it to the admin index it does not show up using: from django.contrib import admin from blog.models import Category admin.site.register(Category) Thanks, J --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Using generic relations as an inline - not working
I'm trying to add some model fields to another model for admin editing and can't seem to get it to work i.e., model doesn't show up in admin, inline or otherwise. project/app/admin.py from project.app.models import SearchKeyword from django.contrib.flatpages.models import FlatPage from django.contrib import admin from django.contrib.contenttypes import generic class KeywordInline(generic.GenericStackedInline): model = SearchKeyword class PageAdmin(admin.ModelAdmin): inlines = [ KeywordInline, ] admin.site.register(PageAdmin) project/app/models.py from django.db import models from django.contrib import admin from django.contrib.flatpages.models import FlatPage class SearchKeyword(models.Model): keyword = models.CharField(max_length=50) page = models.ForeignKey(FlatPage) def __unicode__(self): return self.keyword --~--~-~--~~~---~--~~ 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: tiny_mce TypeError
I figured it out, thanks. On Nov 10, 8:50 pm, neridaj <neri...@gmail.com> wrote: > I'm using 1.2 pre-alpha, I tried pasting that code in, again, but no > dice. > > On Nov 10, 8:06 pm, James Bennett <ubernost...@gmail.com> wrote: > > > On Tue, Nov 10, 2009 at 9:47 PM, neridaj <neri...@gmail.com> wrote: > > > I'm just following "Practical Django Projects" and was curious if > > > anyone else was able to fix a TypeError when trying to add tiny_mce to > > > the admin for flatpages, or is this something buried in the > > > tiny_mce.js file? > > > Compare to this, which is the canonical version (and which worked > > locally for me on 1.1 when I committed it): > > >http://bitbucket.org/ubernostrum/practical-django-projects/src/tip/cm... > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: flatpages not finding site_media
I figured it out, thanks. On Nov 11, 12:00 pm, neridaj <neri...@gmail.com> wrote: > sorry, I'm just trying to use the dev server and added that url: > > (r'^site_media/(?P.*)$', 'django.views.static.serve', > {'document_root': '/Users/neridaj/django-templates/ > neridaj/'}), > > the url for static_media is being appended to the flatpage i.e., > Failed to load source > for:http://127.0.0.1:8000/about/site_media/css/blueprint/screen.css > > On Nov 11, 10:52 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > > > On Nov 11, 3:48 pm, neridaj <neri...@gmail.com> wrote: > > > > On Nov 11, 12:07 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > > > > > Have you set anything up to serve media files? > > > I have a symbolic link named site_media in my project directory. > > > How does that answer the question? What is serving the media > > files?http://docs.djangoproject.com/en/dev/howto/static-files/ > > -- > > DR. --~--~-~--~~~---~--~~ 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: flatpages not finding site_media
sorry, I'm just trying to use the dev server and added that url: (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': '/Users/neridaj/django-templates/ neridaj/'}), the url for static_media is being appended to the flatpage i.e., Failed to load source for: http://127.0.0.1:8000/about/site_media/css/blueprint/screen.css On Nov 11, 10:52 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Nov 11, 3:48 pm, neridaj <neri...@gmail.com> wrote: > > > On Nov 11, 12:07 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > > > > Have you set anything up to serve media files? > > I have a symbolic link named site_media in my project directory. > > How does that answer the question? What is serving the media > files?http://docs.djangoproject.com/en/dev/howto/static-files/ > -- > DR. --~--~-~--~~~---~--~~ 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: flatpages not finding site_media
I have a symbolic link named site_media in my project directory. On Nov 11, 12:07 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Nov 11, 7:50 am, neridaj <neri...@gmail.com> wrote: > > > > > > > I'm trying to use some flatpages for static content and I don''t > > understand why they keep failing to load media files. I have my > > template_dirs defined, media_root and media_url - when used in > > template does not resolve to media_root i.e., template contains: > > > > > > results in: > > > Failed to load source for:http://127.0.0.1:8000/about/css/base.css > > > MEDIA_ROOT = '/Users/neridaj/django-templates/neridaj/' > > MEDIA_URL = '/site_media/' > > TEMPLATE_DIRS = ( > > '/Users/neridaj/django-templates/neridaj/' > > ) > > > The default template renders but without any of the css. > > > Thanks, > > > J > > Have you set anything up to serve media files? > -- > DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
flatpages not finding site_media
I'm trying to use some flatpages for static content and I don''t understand why they keep failing to load media files. I have my template_dirs defined, media_root and media_url - when used in template does not resolve to media_root i.e., template contains: results in: Failed to load source for: http://127.0.0.1:8000/about/css/base.css MEDIA_ROOT = '/Users/neridaj/django-templates/neridaj/' MEDIA_URL = '/site_media/' TEMPLATE_DIRS = ( '/Users/neridaj/django-templates/neridaj/' ) The default template renders but without any of the css. Thanks, J --~--~-~--~~~---~--~~ 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: tiny_mce TypeError
I'm using 1.2 pre-alpha, I tried pasting that code in, again, but no dice. On Nov 10, 8:06 pm, James Bennett <ubernost...@gmail.com> wrote: > On Tue, Nov 10, 2009 at 9:47 PM, neridaj <neri...@gmail.com> wrote: > > I'm just following "Practical Django Projects" and was curious if > > anyone else was able to fix a TypeError when trying to add tiny_mce to > > the admin for flatpages, or is this something buried in the > > tiny_mce.js file? > > Compare to this, which is the canonical version (and which worked > locally for me on 1.1 when I committed it): > > http://bitbucket.org/ubernostrum/practical-django-projects/src/tip/cm... > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
tiny_mce TypeError
Hello, I'm just following "Practical Django Projects" and was curious if anyone else was able to fix a TypeError when trying to add tiny_mce to the admin for flatpages, or is this something buried in the tiny_mce.js file? (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', { 'dcument_root': '/Users/username/src/tinymce/jscripts/tiny_mce' }), tinyMCE.init({ mode: "textareas", theme: "simple" }); Thanks, J --~--~-~--~~~---~--~~ 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: creating symlink for django-admin.py with virtulenv
had to symlink the site-package symlink to django/bin/django-admin.py On Sep 17, 2:29 pm, "neri...@gmail.com"wrote: > I've created my virtual environment but I can't figure out where I can > put a symlink for django-admin.py. I tried my virtualenv/bin/ but that > doesn't work and, due to the shared hosting, I don't have access to / > usr/local/bin/. > > Thanks, > > Jason --~--~-~--~~~---~--~~ 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: benefits of {% url %} for breadcrumbs?
I guess I can just pass it with the context. On Sep 16, 2:55 pm, neridaj <neri...@gmail.com> wrote: > the only point where DRY comes into play is when you're retrieving > data from the same view, is there a better way to make breadcrumbs? > > On Sep 16, 2:40 pm, Maksymus007 <maksymus...@gmail.com> wrote: > > > On Wed, Sep 16, 2009 at 10:53 PM, neri...@gmail.com <neri...@gmail.com> > > wrote: > > > > Is there any benefit to using {% url %} other than retrieving data > > > from the same view? I was looking for a better way to make a > > > breadcrumb menu than hard wiring the urls into every page and came > > > across the {% url %} tag and this post: > > > >http://groups.google.com/group/django-users/browse_thread/thread/b42d... > > > > It makes sense to me to use {% url %} in order to retrieve data form > > > the same view but if you have to pass {% url %} a specific view then > > > what's the difference than hard wiring a url? > > > > Thanks, > > > > Jason > > > DRY principle? --~--~-~--~~~---~--~~ 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: benefits of {% url %} for breadcrumbs?
the only point where DRY comes into play is when you're retrieving data from the same view, is there a better way to make breadcrumbs? On Sep 16, 2:40 pm, Maksymus007wrote: > On Wed, Sep 16, 2009 at 10:53 PM, neri...@gmail.com wrote: > > > Is there any benefit to using {% url %} other than retrieving data > > from the same view? I was looking for a better way to make a > > breadcrumb menu than hard wiring the urls into every page and came > > across the {% url %} tag and this post: > > >http://groups.google.com/group/django-users/browse_thread/thread/b42d... > > > It makes sense to me to use {% url %} in order to retrieve data form > > the same view but if you have to pass {% url %} a specific view then > > what's the difference than hard wiring a url? > > > Thanks, > > > Jason > > DRY principle? --~--~-~--~~~---~--~~ 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: using Max()
Thanks again Karen. On Aug 13, 7:40 pm, Karen Traceywrote: > On Thu, Aug 13, 2009 at 5:01 PM, neri...@gmail.com wrote: > > > > > > > Hello, > > > Do I need t convert the value returned from Max() to an int, or am I > > using it incorrectly? I'm getting this template error: > > > Caught an exception while rendering: (1064, "You have an error in your > > SQL syntax; check the manual that corresponds to your MySQL server > > version for the right syntax to use near ''id__max': '2'} )' at line > > 1") > > 1 > > > from django.db.models import Max > > > def preview(request, template_name='listings/preview.html', > > order_num=Order.objects.aggregate(Max('id'))): > > One problem here is that Order.objects.aggregate(Max('id')) is going to > return a dictionary, not an integer. You never pull the integer value out > of the dictionary so your subsequent attempt to pass that dictionary as a > filter value results in invalid SQL. > > Also, note that that aggregate call is going to be evaluated only once, when > the function is defined at import time. If you want that value to reflect > Orders that have been created since the file containing this function was > loaded, you need to move that code into the body of the function. > > Karen > > > num = order_num > > user = request.user > > listings = Listing.objects.filter > > (order__customer__user__username=user) > > gallery = Photo.objects.filter > > (order__customer__user__username=user, order=num) > > return render_to_response(template_name, { 'user': user, > > 'listings': listings, 'order': num, 'gallery': gallery }) > > > Thanks, > > > Jason --~--~-~--~~~---~--~~ 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: overriding save()
Thanks Karen! I've been stumped on this for quite a while and really appreciate your help, you're the best. Cheers, J On Aug 10, 5:16 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Mon, Aug 10, 2009 at 3:07 PM, neridaj <neri...@gmail.com> wrote: > > > when I do this it just creates a unix executable file of the same name > > selected from the drop down menu of users, i.e., if a user named > > testuser24 is selected from the user menu and there is a folder named > > testuser24 a unix executable is created named testuser24_. Does this > > have something to do with the instance parameter? > > No, you're not joining in the file name in what you are returning from your > upload_to. Callable upload_to needs to return the full path, so if the user > name part is a directory (folder) then you want to add in the file name > parameter (also passed into your callable) to what you are returning. > > (The added underscore behavior is the way the default storage backend avoids > a newly-uploaded file overwriting an existing one. When it comes time to > write the file to disk, if one with the specified name already exists, an > underscore is added and that name is tried, if that also already exists then > another underscore is added, etc.) > > Karen --~--~-~--~~~---~--~~ 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: overriding save()
when I do this it just creates a unix executable file of the same name selected from the drop down menu of users, i.e., if a user named testuser24 is selected from the user menu and there is a folder named testuser24 a unix executable is created named testuser24_. Does this have something to do with the instance parameter? class Listing(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=50) order = models.ForeignKey('Order') def overwrite_upload_to(self, name): user_dir_path = os.path.join('listings', self.user.username) return user_dir_path zipfile = models.FileField(upload_to=overwrite_upload_to) On Aug 9, 8:35 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Sun, Aug 9, 2009 at 10:23 PM, neridaj <neri...@gmail.com> wrote: > > > It was suggested to me in an earlier post, to override save, and > > though I've read the documentation for upload_to before I guess I > > don't quite know how to implement it without an example. Due to my > > lack of experience I don't know how to address the 'instance' and > > 'filename' arguments required by the callable, is this even close? > > > class Listing(models.Model): > > user = models.ForeignKey(User) > > name = models.CharField(max_length=50) > > order = models.ForeignKey('Order') > > > def overwrite_upload_to(self, name): > > user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings', > > self.user.username) > > return user_dir_path > > Don't add in MEDIA_ROOT yourself. The return value from a callable > upload_to (just as if it were a simple string) is appended to your > MEDIA_ROOT setting. So you don't need to add it in yourself. > > > > > zipfile = models.FileField(upload_to=overwrite_upload_to(self, > > name)) > > Don't include the parens and parameters. Just pass the callable: > > zipfile = models.FileField(upload_to=overwrite_upload_to) > > Karen --~--~-~--~~~---~--~~ 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: building directory path with user table
I've revised my code but files are still getting uploaded to the 'listings' directory. class Listing(models.Model): user = models.ForeignKey(User) zipfile = models.FileField(upload_to='listings') name = models.CharField(max_length=50) order = models.ForeignKey('Order') def overwrite_upload_to(self): user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings', self.user.username) self.zipfile.url=user_dir_path def save(self, force_insert=False, force_update=False): Listing.overwrite_upload_to(self) super(Listing, self).save(force_insert, force_update) # Call the "real" save() method. def __unicode__(self): return self.name On Jul 22, 10:59 pm, neridaj <neri...@gmail.com> wrote: > I'm new to django and not sure how to do this, is this remotely close? > > class Listing(models.Model): > user = models.ForeignKey(User, unique=True) > zipfile = models.FileField(upload_to='listings') > name = models.CharField(max_length=50) > order = models.ForeignKey('Order') > > def save(self, user=user): > user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings', > user) > zipfile.upload_to=user_dir_path > > def __unicode__(self): > return self.name > > On Jul 18, 5:20 am, Eugene Mirotin <emiro...@gmail.com> wrote: > > > What you have written (this join for user_dir_path) is evaluated only > > once on model class creation, but what you need is evaluating it for > > each specific object. > > > I recommend you overloading the model save method to alter the image > > save path. > > > On Jul 17, 10:44 am, "neri...@gmail.com" <neri...@gmail.com> wrote: > > > > Hello, > > > > I'm trying to build a photo upload path which corresponds to the > > > selected user i.e., when the user is selected from the drop down the > > > username gets appended to the file upload path dynamically. If you > > > have any ideas I would like to hear them: > > > > class Listing(models.Model): > > > user = models.ForeignKey(User, unique=True) > > > user_directory_path = os.path.join(settings.MEDIA_ROOT, > > > 'listings', > > > user) > > > user_directory = models.FilePathField(path=user_directory_path, > > > recursive=True) > > > photo = models.ImageField(upload_to=user_directory) > > > name = models.CharField(max_length=50) > > > order = models.ForeignKey('Order') > > > > def __unicode__(self): > > > return self.name > > > > I keep getting this error: > > > > AttributeError: 'ForeignKey' object has no attribute 'startswith' --~--~-~--~~~---~--~~ 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: building directory path with user table
I'm new to django and not sure how to do this, is this remotely close? class Listing(models.Model): user = models.ForeignKey(User, unique=True) zipfile = models.FileField(upload_to='listings') name = models.CharField(max_length=50) order = models.ForeignKey('Order') def save(self, user=user): user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings', user) zipfile.upload_to=user_dir_path def __unicode__(self): return self.name On Jul 18, 5:20 am, Eugene Mirotinwrote: > What you have written (this join for user_dir_path) is evaluated only > once on model class creation, but what you need is evaluating it for > each specific object. > > I recommend you overloading the model save method to alter the image > save path. > > On Jul 17, 10:44 am, "neri...@gmail.com" wrote: > > > Hello, > > > I'm trying to build a photo upload path which corresponds to the > > selected user i.e., when the user is selected from the drop down the > > username gets appended to the file upload path dynamically. If you > > have any ideas I would like to hear them: > > > class Listing(models.Model): > > user = models.ForeignKey(User, unique=True) > > user_directory_path = os.path.join(settings.MEDIA_ROOT, 'listings', > > user) > > user_directory = models.FilePathField(path=user_directory_path, > > recursive=True) > > photo = models.ImageField(upload_to=user_directory) > > name = models.CharField(max_length=50) > > order = models.ForeignKey('Order') > > > def __unicode__(self): > > return self.name > > > I keep getting this error: > > > AttributeError: 'ForeignKey' object has no attribute 'startswith' --~--~-~--~~~---~--~~ 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: creating user directories upon account activation
figured it out, it was the = output from the dummy server for the activation code, thanks guys. On Jul 13, 10:03 pm, neridaj <neri...@gmail.com> wrote: > for some reason the function is returning false. This worked fine on > Dreamhost but when I run this using the django server with the dummy > send mail it returns false. The activation code is in the database so > I don't understand why it would return false, here is the output of > the trace: > > -> if SHA1_RE.search(activation_key): > (Pdb) n> > /Users/jasonnerida/django-projects/dzopastudio/registration/models.py(71)activate_user() > > -> return False > (Pdb) n > --Return--> > /Users/jasonnerida/django-projects/dzopastudio/registration/models.py(71)activate_user()->False > > -> return False > (Pdb) n> > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(65)activate() > > -> if extra_context is None: > (Pdb) n> > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(66)activate() > > -> extra_context = {} > (Pdb) n> > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(67)activate() > > -> context = RequestContext(request) > (Pdb) n> > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(68)activate() > > -> for key, value in extra_context.items(): > (Pdb) n> > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(70)activate() > > -> return render_to_response(template_name, > (Pdb) n> > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(71)activate() > > -> { 'account': account, > (Pdb) print account > False > > On Jul 13, 5:46 am, Alex Robbins <alexander.j.robb...@gmail.com> > wrote: > > > You might try pdb[1]. Drop > > "import pdb;pdb.set_trace()" > > into your code the line before "if SHA1_RE". Once at the pdb prompt > > you can just type n to move forward one line at a time. Any python > > code you type will get evaluated so you can check the status of > > variables at each step. (Pdb is a little cryptic at first, but well > > worth the time to learn it.) > > Hope that helps, > > Alex > > > 1http://docs.python.org/library/pdb.html > > > On Jul 12, 11:34 pm, neridaj <neri...@gmail.com> wrote: > > > > moved os import to the top and got rid of try except, with no change. > > > > if SHA1_RE.search(activation_key): > > > try: > > > profile = self.get(activation_key=activation_key) > > > except self.model.DoesNotExist: > > > return False > > > if not profile.activation_key_expired(): > > > media_root = dzopastudio.settings.MEDIA_ROOT > > > user_directory_path = os.path.join(media_root, > > > 'listings', 'neridaj') > > > os.mkdir(user_directory_path) > > > user= profile.user > > > user.is_active = True > > > user.save() > > > profile.activation_key = self.model.ACTIVATED > > > profile.save() > > > returnuser > > > return False > > > > On Jul 12, 8:34 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote: > > > > > On Monday 13 Jul 2009 8:34:23 am neridaj wrote: > > > > > > I still don't get any errors or directories generated from this code, > > > > > any ideas? > > > > > remove the try and except stuff - then you can see where it is failing. > > > > Also > > > > import os on top of your file, not within the code. > > > > -- > > > > regards > > > > kghttp://lawgon.livejournal.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: creating user directories upon account activation
for some reason the function is returning false. This worked fine on Dreamhost but when I run this using the django server with the dummy send mail it returns false. The activation code is in the database so I don't understand why it would return false, here is the output of the trace: -> if SHA1_RE.search(activation_key): (Pdb) n > /Users/jasonnerida/django-projects/dzopastudio/registration/models.py(71)activate_user() -> return False (Pdb) n --Return-- > /Users/jasonnerida/django-projects/dzopastudio/registration/models.py(71)activate_user()->False -> return False (Pdb) n > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(65)activate() -> if extra_context is None: (Pdb) n > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(66)activate() -> extra_context = {} (Pdb) n > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(67)activate() -> context = RequestContext(request) (Pdb) n > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(68)activate() -> for key, value in extra_context.items(): (Pdb) n > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(70)activate() -> return render_to_response(template_name, (Pdb) n > /Users/jasonnerida/django-projects/dzopastudio/registration/views.py(71)activate() -> { 'account': account, (Pdb) print account False On Jul 13, 5:46 am, Alex Robbins <alexander.j.robb...@gmail.com> wrote: > You might try pdb[1]. Drop > "import pdb;pdb.set_trace()" > into your code the line before "if SHA1_RE". Once at the pdb prompt > you can just type n to move forward one line at a time. Any python > code you type will get evaluated so you can check the status of > variables at each step. (Pdb is a little cryptic at first, but well > worth the time to learn it.) > Hope that helps, > Alex > > 1http://docs.python.org/library/pdb.html > > On Jul 12, 11:34 pm, neridaj <neri...@gmail.com> wrote: > > > moved os import to the top and got rid of try except, with no change. > > > if SHA1_RE.search(activation_key): > > try: > > profile = self.get(activation_key=activation_key) > > except self.model.DoesNotExist: > > return False > > if not profile.activation_key_expired(): > > media_root = dzopastudio.settings.MEDIA_ROOT > > user_directory_path = os.path.join(media_root, > > 'listings', 'neridaj') > > os.mkdir(user_directory_path) > > user= profile.user > > user.is_active = True > > user.save() > > profile.activation_key = self.model.ACTIVATED > > profile.save() > > returnuser > > return False > > > On Jul 12, 8:34 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote: > > > > On Monday 13 Jul 2009 8:34:23 am neridaj wrote: > > > > > I still don't get any errors or directories generated from this code, > > > > any ideas? > > > > remove the try and except stuff - then you can see where it is failing. > > > Also > > > import os on top of your file, not within the code. > > > -- > > > regards > > > kghttp://lawgon.livejournal.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: creating user directories upon account activation
yeah, from the front end everything looks as though it's working, but when I log on to the admin site the user is saved but not activated and the user folder is never created. I'm using django's dummy send mail and pasting the generated activation key into the address bar, which displays "account activated" when entered but the active checkbox is not checked when I log into the admin and view the user. On Jul 12, 9:39 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote: > On Monday 13 Jul 2009 10:04:05 am neridaj wrote: > > > moved os import to the top and got rid of try except, with no change. > > useris getting saved, but no directory is created and there is no error > message? > -- > regards > kghttp://lawgon.livejournal.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: creating user directories upon account activation
moved os import to the top and got rid of try except, with no change. if SHA1_RE.search(activation_key): try: profile = self.get(activation_key=activation_key) except self.model.DoesNotExist: return False if not profile.activation_key_expired(): media_root = dzopastudio.settings.MEDIA_ROOT user_directory_path = os.path.join(media_root, 'listings', 'neridaj') os.mkdir(user_directory_path) user = profile.user user.is_active = True user.save() profile.activation_key = self.model.ACTIVATED profile.save() return user return False On Jul 12, 8:34 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote: > On Monday 13 Jul 2009 8:34:23 am neridaj wrote: > > > I still don't get any errors or directories generated from this code, > > any ideas? > > remove the try and except stuff - then you can see where it is failing. Also > import os on top of your file, not within the code. > -- > regards > kghttp://lawgon.livejournal.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: creating user directories upon account activation
I still don't get any errors or directories generated from this code, any ideas? if SHA1_RE.search(activation_key): try: profile = self.get(activation_key=activation_key) except self.model.DoesNotExist: return False if not profile.activation_key_expired(): try: import os media_root = dzopastudio.settings.MEDIA_ROOT user_directory_path = os.path.join(media_root, 'listings', 'neridaj') os.mkdir(user_directory_path) except: print "directory could not be created." user = profile.user user.is_active = True user.save() profile.activation_key = self.model.ACTIVATED profile.save() return user return False On Jul 9, 1:22 pm, Friðrik Már Jónsson <frid...@pyth.net> wrote: > Hi, > > > > > if SHA1_RE.search(activation_key): > > try: > > profile = self.get(activation_key=activation_key) > > except self.model.DoesNotExist: > > return False > > if not profile.activation_key_expired(): > > user= profile.user > > user.is_active = True > > user.save() > > profile.activation_key = self.model.ACTIVATED > > profile.save() > > try: > > import os > > os.mkdir(MEDIA_ROOT + '/listings/' +user) > > except IOError: > > print "could not create folder." > > returnuser > > return False > > For one, I'm a tad befuzzled that you don't get an unexpected indent > error where your `print` statement is. > > Kindly hand over the value of `user_directory_path` and nobody will > get hurt. > > user_directory_path = os.path.join(MEDIA_ROOT, 'listings', user.username) > os.mkdir(user_directory_path) > print user_directory_path > > > I'm attempting to use a try except to catch any error but I don't > > think I'm using it correctly. > > If you don't want an exception when an IOError is thrown (e.g. can't > write to that location), but instead want "could not create folder." > printed on your runserver console, you are using it correctly. > > Regards, > Friðrik Már --~--~-~--~~~---~--~~ 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: creating user directories upon account activation
I tried that and still got no error or directory. if SHA1_RE.search(activation_key): try: profile = self.get(activation_key=activation_key) except self.model.DoesNotExist: return False if not profile.activation_key_expired(): user = profile.user user.is_active = True user.save() profile.activation_key = self.model.ACTIVATED profile.save() try: import os os.mkdir(MEDIA_ROOT + '/listings/' + user) except IOError: print "could not create folder." return user return False On Jul 8, 11:34 pm, Kenneth Gonsalveswrote: > On Thursday 09 Jul 2009 11:08:15 am neri...@gmail.com wrote: > > > profile.save() > > try: > > mkdir(MEDIA_ROOT + '/listings/' + user) > > except IOError: > > print "could notcreatefolder." > > should that not be > import os > os.mkdir(MEDIA_ROOT etc) > > -- > regards > kghttp://lawgon.livejournal.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sending email from local machine
I guess the dummy send_mail works, thanks. On Jul 8, 9:39 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote: > On Thursday 09 July 2009 10:05:08 neridaj wrote: > > > I saw that link but I would actually like to send the email. > > do you have an smtp server running on the machine? > -- > regards > kghttp://lawgon.livejournal.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---