Overriding settings in Django when used by the models

2018-12-30 Thread אורי
https://stackoverflow.com/questions/53953444/overriding-settings-in-django-when-used-by-the-models

We are using Django for Speedy Net and Speedy Match
 (currently Django 1.11.17, we
can't upgrade to a newer version of Django because of one of our
requirements, django-modeltranslation). Some of our settings are used by
the models. For example:

class USER_SETTINGS(object):
MIN_USERNAME_LENGTH = 6
MAX_USERNAME_LENGTH = 40

MIN_SLUG_LENGTH = 6
MAX_SLUG_LENGTH = 200

# Users can register from age 0 to 180, but can't be kept on the
site after age 250.
MIN_AGE_ALLOWED_IN_MODEL = 0  # In years.
MAX_AGE_ALLOWED_IN_MODEL = 250  # In years.

MIN_AGE_ALLOWED_IN_FORMS = 0  # In years.
MAX_AGE_ALLOWED_IN_FORMS = 180  # In years.

MIN_PASSWORD_LENGTH = 8
MAX_PASSWORD_LENGTH = 120

MAX_NUMBER_OF_FRIENDS_ALLOWED = 800

PASSWORD_VALIDATORS = [
{
'NAME':
'speedy.core.accounts.validators.PasswordMinLengthValidator',
},
{
'NAME':
'speedy.core.accounts.validators.PasswordMaxLengthValidator',
},
]

