Django Smuggler is a pluggable application for Django Web Framework that helps you to import/export fixtures via the automatically-generated administration interface.

Overview

Django Smuggler

https://travis-ci.org/semente/django-smuggler.svg?branch=master https://coveralls.io/repos/semente/django-smuggler/badge.png?branch=master

Django Smuggler is a pluggable application for Django Web Framework to easily dump/load fixtures via the automatically-generated administration interface. A fixture is file with model data serialized to e.g. JSON or XML that Django knows how to import to the database.

Smuggler is especially useful for transporting database data between production and development environments, but can also be used as a backup tool.

Project page
http://github.com/semente/django-smuggler
Translations
https://www.transifex.com/projects/p/django-smuggler/

Installing & Setup

Smuggler is in the Python Package Index (PyPI) and you can easily install the latest stable version of it using the tools pip or easy_install. Try:

pip install django-smuggler

or:

easy_install django-smuggler

Alternatively, you can install Smuggler from source code running the follow command on directory that contains the file setup.py:

python setup.py install

After installation you need configure your project to recognizes the Smuggler application adding 'smuggler' to your INSTALLED_APPS setting and setup the project URLConf like follow:

urlpatterns = [
    # ...
    path('admin/', include('smuggler.urls')),  # before admin url patterns!
    path('admin/', admin.site.urls),
]

Then try access these urls:

If you can access the URLs above, the application was setup correctly. Note that these URLs are accessible only by superusers.

Smuggler also provides a template to show buttons for dump and load data on change list page (change_list.html). You can setup the ModelAdmin you are interested like follow:

class ExampleAdmin(admin.ModelAdmin):
    change_list_template = 'smuggler/change_list.html'
    ...

Settings

Smuggler has the following settings available. You can set them in your project settings.py. If you doesn't set them it will assume the default values:

SMUGGLER_EXCLUDE_LIST
List of models to be excluded from dump. Use the form 'app_label.ModelName'. Default: [].
SMUGGLER_FIXTURE_DIR
Uploaded fixtures are stored in this directory (if requested). Default: None.
SMUGGLER_FORMAT
Format for dumped files. Any of the serialization formats supported by Django, json, xml and in some cases yaml. Default: 'json'.
SMUGGLER_INDENT
Indentation for dumped files. Default: 2.

Screenshots

Buttons on change_list.html:

buttons on change_list.html

Load form (with SMUGGLER_FIXTURE_DIR configured):

load form

Release notes

Version 1.0.2 (2020-09-28)

  • Support Django 3.1

Version 1.0.1 (2020-05-15)

  • Fix Python packaging setup

Version 1.0.0 (2020-04-20)

  • Support Django 3.0
  • Drop support for Python < 3.6 and Django < 2.2

Version 0.9.1 (2018-11-05)

  • Support Django 2.1

Version 0.9.0 (2018-03-22)

  • Support Django 2.0
  • Drop support for Django < 1.10

Version 0.8.0 (2016-11-09)

  • Support Django 1.10

Version 0.7.0 (2016-02-25)

  • Support Django 1.8
  • Support Django 1.9
  • Drop support for Django < 1.7
  • Drop support for Python < 2.7

Version 0.6.1 (2015-11-25)

  • Increase Django 1.7 compatibilty by supporting use_natural_foreign_keys and use_natural_primary_keys arguments for dumpdata

Version 0.6 (2014-09-18)

  • HTML5 multiple file upload is now supported for fixture uploads
  • Support loading fixtures from SMUGGLER_FIXTURE_DIR and upload at the same time
  • Recognize fixtures with upper case file extension correctly
  • Loading fixtures now uses loaddata management command
  • Removed signals.py
  • Removed sample templates
  • Cleaner code and better tests :-)

Version 0.5 (2014-08-21)

  • Added an option to specify a list of app labels to the /dump/ view
  • Improved test suite
  • Dropped Django 1.3 support
  • Preliminary Python 3 support

Version 0.4.1 (2013-11-12)

  • Changelist template is now Django 1.6 compatible

Version 0.4 (2013-04-01)

  • Django 1.5+ support;
  • Added German translation;
  • Added some tests.

Version 0.3 (2012-01-31)

  • Significant bug fixes and improvements when loading and exporting data;
  • Allow formats for import besides JSON and XML (aa105b3, needs documentation);
  • Added Dutch translation.

