2017-06-12 10 views
1

Ich wurde mit der Aktualisierung einer Django 1.3-Anwendung bis zu 1,8 beauftragt. Ich habe die Anwendungen Filebrowser mit einer neueren Version von einer Django 1.7 App die wir auch haben geändert. Alles funktioniert super, außer in dem Admin, wenn ich versuche, ein Bild mit Filebrowser laden ich den Fehler ReferenceError: FileBrowser is not defined. Es wird in diesem Filebrowser VorlageFileBrowser ist nicht definiert

Dateibrowser/templates/Dateibrowser/custom_field.html

/* Part that throws the error -> */ FileBrowser.show('id_image', '/admin/filebrowser/browse/?pop=1&dir=/customer_media'); 

{% load fb_versions %} 
<input id="{{ final_attrs.id }}" type="text" class="vFileBrowseField" name="{{ final_attrs.name }}" value="{{ value }}" /><a href="javascript:FileBrowser.show('{{ final_attrs.id }}', '{% url "fb_browse" %}?pop=1{% if final_attrs.directory %}&amp;dir={{ final_attrs.directory }}{% endif %}{% if final_attrs.format %}&amp;type={{ final_attrs.format }}{% endif %}');" class="fb_show"> 
    <img src="{{ final_attrs.search_icon }}" alt="" /> 
</a> 
{% ifequal value.filetype "Image" %} 
<p class="help" id="help_{{ final_attrs.id }}"> 
    <a href="{{ value.url_full }}" target="_blank" id="link_{{ final_attrs.id }}"> 
     <img id="image_{{ final_attrs.id }}" src="{% version value.path final_attrs.ADMIN_THUMBNAIL %}" class="preview" /> 
    </a> 
</p> 
{% else %} 
<p class="help" id="help_{{ final_attrs.id }}" style="display: none;"> 
    <a href="javascript://" target="_self" id="link_{{ final_attrs.id }}"> 
     <img id="image_{{ final_attrs.id }}" class="preview" src="" /> 
    </a> 
</p> 
{% endifequal %} 
{% if final_attrs.DEBUG %} 
<p> 
    <strong>Path</strong> {{ value.path }}<br /> 
    <strong>FileType</strong> {{ value.filetype }}<br /><br /> 
    <strong>Directory</strong> {{ final_attrs.directory }}<br /> 
    <strong>Extensions</strong> {{ final_attrs.extensions }}<br /> 
    <strong>Format</strong> {{ final_attrs.format }} 
</p> 
{% endif %} 
genannt werden

Ich bekomme auch diesen Fehler, obwohl ich sehen kann, dass jquery in der Netzwerk-Registerkarte meines Chrom-Debuggers geladen wird.

TypeError: $ is not a function 

