Closed MAkcanca closed 5 years ago
Hey MAk –
Were you able to get any up and showing at all? I previously wrote a short blog post on how I was able to get most of it set up myself.
Link: https://medium.com/@jpoechill/getting-setup-the-djaodjin-dev-environment-3ce20f982014
––
To get the pricing page to show with correct detail, it's noted that you have to turn on the debug mode, and load the sample data also.
$ diff -u <em>installTop</em>/etc/djaoapp/site.conf
-DEBUG = False
+DEBUG = True
# Create the tests databases and load test datasets.
$ make initdb
# To generate some sample data, disable emailing of receipts and run:
$ python manage.py load_test_transactions
I have debug mode turned on, that's how I got the traceback. Also like I said, I loaded the test data.
But I will try it again and update this post.
Update: Debug is turned on, I used the loaddata stated in README.md, still the same.
I'm using PostgreSQL and Django-allauth for user management. Can you try to reproduce it with vanilla django-cookiecutter ? Thanks
This error shows because the broker
Organization is not present. You will need to populate the database with some bootstrap records. For example, to get quickly started you can load the testsite fixtures.
Assuming you have a auth.User
record with pk=1
, the minimum fixtures required look something like:
{
"fields": {
"slug": "stripe",
"full_name": "Stripe",
"created_at": "2012-08-14T14:16:55-09:00",
"email": "stripe@localhost.localdomain",
"phone": "555-555-5555",
"street_address": "185 Berry St #550",
"locality": "San Francisco",
"region": "CA",
"postal_code": "94107",
"country": "US",
"processor": 1,
"is_provider": 1,
"is_active": 1
},
"model": "saas.Organization", "pk": 1
},
{
"fields": {
"slug": "terms-of-use",
"title": "Terms Of Use",
"modified": "2012-08-14T00:00:00-09:00"
},
"model": "saas.agreement", "pk": 1
},
{
"fields": {
"slug": "djaoapp",
"full_name": "DjaoApp",
"created_at": "2015-06-01T00:00:00+00:00",
"email": "djaoapp@localhost.localdomain",
"phone": "555-555-5555",
"street_address": "",
"locality": "",
"region": "CA",
"postal_code": "94133",
"country": "US",
"processor": 1,
"is_provider": 1,
"is_active": 1
},
"model": "saas.Organization", "pk": 2
},
{
"fields": {
"created_at": "2015-06-01T00:00:00+00:00",
"slug": "manager",
"title": "Profile Manager"
},
"model": "saas.RoleDescription", "pk": 1
},
{
"fields": {
"created_at": "2012-10-01T00:00:00-09:00",
"role_description": 1,
"organization": 2,
"user": 1
},
"model": "saas.Role", "pk": 1
}]
Note that if you are looking to build a full-fledge SaaS product and are starting from django-cookiecutter, you might also want to start from djaoapp.
I will be checking djaoapp but the problem persists. I already used the fixture and loaded test data, I think you misread my question since I stated that many times.
I will reset the database and update this post.
Update: I used the exact test data you provided with a clean database. Problem seems to persist.
DoesNotExist at /pricing/
Organization matching query does not exist.
Apologies. I tried to replicate what you did, installing djaodjin-saas into django-cookiecutter (line-by-line commands following).
The issue is that the broker Organization
installed by the djaodjin-saas/testsite fixtures is called "cowork", while the default value in saas/settings.py is derived from BASE_DIR
(which does not exist in django-cookiecutter settings.py) or the default value "broker".
$ cat /lib/python3.6/site-packages/settings.py:
'GET_INSTANCE': os.path.basename(
getattr(settings, 'BASE_DIR', "broker")),
The djaodjin-saas/testsite/settings.py explicitly set the broker slug to the value in the fixtures.
SAAS = {
'BROKER': {
'GET_INSTANCE': 'cowork',
}
}
When you are looking to go to production, you will want the slug of the broker Organization
defined in the database to match SAAS['BROKER']['GET_INSTANCE']
defined in config/settings/base.py.
Please let us know if this works for you or if you are stumbling on other issues. Thank you.
$ virtualenv-3.6 cookiecutter
$ source cookiecutter/bin/activate
$ pip install "cookiecutter>=1.4.0"
$ cookiecutter https://github.com/pydanny/cookiecutter-django
$ cd mytestsite
$ pip install -r requirements/local.txt
$ pip install djaodjin-saas
$ diff -u prev config/urls.py
from django.views import defaults as default_views
+ from saas.views import UserRedirectView
urlpatterns = [
+ path("api/", include('saas.urls.api')),
+ path("", include('saas.urls.noauth')),
+ path("", include('saas.urls.request')),
+ path("", include('saas.urls.redirects')),
+ path("", include('saas.urls.broker')),
+ path("", include('saas.urls.provider')),
+ path("", include('saas.urls.subscriber')),
+ path("", include('saas.urls.users')),
+ path("", UserRedirectView.as_view(), name='accounts_profile'),
$ diff -u prev config/settings/base.py
DATABASES = {
- "default": env.db("DATABASE_URL", default="postgres:///mytestsite")
+ # Didn't want to complicate things by installing postgres.
+ "default": env.db("DATABASE_URL", default="sqlite:///db.sqlite")
}
THIRD_PARTY_APPS = [
"crispy_forms",
"allauth",
"allauth.account",
"allauth.socialaccount",
"rest_framework",
+ "saas",
]
TEMPLATES = [
{
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
"BACKEND": "django.template.backends.django.DjangoTemplates",
# https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
"DIRS": [str(APPS_DIR.path("templates"))],
"OPTIONS": {
+ "builtins": [
+ "saas.templatetags.saas_tags",
+ ],
Here we will download the sample test data to get started quickly. Unfortunately django-cookiecutter is not using the auth.User
model but a users.User
model instead, so we first need to do a string replace in the fixtures file.
$ cd ..
$ git clone https://github.com/djaodjin/djaodjin-saas
$ diff -u prev djaodjin-saas/testsite/fixtures/test_data.json
...
- "model": "auth.User", "pk": 2
+ "model": "users.User", "pk": 2
...
$ cd mytestsite
We also configure the project settings.py to use the correct Organization
as a broker.
$ diff -u prev config/settings/base.py
+SAAS = {
+ 'BROKER': {
+ 'GET_INSTANCE': 'cowork',
+ }
+}
$ python manage.py loaddata ../djaodjin-saas/testsite/fixtures/test_data.json
Installed 61 object(s) from 1 fixture(s)
$ python manage.py migratedb
$ python manage.py runserver
Browsing the pricing page loads correctly at this point.
This ^ Kudos for your attention. Thank you so much. Didn't realize I had to set broker.
Hey!
I'm trying to install the djaodjin-saas but had no luck so far. I used pip install to install the package and added the url. But whenever I visit, for example xxx:/pricing it gives me this error: Organization matching query does not exist I loaded the test data fixture with loaddata. Database: PostgreSQL I'm using django-cookiecutter as a boilerplate.
Traceback
Thanks