Code Monkey home page Code Monkey logo

cookiecutter / cookiecutter-django Goto Github PK

View Code? Open in Web Editor NEW
11.5K 200.0 2.8K 8.55 MB

Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Home Page: https://cookiecutter-django.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.55% Python 72.54% Shell 8.65% CSS 0.11% JavaScript 4.29% HTML 8.21% Batchfile 0.50% Dockerfile 4.66% SCSS 0.29% Procfile 0.20%
python django cookiecutter cookiecutter-django django-cookiecutter project-template boilerplate docker heroku celery

cookiecutter-django's Introduction

cookiecutter Logo

pypi python Build Status codecov discord docs Code Quality

Cookiecutter

Create projects swiftly from cookiecutters (project templates) with this command-line utility. Ideal for generating Python package projects and more.

Installation

Install cookiecutter using pip package manager:

# pipx is strongly recommended.
pipx install cookiecutter

# If pipx is not an option,
# you can install cookiecutter in your Python user directory.
python -m pip install --user cookiecutter

Features

  • Cross-Platform: Supports Windows, Mac, and Linux.
  • User-Friendly: No Python knowledge required.
  • Versatile: Compatible with Python 3.7 to 3.12.
  • Multi-Language Support: Use templates in any language or markup format.

For Users

Quick Start

The recommended way to use Cookiecutter as a command line utility is to run it with pipx, which can be installed with pip install pipx, but if you plan to use Cookiecutter programmatically, please run pip install cookiecutter.

Use a GitHub template

# You'll be prompted to enter values.
# Then it'll create your Python package in the current working directory,
# based on those values.
# For the sake of brevity, repos on GitHub can just use the 'gh' prefix
$ pipx run cookiecutter gh:audreyfeldroy/cookiecutter-pypackage

Use a local template

$ pipx run cookiecutter cookiecutter-pypackage/

Use it from Python

from cookiecutter.main import cookiecutter

# Create project from the cookiecutter-pypackage/ template
cookiecutter('cookiecutter-pypackage/')

# Create project from the cookiecutter-pypackage.git repo template
cookiecutter('gh:audreyfeldroy//cookiecutter-pypackage.git')

Detailed Usage

  • Generate projects from local or remote templates.
  • Customize projects with cookiecutter.json prompts.
  • Utilize pre-prompt, pre- and post-generate hooks.

Learn More

For Template Creators

  • Utilize unlimited directory nesting.
  • Employ Jinja2 for all templating needs.
  • Define template variables easily with cookiecutter.json.

Learn More

Available Templates

Discover a variety of ready-to-use templates on GitHub.

Special Templates

Community

Join the community, contribute, or seek assistance.

Support

  • Star us on GitHub.
  • Stay tuned for upcoming support options.

Feedback

We value your feedback. Share your criticisms or complaints constructively to help us improve.

Waiting for a Response?

  • Be patient and consider reaching out to the community for assistance.
  • For urgent matters, contact @audreyfeldroy for consultation or custom development.

Code of Conduct

Adhere to the PyPA Code of Conduct during all interactions in the project's ecosystem.

Acknowledgements

Created and led by Audrey Roy Greenfeld, supported by a dedicated team of maintainers and contributors.

cookiecutter-django's People

Contributors

actions-user avatar afrowave avatar andrew-chen-wang avatar arnav13081994 avatar ashwoods avatar audreyfeldroy avatar bogdal avatar browniebroke avatar burhan avatar crdoconnor avatar danihodovic avatar demestav avatar dependabot[bot] avatar foarsitter avatar github-actions[bot] avatar hackebrot avatar jayfk avatar kappataumu avatar kevgathuku avatar luzfcb avatar noisy avatar pydanny avatar pyup-bot avatar sfdye avatar shireenrao avatar tanoabeleyra avatar theskumar avatar trungdong avatar webyneter avatar yunti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cookiecutter-django's Issues

Django 1.7a1?

