krisfields / django-baker Goto Github PK
View Code? Open in Web Editor NEWAdds a management command that generates views, forms, urls, admin, and templates based off the contents of models.py
License: BSD 3-Clause "New" or "Revised" License
Adds a management command that generates views, forms, urls, admin, and templates based off the contents of models.py
License: BSD 3-Clause "New" or "Revised" License
HI,
I'm getting TemplateDoesNotExist error (running locale on MacOs).
Template loader postmortem report that it looked into django.template.loaders.app_directories.Loader: /anaconda3/lib/python3.6/site-packages/django_baker/templates/base.html
while pip install put templates into /anaconda3/lib/python3.6/site-packages/django_baker/templates/django_baker/
File "/srv/bbb/lib/python3.4/site-packages/django_baker/management/commands/bake.py", line 54
print app_label, model_names
^
SyntaxError: Missing parentheses in call to 'print'
Python 2 only?
From Python 3+, absolute imports are the default. This breaks the behavior of the views init.py since it uses relative imports.
It just needs to change the way it generates the init.py file from:
from myview_views import * #NOQA
to:
from .myview_view import * #NOQA
I'll try to write a pull request for this later.
Greeting,
After a successful installation of djano_baker with the command:
pip install django_baker
i added the following in setting as mentioned in the readme page as mentioned bellow :
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_baker' ]
when running python3 manage.py runserver i get this error
Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run autoreload.raise_last_exception() File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception raise _exception[1] File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 398, in execute autoreload.check_errors(django.setup)() File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/apps/registry.py", line 124, in populate app_config.ready() File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/contrib/admin/apps.py", line 27, in ready self.module.autodiscover() File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/contrib/admin/__init__.py", line 50, in autodiscover autodiscover_modules("admin", register_to=site) File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 58, in autodiscover_modules import_module("%s.%s" % (app_config.name, module_to_search)) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/home/anis/fjango/my_venv/lib/python3.10/site-packages/django_baker/admin.py", line 2, in <module> from django.db.models.fields import FieldDoesNotExist ImportError: cannot import name 'FieldDoesNotExist' from 'django.db.models.fields' (/home/anis/fjango/my_venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py)
if possible can tI get some help to resolve tis probleme
more information:
python version : Python 3.10.6
django version: 4.1.5
Ubuntu version: 22.04
Specifying both 'fields' and 'form_class' is not permitted.
After running bake and going to the create view, I get the error mentioned in the title. This is a fresh bake with no modifications to the generated views.py.
However maybe it's left up to the user to decide which to use?
I'm using django 1.8.7
You get errors unless you're logged in. Without an auth app, that likely means from the admin. I think it's worth mentioning in the README.
I'm using this with a model that has a MoneyField from https://github.com/django-money/django-money/
It creates a field that has multiple options, and some are set to be non-editable. For instance, I can set the currency in the model, but the user can't choose the currency.
When using baker, it raises an exception when trying to create a currency field. For example:
FieldError at /vehicles/
'purchase_price_currency' cannot be specified for CompanyOwnedVehicle model form as it is a non-editable field
It should check to see if a field is non-editable before trying to generate it.
I've tried running this on a Python 3 project and I got the following error:
File "-deleted-/lib/python3.4/site-packages/django_baker/management/commands/bake.py", line 54
print app_label, model_names
^
SyntaxError: Missing parentheses in call to 'print'
Seems like there is not reason to support Python 2 and Python 3, is this project still in active development? If so I can work on a pull request if desired.
I already added encoding declarations to all files (which is also pep8 compliant). It gets removed by django-baker. That should be retained.
Good work, man. This project looks promising. Am i right to assume it is inspired by rails?
Just wanted to let you know that django-baker isn't working with Django 1.9. It appears that they changed how get_app works, so importing that now fails. Seems to be this change needed:
http://stackoverflow.com/questions/34069486/add-all-models-to-admin-site-django-1-9
I had this error:
File "/home/username/.local/lib/python3.7/site-packages/django_baker/bakery.py", line 10, in <module>
from django.utils.six import iteritems
ModuleNotFoundError: No module named 'django.utils.six'
i changed it into
from six import iteritems
and now it works.
Getting 'ForeignKey' object has no attribute 'rel' on administration view. Model file attached
models.py.txt
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/marc/geonode-dev/.venvs/djangocaketut/local/lib/python2.7/site-packages/django/core/management/init.py", line 338, in execute_from_command_line
utility.execute()
File "/home/marc/geonode-dev/.venvs/djangocaketut/local/lib/python2.7/site-packages/django/core/management/init.py", line 312, in execute
django.setup()
File "/home/marc/geonode-dev/.venvs/djangocaketut/local/lib/python2.7/site-packages/django/init.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/marc/geonode-dev/.venvs/djangocaketut/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/marc/geonode-dev/.venvs/djangocaketut/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/marc/geonode-dev/.venvs/djangocaketut/local/lib/python2.7/site-packages/django/contrib/admin/init.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/marc/geonode-dev/.venvs/djangocaketut/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/marc/djangocaketut/djangocaketut/bread/admin.py", line 2
from .models import
^
SyntaxError: invalid syntax
both with py2 and py3 I get this when accessing the baked admin view
Exception Type: AttributeError
Exception Value:
'EmailValidator' object has no attribute 'regex'
Exception Location: /usr/local/lib/python2.7/site-packages/django_baker/admin.py in is_urlfield, line 45
Hello,
Does this project support Django 2.0 running on Python 3.6?
I get the following error using bake
.
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-packages/django_baker/management/commands/bake.py", line 23, in handle
baker.bake(ingredients)
File "/usr/local/lib/python3.6/site-packages/django_baker/bakery.py", line 28, in bake
self.create_init_files(app, model_names.keys(), models)
File "/usr/local/lib/python3.6/site-packages/django_baker/bakery.py", line 70, in create_init_files
"model_names_dict": model_names_dict
File "/usr/local/lib/python3.6/site-packages/django_baker/bakery.py", line 120, in create_file_from_template
new_file.write(get_template(template_path).render(Context(context_variables)))
File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 59, in render
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
File "/usr/local/lib/python3.6/site-packages/django/template/context.py", line 274, in make_context
raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than Context.
Forms should use enctype="multipart/form-data"
if files are in the model.
Alternatively, forms could always use enctype="multipart/form-data"
and developers could comment it out if they needed increased efficiency.
Example of form with working file uploads:
<form enctype="multipart/form-data" method="post" action="/foo/">
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.