Coder Social home page Coder Social logo

alir3z4 / django-databrowse Goto Github PK

View Code? Open in Web Editor NEW
42.0 9.0 21.0 96 KB

Databrowse is a Django application that lets you browse your data.

Home Page: http://pypi.python.org/pypi/django-databrowse

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

Python 74.93% HTML 25.07%
django database data

django-databrowse's Introduction

Django Databrowse

travis-cli tests status for django-databrowse

Databrowse is a Django application that lets you browse your data.

As the Django admin dynamically creates an admin interface by introspecting your models, Databrowse dynamically creates a rich, browsable Web site by introspecting your models.

django-databrowse is available on pypi

http://pypi.python.org/pypi/django-databrowse

So easily install it by pip

$ pip install django-databrowse

Or by easy_install

$ easy_install django-databrowse

Another way is by cloning django-databrowse's git repo

$ git clone git://github.com/Alir3z4/django-databrowse.git

Then install it by running:

$ python setup.py install
  1. Point Django at the default Databrowse templates. There are two ways to do this:

    • Add 'django_databrowse' to your INSTALLED_APPS setting. This will work if your TEMPLATE_LOADERS setting includes the app_directories template loader (which is the case by default). See the template loader docs for more.
    • Otherwise, determine the full filesystem path to the django_databrowse/templates directory, and add that directory to your TEMPLATE_DIRS setting.
  2. Register a number of models with the Databrowse site:

    import django_databrowse
    from myapp.models import SomeModel, SomeOtherModel, YetAnotherModel
    
    django_databrowse.site.register(SomeModel)
    django_databrowse.site.register(SomeOtherModel, YetAnotherModel)
    

    Note that you should register the model classes, not instances.

    it is possible to register several models in the same call to django_databrowse.site.register.

    It doesn't matter where you put this, as long as it gets executed at some point. A good place for it is in your URLconf file (urls.py).

  3. Change your URLconf to import the ~django_databrowse module:

    from django_databrowse
    

    ...and add the following line to your URLconf:

    (r'^django_databrowse/(.*)', django_databrowse.site.root),
    

    The prefix doesn't matter -- you can use databrowse/ or db/ or whatever you'd like.

  4. Run the Django server and visit /databrowse/ in your browser.

You can restrict access to logged-in users with only a few extra lines of code. Simply add the following import to your URLconf:

from django.contrib.auth.decorators import login_required

Then modify the URLconf so that the django_databrowse.site.root view is decorated with django.contrib.auth.decorators.login_required:

(r'^databrowse/(.*)', login_required(django_databrowse.site.root)),

If you haven't already added support for user logins to your URLconf, as described in the user authentication docs, then you will need to do so now with the following mapping:

(r'^accounts/login/$', 'django.contrib.auth.views.login'),

The final step is to create the login form required by django.contrib.auth.views.login. The user authentication docs provide full details and a sample template that can be used for this purpose.

django-databrowse has been tested Django 1.6 and later. To run the the tests:

$ python run_tests.py

It's also available on travis-ci:

https://travis-ci.org/Alir3z4/django-databrowse/

Currently English is only available language that is being packaged. If you would like to contribute in localization you can find django-databrowse project on Transifex as well: https://www.transifex.com/projects/p/django-databrowse/

Translation Status on Transifex

django-databrowse translation status on transifex

django-databrowse's People

Contributors

alir3z4 avatar cometsong avatar isthisthat avatar jstbriggs avatar justinasjaronis avatar nikolas avatar sdreher avatar tcsorrel 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-databrowse's Issues

Python 3 support

django-databrowse is working properly on Django 1.6 and later with python2, still doesn't support python3.

Feel free to contribute if necessary, contribution is welcome.

'dict_values' object has no attribute 'sort'

Versions:

Python: 3.6.1
Django: 1.11.9
Databrowse: updated along with mods from ccnmtl plus others.

Actions:
When viewing object list page sorted by a field, then tried clicking on the 'Fields' breadcrumbs link and got this error.

Traceback: (note: the "id_generate/jaxiddetail" is the app/model name and the "parent_jaxid" is the currently chosen sort field.)

Internal Server Error: /databrowse/id_generate/jaxiddetail/fields/, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
Traceback (most recent call last):, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    response = get_response(request), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    response = self.process_exception_by_middleware(e, request), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    response = wrapped_callback(request, *callback_args, **callback_kwargs), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/src/databrowse/django_databrowse/sites.py", line 162, in root, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    return self.model_page(request, *url.split('/', 2)), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/src/databrowse/django_databrowse/sites.py", line 191, in model_page, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    return databrowse_class(model, self).root(request, rest_of_url), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/src/databrowse/django_databrowse/sites.py", line 73, in root, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    return plugin.model_view(request, self, rest_of_url), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/src/databrowse/django_databrowse/plugins/fieldchoices.py", line 76, in model_view, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    return self.homepage_view(request), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
  File "/var/www/apps/src/databrowse/django_databrowse/plugins/fieldchoices.py", line 90, in homepage_view, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
    field_list.sort(key=lambda k: k.verbose_name), /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
