Code Monkey home page Code Monkey logo

django-orm's People

Contributors

dancaron avatar ewerton94 avatar junkydeveloper avatar pyloris avatar wsqy 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  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  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

django-orm's Issues

not working for me

is something missing?

django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

poetry show:

anyio                        3.6.1       High level compatibility layer for multiple asynchronous event loop implementations
APScheduler                  3.9.1       In-process task scheduler with Cron-like capabilities
asgiref                      3.5.2       ASGI specs, helper code, and adapters
async_generator              1.10        Async generators and context managers for Python 3.5+
attrs                        22.1.0      Classes Without Boilerplate
autopep8                     1.7.0       A tool that automatically formats Python code to conform to the PEP 8 style guide
cachetools                   5.2.0       Extensible memoizing collections and decorators
certifi                      2022.9.24   Python package for providing Mozilla's CA Bundle.
cffi                         1.15.1      Foreign Function Interface for Python calling C code.
charset-normalizer           2.1.1       The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Char...
commonmark                   0.9.1       Python parser for the CommonMark Markdown spec
contourpy                    1.0.5       Python library for calculating contours of 2D quadrilateral grids
cryptography                 38.0.1      cryptography is a package which provides cryptographic recipes and primitives to Python developers.
cycler                       0.11.0      Composable style cycles
Django                       4.1.1       A high-level Python web framework that encourages rapid development and clean, pragmatic design.
et-xmlfile                   1.1.0       An implementation of lxml.xmlfile for the standard library
exceptiongroup               1.0.0rc9    Backport of PEP 654 (exception groups)
flake8                       5.0.4       the modular source code checker: pep8 pyflakes and co
fonttools                    4.37.4      Tools to manipulate font files
h11                          0.12.0      A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
httpcore                     0.15.0      A minimal low-level HTTP client.
httpx                        0.23.0      The next generation HTTP client.
idna                         3.4         Internationalized Domain Names in Applications (IDNA)
imgkit                       1.2.2       Wkhtmltopdf python wrapper to convert html to image using the webkit rendering engine and qt
iniconfig                    1.1.1       iniconfig: brain-dead simple config-ini parsing
Jinja2                       3.1.2       A very fast and expressive template engine.
kiwisolver                   1.4.4       A fast implementation of the Cassowary constraint solver
MarkupSafe                   2.1.1       Safely add untrusted strings to HTML/XML markup.
matplotlib                   3.6.1       Python plotting package
mccabe                       0.7.0       McCabe checker, plugin for flake8
msal                         1.19.0      The Microsoft Authentication Library (MSAL) for Python library enables your app to access the Micro...
mypy                         0.971       Optional static typing for Python
mypy-extensions              0.4.3       Experimental type system extensions for programs checked with the mypy typechecker.
mysql-connector-python       8.0.30      MySQL driver written in Python
mysqlclient                  2.1.1       Python interface to MySQL
numpy                        1.23.3      NumPy is the fundamental package for array computing with Python.
Office365-REST-Python-Client 2.3.14      Microsoft 365 & Microsoft Graph Library for Python
openpyxl                     3.0.10      A Python library to read/write Excel 2010 xlsx/xlsm files
outcome                      1.2.0       Capture the outcome of Python function calls.
packaging                    21.3        Core utilities for Python packages
pandas                       1.5.0       Powerful data structures for data analysis, time series, and statistics
pendulum                     2.1.2       Python datetimes made easy
Pillow                       9.2.0       Python Imaging Library (Fork)
pluggy                       1.0.0       plugin and hook calling mechanisms for python
protobuf                     3.20.1      Protocol Buffers
py                           1.11.0      library with cross-python path, ini-parsing, io, code, log facilities
pyaes                        1.6.1       Pure-Python Implementation of the AES block-cipher and common modes of operation
pyasn1                       0.4.8       ASN.1 types and codecs
pycodestyle                  2.9.1       Python style guide checker
pycparser                    2.21        C parser in Python
pyflakes                     2.5.0       passive checker of Python programs
Pygments                     2.13.0      Pygments is a syntax highlighting package written in Python.
PyJWT                        2.5.0       JSON Web Token implementation in Python
pyparsing                    3.0.9       pyparsing module - Classes and methods to define and execute parsing grammars
PySocks                      1.7.1       A Python SOCKS client module. See https://github.com/Anorov/PySocks for more information.
pytest                       7.1.3       pytest: simple powerful testing with Python
pytest-django                4.5.2       A Django plugin for pytest.
python-dateutil              2.8.2       Extensions to the standard Python datetime module
python-dotenv                0.21.0      Read key-value pairs from a .env file and set them as environment variables
python-telegram-bot          20.0a4      We have made you a wrapper you can't refuse
pytz                         2022.2.1    World timezone definitions, modern and historical
pytz-deprecation-shim        0.1.0.post0 Shims to make deprecation of pytz easier
pytzdata                     2020.1      The Olson timezone database for Python.
requests                     2.28.1      Python HTTP for Humans.
rfc3986                      1.5.0       Validating URI References per RFC 3986
rich                         12.5.1      Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
rsa                          4.9         Pure-Python RSA implementation
selenium                     4.5.0       
setuptools                   65.4.1      Easily download, build, install, upgrade, and uninstall Python packages
setuptools-scm               7.0.5       the blessed package to manage your versions by scm tags
six                          1.16.0      Python 2 and 3 compatibility utilities
sniffio                      1.3.0       Sniff out which async library your code is running under
sortedcontainers             2.4.0       Sorted Containers -- Sorted List, Sorted Dict, Sorted Set
sqlparse                     0.4.3       A non-validating SQL parser.
Telethon                     1.25.2      Full-featured Telegram client library for Python 3
toml                         0.10.2      Python Library for Tom's Obvious, Minimal Language
tomli                        2.0.1       A lil' TOML parser
tornado                      6.2         Tornado is a Python web framework and asynchronous networking library, originally developed at Frie...
trio                         0.22.0      A friendly Python library for async concurrency and I/O
trio-websocket               0.9.2       WebSocket library for Trio
types-cryptography           3.3.23      Typing stubs for cryptography
types-requests               2.28.11     Typing stubs for requests
types-urllib3                1.26.25     Typing stubs for urllib3
typing-extensions            4.3.0       Backported and Experimental Type Hints for Python 3.7+
tzdata                       2022.4      Provider of IANA time zone data
tzlocal                      4.2         tzinfo object for the local timezone
Unidecode                    1.3.6       ASCII transliterations of Unicode text
urllib3                      1.26.12     HTTP library with thread-safe connection pooling, file post, and more.
wsproto                      1.2.0       WebSockets state-machine based protocol implementation
XlsxWriter                   3.0.3       A Python module for creating Excel XLSX files.

