19

I'm using django 1.8 and having trouble with it. I am trying to import tinymce in my project. When I render it caught

AttributeError: tuple' object has no attribute 'regex'

When I remove the url in url.py it is working. Here is my codes.

url.py

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    # Examples:
    # url(r'^$', 'hizlinot.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^admin/', include(admin.site.urls)),
    (r'^tinymce/', include('tinymce.urls')),

]

settings.py

"""
Django settings for hizlinot project.

Generated by 'django-admin startproject' using Django 1.8.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'b-4jipu5t(+)g(2-7g#s=1rs19dhpj-1-!x1b-*v7s85f-m%&q'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'edebiyat',
    'tinymce',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'hizlinot.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'hizlinot.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'

2 Answers 2

51

You forgot the 'url'

url(r'^admin/', include(admin.site.urls)),
url(r'^tinymce/', include('tinymce.urls')),

urlpatterns should be a list of url() instances

url returns RegexURLPattern but instead a tuple is found in your list.

https://docs.djangoproject.com/en/1.8/_modules/django/conf/urls/#url

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the quick response @DTing I tried to add 'url' start of the tinymce url but this time it doesn't appear HTMLField. It's appears textarea not HTMLField. models.py is fine from tinymce.models import HTMLField someHtmlEditor = HTMLField(null=True, verbose_name='Karakterlerin İncelemesi')
That is out of the scope of the original question. It is difficult to tell what the problem is from talking in comments. Try posting another question with the related code and error.
Problem solved. Thank you so much @DTing. I changed tinymce settings.py before and I forgot. When I fix Tinymce setting.py then I apply your advice It worked! :) Thanks
4

I know it's not absolutely related to the question, but sometimes this error can be a little deeper than directly in a urls.py file.

I got this error and the cause of the problem wasn't in the error stack trace.

I had this problem while browsing the Admin with a custom Admin Class, and the problem was with the method get_urls() of this class, which was returning something like:

def get_urls(self):
    from django.conf.urls import patterns
    return ['',
            (r'^(\d+)/password/$',
             self.admin_site.admin_view(self.user_change_password))] + super(CompanyUserAdmin, self).get_urls()

To fix it:

def get_urls(self):
    from django.conf.urls import patterns
    return [
            url(r'^(\d+)/password/$',
             self.admin_site.admin_view(self.user_change_password))] + \
           super(CompanyUserAdmin, self).get_urls()

Don't forget the import of 'url':

from django.conf.urls import url

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.