Skip to content

Commit

Permalink
feature/update docs and usage of str format (#355)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick <ptrck@users.noreply.github.com>
  • Loading branch information
jackton1 and ptrck committed Jun 2, 2021
1 parent caaa5ef commit c9ee5d3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ run: migrate
@echo "Starting server..."
@$(MANAGE_PY) runserver

default-user: migrate
@echo "Creating a default user..."
@$(MANAGE_PY) create_default_user
@echo "Username: admin@admin.com"
@echo "Password: admin"

test:
@echo "Running `$(PYTHON_VERSION)` test..."
@$(MANAGE_PY) test
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,18 @@ INSTALLED_APPS = [
]
```

## Running locally

```shell
$ git clone git@github.com:tj-django/django-clone.git
$ make default-user
$ make run
```

Spins up a django server running the demo app.

Visit http://127.0.0.1:8000

## Found a Bug?

To file a bug or submit a patch, please head over to [django-clone on github](https://github.com/tj-django/django-clone/issues).
Expand Down
2 changes: 1 addition & 1 deletion model_clone/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def make_clone(self, request, queryset):
if clone_obj_ids:
self.message_user(
request,
_("Successfully created: {} new duplicates".format(len(clone_obj_ids))),
_("Successfully created: {} new duplicates").format(len(clone_obj_ids)),
)

make_clone.short_description = _("Duplicate selected %(verbose_name_plural)s")
Expand Down
10 changes: 3 additions & 7 deletions sample/management/commands/create_default_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

class Command(BaseCommand):
def handle(self, *args, **options):
email, password = self._get_credentials()
email = os.getenv("ADMIN_EMAIL", "admin@admin.com")
password = os.getenv("ADMIN_PASSWORD", "admin")

if not User.objects.filter(email=email).exists():
User.objects.create_superuser(
username=email,
Expand All @@ -20,9 +22,3 @@ def handle(self, *args, **options):
self.stdout.write("Created superuser.")
else:
self.stderr.write("User already exists.")

@staticmethod
def _get_credentials():
email = os.getenv("ADMIN_EMAIL", "admin@admin.com")
password = os.getenv("ADMIN_PASSWORD", "admin")
return email, password

0 comments on commit c9ee5d3

Please sign in to comment.