django-1.5

Django south circular dependency

感情迁移 提交于 2019-12-22 04:29:17
问题 I have an app (let's call it MyApp) in a Django 1.5 project. MyApp defines a custom user model (MyUser). The project uses another app (AnotherApp) which references MyUser. MyApp references fields in AnotherApp. Everything has been working fine on my development laptop. I'm attempting to deploy my project on a server, and when I come to the migrate step, MyApp fails due to a dependency to AnotherApp, and AnotherApp fails on a dependency to MyApp (I have tried migrating the apps independently).

Django 1.5b1: executing django-admin.py causes “No module named settings” error

允我心安 提交于 2019-12-21 03:33:35
问题 I've recently installed Django-1.5b1. My system configuration: OSX 10.8 Python 2.7.1 Virtualenv 1.7.2 When I call django-admin.py command I get the following error (devel)ninja Django-1.5b1: django-admin.py Usage: django-admin.py subcommand [options] [args] Options: -v VERBOSITY, --verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output --settings=SETTINGS The Python path to a settings module, e.g. "myproject.settings.main". If this isn

Migrate url tags to django 1.5

血红的双手。 提交于 2019-12-20 09:49:18
问题 I'm trying to migrate an old django application to django 1.5, There are 745 urls in different html files as this way: {% url url_name %} If I'm not wrong, this was deprecated and can't be used anymore from django 1.5 (as said here), and I have to transform all of them into: {% url 'url_name' %} Any idea to do this without going crazy? Maybe, some kind of script, I dont know... I can't imagine a way to do it with replace in path. I'm probably missing something obvious. 回答1: NOTE: This command

When to use the Custom User Model in Django 1.5

扶醉桌前 提交于 2019-12-20 09:06:10
问题 I have a question regarding the custom user model in Django 1.5 So right now the default user model looks just fine to me, I just need to add a few other variables such as gender,location and birthday so that users can fill up those variables after they have successfully registered and activated their account. So, what is the best way to implement this scenario? Do I have to create a new app called Profile and inherit AbstractBaseUser? and add my custom variable to models.py? Any good example

Django Query sort case-insensitive using Model method with PostgreSQL

扶醉桌前 提交于 2019-12-18 06:51:42
问题 I'm really new to django, python and postgres... I can't seem to find the answer on how to order_by being case insensitive while using Model as the query method, only if you use direct SQL queries. Model @classmethod def get_channel_list(cls, account): return cls.objects.filter(accountid=account).order_by('-name').values_list('name', 'channelid') Data set and order it's currently being ordered in test b test a test channel a test channel a test 2 a b test Test Channel Test 3 Test 3 Test 2

How to configure Django's “staticfiles” app to list directory contents?

此生再无相见时 提交于 2019-12-17 20:52:10
问题 I'm using Django's built-in web server, in DEBUG mode. This is part of my settings.py : STATIC_ROOT = '/home/user/static_root' STATIC_URL = '/static/' STATICFILES_DIRS = ( '/abs/path/to/static/dir', ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) If I access http://localhost:8000/static/png/ , I would expect to see a list of files available in /abs/path/to/static/dir/png . Instead I get a 404 error

Django allauth social login: automatically linking social site profiles using the registered email

眉间皱痕 提交于 2019-12-17 17:24:53
问题 I aim to create the easiest login experience possible for the users of my Django site. I imagine something like: Login screen is presented to user User selects to login with Facebook or Google User enter password in external site User can interact with my site as an authenticated user Ok, this part is easy, just have to install django-allauth and configure it. But I also want to give the option to use the site with a local user. It would have another step: Login screen is presented to user

Django locale enabled app always returns 404 when debug is off

蓝咒 提交于 2019-12-12 11:44:52
问题 I've been developing an app that uses i18n/locale as url prefix in the root/landing page. I tried to deploy my application earlier for testing purposes with DEBUG=True and everything was working perfectly. If attempting to access domain.com it would redirect to domain.com/en/ Now, since I disabled DEBUG=False, it won't redirect to /en/, instead it would show 404 error. I saw this question, which is close to my scenario Django 1.4 LocaleMiddleware not working with Apache, but works with

Django custom user model: How to manage staff permissions?

我怕爱的太早我们不能终老 提交于 2019-12-11 06:49:35
问题 I'm trying to benefit from Django 1.5 and created custom user model. In order to use builtin permissions, which I would like to limit access with in the admin interface. I inherited my user class also from PermissionMixin. But when I create new user and check Staff box, the new user gets all the access that superuser has. What am I doing wrong? models.py class MyUserManager(BaseUserManager): def create_user(self, email, password=None): if not email: raise ValueError(_('Users must have an

How do you generate a custom form in Django?

China☆狼群 提交于 2019-12-09 22:37:14
问题 In one of the template pages of my Django app, the page asks for the user to select the choices he wants, from a checkbox list. The catch is, that there are different choices for different users (for example, based on their past interests, there are different options). How do you generate Django forms with CheckboxSelectMultiple() fields that generate custom choices for each user? 回答1: In forms.py you need to override the __init__ method, and set there the choices passed from the view when