As this is a "bleeding edge" template, is there any plans to/no to change to Django 1.7a1? I'm really keen to test out the new migrations.

Thanks for the awesome work on this as always. Keep it up

Suggestion: Add grunt task runner.

We can include grunt to setup a development server. The possibilities include.

  • Live reloading of pages. If js/css/html files changed on disk.
  • Watch and compile/minify sass/coffeescript files if available in project.
  • etc, etc. [1]

You can start the django devserver and grunt watch by using grunt serve command.

I've a working django-cookiecutter[2], I can send a pull request.

Cheers,
Saurabh

[1] http://gruntjs.com/
[2] https://github.com/theskumar/cookiecutter-django/compare/grunt?expand=1

Suggestion: Allow themeability

First, thanks for the work on this. I've been using it in the past weeks and it's saving me quite a lot of time :)

I find that, once all is done, I want to use a different theme (not the vanilla-ish bootstrap). Currently, the only way is to change the templates/static with the new theme. An alternative would be IMO to create applications for themes (like mezzanine has). My current layout for example is:

{{cookiecutter.repo_name}}
   +- docs
   +- requirements
   +- {{cookiecutter.project_name}}
       +- config
       +- users
       +- theme_default (a django app)
            +- static (your static dir)
            +- templates (your templates dir)
            +- __init__.py
       +- theme_mine (another django app)
            +- static
            +- templates
...

then in my config/settings.py:

class Common(Configuration):

    ########## APP CONFIGURATION
    THEME_APPS = (  # this allows the changed templates to be selected before default
        'theme_spot',
        'theme_default',
    )
    ...
    # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
    INSTALLED_APPS = THEME_APPS + DJANGO_APPS + \
        THIRD_PARTY_APPS + LOCAL_APPS

novice question

I'm kind of new to Python/Django and this cookiecutter looks like it could save me. I've bought both of your books and I'm trying to stick to one particular school/concept. In your docs you say this won't work with Apache/mod_wsgi due to environment variables. Unfortunately thats the only way I know to deploy on Webfaction. Is it somewhat painless to overcome the constraint?

thanks in advance,

Michael

Integrate @bkonkle's Settings concepts

  1. Break up the settings into one module per configuration class.
  2. Import explicitly, rather than the import *.

Advantage: settings.py is no longer a giant, single god-class-style module. Instead we have more manageable 'singletons'.

Note to @bkonkle: Doing this in advance of our mad, secret plan. Bwah ha ha ha!

ImportError: cannot import name AbstractUser

I'm having the above error when executing the runserver command for the first time:

python financial-independence-app/manage.py runserver

Some more details about the error:

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x108a79690>>
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/commands/runserver.py", line 91, in inner_run
    self.validate(display_num_errors=True)
  File "/Library/Python/2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/validation.py", line 30, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/Library/Python/2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/models/loading.py", line 158, in get_app_errors
    self._populate()
  File "/Library/Python/2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/models/loading.py", line 67, in _populate
    self.load_app(app_name)
  File "/Library/Python/2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/models/loading.py", line 88, in load_app
    models = import_module('.models', app_name)
  File "/Library/Python/2.7/site-packages/Django-1.4.10-py2.7.egg/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/Username/app-name/app-name/users/models.py", line 3, in <module>
    from django.contrib.auth.models import AbstractUser
ImportError: cannot import name AbstractUser

requirements/base.txt: pytz

I got a DataError exception (Django 1.7, Python 2.7)

time zone "Pacific Standard Time" not recognized

in

h:\development\regxact\regxact_api_venv\lib\site-packages\django\db\backends\utils.py in execute, line 65

probably triggered by a last_modified field

last_modified = models.DateTimeField(auto_now=True, db_index=True)

This problem was resolved by installing pytz (2017.7). Perhaps you might consider adding pytz to requirements.

Thanks, Bernd

Memcached connection error 3 on Heroku

