django-1.5

Python Django ImportError: No module named website

心已入冬 提交于 2019-12-08 08:28:20
问题 I am running a sample site on Django 1.5.1 but I am getting ImportError while creating Django app named "website". Here is my Application Heirarchy. TrackLeech -- __init__.py -- manage.py TrackLeech -- __init__.py -- setting.py -- urls.py -- wsgi.py website -- __init__.py -- models.py -- tests.py -- views.py templates -- index.html Now when I run the command, the server starts well at port 8000 but the localhost:8000 page shows ImportError $ python manage.py runserver Validating models... 0

Django 1.5: Accessing custom user model fields in models.py

折月煮酒 提交于 2019-12-07 04:06:52
问题 I'm working on a Django 1.5 project and I have a custom user model (let's call it CustomUser ). Another app (SomeApp) needs to reference this custom user model. For the purposes of ForeignKey and such, the Django documentation says to use User = settings.AUTH_USER_MODEL However, some functions in SomeApp.models need to access what would have formerly been known as User.objects . But User is now a string and not a class, so User.objects fails. The alternative would be from django.contrib.auth

how to split the string in django template?

▼魔方 西西 提交于 2019-12-07 03:38:39
问题 i am trying to split the string in template using custom template filter. But i got an error TemplateSyntaxError at /job/16/ 'for' statements should use the format 'for x in y': for skill in form.instance.skills | split : "," Here it is my filter @register.filter(name='split') def split(value, key): """ Returns the value turned into a list. """ return value.split(key) this is my template <h4>Skills</h4> {% for skill in form.instance.skills | split : "," %} {{ skill }} {% endfor %} Thanks 回答1:

Python Django ImportError: No module named website

余生长醉 提交于 2019-12-06 23:40:57
I am running a sample site on Django 1.5.1 but I am getting ImportError while creating Django app named "website". Here is my Application Heirarchy. TrackLeech -- __init__.py -- manage.py TrackLeech -- __init__.py -- setting.py -- urls.py -- wsgi.py website -- __init__.py -- models.py -- tests.py -- views.py templates -- index.html Now when I run the command, the server starts well at port 8000 but the localhost:8000 page shows ImportError $ python manage.py runserver Validating models... 0 errors found July 24, 2013 - 13:29:03 Django version 1.5.1, using settings 'TrackLeech.settings'

Subclassing AbstractUser in Django for two types of users

▼魔方 西西 提交于 2019-12-06 16:54:14
问题 I'm developing a school database system in Django 1.5, and was planning on having a number of different user types (Student, Staff, Parent) which subclass AbstractUser (actually, another abstract subclass of AbstractUser). I was just attempting to add an externally developed app to my system, which uses User in a ForeignKey for some of its models, however, this fails as my user type is not a 'User' instance. I can't set the apps models to use AbstractUser as one can't use abstract classes for

Custom user model in django does not allow setting password in admin

血红的双手。 提交于 2019-12-06 03:45:49
问题 I have created a custom user model which I am successfully using within my app. The problem is that within the Admin, on the user edit screen, I get a display of the present password hash, instead of the very useful interface for setting the password. I am using Django 1.5b1 on Python 2.7. How can I convince the Django admin to treat my user model the same way it treats the native User, for the sake of the admin user interface? 回答1: Documentation suggest that you need to register the custom

django admin inline many to many custom fields

那年仲夏 提交于 2019-12-05 15:06:55
问题 Hi I am trying to customize my inlines in django admin. Here are my models: class Row(models.Model): name = models.CharField(max_length=255) class Table(models.Model): rows = models.ManyToManyField(Row, blank=True) name = models.CharField(max_length=255) def __unicode__(self): return self.name and my admin: class RowInline(admin.TabularInline): model = Table.rows.through fields = ['name'] class TableAdmin(admin.ModelAdmin): inlines = [ RowInline, ] exclude = ('rows',) However I get this error

AUTH_USER_MODEL refers to model .. that has not been installed and created AbstractUser models not able to login

断了今生、忘了曾经 提交于 2019-12-05 11:59:31
问题 AUTH_USER_MODEL error solved in EDIT3. Passwords still will not save on user creation via form. I'm using Django 1.5 playing around with the new user override/extension features, and I am not able to register new users via my registration form - only via the Admin. When registering via the registration form, I get the following error: Manager isn't available; User has been swapped for 'poker.PokerUser' models.py: class PokerUser(AbstractUser): poker_relate = models.ForeignKey(settings.AUTH

Django 1.5: Accessing custom user model fields in models.py

吃可爱长大的小学妹 提交于 2019-12-05 06:47:51
I'm working on a Django 1.5 project and I have a custom user model (let's call it CustomUser ). Another app (SomeApp) needs to reference this custom user model. For the purposes of ForeignKey and such, the Django documentation says to use User = settings.AUTH_USER_MODEL However, some functions in SomeApp.models need to access what would have formerly been known as User.objects . But User is now a string and not a class, so User.objects fails. The alternative would be from django.contrib.auth import get_user_model User = get_user_model() Which works in other modules, but when I use this in

Django admin does not login properly with custom User model

那年仲夏 提交于 2019-12-05 03:28:15
I upgraded an app I had on Django 1.4.5 to Django 1.5 and just finished migrating over to a custom User model. When I login to my app, using my own authentication form, with my superuser credentials (created when doing manage.py syncdb ) everything works fine. I am able to get authenticated and if I go to /admin , I am already logged in, as expected. I am able to navigate and use the Admin panel perfectly. However, if I try to login to the admin panel from /admin , using the django admin login form, I get the error: Please enter the correct email and password for a staff account. Note that