├── admin_media 
│   └── js 
├── customer_media 
│   └── js 
├── site_media 
│   ├── js 
├── sqlite 
│   └── endeavor.db 
├── templates 
│   ├── admin 
│   │   └── base_site.html 
│   ├── base.html 
│   ├── detail 
│   │   ├── detail_base.html 
│   │   └── detail_page.html 
│   ├── donation.html 
│   ├── faqs.html 
│   ├── fund_list.html 
│   ├── home.html 
│   ├── news 
│   │   ├── news_article.html 
│   │   ├── news_articles.html 
│   │   └── news_list.html 
│   ├── staff.html 
│   └── thank_you.html 
├── webapp 
│   ├── DoImport.py 
│   ├── FundsList.csv 
│   ├── __init__.py 
│   ├── filebrowser 
│   │   ├── __init__.py 
│   │   ├── __init__.pyc 
│   │   ├── base.py 
│   │   ├── base.pyc 
│   │   ├── conf.py 
│   │   ├── conf.pyc 
│   │   ├── decorators.py 
│   │   ├── fields.py 
│   │   ├── fields.pyc 
│   │   ├── forms.py 
│   │   ├── functions.py 
│   │   ├── management 
│   │   │   ├── __init__.py 
│   │   │   └── commands 
│   │   │    ├── __init__.py 
│   │   │    └── version_generator.py 
│   │   ├── models.py 
│   │   ├── settings.py 
│   │   ├── static 
│   │   │   └── filebrowser 
│   │   │    ├── js 
│   │   │    │   ├── AddFileBrowser.js 
│   │   │    │   ├── FB_CKEditor.js 
│   │   │    │   ├── FB_FileBrowseField.js 
│   │   │    │   ├── FB_Redactor.js 
│   │   │    │   ├── FB_TinyMCE.js 
│   │   │    │   └── TinyMCEAdmin.js 
│   │   │    └── uploadify 
│   │   │     ├── Instructions.txt 
│   │   │     ├── Sample 
│   │   │     │   ├── check-exists.php 
│   │   │     │   ├── index.php 
│   │   │     │   ├── jquery.min.js 
│   │   │     │   ├── jquery.uploadifive.min.js 
│   │   │     │   ├── uploadifive-cancel.png 
│   │   │     │   ├── uploadifive-image-only.php 
│   │   │     │   ├── uploadifive.css 
│   │   │     │   └── uploadifive.php 
│   │   │     ├── change-log.txt 
│   │   │     ├── check-exists.php 
│   │   │     ├── index.php 
│   │   │     ├── jquery.min.js 
│   │   │     ├── jquery.uploadifive.js 
│   │   │     ├── jquery.uploadifive.min.js 
│   │   │     ├── license-commercial.txt 
│   │   │     ├── uploadifive-cancel.png 
│   │   │     ├── uploadifive-image-only.php 
│   │   │     ├── uploadifive.css 
│   │   │     └── uploadifive.php 
│   │   ├── templates 
│   │   │   └── filebrowser 
│   │   │    ├── append.html 
│   │   │    ├── custom_field.html 
│   │   │    ├── include 
│   │   │    │   ├── _response.html 
│   │   │    │   ├── breadcrumbs.html 
│   │   │    │   ├── filelisting.html 
│   │   │    │   ├── filter.html 
│   │   │    │   ├── paginator.html 
│   │   │    │   ├── search.html 
│   │   │    │   ├── tableheader.html 
│   │   │    │   └── toolbar.html 
│   │   │    ├── index.html 
│   │   │    ├── makedir.html 
│   │   │    ├── rename.html 
│   │   │    ├── upload.html 
│   │   │    └── versions.html 
│   │   ├── templatetags 
│   │   │   ├── __init__.py 
│   │   │   ├── fb_csrf.py 
│   │   │   ├── fb_pagination.py 
│   │   │   ├── fb_tags.py 
│   │   │   └── fb_versions.py 
│   │   ├── urls.py 
│   │   └── views.py 
│   ├── fund_list.csv 
│   ├── manage.py 
│   ├── settings.py 
│   ├── sslDecorator.py 
│   ├── static 
│   │   ├── admin 
│   │   │   └── js 
│   │   │    ├── LICENSE-JQUERY.txt 
│   │   │    ├── SelectBox.js 
│   │   │    ├── SelectFilter2.js 
│   │   │    ├── actions.js 
│   │   │    ├── actions.min.js 
│   │   │    ├── admin 
│   │   │    │   ├── DateTimeShortcuts.js 
│   │   │    │   └── RelatedObjectLookups.js 
│   │   │    ├── calendar.js 
│   │   │    ├── collapse.js 
│   │   │    ├── collapse.min.js 
│   │   │    ├── core.js 
│   │   │    ├── inlines.js 
│   │   │    ├── inlines.min.js 
│   │   │    ├── jquery.init.js 
│   │   │    ├── jquery.js 
│   │   │    ├── jquery.min.js 
│   │   │    ├── prepopulate.js 
│   │   │    ├── prepopulate.min.js 
│   │   │    ├── related-widget-wrapper.js 
│   │   │    ├── timeparse.js 
│   │   │    └── urlify.js 
│   │   └── filebrowser 
│   │    ├── css 
│   │    │   ├── filebrowser.css 
│   │    │   └── suit-filebrowser.css 
│   │    ├── img 
│   │    │   ├── explorer.png 
│   │    │   ├── filebrowser_icon_delete.gif 
│   │    │   ├── filebrowser_icon_delete_hover.gif 
│   │    │   ├── filebrowser_icon_rename.gif 
│   │    │   ├── filebrowser_icon_rename_hover.gif 
│   │    │   ├── filebrowser_icon_select.gif 
│   │    │   ├── filebrowser_icon_select_disabled.gif 
│   │    │   ├── filebrowser_icon_select_hover.gif 
│   │    │   ├── filebrowser_icon_show.gif 
│   │    │   ├── filebrowser_icon_show_hover.gif 
│   │    │   ├── filebrowser_icon_showversions.gif 
│   │    │   ├── filebrowser_icon_showversions_hover.gif 
│   │    │   ├── filebrowser_type_.gif 
│   │    │   ├── filebrowser_type_audio.gif 
│   │    │   ├── filebrowser_type_code.gif 
│   │    │   ├── filebrowser_type_document.gif 
│   │    │   ├── filebrowser_type_folder.gif 
│   │    │   ├── filebrowser_type_image.gif 
│   │    │   ├── filebrowser_type_video.gif 
│   │    │   ├── icon-fb-preview-hover.png 
│   │    │   ├── icon-fb-preview.png 
│   │    │   ├── icon-fb-view-image-hover.png 
│   │    │   ├── icon-pulldown-actions-active.png 
│   │    │   ├── icon-pulldown-actions-hover.png 
│   │    │   ├── icon-pulldown-actions.png 
│   │    │   ├── icon-searchbox.png 
│   │    │   └── icon-showversions.png 
│   │    ├── js 
│   │    │   ├── AddFileBrowser.js 
│   │    │   ├── FB_CKEditor.js 
│   │    │   ├── FB_FileBrowseField.js 
│   │    │   ├── FB_Redactor.js 
│   │    │   ├── FB_TinyMCE.js 
│   │    │   └── TinyMCEAdmin.js 
│   │    └── uploadify 
│   │     ├── Instructions.txt 
│   │     ├── Sample 
│   │     │   ├── check-exists.php 
│   │     │   ├── index.php 
│   │     │   ├── jquery.min.js 
│   │     │   ├── jquery.uploadifive.min.js 
│   │     │   ├── uploadifive-cancel.png 
│   │     │   ├── uploadifive-image-only.php 
│   │     │   ├── uploadifive.css 
│   │     │   └── uploadifive.php 
│   │     ├── change-log.txt 
│   │     ├── check-exists.php 
│   │     ├── index.php 
│   │     ├── jquery.min.js 
│   │     ├── jquery.uploadifive.js 
│   │     ├── jquery.uploadifive.min.js 
│   │     ├── license-commercial.txt 
│   │     ├── uploadifive-cancel.png 
│   │     ├── uploadifive-image-only.php 
│   │     ├── uploadifive.css 
│   │     └── uploadifive.php 
│   ├── urls.py 
│   ├── utility.py 
│   ├── views.py 
│   └── wsgi.py 
└── webapp_admin 

