python - Django modify templates of pip-installed app -
I am thinking that is the right way to override the template for an app that is installed through PIP. My example is related to the app structure as follows:
Notification | ---- __init__.py | ---- Templates | ---- Notifications | ---- list.html | ---- notice.html I have duplicated this structure in my app and accordingly modify .html files. However, now I am facing the following error: ImportError: The name can not be notified which occurs when a view from another app (profile) where i from notification import I I did not get any error without overriding the template. What am I losing? Is there anything extra settings.py?
(I have corrected the readme.md installation instructions in the package and it is working properly without overwritten templates)
trackback < Pre> file "/projectpath/project/urls.py", line 13, & lt; Module & gt; Url (r '^ Profile /', include ( 'profile.urls')), the file "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/django/conf/urls/ __init__ include .py ", line 26, urlconf_module = import_module (urlconf_module) file" /home/user/.virtualenvs/project/local/lib/python2.7/site-packages/django/utils/importlib.py ", line 40, import_module __import __ (name) in the file "/projectpath/profile/urls.py", line 2, & lt; Module & gt; From the profile import views, the file "/projectpath/profile/views.py", line 17, in the & lt; Module & gt; Notify Import Import Import Import: Can not Import Name Import View Import import information from imported notifications (request): .. . notify.send (request yunite.settings: .user, recipient = request.user, verb =) setting # project directory root 'You reached level 10. Base PROJECT_DIR = path (__ file __). Ancestor (3) #ROOT_PATH = os.path.dirname (__ file__) TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders .eggs.Loader ',) TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.request", "django.contrib.auth.context_processors.auth",) # directory to find templates TEMPLATE_DIRS = (PROJECT_DIR. Children ( "templates") ); INSTALLED_APPS = (... 'Notifications',)
A template in Django Override is simple in your main application directory, a template directory (if not already created) Minister must. Then create a new directory inside the template directory, which is named in your case (notifications) then template files here in your case ( list.html and notice.html ) Copy. When done, you have overridden the app templates with your own templates, feel free to edit them.
Comments
Post a Comment