django-1.5

AttributeError: 'Manager' object has no attribute 'get_by_natural_key' error in Django?

ⅰ亾dé卋堺 提交于 2019-11-28 21:26:26
I am using Django '1.5c1' . I have this line in my settings.py: AUTH_USER_MODEL = 'fileupload.galaxyuser' Here's my Galaxyuser model: class GalaxyUser(models.Model): id = models.IntegerField(primary_key=True) create_time = models.DateTimeField(null=True, blank=True) update_time = models.DateTimeField(null=True, blank=True) email = models.CharField(max_length=765) password = models.CharField(max_length=120) external = models.IntegerField(null=True, blank=True) deleted = models.IntegerField(null=True, blank=True) purged = models.IntegerField(null=True, blank=True) username = models.CharField(max

Changing password in Django Admin

与世无争的帅哥 提交于 2019-11-28 21:26:19
I recently created the admin.py based in the Django Project Document: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.AbstractBaseUser But I really missed the functionality that allow the administrator the possibility to change the users passwords. How is possible to add this functionality? I just copied and pasted the code the is in the link above. from django import forms from django.contrib import admin from django.contrib.auth.models import Group from django.contrib.auth.admin import UserAdmin from django.contrib.auth.forms import

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

笑着哭i 提交于 2019-11-28 13:48:11
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 "Directory indexes are not allowed here." Now if I access the files directly, e.g. http://localhost:8000

File field not passing data to form

给你一囗甜甜゛ 提交于 2019-11-28 11:20:09
问题 I am using python 2.7 & django 1.5 Forms.py class FileUploadForm( forms.Form ): file = forms.FileField() title = forms.CharField(max_length = 200) HTML <form action="{% url 'upload_file' %}" method="post" class="userFroms"> {% csrf_token %} <ul class="pull-left"> <li> <div class="formLabel ">Title</div> <div class="formFields"><input name="title" type="text" /> </div> </li> <li> <div class="formLabel">Upload File</div> <div class="formFields"> <input name="file" type="file" size="20" /> </div

select_related with reverse foreign keys

时光怂恿深爱的人放手 提交于 2019-11-28 06:17:06
I have two Models in Django. The first has the hierarchy of what job functions (positions) report to which other positions, and the second is people and what job function they hold. class PositionHierarchy(model.Model): pcn = models.CharField(max_length=50) title = models.CharField(max_length=100) level = models.CharField(max_length=25) report_to = models.ForeignKey('PositionHierachy', null=True) class Person(model.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) ... position = models.ForeignKey(PositionHierarchy) When I have a Person record and

Implementing multiple user types with Django 1.5

大憨熊 提交于 2019-11-28 03:06:31
What is the recommended way to implement multiple user types using Django 1.5's new configurable user model functionality? I would like to have two user types: private users and trade users, each with their own set of required fields. There are two ways I can think to implement this: 1) Multi-table inheritance class BaseUser(AbstractBaseUser): email = models.EmailField(max_length=254, unique=True) # ... class PrivateUser(BaseUser): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) # ... class TradeUser(BaseUser): company_name = models.CharField(max_length

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

 ̄綄美尐妖づ 提交于 2019-11-28 03:02:21
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 User selects to register User enter credentials Site sends a verification email User clicks in email link

Using email as username field in Django 1.5 custom User model results in FieldError

回眸只為那壹抹淺笑 提交于 2019-11-27 14:31:43
问题 I want to use an email field as the username field for my custom user model. I have the following custom User model subclassing Django's AbstractUser model: class CustomUser(AbstractUser): .... email = models.EmailField(max_length=255, unique=True) USERNAME_FIELD = 'email' But when I run python manage.py sql myapp I get the following error: FieldError: Local field 'email' in class 'CustomUser' clashes with field of similar name from base class 'AbstractUser' The reason I include my own email

AttributeError: 'Manager' object has no attribute 'get_by_natural_key' error in Django?

≯℡__Kan透↙ 提交于 2019-11-27 13:58:47
问题 I am using Django '1.5c1' . I have this line in my settings.py: AUTH_USER_MODEL = 'fileupload.galaxyuser' Here's my Galaxyuser model: class GalaxyUser(models.Model): id = models.IntegerField(primary_key=True) create_time = models.DateTimeField(null=True, blank=True) update_time = models.DateTimeField(null=True, blank=True) email = models.CharField(max_length=765) password = models.CharField(max_length=120) external = models.IntegerField(null=True, blank=True) deleted = models.IntegerField

Changing password in Django Admin

感情迁移 提交于 2019-11-27 13:52:56
问题 I recently created the admin.py based in the Django Project Document: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.AbstractBaseUser But I really missed the functionality that allow the administrator the possibility to change the users passwords. How is possible to add this functionality? I just copied and pasted the code the is in the link above. from django import forms from django.contrib import admin from django.contrib.auth.models import Group