GithubHelp home page GithubHelp logo

liip / django-template Goto Github PK

View Code? Open in Web Editor NEW
17.0 42.0 14.0 1.02 MB

Project template for Django projects

License: MIT License

Python 68.84% Shell 4.54% HTML 1.24% Makefile 5.15% JavaScript 14.46% CSS 1.43% Dockerfile 4.33%

django-template's Introduction

Django project template

To create a new project using this template, do the following:

pip install cookiecutter
cookiecutter gh:liip/django-template

Go to http://my-project.docker.test/ and start hacking!

Troubleshooting

If you get the following error when running cookiecutter:

Traceback (most recent call last):
  File "/home/me/.virtualenvs/tmp-1081dbf5557421f7/bin/pip-compile", line 7, in <module>
    from piptools.scripts.compile import cli
  File "/home/me/.virtualenvs/tmp-1081dbf5557421f7/local/lib/python2.7/site-packages/piptools/scripts/compile.py", line 16, in <module>
    from ..repositories import PyPIRepository
  File "/home/me/.virtualenvs/tmp-1081dbf5557421f7/local/lib/python2.7/site-packages/piptools/repositories/__init__.py", line 2, in <module>
    from .pypi import PyPIRepository
  File "/home/me/.virtualenvs/tmp-1081dbf5557421f7/local/lib/python2.7/site-packages/piptools/repositories/pypi.py", line 10, in <module>
    from pip.req.req_set import RequirementSet
ImportError: No module named req_set

That's because your pip version is too old. Upgrade it either with your package manager, or by running pip install --upgrade pip.

Deploying your site

You can use the provided fabfile to deploy your site. Before using it, check the fabfile.py file and adjust the settings at the top of the file.

Once the settings are adjusted and the dependencies installed, you can use the bootstrap command that will create the directory structure, push the code to the server and deploy your project. For example, the following command will bootstrap your dev environment:

fab dev bootstrap

You'll have to run the bootstrap command for each of the environments you want to bootstrap. After the site is bootstrapped, subsequent deployments can be done with the deploy command:

fab dev deploy

django-template's People

Contributors

danickfort avatar dependabot[bot] avatar etoulas avatar fanderegg avatar hugo-torres avatar ldgtd avatar lebenleben avatar nadeempoco avatar odyx avatar renatomoor avatar rhea-astons avatar schtibe avatar sephii avatar simonbru avatar t4m avatar

Stargazers

 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

django-template's Issues

Add Wagtail

Just like DjangoCMS, provide a template for Wagtail sites.

Use more efficient reloader in backend container

Django's dev server uses almost no CPU time when idle with the watchman reloader. However this requires the watchman binary and pywatchman library.

The watchman binary is packaged in debian bullseye, but not the current stable release (buster).
I tried copying the binary from a 3rd party image in the Dockerfile. It is ugly but it works:

COPY --from=workbenchdata/watchman-bin:latest-buster-slim /usr/bin/watchman /usr/local/bin/
RUN install -m777 -d /usr/var/run/watchman/

An alternative solution could be to use runserver_plus from django extensions with the watchdog reloader. It is less efficient (~2% of idle CPU usage on my machine), but easier to setup (we just need to add watchdog to dev requirements).

Fix postgres credentials in docker-compose.yml

The postgres image does not accept empty passwords anymore:

2020-02-17T13:12:11.756884209Z Error: Database is uninitialized and superuser password is not specified.
2020-02-17T13:12:11.756931646Z You must specify POSTGRES_PASSWORD for the superuser. Use
2020-02-17T13:12:11.756939680Z "-e POSTGRES_PASSWORD=password" to set it in "docker run".
2020-02-17T13:12:11.756946255Z
2020-02-17T13:12:11.756951738Z You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections
2020-02-17T13:12:11.756957449Z without a password. This is not recommended. See PostgreSQL
2020-02-17T13:12:11.756962959Z documentation about "trust":
2020-02-17T13:12:11.756968449Z https://www.postgresql.org/docs/current/auth-trust.html

We should either set POSTGRES_HOST_AUTH_METHOD: trust or set a password.

Feature: Add services on request

Ideally the startup script would ask whether we need the following services to be setup:

  • celery
  • sentry
  • heroku (idea is to push heroku master and it just works)

Cannot pass arguments to fabric tasks

Some tasks, such as import-db, can take command-line arguments, for example to specify the path to the dump file to load. But if you check the output of fab --help import-db you’ll see that the task doesn’t seem to accept any argument. That’s caused by the @remote decorator. I guess because the wrapper function takes *args and **kwargs, fabric cannot parse its signature.

I’m not sure if it can be solved. If there’s no other way, we could remove the @remote decorator.

Disconnect other clients from DB on import

import_db often fails because postgres refuses to drop the schema when other clients are connected.
We could run something like this before starting the import:

psql -c "select pg_terminate_backend(pid) from pg_stat_activity where datname='{db_name}';"

Django version

In requirements/base.txt, we have django==1.9, in requirements/dev.txt, we have django==1.8.4.

Add black

Now that we use black in all new Swing projects, it seems useful to integrate it in the template.

Prevent conflicts between multiple containers with the same name on the same network

All containers connected to a specific network share a common DNS namespace, which may lead to confusing conflicts.
Exemple: my frontend container/service is connected to the default network AND the pontsun network. It tries to proxy requests to the backend container/service, but the backend domain name resolves to another backend container from another project that is also part of the pontsun network.

To prevent this issue, we could give an explicit name to the default network (e.g. myproject) and use FQDNs (e.g. backend.myproject) in configuration files such as webpack.config.js.

Npm run start => error on fresh setup

Fresh setup gives the following error when running npm run start

(ENV) vagrant@capstone:/vagrant$ npm start

[email protected] start /vagrant
NODE_ENV=development webpack-dev-server --hot

/vagrant/node_modules/webpack-cli/bin/config-yargs.js:89
describe: optionsSchema.definitions.output.properties.path.description,
^

TypeError: Cannot read property 'properties' of undefined
at module.exports (/vagrant/node_modules/webpack-cli/bin/config-yargs.js:89:48)
at Object. (/vagrant/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:40)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: NODE_ENV=development webpack-dev-server --hot
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2018-10-29T21_24_36_244Z-debug.log

Upgrade webpack-cli to latest version fixes the problem, but then no assets is served correctly (404 on .css and .js). I've no time for more investigation atm.

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.