Editing
Packaging Stand-Alone Django Apps
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Using the package == <div class="alert alert-warning">Follow the instructions for [[#Upgrading_the_package|upgrading the package]] if the package has already been installed.</div> === Installing the package === Push the package distribution to GitHub. (For development purposes, not strictly necessary for installation.) Upload the zipped distribution to Amazon S3 bucket `[https://console.aws.amazon.com/s3/home?region=us-west-2#&bucket=nrose-django-packages&prefix= nrose-django-packages]` ==== Command line ==== `npm install https://s3-us-west-2.amazonaws.com/nrose-django-packages/django-jinja2-gtm-0.1.1.zip` ==== requirements.txt ==== Add the URL on its own line in the `requirements.txt` file: <syntaxhighlight lang="text"> https://s3-us-west-2.amazonaws.com/nrose-django-packages/django-jinja2-gtm-0.1.1.zip </syntaxhighlight> Then to install with `pip`: <syntaxhighlight lang="bash"> $ pip install -r requirements.txt </syntaxhighlight> === Upgrading the package === Update the version number in `requirements.txt`. Run `pip install -r requirements.txt` === Using the package in a project === Assuming that the package is <syntaxhighlight lang="text"> |- django-addresses | | | |- addresses | | | | | `-- [...] | | | `-- [...] | `-- [...] </syntaxhighlight> In the project's `settings.py`: <syntaxhighlight lang="python"> INSTALLED_APPS = ( ... 'addresses', ) </syntaxhighlight> Then from the web project root: <syntaxhighlight lang="bash"> $ python manage.py makemigrations addresses $ python manage.py migrate addresses </syntaxhighlight> To reference the objects in a model within the web project: <syntaxhighlight lang="python"> class Person(models.Model): address = models.ForeignKey('addresses.Address') # ... </syntaxhighlight> === Resetting migrations === In the case that migrations have been made, and you want to rebuild the database objects from scratch: <syntaxhighlight lang="bash"> $ python manage.py migrate --fake addresses zero $ python manage.py migrate addresses </syntaxhighlight> * The first command sets the migration counter to before the initial (`0001`) migration. * The 2nd command migrates the models at the state of the latest migration.<ref>[http://stackoverflow.com/a/27008518 How to reset migrations in Django 1.7?] (Stackoverflow)</ref>
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information