django-1.8

STATIC_ROOT setup in Django 1.8

和自甴很熟 提交于 2019-12-04 20:57:11
I was tried n I can't set-up as per official documents... I am attaching IMG here, pls give me suggestions, Where is the problem. enter image description here Or, give me simple steps for it with dictionary tree structure. Thank you. # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_root', 'static') STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), # '/var/www/static/', ) STATIC_ROOT = 'os.path.join(BASE_DIR, 'static_root', 'static') can't work. Try this : # define your

How to access model's class level variable in data migration?

家住魔仙堡 提交于 2019-12-04 07:16:42
Here is my model. Poll(models.Model): title = models.CharField(max_length=1024) MY_VAR = ['my_class_level_attribute'] # I want to access this Here is my data migration: def my_func(apps, schema_editor): Poll = apps.get_model('my_app', 'Poll') print Poll.MY_VAR class Migration(migrations.Migration): dependencies = [ ('webmerge', '0012_previous_migration'), ] operations = [ migrations.RunPython(my_func) ] The line print Poll.MY_VAR gives an attribute error. I think the issue might is in how get_model performs within a data migration because the following lines succeed in a Django shell: In [2]:

Selecting specific fields using select_related in Django

烂漫一生 提交于 2019-12-04 00:02:55
I have two models Article and Blog related using a foreign key. I want to select only blog name while extracting the article. articles = Articles.objects.all().select_related('blog__name') The query generated shows that it selected all the fields from the Blog model. I tried using only() and defer() with select_related but both didn't work out. articles = Articles.objects.all().select_related('blog__name').only('blog__name', 'title', 'create_time') The above query resulted in error: Invalid field name(s) given in select_related: Choices are: blog How do i generate a query so that only article

Django 1.8 LookupError AUTH_USER_MODEL

孤街醉人 提交于 2019-12-03 17:05:05
I'm using a custon user model as such in my app called fowl . When I run syncdb or makemigrations or migrate I get a LookupError . Please help In settings.py I have defined AUTH_USER_MODEL as 'fowl.User' fowl/models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager from django.utils import timezone from django.core.mail import send_mail from django.utils.translation import ugettext_lazy as _ class UserManager(BaseUserManager): def create_user(self, email, password=None): """ Creates and saves a User with the given email,

Django 1.8 to 1.9 upgrade: django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet

我的梦境 提交于 2019-12-03 14:46:23
问题 I have a project currently working on Django 1.8. Since 1.9 just released, I thought I would update via pip install django==1.9 . However, when running python manage.py test -v 3 , I get this error: Traceback (most recent call last): File "manage.py", line 11, in <module> execute_from_command_line(sys.argv) File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line utility.execute() File "/home/user/Envs/intranet/lib

Upgrading from Django 1.6 (with south) to 1.8 doesn't modify 'last_login' on the user table

喜夏-厌秋 提交于 2019-12-03 14:42:44
问题 I have upgraded from Django 1.6.5 (with south migrations) to Django 1.8. I have followed the instructions here: https://docs.djangoproject.com/en/1.8/topics/migrations/#upgrading-from-south So, I remove South, delete my previous migrations and run python manage.py makemigrations which makes a new migration file. Then I run python manage.py migrate --fake-initial to fake the initial migration. Then I run python manage.py migrate . It all runs fine with no errors. I have a custom user model

Auto register Django auth models using custom admin site

不羁的心 提交于 2019-12-03 11:15:28
问题 I implemented authentication management using Django auth with the default admin site but then I wanted to use my own AdminSite to rewrite some behaviors: class OptiAdmin(admin.AdminSite): site_title = "Optimizer site's admin" #...Other stuff here Then registered my own models: admin_site = OptiAdmin(name='opti_admin') admin.site.register(MyModel, MyModelAdmin) #Other stuff here But when I go to the admin site I am only able to see the models I just registered, which sounds fair to me but I

Upgrading from Django 1.6 (with south) to 1.8 doesn't modify 'last_login' on the user table

ぃ、小莉子 提交于 2019-12-03 04:29:23
I have upgraded from Django 1.6.5 (with south migrations) to Django 1.8. I have followed the instructions here: https://docs.djangoproject.com/en/1.8/topics/migrations/#upgrading-from-south So, I remove South, delete my previous migrations and run python manage.py makemigrations which makes a new migration file. Then I run python manage.py migrate --fake-initial to fake the initial migration. Then I run python manage.py migrate . It all runs fine with no errors. I have a custom user model which inherits AbstractBaseUser . In Django 1.8 it seems there is a change to the last_login field where

Django 1.8 to 1.9 upgrade: django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet

邮差的信 提交于 2019-12-03 03:46:46
I have a project currently working on Django 1.8. Since 1.9 just released, I thought I would update via pip install django==1.9 . However, when running python manage.py test -v 3 , I get this error: Traceback (most recent call last): File "manage.py", line 11, in <module> execute_from_command_line(sys.argv) File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line utility.execute() File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/core/management/__init__.py", line 324, in execute django.setup() File "

Not able to create super user with Django manage.py

喜欢而已 提交于 2019-12-03 03:37:52
问题 Trying to create a super user for my database: manage.py createsuperuser Getting a sad recursive message: Superuser creation skipped due to not running in a TTY. You can run manage.py createsuperuser in your project to create one manually. Seriously Django? Seriously? The only information I found for this was the one listed above but it didn't work: Unable to create superuser in django due to not working in TTY And this other one here, which is basically the same: Can't Create Super User