I try to save model from Django IDLE shell and it gives me an error

Hello. I have Python 2.7 and Django 1.4.1 installed on Windows 7 machine. I have not modified the python files in any way.
I tried to run main.py and also in the Django IDLE shell but I get an error. This is what I do.

c:\foo> python manage.py shell

from db.models import User
user = User(name="Dan", email="[email protected]")

but then I try to save:

user.save()
and I get the following error:

File "main.py", line 12, in
user.save()
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 910, in execute_sql
cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: db_user

Why is this happening? Also, keep up the great work. I really like this Django-ORM!

ORM needs the same app/class structure (Just a Comment)

If you put all the models on the same model.py (db.py) , orm get the table name like 'db_' (app name)+ lower(Model Class Name), so the database query fails.
django.db.utils.ProgrammingError: ('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'db_servers'. (208) (SQLExecDirectW)")
because dont exists, to avoid this yo must respect the app/class model structure of the original django project and import it in the same way.
or a cleaner way is to set the db_table property on every model class and keep it in the same file:

class Meta: db_table='catalog_servers'


>>> from db.models import Servers
>>> Servers.objects.all()
<QuerySet [<Servers: SOME PRODUCCION>, <Servers: OTHER PRODUCCION>, <Servers: SOME_DEV>, <Servers: ANOTHER PRODUCCION>]>

Have Apps aren't loaded yet. error

I have this error
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

script code

import sys
sys.dont_write_bytecode = True

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "navitest.settings")
import django
django.setup()

from .core import models


def init():
    print("Welcome to Django ORM!")
    print("Now you have the power of Django data modeling without the overhead.")
    print("The sample output below is printing usernames from the User model.")

if __name__ == '__main__':
    init()

problem

In the main directory of the project, I created a folder named main and moved the main.py file into it, but it gives an error!

Does not work with Python 3 and Django 1.9

I found your repo on stackoverflow, but unfortunately it does not work with Python 3 (missing parentheses on prints - nothing special), but then it shouts about missing SECRET_KEY:

Traceback (most recent call last):
File "./main.py", line 6, in
from db.models import *
File "/home/alchemyx/PycharmProjects/Django-ORM/db/models.py", line 10, in
class User(models.Model):
File "/home/alchemyx/PycharmProjects/Django-ORM/db/models.py", line 11, in User
name = models.CharField(max_length=255)
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/db/models/fields/init.py", line 1072, in init
super(CharField, self).init(_args, *_kwargs)
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/db/models/fields/init.py", line 166, in init
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/conf/init.py", line 55, in getattr
self._setup(name)
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/conf/init.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/conf/init.py", line 120, in init
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

After filling it in in settings.py with some random string I get:

Traceback (most recent call last):
File "./main.py", line 6, in
from db.models import *
File "/home/alchemyx/PycharmProjects/Django-ORM/db/models.py", line 10, in
class User(models.Model):
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/db/models/base.py", line 94, in new
app_config = apps.get_containing_app_config(module)
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
self.check_apps_ready()
File "/home/alchemyx/venv-ase/lib/python3.4/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

So it seems that something has changed in Djano 1.9?

Why?

HI. What is the meaning of this project? The user can install Django himself and remove some lines, it will take 3 minutes. I think if you do it in the form of a pip package and simplify the methods, it will be more attractive!

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.