AttributeError: 'dict_values' object has no attribute 'sort', /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/
, /databrowse/id_generate/jaxiddetail/fields/parent_jaxid/

Add a Search bar? reverse sort direction?

Is it possible to add a search bar to the main databrowse app page?

I like the sortable aspect, but it is not reversible in direction.
We've got 107k records in one of the models people want to view,
Paging through it all takes a loooong time. :(

If there is a specific way to do this that comes to mind, I'll try to work on it and potentially PR it.

Objects passed to template are not EasyInstance instances

When loading http://localhost:8000/browse/app/model/, it correctly prints a list of objects, but they all link to http://localhost:8000/browse/app/model (instead of http://localhost:8000/browse/app/model/objects/X)

It looks like the objects passed to the template model_detail.html are not EasyInstance instances, which is why object.url is empty. The objects are simply instances of the Django model.

After a bit of debugging, I found out that the iterator method of EasyQuerySet is never called, so that we end up with an EasyQuerySet that contains Django model instances (in EasyModel.objects).

This is with Django 1.11.7 and Python 3.6

Paginator in views

Hello, not sure what the development plans are for this repository. I was wondering whether you could include pagination in your views. That would help a lot.
Thanks for this piece of code.

'EasyModel' object has no attribute '_meta' with Django 1.6.2

Hello,

I am experimenting Django with an extremly simple example and would like to use the databrowser on it. I followed your usage instructions but arrive on an error message, inserted below:

ERROR CAPTURE --------------------------------
'EasyModel' object has no attribute '_meta'

Request Method:     GET
Request URL:    http://127.0.0.1:8000/databrowse/ticket/task/calendars/due_date/
Django Version:     1.6.2
Exception Type:     AttributeError
Exception Value:    

'EasyModel' object has no attribute '_meta'

Exception Location:     /home/chris/site/tracker_env/local/lib/python2.7/site-packages/django/views/generic/dates.py in uses_datetime_field, line 289
Python Executable:  /home/chris/site/tracker_env/bin/python
Python Version:     2.7.3
Python Path:    

['/home/chris/site/tracker',
 '/home/chris/site/tracker_env/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg',
 '/home/chris/site/tracker_env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
 '/home/chris/site/tracker_env/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg',
 '/home/chris/site/tracker_env/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
 '/home/chris/site/tracker_env/lib/python2.7',
 '/home/chris/site/tracker_env/lib/python2.7/plat-linux2',
 '/home/chris/site/tracker_env/lib/python2.7/lib-tk',
 '/home/chris/site/tracker_env/lib/python2.7/lib-old',
 '/home/chris/site/tracker_env/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/chris/site/tracker_env/local/lib/python2.7/site-packages',
 '/home/chris/site/tracker_env/lib/python2.7/site-packages']
END ERROR CAPTURE --------------------------------

Here is the simple code I am trying to run:
---------------- models.py ------------------

    from django.db import models
    from datetime import date, timedelta
    from django.template.defaultfilters import date as django_date

    class Task(models.Model):
        name = models.CharField(max_length=250)
        description = models.TextField()
        created_date = models.DateField(auto_now_add=True)
        due_date = models.DateField()
        schedule_date = models.DateField()
        closed = models.BooleanField(default=False)

        def __unicode__(self):
        return self.name

        def colored_due_date(self):
        due_date = django_date(self.due_date, "d F Y")
        if self.due_date - timedelta(days=7) > date.today():
            color = "green"
        elif self.due_date + timedelta(days=7) > date.today():
            color = "orange"
        else:
            color = "red"
        return " <span style=color:%s>%s</span>" % (color, due_date)
        colored_due_date.allow_tags = True

-------- databrowse_config.py -------------------

    import django_databrowse
    from models import Task
    django_databrowse.site.register(Task)

------ urls.py ----------------------------------------

    from django.conf.urls import patterns, include, url
    from django.contrib.auth.decorators import login_required

    from django.contrib import admin
    from ticket.databrowse_config import *
    admin.autodiscover()

    urlpatterns = patterns('',
        url(r'^ticket/', include('ticket.urls')),
        url(r'^databrowse/(.*)', login_required(django_databrowse.site.root)),
        url(r'^accounts/login/$', 'django.contrib.auth.views.login'),
        url(r'^admin/', include(admin.site.urls)),
    )

end code ---------------------------------------------------------

Has the package been validated against the latest versions of Django? A compatibility problem may have slipped in.
Thanks for your package.

Regards, Christian.

Transifex for translation

What have to be done for this task or in on the word TODO:

  • Make translation messages.
  • Compile translation messages.
  • Create a project page on Transifex.
  • Adding .tx file to the root of project.

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.