Version 0.2 (2011-08-19)

  • Django 1.2+ support;
  • Keep uploaded files as alternative choices to import (issues #1 and #6);
  • Vulnerability fixed (d73cec6);
  • Added Polish, Russian, Catalan and Brazilian Portuguese translations.

Version 0.1.1 (2010-01-20)

  • First stable version.

Backwards-incompatible changes

  • Removed AdminFormMixin (Version 0.7)
  • Removed signals.py (Version 0.6)
  • Renamed urls from import/export to load/dump (Version 0.1)

Contributing

If you find any problems in the code or documentation, please take 30 seconds to fill out a issue here.

The contributing with code or translation is MUCH-APPRECIATED. Feel free to fork or send patches.

You can translate this application to your language using Transifex. Access the project page on Transifex.

See the AUTHORS file for a complete authors list of this application.

Thanks to Interaction Consortium for sponsoring the first releases of the project.

Tests

If you are contributing to django-smuggler we recommend setting up a virtualenv and running:

pip install -r test-requirements.txt

You can then run the tests with:

make tests

Before submitting a pull request please test against our supported versions of Python and Django by running:

tox

To see if you need to add tests we use coverage. You can generate a coverage report with:

make coverage

To check if your code follows the style guide you can run:

make lint

Copying conditions

Django Smuggler is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

Django Smuggler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program; see the file COPYING.LESSER. If not, see http://www.gnu.org/licenses/.

Comments
  • Update to suport Django 1.10

    Update to suport Django 1.10

    Django 1.10 uses natural key for sites, so pk needs to be removed from SITE_DUMP Using call_command instead of execute to avoid 'no_color' KeyError prefix param in url not supported on Django1.10

    I usually not do PR, most likely is wrong, but maybe someone can improve it.

    opened by kliver 10
  • Fix for Django 2.0

    Fix for Django 2.0

    User.is_authenticated is now an attribute; backwards-compatibility support for using it as a method has been removed in Django 2.0. See:

    https://docs.djangoproject.com/en/1.11/ref/contrib/auth/#django.contrib.auth.models.User.is_authenticated

    Also, unit tests have been revised, and Django 2.0 added to Tox envlist

    opened by morlandi 9
  • Load view not working

    Load view not working

    I'm running Django 2.2.5 on Python 3.7, and I've noticed that, when trying to open the 'load' view in DEBUG=False, it produces a Server error (500) view; it does, however, function correctly in DEBUG=True. Please, consider looking into this. Thanks a lot.

    My settings.py can be found in here and my urls.py is here. If you need any more information please reply to the issue.

    opened by MarioBG 7
  • Getting debug information in my dump

    Getting debug information in my dump

    see:

    [    [sql] SELECT ...
          FROM "frontend_userprofile"
          ORDER BY "frontend_userprofile"."id" ASC
        [sql] SELECT ...
          FROM "auth_user"
          WHERE "auth_user"."id" = 2
    {
      "pk": 1, 
      "model": "frontend.userprofile", 
      "fields": {
        "acknowledged_warnings": "0", 
        "royale_expiration": null, 
        "json_properties": null, 
        "subscription_method": null, 
        "email_verified": false, 
        "paypal_customer_id": null, 
        "braintree_customer_id": null, 
        "user": [
          "[email protected]"
        ], 
        "subscription_id": null, 
        "email_optin": false, 
        "screenname": "peter"
      }
    }
    

    screen shot 2014-08-15 at 9 52 36 am

    Is there an option I should be changing?

    opened by pconerly 7
  • PermissionError on Windows when using the 'load' action with uploaded files

    PermissionError on Windows when using the 'load' action with uploaded files

    I am using Windows python and Django. Tried django-smuggler and found this issue:

    Succeed on 'dump', and created file: 2018-04-27T11_05_53.741567.json

    on a new database, tried '/admin/load', it did display a page and asking for the file. clicked the file that just saved, then clicked 'load' button. It shows an error:

    PermissionError at /admin/load/ [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\Ken\AppData\Local\Temp\repair_2018-04-27T15_44_57.883458_fz9nmkw9.json'

    I notice that the file name has been changed during the process, but i don't know why? or did I do anything wrong?

    opened by kenliit 6
  • Release a new version with Django 1.5 compat

    Release a new version with Django 1.5 compat

    Django 1.5 has been out for a while, smuggler is now compatible with this version so a new release is in order.

    Most important changes are the ones done for issue #22 and #23

    opened by jaap3 6
  • Loading data form keyerror

    Loading data form keyerror

    This is using python 3.5 and Django 1.9

    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 149, in get_response
        response = self.process_exception_by_middleware(e, request)
      File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 147, in get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "/usr/local/lib/python3.5/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
        return view_func(request, *args, **kwargs)
      File "/usr/local/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view
        return self.dispatch(request, *args, **kwargs)
      File "/usr/local/lib/python3.5/site-packages/django/views/generic/base.py", line 88, in dispatch
        return handler(request, *args, **kwargs)
      File "/usr/local/lib/python3.5/site-packages/django/views/generic/edit.py", line 213, in get
        return self.render_to_response(self.get_context_data())
      File "/usr/local/lib/python3.5/site-packages/smuggler/views.py", line 87, in get_context_data
        adminform=self.get_admin_form(kwargs['form']),
    KeyError: 'form'
    
    opened by LookLikeAPro 5
  • Added queryparams to dump_data view and added test for it.

    Added queryparams to dump_data view and added test for it.

    @semente @jaap3

    For #30

    This is only the multiple app_label endpoint for the /admin/smuggler/ page. I think it makes sense to just overload the /admin/dump/ aka dump_data view to have an optional app_label feature.

    opened by pconerly 5
  • Add support for django 1.5

    Add support for django 1.5

    There was some changes in command execution in django 1.5, now everything is printed in sys.stdout and not returned as output of handle.

    I've switched to create sys.stdout as a StringIO, which is written to the response afterwards. This will not work with django < 1.5.x

    opened by kunitoki 5
  • ProgrammingError when an app has a model with managed=false

    ProgrammingError when an app has a model with managed=false

    I have an app where the database tables don't actually exist:

    class Report(models.Model):
        class Meta:
            managed = False
    

    When accessing smuggler via the url: http://localhost:8000/admin/export/

    I get:

    ProgrammingError: (1146, "Table 'myapp.reporting_report' doesn't exist")

    which is obviously true but stops me using Smuggler for the rest of my apps.

    bug 
    opened by andybak 5
  • Saving to fixtures that are under version control

    Saving to fixtures that are under version control

    Our workflow would be something like this:

    1.PERSON A: with smuggler, create app_fixture.json on the server 2. git add app_fixture.json; git commit -a 3. in django, change app data 4. with smuggler, click 'export' and overwrite app_fixture.json 5. git commit -a; git push 6. PERSON B:git pull, to get the latest app_fixture.json 7. with smuggler, click 'import' and import app_fixture.json

    Person A and Person B now have an easy way to share fixtures.

    The main point is, sometimes you want to 'save as...' and choose a filename, sometimes you want to 'save' over a default filename. Mostly, we will want to save over a default filename.

    ui-ux 
    opened by cogat 5
  • docs: fix simple typo, compatibilty -> compatibility

    docs: fix simple typo, compatibilty -> compatibility

    There is a small typo in README.rst.

    Should read compatibility rather than compatibilty.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Create a json file

    Create a json file

    One of the main problems is the loading time for preparing the file. Meanwhile, I suggest an option where we can enable to use of multiprocessing, in order to return the request back and then create a .json file in the file repository, and then it can be efficient. Currently, for my use case, I need to set timeout to a high value, which is not a good solution.

    opened by ManiMozaffar 0
  • allow dev to set url for login page when not logged in.

    allow dev to set url for login page when not logged in.

    Trying to access /admin/dump when admin is not logged in now dumps the user to /accounts/login/?next=/admin/dump/, which appears to be hard-wired into the app.

    My app has its login page at /admin/login/, not /accounts/login/.

    Can we have a setting that lets us change to login page

    thanks for a useful app!

    John

    opened by dllabs 1
  • Dump filenames without spaces

    Dump filenames without spaces

    Filenames for /app/model/dump end up as app-model-_2021-02-05T12 25 46.775165.yaml for me. It would be simpler to use these filenames didnt contain spaces (), or even :. Also the _ before the year, i.e. -_2021 is a bit odd. i.e. ISO 8601 without the colons would be ideal, especially in UTC given the file could be moved across timezones, and thus the stamp should be terminated with Z.

    opened by jayvdb 1
  • Have an /admin/smuggler/ page

    Have an /admin/smuggler/ page

    So. I have a many-to-many relationship, and I obsfucate the through model from the django admin, b/c my coworkers don't need to see it.

    I'd like to be able to replicate our production data into our staging / QA / dev environments. So there are three specific models I need to download the data from.

    It'd be awesome if there were a general smuggler page. Something that would just list all apps and models, and you could check boxes for what you want to dump, and then a "dump" button.

    /auth
    /djcelery
    /app
      /unimportant model
      /unimportant model 2
      X article
      X group
      X group-article
    /app2
      /foo
      /bar
    

    @semente what are your thoughts about a feature like this?

    Is there some easy way I can overload a dump() call to give me 3 specific models, so I can at least hack a solution for myself?

    ui-ux wishlist 
    opened by pconerly 8
Owner
semente
semente
WordPress look and feel for Django administration panel

Django WP Admin WordPress look and feel for Django administration panel. Features WordPress look and feel New styles for selector, calendar and timepi

Maciej Marczewski 266 Nov 21, 2022
An administration website for Django

yawd-admin, a django administration website yawd-admin now has a live demo at http://yawd-admin.yawd.eu/. Use demo / demo as username & passowrd. yawd

Pantelis Petridis 140 Oct 30, 2021
📱 An extension for Django admin that makes interface mobile-friendly. Merged into Django 2.0

Django Flat Responsive django-flat-responsive is included as part of Django from version 2.0! ?? Use this app if your project is powered by an older D

elky 248 Sep 2, 2022
Disable dark mode in Django admin user interface in Django 3.2.x.

Django Non Dark Admin Disable or enable dark mode user interface in Django admin panel (Django==3.2). Installation For install this app run in termina

Artem Galichkin 6 Nov 23, 2022
WebVirtCloud is virtualization web interface for admins and users

WebVirtCloud is a virtualization web interface for admins and users. It can delegate Virtual Machine's to users. A noVNC viewer presents a full graphical console to the guest domain. KVM is currently the only hypervisor supported.

Anatoliy Guskov 1.3k Dec 29, 2022
Simple and extensible administrative interface framework for Flask

Flask-Admin The project was recently moved into its own organization. Please update your references to [email protected]:flask-admin/flask-admin.git. Int

Flask-Admin 5.2k Dec 29, 2022
Simple and extensible administrative interface framework for Flask

Flask-Admin The project was recently moved into its own organization. Please update your references to [email protected]:flask-admin/flask-admin.git. Int

Flask-Admin 4.6k Feb 7, 2021
A python application for manipulating pandas data frames from the comfort of your web browser

A python application for manipulating pandas data frames from the comfort of your web browser. Data flows are represented as a Directed Acyclic Graph, and nodes can be ran individually as the user sees fit.

Schlerp 161 Jan 4, 2023
Modern responsive template for the Django admin interface with improved functionality. We are proud to announce completely new Jet. Please check out Live Demo

Django JET Modern template for Django admin interface with improved functionality Attention! NEW JET We are proud to announce completely new Jet. Plea

Geex Arts 3.4k Dec 29, 2022
A jazzy skin for the Django Admin-Interface (official repository).

Django Grappelli A jazzy skin for the Django admin interface. Grappelli is a grid-based alternative/extension to the Django administration interface.

Patrick Kranzlmueller 3.4k Dec 31, 2022
django's default admin interface made customizable. popup windows replaced by modals. :mage: :zap:

django-admin-interface django-admin-interface is a modern responsive flat admin interface customizable by the admin itself. Features Beautiful default

Fabio Caccamo 1.3k Dec 31, 2022
Modern theme for Django admin interface

Django Suit Modern theme for Django admin interface. Django Suit is alternative theme/skin/extension for Django administration interface. Project home

Kaspars Sprogis 2.2k Dec 29, 2022
A flat theme for Django admin interface. Modern, fresh, simple.

Django Flat Theme django-flat-theme is included as part of Django from version 1.9! ?? Please use this app if your project is powered by an older Djan

elky 416 Sep 22, 2022
A jazzy skin for the Django Admin-Interface (official repository).

Django Grappelli A jazzy skin for the Django admin interface. Grappelli is a grid-based alternative/extension to the Django administration interface.

Patrick Kranzlmueller 3.4k Dec 31, 2022
Modern theme for Django admin interface

Django Suit Modern theme for Django admin interface. Django Suit is alternative theme/skin/extension for Django administration interface. Project home

Kaspars Sprogis 2.2k Dec 29, 2022
Jet Bridge (Universal) for Jet Admin – API-based Admin Panel Framework for your application

Jet Bridge for Jet Admin – Admin panel framework for your application Description About Jet Admin: https://about.jetadmin.io Live Demo: https://app.je

Jet Admin 1.3k Dec 27, 2022
Tornadmin is an admin site generation framework for Tornado web server.

Tornadmin is an admin site generation framework for Tornado web server.

Bharat Chauhan 0 Jan 10, 2022
Django application and library for importing and exporting data with admin integration.

django-import-export django-import-export is a Django application and library for importing and exporting data with included admin integration. Featur

null 2.6k Jan 7, 2023
A cool, modern and responsive django admin application based on bootstrap 5

django-baton A cool, modern and responsive django admin application based on bootstrap 5 Documentation: readthedocs Live Demo Now you can try django-b

Otto srl 678 Jan 1, 2023