添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Related Posts

  • Django Reverse for 'document' with keyword arguments {'title':'computer science'} not found. 1 pattern tried
  • How to run celery as a daemon in production?
  • Embedding JSON objects in script tags
  • How to inject a variable into a Django template's context, similar to the 'as' argument of the built-in 'url' tag?
  • Error "can only concatenate tuple (not "list") to tuple" when adding heroku line
  • How to populate html table with info from list in django
  • Django add objects to Related Manager during creation
  • How to iterate over object attributes and check for duplicate in python?
  • Django filter by hour of day when timezone info stored in database
  • How to use Django templating as is without server
  • Django: Add context to TemplateView
  • TypeError: context must be a dict rather than Context
  • clean form data only if creating model, not when updating
  • Join Many to Many tables in Django
  • Django, Dajax and Javascript - onclick not calling python method
  • How to create tally counts by group in long format using dplyr
  • Replace characters after character grouping with nothing
  • Spark redis connector to write data into specific index of the redis
  • Pyspark repeated in loop
  • Join in spark dataframe (scala) based on not null values
  • Passing sparkSession Between Scala Spark and PySpark
  • Combine rows in data frame without grouping
  • How to read PGN data into a DataFrame
  • Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : Arguments imply different number of rows: 1, 4, 5, 2
  • Filtering long format Pandas DF based on conditions from the dictionary
  • django

  • Get request body as string in Django
  • How can I get a decimal field to show more decimal places in a template?
  • Django: Search form in Class Based ListView
  • Transaction managed block ended with pending COMMIT/ROLLBACK
  • Sharing django sessions on specific subdomains
  • integrate django password validators with django rest framework validate_password
  • Check if model field exists in Django
  • Django: Insert row into database
  • Django: "Reverse not found"
  • Django - How to increment integer field from user input?
  • I am trying to add view_amodel permission to my models. I decided to add the permission after migration. So I made following approach.

    At an_app/ init .py

    from an_app.apps import MyAppConfig
    default_app_config = MyAppConfig
    

    At an_app/apps.py

    from django.apps import AppConfig
    from django.db.models.signals import post_migrate
    from django.contrib.contenttypes.models import ContentType
    from django.contrib.auth.models import Permission
    def add_view_permissions(sender, **kwargs):
        This syncdb hooks takes care of adding a view permission too all our
        content types.
        # for each of our content types
        for content_type in ContentType.objects.all():
            # build our permission slug
            codename = "view_%s" % content_type.model
            # if it doesn't exist..
            if not Permission.objects.filter(content_type=content_type, codename=codename):
                # add it
                Permission.objects.create(content_type=content_type,
                                          codename=codename,
                                          name="Can view %s" % content_type.name)
                print "Added view permission for %s" % content_type.name
    class MyAppConfig(AppConfig):
        def ready(self):
            post_migrate.connect(add_view_permissions, sender=self)
    

    When I do python manage.py migrate, I get following error,

    AttributeError: type object 'MyAppConfig' has no attribute 'rpartition'

    How to solve it.

    Accepted answer

    The reference to the AppConfig in the app's __init__.py is supposed to be a string, not the class itself.

    Specify

    default_app_config = 'an_app.apps.MyAppConfig'
    

    and remove the import.

    See the documentation.

    Related Query

  • How to fix " AttributeError at /api/doc 'AutoSchema' object has no attribute 'get_link' " error in Django
  • django type object Http404 has no attribute get
  • Django REST framework: type object X has no attribute 'get_extra_actions'
  • Django AttributeError 'tuple' object has no attribute 'regex'
  • AttributeError at / 'OrderedDict' object has no attribute 'register' in Django REST framework from quickstart documentation
  • Django AttributeError Model object has no attribute 'filter'
  • Type object 'X' has no attribute 'DoesNotExist' with django
  • AttributeError 'tuple' object has no attribute 'values' django rest framework
  • type object 'User' has no attribute 'objects django
  • Django AttributeError 'datetime.date' object has no attribute 'utcoffset'
  • unable to resole: type object 'Member' has no attribute '_default_manager, django 1.10
  • AttributeError : type object '_io.StringIO' has no attribute 'StringIO'
  • django none type object has no attribute status
  • Django Elastic Search: AttributeError: type object 'PostDocument' has no attribute 'Django'
  • Type object 'Post' has no attribute 'published' Django
  • AttributeError in views.py: type object 'Transaction' has no attribute 'objects'
  • Django 1.9 url include AttributeError 'str' object has no attribute 'regex'
  • Django Rest Framework AttributeError 'function' object has no attribute 'model' in router.register
  • Django 2.0 Tutorial - AttributeError at /polls/1/vote/ 'ReverseManyToOneDescriptor' object has no attribute 'get'
  • AttributeError at /admin/ by Django 'WSGIRequest' object has no attribute 'user'
  • Django 1.8: AttributeError at /: 'str' object has no attribute 'copy'
  • Django Test: type object has no attribute 'objects'
  • Django Treebread admin AttributeError - 'Page' object has no attribute 'page_ptr_id'
  • AttributeError - type object 'Services' has no attribute 'service_price'
  • Django form saving issue AttributeError 'tuple' object has no attribute 'get'
  • Django AttributeError 'ModelFormOptions' object has no attribute 'concrete_fields'
  • django AttributeError, type object 'object' has no attribute python 3
  • Django error: AttributeError at 'Manager' object has no attribute 'create_user'
  • Django UpdateView AttributeError 'UserPostUpdateView' object has no attribute 'publish'
  • Django AttributeError " " object has no attribute " "
  • More Query from same tag

  • Python/Django: RelatedObjectDoesNotExist: Cart has no user
  • Django: Rename Group to Role
  • How do I set collation_connection in Django?
  • Compare mutiple ids present in list of dictionaries with the ids of model django
  • Getting the value of a field in the default language in django-transmeta
  • Django with Postgresql on Heroku - Could not translate host name "db" to address: Name or service not known
  • Get All Users in django
  • Admin URL resolver to pass a filtering argument
  • Full text search: Whoosh Vs SOLR
  • difference between localhost and postgres for host in docker
  • Deploying Django app on Heroku: Can I manually set environment variables in the .env file? Do I need to install tools like autoenv, heroku-config...?
  • How do I prevent Django from running unit tests on parent class when subclassing TestCase?
  • django.core.exceptions.ImproperlyConfigured: The included URLconf '' does not appear to have any patterns in it
  • raise TypeError('view must be a callable or a list/tuple in the case of include()
  • Cannot generate foreign key field in Django
  • how would I count the number of returns in my list and include it in my printed statement? Dash figure title positioning Drawing widget class won't draw when added to existing code Kivy Python Multiplying Two Dictionaries Together, Then Dividing By Sum of One Dictionary Key Value Azure DevOps Pipeline does not run Pytest. Keeps loading How do I remove/replace the ⁿ character from a string? Why Gunicorn spawn processes running on single cpu core? despite having 8 cores on my system? Extract last value of list in each row read and get data from xml file stored in s3 bucket