(which is defined in
https://github.com/speedy-net/speedy-net/blob/uri_merge_with_master_2018-12-26_a/speedy/net/settings/global_settings.py).
And then in the models I use:

from django.conf import settings as django_settings
class User(ValidateUserPasswordMixin, PermissionsMixin, Entity,
AbstractBaseUser):
settings = django_settings.USER_SETTINGS

(and then use attributes of settings, such as settings.MIN_SLUG_LENGTH, in
the class).

The problem is, when I try to override such settings in tests (you can see
my question & answer on Can I define classes in Django settings, and how
can I override such settings in tests?

), User.settings remains the same and is not overridden by the settings I
tried to override. This is a problem since in the model I passed
settings.MIN_SLUG_LENGTH for example to validators, which are also passed
other values by other models. Is it possible to define the models and
settings in such a way which the correct settings will be used both in
production and in tests, including when I want to override them?

I'm aware of this quote from
https://docs.djangoproject.com/en/dev/topics/testing/tools/#overriding-settings
:

*Warning*

The settings file contains some settings that are only consulted during
initialization of Django internals. If you change them with
override_settings, the setting is changed if you access it via the
django.conf.settings module, however, Django’s internals access it
differently. Effectively, using override_settings() or modify_settings()
with these settings is probably not going to do what you expect it to do.

We do not recommend altering the DATABASES setting. Altering the CACHES
setting is possible, but a bit tricky if you are using internals that make
using of caching, like django.contrib.sessions. For example, you will have
to reinitialize the session backend in a test that uses cached sessions and
overrides CACHES.

Finally, avoid aliasing your settings as module-level constants as
override_settings() won’t work on such values since they are only evaluated
the first time the module is imported.

Which I understand are relevant in this case, but how do I define the
settings in such a way that I can override them?
Thanks,
אורי (Uri)
u...@speedy.net


אורי
u...@speedy.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABD5YeEpMnMAHiNOerSCni3hvntWWzBM7-QFkuZMDfDjsA%3Dx-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: STATIC FILES not working for admin site, projects and apps on DJANGO

2018-12-30 Thread Joel Mathew
Your site has more wrong with it than just static css. Your html is
appearing as html. You need to unescape them in template or check your tags

On Mon, 31 Dec, 2018, 1:10 AM abel otugeme  I have done all that i used the docs first and it did not work. Then i
> tired this video https://www.youtube.com/watch?v=YH-ipgxlJzs
>
> On Sun, Dec 30, 2018 at 5:09 PM Lunga Baliwe  wrote:
>
>> Please have a look at this link
>> https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/modwsgi/ on
>> how to setup static files.
>> You may also want to run python manage.py collectstatic
>>
>> On Sun, Dec 30, 2018 at 4:31 AM abel otugeme  wrote:
>>
>>> This is how a site looks when i open it up in my browser No CSS! i
>>> have done the necessary settings for Django to find the static files
>>>
>>> On Sat, Dec 29, 2018 at 5:14 PM Kasper Laudrup 
>>> wrote:
>>>
 Hi Abel,

 On 29/12/2018 08.07, abel otugeme wrote:
 > I really need help i have combed through stackover flow and this
 group
 > but the solutions provided don't work for me.  i use a 32bit windows
 7
 > OS and the latest version of django
 >

 It would probably be easier for someone to help you if you tried to
 describe what your actual problem is.

 Kind regards,

 Kasper Laudrup

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To post to this group, send email to django-users@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/c8273be3-bc53-2103-f503-ae7668f01622%40stacktrace.dk
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMrS0S91GG0A%3D3Z263Q9nxLccStat-URs3NsW_pfqES_J5uU2Q%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CANDnEWfqpqyk-nesQcAKT-4i9tzAw8aJne2VjXFkgxqFWKJXiA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMrS0S_3dqSeH6osEsganiWJHk%3Dd%2B0Di0j2V9iqhDr0uD4qvag%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_9oqRts%3DjYUj%3DXkQBFXkfK-gU27vGTBfzxsTUpyichF3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: STATIC FILES not working for admin site, projects and apps on DJANGO

2018-12-30 Thread Okware Aldo
I can have a look if you give me access to the code, we could do
teamviewer, or  repo.

Let me know.

On Sun, 30 Dec 2018, 22:40 abel otugeme,  wrote:

> I have done all that i used the docs first and it did not work. Then i
> tired this video https://www.youtube.com/watch?v=YH-ipgxlJzs
>
> On Sun, Dec 30, 2018 at 5:09 PM Lunga Baliwe  wrote:
>
>> Please have a look at this link
>> https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/modwsgi/ on
>> how to setup static files.
>> You may also want to run python manage.py collectstatic
>>
>> On Sun, Dec 30, 2018 at 4:31 AM abel otugeme  wrote:
>>
>>> This is how a site looks when i open it up in my browser No CSS! i
>>> have done the necessary settings for Django to find the static files
>>>
>>> On Sat, Dec 29, 2018 at 5:14 PM Kasper Laudrup 
>>> wrote:
>>>
 Hi Abel,

 On 29/12/2018 08.07, abel otugeme wrote:
 > I really need help i have combed through stackover flow and this
 group
 > but the solutions provided don't work for me.  i use a 32bit windows
 7
 > OS and the latest version of django
 >

 It would probably be easier for someone to help you if you tried to
 describe what your actual problem is.

 Kind regards,

 Kasper Laudrup

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To post to this group, send email to django-users@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/c8273be3-bc53-2103-f503-ae7668f01622%40stacktrace.dk
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMrS0S91GG0A%3D3Z263Q9nxLccStat-URs3NsW_pfqES_J5uU2Q%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CANDnEWfqpqyk-nesQcAKT-4i9tzAw8aJne2VjXFkgxqFWKJXiA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMrS0S_3dqSeH6osEsganiWJHk%3Dd%2B0Di0j2V9iqhDr0uD4qvag%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMEZma9ja8TOwuh_n5fpzaBrANt3igG1%2BkBhz%3DSearvJw1NQAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django admin site change_related_template_url problem

2018-12-30 Thread Ryan Nowakowski
You're better off not using the HTML rewriting features of your reverse proxy. 
Instead configure Django to use the reverse proxied url prefix for all it's 
URLs.

On December 29, 2018 9:03:39 AM CST, Zhe Li  wrote:
>Hi,
>
>I am having issues with django installed on a server reversed proxied
>to 
>the main website. Most of the sites work just fine except a very small 
>detail in the admin site, change form page.
>
>Django is running on server A, served at / on port 12345. Server B
>which is 
>the main web server and has a domain www.example.com, and serves
>content 
>(reverse proxies) from server A under /app/myapp.
>
>i.e. *http://A:12345/admin/* translates to 
>*https://www.example.com/app/myapp/admin*.
>
>Everything is fine except when I try to modify a foreign key value from
>the 
>model that it is referenced. You know, if I modify fields of model A in
>the 
>django admin site, I can click on these buttons to change a foreign key
>
>model B.
>
>[image: Screen Shot 2018-12-29 at 9.45.42
>AM.png] 
>
>
>
>
>
>
>The problem is that the links are not properly translated on server B.
>The 
>"add" button is fine, but the "change" and the "delete" buttons are
>not. 
>For example, the correct "change" button should point to 
>*https://www.example.com/app/myapp/admin/main/modelb/1/change/?_to_field=id&_popup=1*,
>
>but it actually points to 
>*https://www.example.com/admin/main/modelb/1/change/?_to_field=id&_popup=1*,
>
>which does not exist. The problem is that the relative URL is stored in
>the 
>"data-href-template" attribute of the  tag, like this
>
>*> id="change_id_modelb" 
>>
>data-href-template="/admin/main/modelb/__fk__/change/?_to_field=id&_popup=1"
>
>> title="Change selected modelb">*
>>
>
>which is parsed by static/admin/js/admin/RelatedObjectLookups.js, which
>
>adds a "real" href attribute via JS, giving
>
>*> id="change_id_system" 
>>
>data-href-template="/admin/main/modelb/__fk__/change/?_to_field=id&_popup=1"
>
>> title="Change selected modelb" 
>> href="/admin/main/modelb/1/change/?_to_field=id&_popup=1">> src="/app/myapp/static/admin/img/icon-changelink.svg"
>alt="Change">*
>
>
>The reverse proxy program, however, only translates whatever is in the
>HTML 
>, and does nothing about this customized data field.
>
>This is not necessarily a bug, as it only happens in special cases like
>
>mine. I am not sure what to do -- I can modify this
>RelatedObjectLookups.js 
>and just add '/app/myapp' in front of every link it produces, which
>should 
>work and fix this problem at this point. However, a more complete
>solution 
>would be to overhaul this lookup js and put a real link there, which is
>
>quite some work to do. Should I write a new ticket to Django Project,
>or do 
>you have better suggestions?
>
>Thank you
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to django-users+unsubscr...@googlegroups.com.
>To post to this group, send email to django-users@googlegroups.com.
>Visit this group at https://groups.google.com/group/django-users.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/cf876c89-c3e7-414e-8290-1e050f80f7b7%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/758772A2-552D-4B90-8D8D-B3F94DCF8EA9%40fattuba.com.
For more options, visit https://groups.google.com/d/optout.


Re: STATIC FILES not working for admin site, projects and apps on DJANGO

2018-12-30 Thread abel otugeme
I have done all that i used the docs first and it did not work. Then i
tired this video https://www.youtube.com/watch?v=YH-ipgxlJzs

On Sun, Dec 30, 2018 at 5:09 PM Lunga Baliwe  wrote:

> Please have a look at this link
> https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/modwsgi/ on
> how to setup static files.
> You may also want to run python manage.py collectstatic
>
> On Sun, Dec 30, 2018 at 4:31 AM abel otugeme  wrote:
>
>> This is how a site looks when i open it up in my browser No CSS! i
>> have done the necessary settings for Django to find the static files
>>
>> On Sat, Dec 29, 2018 at 5:14 PM Kasper Laudrup 
>> wrote:
>>
>>> Hi Abel,
>>>
>>> On 29/12/2018 08.07, abel otugeme wrote:
>>> > I really need help i have combed through stackover flow and this group
>>> > but the solutions provided don't work for me.  i use a 32bit windows 7
>>> > OS and the latest version of django
>>> >
>>>
>>> It would probably be easier for someone to help you if you tried to
>>> describe what your actual problem is.
>>>
>>> Kind regards,
>>>
>>> Kasper Laudrup
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/c8273be3-bc53-2103-f503-ae7668f01622%40stacktrace.dk
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMrS0S91GG0A%3D3Z263Q9nxLccStat-URs3NsW_pfqES_J5uU2Q%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANDnEWfqpqyk-nesQcAKT-4i9tzAw8aJne2VjXFkgxqFWKJXiA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMrS0S_3dqSeH6osEsganiWJHk%3Dd%2B0Di0j2V9iqhDr0uD4qvag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: template location for django-registration framework

2018-12-30 Thread Yuval Bachrach
First: thank you!
Yes I did search before asking
I was trying to place the templates under my project tree (rather than
under
"Python37-32\Lib\site-packages\django\contrib\admin\templates\registration"
and could not make it work.
Per you advice I also tried putting the template file at the above
mentioned directory as a temporary solution but I still get the same error
message.

On Sat, Dec 29, 2018 at 5:45 PM Zhe Li  wrote:

> Have you searched the internet before posting?
>
>
> https://stackoverflow.com/questions/6127264/troubleshooting-templatedoesnotexist-at-accounts-login-django-auth-setup
>
> You can either create your own pages or copy the whole templates under the
> django admin site
> -- site-packages/django/contrib/admin/templates/registration/
>
> On Saturday, December 29, 2018 at 10:22:11 AM UTC-5, Yuval Bachrach wrote:
>>
>> I have installed "django-registration:" and now follow "
>> https://django-registration.readthedocs.io/en/3.0/quickstart.html";
>>
>> I have set URLs as explained (see below) but failed to tell django where
>> to find the templates.
>>
>> What do I need to do to have django find the templates?
>>
>>
>> More details:
>>
>> http://127.0.0.1:8000/accounts/register/
>>
>> is resulted with an error:
>> TemplateDoesNotExist at /accounts/register/
>>
>> django_registration/registration_form.html
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/accounts/register/
>> Django Version: 2.1.3
>> Exception Type: TemplateDoesNotExist
>> Exception Value:
>>
>> django_registration/registration_form.html
>>
>> Exception Location: C:\Program Files
>> (x86)\Python37-32\lib\site-packages\django\template\loader.py in
>> select_template, line 47
>> Python Executable: C:\Program Files (x86)\Python37-32\python.exe
>> Python Version: 3.7.1
>>
>> I have tried to locate *registration_form.html* at
>> django_reistration/reister/templates at
>> "django_registration\registration\templates\registration" under my
>> project.
>> Also tried "django-registration\registration\templates\registration" and
>> several other locations but I keep getting the error message.
>>
>> The problem could be the template location or  a missing setting,...
>>
>>- I added no app to the "INSTALLED_APPS" at setting.py
>>- my template is:
>>
>> TEMPLATES = [
>> {
>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>> # changed at tutor7
>> # 'DIRS': [],
>> 'DIRS': [os.path.join(BASE_DIR, 'templates')],
>> # DIRS is a list of filesystem directories to check when loading
>> Django templates; it’s a search path
>> 'APP_DIRS': True,
>> 'OPTIONS': {
>> 'context_processors': [
>> 'django.template.context_processors.debug',
>> 'django.template.context_processors.request',
>> 'django.contrib.auth.context_processors.auth',
>> 'django.contrib.messages.context_processors.messages',
>> ],
>> },
>> },
>> ]
>>
>>
>>
>> from django.conf.urls import include, url
>> urlpatterns = [
>> # Other URL patterns ...
>> url(r'^accounts/', 
>> include('django_registration.backends.activation.urls')),
>> url(r'^accounts/', include('django.contrib.auth.urls')),
>> # More URL patterns ...
>>
>>
>>
>> --
>>
>> Yuval B
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a0f6a2f7-455d-4cdc-985d-acc8a810daf4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Yuval B

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD16PYR5OgHMS5UOzDYsmYFROh0CnO6T61%3DpKhw-giT9VED1bQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: STATIC FILES not working for admin site, projects and apps on DJANGO

2018-12-30 Thread Lunga Baliwe
Please have a look at this link
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/modwsgi/ on how
to setup static files.
You may also want to run python manage.py collectstatic

On Sun, Dec 30, 2018 at 4:31 AM abel otugeme  wrote:

> This is how a site looks when i open it up in my browser No CSS! i
> have done the necessary settings for Django to find the static files
>
> On Sat, Dec 29, 2018 at 5:14 PM Kasper Laudrup 
> wrote:
>
>> Hi Abel,
>>
>> On 29/12/2018 08.07, abel otugeme wrote:
>> > I really need help i have combed through stackover flow and this group
>> > but the solutions provided don't work for me.  i use a 32bit windows 7
>> > OS and the latest version of django
>> >
>>
>> It would probably be easier for someone to help you if you tried to
>> describe what your actual problem is.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/c8273be3-bc53-2103-f503-ae7668f01622%40stacktrace.dk
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMrS0S91GG0A%3D3Z263Q9nxLccStat-URs3NsW_pfqES_J5uU2Q%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANDnEWfqpqyk-nesQcAKT-4i9tzAw8aJne2VjXFkgxqFWKJXiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: MySQL accepts 0 for a primary key but Django does not

2018-12-30 Thread Simon Charette
Hello Derek,

Not sure of your custom module structure but you'll want to point ENGINE to 
'custom'
and not 'custom.base' just like you were pointing to 
'django.db.backends.mysql' and
not 'django.db.backends.mysql.base'.

Cheers,
Simon

Le dimanche 30 décembre 2018 04:01:59 UTC-5, Derek a écrit :
>
> Hi Simon
>
> Much appreciated.
>
> However, I am obviously doing something wrong.  If I save that code into a 
> file called "base.py" stored in my 'custom' app, and then change my 
> settings file to have:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'custom.base',  # WAS: 'django.db.backends.mysql',
> 'NAME': DB_NAME,
> 'USER': DB_USER,
> 'PASSWORD': DB_PWORD,
> 'HOST': '',
> 'PORT': '',
> }
> }
>
> Then I get this error on startup:
>
> Traceback (most recent call last):
>   File "manage.py", line 14, in 
> execute_from_command_line(sys.argv)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 399, in execute_from_command_line
> utility.execute()
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 280, in execute
> translation.activate('en-us')
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
>  
> line 130, in activate
> return _trans.activate(language)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  
> line 188, in activate
> _active.value = translation(language)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  
> line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  
> line 159, in _fetch
> app = import_module(appname)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/importlib.py",
>  
> line 40, in import_module
> __import__(name)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/massadmin/__init__.py",
>  
> line 28, in 
> from django.contrib import admin
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
>  
> line 6, in 
> from django.contrib.admin.sites import AdminSite, site
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/sites.py",
>  
> line 4, in 
> from django.contrib.admin.forms import AdminAuthenticationForm
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/forms.py",
>  
> line 6, in 
> from django.contrib.auth.forms import AuthenticationForm
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/forms.py",
>  
> line 17, in 
> from django.contrib.auth.models import User
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
>  
> line 48, in 
> class Permission(models.Model):
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
>  
> line 96, in __new__
> new_class.add_to_class('_meta', Options(meta, **kwargs))
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
>  
> line 264, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/options.py",
>  
> line 124, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/__init__.py",
>  
> line 34, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
>  
> line 198, in __getitem__
> backend = load_backend(db['ENGINE'])
>   File 
> "/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
>  
> line 131, in load_backend
> raise ImproperlyConfigured(error_msg)
> django.core.exceptions.ImproperlyConfigured: 'custom.base' isn't an 
> available database backend.
> Try using 'django.db.backends.X

Re: MySQL accepts 0 for a primary key but Django does not

2018-12-30 Thread Derek
Hi Simon

Much appreciated.

However, I am obviously doing something wrong.  If I save that code into a 
file called "base.py" stored in my 'custom' app, and then change my 
settings file to have:

DATABASES = {
'default': {
'ENGINE': 'custom.base',  # WAS: 'django.db.backends.mysql',
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PWORD,
'HOST': '',
'PORT': '',
}
}

Then I get this error on startup:

Traceback (most recent call last):
  File "manage.py", line 14, in 
execute_from_command_line(sys.argv)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 399, in execute_from_command_line
utility.execute()
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 280, in execute
translation.activate('en-us')
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
 
line 130, in activate
return _trans.activate(language)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 
line 188, in activate
_active.value = translation(language)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 
line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 
line 159, in _fetch
app = import_module(appname)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/importlib.py",
 
line 40, in import_module
__import__(name)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/massadmin/__init__.py",
 
line 28, in 
from django.contrib import admin
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
 
line 6, in 
from django.contrib.admin.sites import AdminSite, site
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/sites.py",
 
line 4, in 
from django.contrib.admin.forms import AdminAuthenticationForm
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/forms.py",
 
line 6, in 
from django.contrib.auth.forms import AuthenticationForm
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/forms.py",
 
line 17, in 
from django.contrib.auth.models import User
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
 
line 48, in 
class Permission(models.Model):
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 264, in add_to_class
value.contribute_to_class(cls, name)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/options.py",
 
line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/__init__.py",
 
line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
 
line 198, in __getitem__
backend = load_backend(db['ENGINE'])
  File 
"/home/gamesbook/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
 
line 131, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'custom.base' isn't an 
available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'

Any idea what I have missed?

Thanks
Derek


On Friday, 28 December 2018 16:20:33 UTC+2, Simon Charette wrote:
>
> Hello Derek,
>
> There's no setting but this is controlled by the allows_auto_pk_0 feature 
> flag [0].
> Database feature are set to the default database configurations so Django 
> can
> minimized the number of introspection queries required to work 
> appropriately
> each time a connection is opened.
>
> In order to override it I suggest you create a subc