Apologies if this is not considered an issue, I have also posted it on Stack Overflow

I'm getting the following error when I go to avatar's standard /avatar/change/ url, which is at http://staging.cryptopals.org/avatar/change/ on my site (link requires signup). I also added django-heroku-memcacheify==0.5 to my requirements file but it has no effect. This problem does not occur locally.

Traceback (most recent call last):

File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response
  response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view
  return view_func(request, *args, **kwargs)

File "/app/.heroku/python/lib/python2.7/site-packages/avatar/views.py", line 123, in change
  return render(request, 'avatar/change.html', context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 53, in render
  return HttpResponse(loader.render_to_string(*args, **kwargs),

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader.py", line 169, in render_to_string
  return t.render(context_instance)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 140, in render
  return self._render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
  return self.nodelist.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 840, in render
  bit = self.render_node(node, context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/debug.py", line 78, in render_node
  return node.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader_tags.py", line 123, in render
  return compiled_parent._render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
  return self.nodelist.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 840, in render
  bit = self.render_node(node, context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/debug.py", line 78, in render_node
  return node.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader_tags.py", line 123, in render
  return compiled_parent._render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
  return self.nodelist.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 840, in render
  bit = self.render_node(node, context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/debug.py", line 78, in render_node
  return node.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader_tags.py", line 62, in render
  result = block.nodelist.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 840, in render
  bit = self.render_node(node, context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/debug.py", line 78, in render_node
  return node.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 1125, in render
  return func(*resolved_args, **resolved_kwargs)

File "/app/.heroku/python/lib/python2.7/site-packages/avatar/templatetags/avatar_tags.py", line 54, in avatar
  url = avatar_url(user, size)

File "/app/.heroku/python/lib/python2.7/site-packages/avatar/util.py", line 72, in cached_func
  result = cache.get(key)

File "/app/.heroku/python/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 75, in get
  val = self._cache.get(key)

ConnectionError: error 3 from memcached_get(:1:avatar_url_eui_80_2387): CONNECTION FAILURE, host: 127.0.0.1:11211 -> libmemcached/get.cc:314


<WSGIRequest
path:/avatar/change/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'_ga': 'GA1.2.563346429.1397860873',
 'csrftoken': '7srXCc4fgIGaJv4YHXs0Oo4afq6Nsqlm',
 'fbsr_623955891003497': 'cneNho68Qq-S4JyqCboIPgTNXk0ex5YKNjeIEh_79bo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUURxc1ZPS0h3T3d4ZVRHMmR5MWhjN3pubElsX0stRGNCci1tNXY0NVplbkhJMVJac1NaNElTeFVJTGVzREZULUV4QTJxQUVIUmtVcS1MYUN4LVVxVnhtT0lQa3JaQlJaUGdlVk1ZMWJGNFZIdFo5VktnNlZaSmlOOHc1Y0JNck1lQ1NsZlUydC1ZN2xndGdnNFpNdThTWnZMYzl3b0xKNGZaRWNqSGpScF9IRTI1TW1CYlpMeGRWLV9Bc1Nha2Y3bGNVcFp5eEtIX2xxaUpuRkpiRDNxNWJNNGNjaElra3ZCZUpwRWpNVlRkd1pQZEpiWGVBTXo2TEcxRFhaamZUU3JyVlZGeDlscFZiNzhTdEEtcnFsZTRKLVJoV2MzSkRoYnh1OXQwTmxJeXBWcDVqM3JyZ1AxNFMtVWFrS0U5ZUMzQ3dHY1IyOGhPWmR4N0I1RTZCQjdIdCIsImlzc3VlZF9hdCI6MTQwNzQ5ODg1OCwidXNlcl9pZCI6IjEwMDAwMTMyNjM3OTU2NSJ9',
 'sessionid': '0qke11tcx2nh9ur17hjzdyugnszb539d'},
META:{u'CSRF_COOKIE': u'7srXCc4fgIGaJv4YHXs0Oo4afq6Nsqlm',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8,es;q=0.6',
 'HTTP_CONNECTION': 'close',
 'HTTP_CONNECT_TIME': '1',
 'HTTP_COOKIE': '_ga=GA1.2.563346429.1397860873; fbsr_623955891003497=cneNho68Qq-S4JyqCboIPgTNXk0ex5YKNjeIEh_79bo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUURxc1ZPS0h3T3d4ZVRHMmR5MWhjN3pubElsX0stRGNCci1tNXY0NVplbkhJMVJac1NaNElTeFVJTGVzREZULUV4QTJxQUVIUmtVcS1MYUN4LVVxVnhtT0lQa3JaQlJaUGdlVk1ZMWJGNFZIdFo5VktnNlZaSmlOOHc1Y0JNck1lQ1NsZlUydC1ZN2xndGdnNFpNdThTWnZMYzl3b0xKNGZaRWNqSGpScF9IRTI1TW1CYlpMeGRWLV9Bc1Nha2Y3bGNVcFp5eEtIX2xxaUpuRkpiRDNxNWJNNGNjaElra3ZCZUpwRWpNVlRkd1pQZEpiWGVBTXo2TEcxRFhaamZUU3JyVlZGeDlscFZiNzhTdEEtcnFsZTRKLVJoV2MzSkRoYnh1OXQwTmxJeXBWcDVqM3JyZ1AxNFMtVWFrS0U5ZUMzQ3dHY1IyOGhPWmR4N0I1RTZCQjdIdCIsImlzc3VlZF9hdCI6MTQwNzQ5ODg1OCwidXNlcl9pZCI6IjEwMDAwMTMyNjM3OTU2NSJ9; sessionid=0qke11tcx2nh9ur17hjzdyugnszb539d; csrftoken=7srXCc4fgIGaJv4YHXs0Oo4afq6Nsqlm',
 'HTTP_HOST': 'staging.cryptopals.org',
 'HTTP_REFERER': 'http://staging.cryptopals.org/users/eui/',
 'HTTP_TOTAL_ROUTE_TIME': '0',
 'HTTP_USER_AGENT': 'Mozilla/5.0',
 'HTTP_VIA': '1.1 vegur',
 'HTTP_X_FORWARDED_FOR': '94.223.6.33',
 'HTTP_X_FORWARDED_PORT': '80',
 'HTTP_X_FORWARDED_PROTO': 'http',
 'HTTP_X_REQUEST_ID': '52f2318d-5f4c-4717-ba2c-0e67313d86af',
 'HTTP_X_REQUEST_START': '1407499899207',
 'PATH_INFO': u'/avatar/change/',
 'QUERY_STRING': '',
 'RAW_URI': '/avatar/change/',
 'REMOTE_ADDR': '10.121.6.32',
 'REMOTE_PORT': '43523',
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': u'',
 'SERVER_NAME': 'staging.cryptopals.org',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'gunicorn/0.17.4',
 'gunicorn.socket': <socket._socketobject object at 0x3b2c360>,
 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7f210e5271e0>,
 'wsgi.file_wrapper': <class gunicorn.http.wsgi.FileWrapper at 0x2561e20>,
 'wsgi.input': <gunicorn.http.body.Body object at 0x3b2ee10>,

What's going wrong here?

Settings import error

After I set up the project, I'm unable to python manage.py runserver because of an ImportError.

(test)a@a:~/test_repo/test_project$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 11, in 
    execute_from_command_line(sys.argv)
  File "/home/a/.virtualenvs/test/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/a/.virtualenvs/test/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/a/.virtualenvs/test/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    commands = get_commands()
  File "/home/a/.virtualenvs/test/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
    apps = settings.INSTALLED_APPS
  File "/home/a/.virtualenvs/test/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)
  File "/home/a/.virtualenvs/test/local/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/a/.virtualenvs/test/local/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__
    % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'test_project.config.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named test_project.config.settings


Issues deploying to heroku

I am trying to deploy the app to Heroku following the instructions, but when I get to this step:
heroku run python <project_name>/manage.py syncdb --noinput I get an error message "ImportError: No module named storages". Even after manually installing django_storages through pip in heroku, the same error shows up.

Constraints, Environment Variables, Apache/mod_wsgi

In the Readme it says under constraints that environment variables for configuration won't work with Apache/mod_wsgi.

This is kind of surprsing to me, since I have not heard of that issue before. It would be great to explain that in more detail or provide some links for more details.

And much more important: are there any workarounds for that problem. Apache/mod_wsgi is still a kind of common way to serve a Django project. And actually also my current way of serving my django projects. I have actually planned to use it in combination with envdir; but assume that this will suffer from the same problem.

I am aware that this problem does not originate from cookiecutter-django, but at the moment it pops up here - at least for me - for the first time.

`collectstatic` error: Memcached or S3?

Calling collectstatic on heroku app causes the following error:

Traceback (most recent call last):
  File "bananapeel/manage.py", line 11, in 
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/app/.heroku/python/lib/python2.7/site-packages/collectfast/management/commands/collectstatic.py", line 135, in handle_noargs
    collected = self.collect()
  File "/app/.heroku/python/lib/python2.7/site-packages/collectfast/management/commands/collectstatic.py", line 33, in collect
    ret = super(Command, self).collect(*args, **kwargs)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 111, in collect
    handler(path, prefixed_path, storage)
  File "/app/.heroku/python/lib/python2.7/site-packages/collectfast/management/commands/collectstatic.py", line 92, in copy_file
    self.destroy_lookup(prefixed_path)
  File "/app/.heroku/python/lib/python2.7/site-packages/collectfast/management/commands/collectstatic.py", line 61, in destroy_lookup
    cache.delete(self.get_cache_key(path))
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 86, in delete
    self._cache.delete(key)
_pylibmc.MemcachedError: error 47 from memcached_delete(:1:collectfast_asset_dc44a7965f7): SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY, host: 127.0.0.1:11211 -> libmemcached/connect.cc:592

I think this is an issue with S3 and not memcached because I'm getting a 403 in my resource requests (when I manually upload it).

Apart from setting the DJANGO_AWS_ACCESS_KEY_ID, DJANGO_AWS_SECRET_ACCESS_KEY, and DJANGO_AWS_STORAGE_BUCKET_NAME, and setting up a user/group/bucket in S3 with the proper permissions, is there something else to be done?

uknown tag load

Cloning into 'cookiecutter-dj-project'...
remote: Counting objects: 441, done.
remote: Compressing objects: 100% (227/227), done.
remote: Total 441 (delta 196), reused 437 (delta 196)
Receiving objects: 100% (441/441), 118.47 KiB | 0 bytes/s, done.
Resolving deltas: 100% (196/196), done.
Checking connectivity... done
project_name (default is "project_name")?
repo_name (default is "repo_name")?
author_name (default is "Your Name")?
email (default is "Your email")?
description (default is "A short description of the project.")?
year (default is "Current year")?
domain_name (default is "Domain name")?
Traceback (most recent call last):
  File "/Users/mgutz/.virtualenvs/foo/bin/cookiecutter", line 9, in <module>
    load_entry_point('cookiecutter==0.6.4', 'console_scripts', 'cookiecutter')()
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/cookiecutter/main.py", line 90, in main
    cookiecutter(args.input_dir)
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/cookiecutter/main.py", line 61, in cookiecutter
    context=context
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/cookiecutter/generate.py", line 135, in generate_files
    generate_file(infile, context, env)
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/cookiecutter/generate.py", line 85, in generate_file
    tmpl = env.get_template(infile_fwd_slashes)
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/jinja2/environment.py", line 791, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/jinja2/environment.py", line 765, in _load_template
    template = self.loader.load(self, name, globals)
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/jinja2/loaders.py", line 125, in load
    code = environment.compile(source, name, filename)
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/jinja2/environment.py", line 554, in compile
    self.handle_exception(exc_info, source_hint=source)
  File "/Users/mgutz/.virtualenvs/foo/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "./cookiecutter-dj-project/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/avatar/add.html", line 2, in template
    {% load i18n avatar_tags %}
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'load'.

Installing requirements tries to install Django 1.5.4

Even though it requires Django 1.6, it also attempts to install Django 1.5:

Downloading/unpacking django>=1.4.2 (from django-model-utils==1.5.0->-r requirements/base.txt (line 16))
  Downloading Django-1.5.4.tar.gz (8.1MB):  87%  7.0MB

'STATIC_URL' value is not set properly

The issue is at this line:

STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME

The __repr__ method for values.Value will return a string not suitable to be inserted into a URL: <Value Default: None>

It will replace None with whatever it could resolve from the environment. The problem is now the URL becomes:

https://s3.amazonaws.com/%lt;Value%20Default:%20foo&gt;/

I have a fix - its more of a hack really at this commit that will resolve the issue.

This commit just updates the above to reflect the environment variable as per the documentation.

AttributeError: 'DatabaseOperations' object has no attribute 'shorten_name'

I get this error if i try to run migrate:

python manage.py migrate

Traceback (most recent call last):
File "medfuturo/manage.py", line 11, in
execute_from_command_line(sys.argv)
File "/home/raony/webapps/medfuturo/lib/python2.7/django/core/management/init.py", line 399, in execute_from_command_line
utility.execute()
File "/home/raony/webapps/medfuturo/lib/python2.7/django/core/management/init.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/raony/webapps/medfuturo/lib/python2.7/django/core/management/base.py", line 242, in run_from_argv
self.execute(_args, *_options.dict)
File "/home/raony/webapps/medfuturo/lib/python2.7/django/core/management/base.py", line 285, in execute
output = self.handle(_args, *_options)
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/management/commands/migrate.py", line 108, in handle
ignore_ghosts = ignore_ghosts,
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/migration/init.py", line 213, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 235, in migrate_many
result = migrator.class.migrate_many(migrator, target, migrations, database)
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 310, in migrate_many
result = self.migrate(migration, database)
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 133, in migrate
result = self.run(migration)
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 107, in run
return self.run_migration(migration)
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/home/raony/lib/python2.7/South-0.7.6-py2.7.egg/south/migration/migrators.py", line 57, in
return (lambda: direction(orm))
File "/home/raony/webapps/medfuturo/medfuturo/medfuturo/users/migrations/0001_initial.py", line 28, in forwards
m2m_table_name = db.shorten_name(u'users_user_groups')
AttributeError: 'DatabaseOperations' object has no attribute 'shorten_name'

Provide option to use MySQL instead of PostgreSQL

While I really prefer PostgreSQL, a lot of people use MySQL. With cookiecutter, we could pass in a new cookiecutter.json prompt:

{
"Database Engine (PostgreSQL or MySQL)": "PostgreSQL"
}

Then, in the settings template, we could use this variable for a Jinja2 conditional which would either set things up for PostgreSQL or MySQL.

Python 3.4 and python-memcached

The python-memcached library isn't compatible with Python 3.4, and it's uncertain when 3.4 compatibility will be finished (see linsomniac/python-memcached#54).

The main release of pylibmc suffers from a similar issue.

It would be nice to update the documentation with this information, or perhaps comment out the entries. Let me know if you'd like a pull request for this!

Regardless, this project (and your book, I have the Django 1.5 edition) have been immensely helpful. Thank you!

Reverse fails with usernames which include dots

I was getting a NoReverseMatch error with usernames which contained dots, such as those constructed from Facebook names which were saved automatically as e.g. 'earle.nerve'.

I fixed by amending the Line 21 of:

https://github.com/pydanny/cookiecutter-django/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.repo_name%7D%7D/users/urls.py

adding a dot capture to the regex. I think I will make the regex match more character too. Can you suggest an optimal regex?

Is there a better fix? Is this a problem you have dealt with or avoided some other way?

Thanks!

Question about the project structure...

I was wondering the reasoning behind making the project root a python module vs. following Django's default of making a package within the root for configurations and site level things?

It definitely seems a lot cleaner, but I wasn't sure if this would evolve to eventually match what Django is doing or if this will be the way moving forward?

Or if maybe this template existed before Django made the change and there was no need to change it?

Thanks!

__init__.py next to manage.py might break relative imports from apps

I've just run into a problem, where a relative import (from .models import Model) in an app caused problems with Django 1.7's app-loader: the model gets registered with two different names, and Django halts:
https://code.djangoproject.com/ticket/22280#comment:6

Since you also have a __init__.py file next to manage.py, this is probably something to re-consider?

I might be missing something obvious here, and have not tested it with cookiecutter-django.

Will the use of the configurations package result in environment variable conflicts when deploying multiple sites to a VPS?

It would seem that if I have multiple sites sitting on a production VPS, I'm going to have problems with environmental settings like "DJANGO_AWS_ACCESS_KEY_ID" as such items will generally vary from project-to-project.

Am I correct in my assessment or am I missing something?

An easy fix, which I'm willing to do and submit a pull-request if appropriate, is to simply add the project name into the naming convention here (e.g., so you will use DJANGO_<PROJECT_NAME>_AWS_ACCESS_KEY_ID instead).

Thoughts?

add https://requires.io/ badge

Hello @pydanny , I found these days the requires.io. Basically it is a service which checks that the versions of the dependencies of the project are in the latest version or not and execute some actions thereafter. Its operation is very similar as Travis-ci.

It is free for open source projects. To activate it by logging in to Requires.io using your github account and enable a repository you want to check.

I activated on my brach, and it worked perfectly:
https://github.com/luzfcb/cookiecutter-django-fabio

By default Requires.io looks for the Following requirements files in the project:

setup.py,
all files matching req_.txt or req_.pip,
all files matching requirements/.txt or requirements/.pip,
buildout.cfg and versions.cfg,
tox.ini.

List dependencies outside pip

I had to install memcached before I could install the requirements. I know this is a pip dependency problem but just thought you might want to list the external dependencies on the readme.

Gunicorn and django-configurations error (after settings refactoring)

After recent settings refactoring it's not possible to start the application using gunicorn. It raises:

File "/home/user/www/project/project/settings/__init__.py", line 3, in <module>
from .local import Local # noqa
File "/home/user/www/project/project/settings/local.py", line 16, in <module>
class Local(Common):
File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/configurations/base.py", line 30, in __new__
raise ImproperlyConfigured(install_failure)
ImproperlyConfigured: django-configurations settings importer wasn't correctly installed. Please use one of the starter functions to install it as mentioned in the docs: http://django-configurations.readthedocs.org/

The solutions seems to be adding explicit:

from configurations import importer
importer.install()

to the config/init.py (in my case config dir is called settings)

Also see: jazzband/django-configurations#25

additions to the "usage" part

new user here, please tell me if this is noise.

after pip install requirements/local.txt....

  1. Go create a database for your site to use
  2. edit myapp/config/settings.py and change the database URL. This should be
postgres://username:password@hostname:port/databasename
  1. python manage.py syncdb (to create basic tables)
  2. python manage.py migrate (to install the migrations)
  3. python manage.py runserver (to start the server)
  4. hit localhost:8000 (to see if everything worked)

At this point, you WON'T have any admin user set up. (Is this a 1.6 bug? Usually the initial user is set up at the first syncdb.)

  1. edit your settings again and find EMAIL_BACKEND. change "smtp" to "console". This is so you don't have to go through all the rigamarole of getting email connectivity working right now.

  2. use the "Sign up" link available from http://localhost:8000 to sign up for an account. The verification email will appear in the window where you started the server. (The console.)

  3. Copy the confirmation link from the console and paste it into your browser. Confirm your email, and you'll be taken to the login screen.

  4. Now you can login to the site, but you still don't have an administrative user. To make the user you just registered an admin user, fire up a postgres query tool (psql, pgadmin3, etc), and run:

update users_user
set is_superuser = true
, is_staff = true
where id = 1; # or use username or email to restrict your update.

Now you are ready to start creating your own app. (I'll file another ticket with that doco when I get it working.)

Clearer notes on database setup in README

I'm a beginner with postgres and just spent a few hours figuring out that I had to include a database username and password in the connection URL. The confusion mostly came from not using the defualt Django database connection settings layout (separate uesrname, password, server, port fields).

Would it be possible to modify the README with a note about this? While I understand this project is mainly for regular developers to save time, maybe this could save the next noob an evening wasted fighting with postgres.

Happy to make an edit from the beginner perspective in a pull request if it would possibly be accepted.

Checking if database is set fails

This check will never be True, since it returns a value object and not a dict.

    DATABASES = values.DatabaseURLValue()
    if DATABASES == {'default': {}}:
        DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.postgresql_psycopg2',
                'NAME': "awesome-list",
            }
        }

celery or python-rq?

I prefer the simplicity of redis-py, but I'm open to debate as to which project to use queues.

Adding database credentials

When I ran ./manage migrate for the first time I got

django.db.utils.OperationalError: fe_sendauth: no password supplied

I'm proposing to add credentials to the database URL replacing:

DATABASES = values.DatabaseURLValue('postgres://localhost/{{cookiecutter.repo_name}}')      

with

DATABASES = values.DatabaseURLValue('postgres://localhost/django:blank@{{cookiecutter.repo_name}}') 

In addition I would add a security check to make sure that an error is flagged if the production database password is 'blank'. I have opened a pull request #139.

Remove unnecessary `account` templates

There are two templates in templates/accounts (directory where templates override those included in 3rd-party package allauth) that seems not to be used at all, and are not part of the allauth. These are password_delete.html and password_delete_done.html.

I might be missing something but If I'm right, they should be removed.

django-debug-toobar not installed

I may be doing this wrong.

I went throught https://github.com/pydanny/cookiecutter-django/blob/master/README.rst and that created my directory. Great.

cd myapp/myapp
pip install -r requirements.txt  (barked my shins on a few mising -dev libraries there)
python manage.py runserver

gives me a message about dj_debug_toolbar not installed. pip install django-debug-toolbar seems to fix it.

I think my mistake was running with the top-level requirements.txt, when what I should be doing for local develoment is pip install -r requirements/local.txt

I think...

Author names with apostrophes break the settings file

The cookiecutter author_name variable can contain an apostrophe for many people ("O'Connor", in my case), which leads to a syntax error in config/common.py when it is inserted into ADMINS.

That case might be minimally addressed here by, say, wrapping the value in double quotes or triple quotes to be safer.

However, it might also be reflective of a broader problem of a lack on validation or context awareness in injecting the cookiecutter variables into code, though that doesn't seem likely to be a problem other places in this project.

Deployment script

I'd be awesome to have some sort of deployment script. I'm quite new into django but I think Fabric does the trick.

BTW, Great project!

display messages in base.html

since it appears that the messsages framework is going to be used (and it's a real common part of most sites), it would make sense to display the messages in base.html. Here's an addition to the base.html template that seems to pick up the default bootstrap styles.

      {% if messages %}
        {% for message in messages %}
          <div class="alert {% if message.tags %}alert-{{ message.tags }}"{% endif %}>{{ message }}</div>
        {% endfor %}
      {% endif %}

      {% block content %} ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.