Einstellungen

import logging 
import os 

import sys 
from posixpathhelp import parentpath 

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) 
PROJECT_PARENT = parentpath(PROJECT_ROOT) 

sys.path.insert(0, PROJECT_ROOT) 

DEVELOPMENT = False 

# Make this unique, and don't share it with anybody. 
SECRET_KEY = '' 

# SECURITY WARNING: don't run with debug turned on in production! 
ALLOWED_HOSTS = ['*', ] 

SITE_ID = 1 

# EMAIL SETTINGS 
EMAILTO = '[email protected]' 
EMAIL_HOST = 'smtp.gmail.com' 
EMAIL_PORT = xxx 
EMAIL_HOST_USER = '[email protected]' 
EMAIL_HOST_PASSWORD = 'xxxxxxx' 
EMAIL_USE_TLS = True 

# Application definition 
INSTALLED_APPS = (
    'filebrowser', 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.sites', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'django.contrib.sitemaps', 
    'tinymce', 
    'content', 
    'page_content', 
    'staff', 
    'news', 
    'donation', 
    'paypal.standard', 
    'paypal.pro', 
    'paypal.standard.ipn', 
) 

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware', 
    'django.contrib.sessions.middleware.SessionMiddleware', 
    # 'django.middleware.csrf.CsrfViewMiddleware', 
    'django.contrib.auth.middleware.AuthenticationMiddleware', 
    'django.contrib.messages.middleware.MessageMiddleware', 
) 

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP 

TEMPLATE_CONTEXT_PROCESSORS = TCP + (
    'django.core.context_processors.request', 
    'common_context_processors.common_context', 
) 

ROOT_URLCONF = 'webapp.urls' 

WSGI_APPLICATION = 'webapp.wsgi.application' 

TIME_ZONE = 'America/New_York' 

LANGUAGE_CODE = 'en-us' 

USE_I18N = True 

USE_L10N = True 

MEDIA_ROOT = os.path.join(PROJECT_PARENT, "site_media/") 
CUSTOMER_MEDIA_ROOT = os.path.join(PROJECT_PARENT, "customer_media/") 

MEDIA_URL = '/site_media/' 
CUSTOMER_MEDIA_URL = '/customer_media/' 

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') 
STATIC_URL = '/static/' 

FILE_UPLOAD_PERMISSIONS = 0644 

SESSION_COOKIE_AGE = 3600 
SESSION_EXPIRE_AT_BROWSER_CLOSE = True 
SESSION_SAVE_EVERY_REQUEST = True 

LOGGING = { 
    'version': 1, 
    'disable_existing_loggers': True, 
    'formatters': { 
     'verbose': { 
      'format': '%(levelname)s %(asctime)s %(filename)s %(funcName)s %(lineno)d %(message)s' 
     }, 
     'normal': { 
      'format': '%(levelname)s %(asctime)s %(funcName)s %(message)s' 
     }, 
     'simple': { 
      'format': '%(levelname)s %(message)s' 
     }, 
    }, 
    'filters': { 
     'require_debug_false': { 
      '()': 'django.utils.log.RequireDebugFalse' 
     } 
    }, 
    'handlers': { 
     'console': { 
      'level': 'ERROR', 
      'class': 'logging.StreamHandler', 
      'formatter': 'verbose' 
     }, 
    }, 
    'loggers': { 
     'django.request': { 
      'handlers': ['console'], 
      'level': 'ERROR', 
      'propagate': True, 
     }, 
     'webapp': { 
      'handlers': ['console'], 
      'level': 'ERROR', 
      'propagate': True, 
     }, 
     '': { 
      'handlers': ['console'], 
      'level': 'ERROR', 
     }, 
    } 
} 

DJANGO_FRONT_ALLOWED_EDITORS = ['tinymce', ] 
DJANGO_FRONT_EDIT_MODE = 'inline' 
DJANGO_FRONT_EDITOR_OPTIONS = { 
    'filebrowserBrowseUrl': '/admin/filebrowser/browse/?pop=3', 
    'contentsCss': '/static/css/contents.css' 
} 

DJANGO_FRONT_KEY = 'xxxxxxxxxxxxxxxxxxxxxxx' # MAKE THIS UNIQUE PER SETTINGS FILE 

TRACKING_RESULTS_PER_PAGE = 50 

ADMINS = (
    ('XXXX XXXXXXXX', '[email protected]'), 
) 

MANAGERS = ADMINS 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', 
     # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 
     'NAME': os.path.join(PROJECT_PARENT, "sqlite/endeavor.db"), # Or path to database file if using sqlite3. 
     'USER': '', # Not used with sqlite3. 
     'PASSWORD': '', # Not used with sqlite3. 
     'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 
     'PORT': '', # Set to empty string for default. Not used with sqlite3. 
    } 
} 

if DEVELOPMENT: 
    ADMIN_MEDIA_PREFIX = 'http://127.0.0.1:8080/admin_media/' 
else: 
    ADMIN_MEDIA_PREFIX = '/admin_media/' 

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [ 
      # insert your TEMPLATE_DIRS here 
      os.path.join(PROJECT_PARENT, "templates"), 
     ], 
     'APP_DIRS': True, 
     'OPTIONS': { 
      'context_processors': [ 
       # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this 
       # list if you haven't customized them: 
       'django.contrib.auth.context_processors.auth', 
       'django.template.context_processors.debug', 
       'django.template.context_processors.i18n', 
       'django.template.context_processors.media', 
       'django.template.context_processors.static', 
       'django.template.context_processors.tz', 
       'django.contrib.messages.context_processors.messages', 
      ], 
     }, 
    }, 
] 

PAYPAL_TEST = False # Testing mode on 
PAYPAL_WPP_USER = "xxxxxxxxx" # Get from PayPal 
PAYPAL_WPP_PASSWORD = "xxxxxxxxxxxxx" 
PAYPAL_WPP_SIGNATURE = "xxxxxxxxxxxxxxxxxxxxxxxx" 
PAYPAL_RECEIVER_EMAIL = "[email protected]" 

Antwort

1

aus Ihrer Fehlermeldung:

TypeError: $ is not a function 

Es sieht aus wie die jQuery globale Variable $ ist nicht immer geladen.

Sind Sie sicher, dass Ihre statische jQuery-Datei jquery.min.js korrekt geladen wird?

+0

Das war was es war. Es stellte sich heraus, dass es nur eine Menge Javascript-Dateien gab, die aus irgendeinem Grund nicht hochgeschoben worden waren. Ich verstand, warum Filebrowser nicht funktionierte, aber es war seltsam, dass jquery immer noch nicht geladen wurde, weil ich ein CDN dafür in meiner Basisvorlage hatte. So oder so, danke Nathan! – JBT