django-contrib

Django upgrade from 1.8 to 1.9 is breaking on model import in init

痞子三分冷 提交于 2020-04-30 06:57:27
问题 I have run into the same problem that @JohnnyQ has commented on here. My __init__.py is referring to multiple imports that in-turn are referring to models and these are required. The code works perfectly fine with django 1.8.x but breaks when Django is upgraded to 1.9.x. I am guessing it to be some class-loading sequence issue. What has changed in 1.9 w.r.t to model imports in apps triggering the AppRegistryNotReady exception? The traceback is here: Traceback (most recent call last): File "

Django upgrade from 1.8 to 1.9 is breaking on model import in init

╄→гoц情女王★ 提交于 2020-04-30 06:57:05
问题 I have run into the same problem that @JohnnyQ has commented on here. My __init__.py is referring to multiple imports that in-turn are referring to models and these are required. The code works perfectly fine with django 1.8.x but breaks when Django is upgraded to 1.9.x. I am guessing it to be some class-loading sequence issue. What has changed in 1.9 w.r.t to model imports in apps triggering the AppRegistryNotReady exception? The traceback is here: Traceback (most recent call last): File "

django default Authenticaiton form shows username rather than email

試著忘記壹切 提交于 2020-01-16 09:48:06
问题 I implemented my own user login form with django like below from django.contrib.auth.forms import AuthenticationForm class CustomUserLoginForm(AuthenticationForm): class Meta: model = CustomUser fields = ('email', 'password') then as a view this is what I have: from rest_auth.views import LoginView from users.forms import CustomUserLoginForm class CustomLoginView(LoginView): def get(self, request): form = CustomUserLoginForm() return render(request, "api/test_template.html", context={"form":

Django comments framework

痞子三分冷 提交于 2020-01-06 15:19:11
问题 Hi I am quite new to Django and am trying to get to grips with a few things. I would like to know if the comments framework that is bundled with django can redirect to the refering page if the comment form contains errors? Also if I were to make a rating framework how would I go about achieving this functionality. Would I simply pass the refering url inside my rating form? Thanks for any help Mark 回答1: As someone who dealt with the first issue, I can say I could not find a way, at least

Using Django Cache Middleware causes contrib.auth unit tests to fail

爱⌒轻易说出口 提交于 2020-01-01 18:55:36
问题 Problem: When I add UpdateCacheMiddleware and FetchFromCacheMiddleware to my Django project, I get unittest failures. This is regardless of the CACHE_BACKEND I use (right now I am using locmem://, but the errors are the same when I use file:///path_to_cache) My Middleware: MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',

contrib.staticfiles and Django admin media

你。 提交于 2020-01-01 08:54:13
问题 I just switched from 1.2 to trunk (r15175 at this writing) to play with contrib.staticfiles , and now when using the local devserver all my admin media returns a 404. The static media (as managed by the new contrib app) all work as expected, but I'd like to be able to use the admin with the dev server so that I don't have to restart a local apache instance when dev code changes. Is this known behaviour? I haven't gotten a response in IRC. edit: Seems related to: Admin media disappear while

contrib.staticfiles and Django admin media

假装没事ソ 提交于 2020-01-01 08:54:08
问题 I just switched from 1.2 to trunk (r15175 at this writing) to play with contrib.staticfiles , and now when using the local devserver all my admin media returns a 404. The static media (as managed by the new contrib app) all work as expected, but I'd like to be able to use the admin with the dev server so that I don't have to restart a local apache instance when dev code changes. Is this known behaviour? I haven't gotten a response in IRC. edit: Seems related to: Admin media disappear while

Does Django ship with the authentication templates for use with the django.contrib.auth module? [duplicate]

浪子不回头ぞ 提交于 2019-12-18 05:55:46
问题 This question already has answers here : Is there a built-in login template in Django? (5 answers) Closed 3 years ago . I found some under the tests directory but I'm not sure if they are the right ones. By authentication templates I mean login.htm , password_reset.htm , etc. Some of the templates can be found at: http://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/ 回答1: No, it looks for those templates in a "registration" directory within your templates

Django Postgres ArrayField aggregation and filtering

Deadly 提交于 2019-12-13 07:13:30
问题 Following on from this question: Django Postgresql ArrayField aggregation I have an ArrayField of Categories and I would like to retrieve all unique values it has - however the results should be filtered so that only values starting with the supplied string are returned. What's the "most Django" way of doing this? Given an Animal model that looks like this: class Animal(models.Model): # ... categories = ArrayField( models.CharField(max_length=255, blank=True), default=list, ) # ... Then, as

Editing a Django Comment

99封情书 提交于 2019-12-11 20:16:05
问题 I'm attempting to edit an existing comment (i.e. replace old comment with a new one). My comments app is django.contrib.comments. new_comment = form.cleaned_data['comment'] #all of the comments for this particular review comments = Comment.objects.for_model(Review).filter(object_pk=review_id) print comments[0].comment #'old comment' comments[0].comment = new_comment print comments[0].comment #'old comment' is still printed Why is the comment not being updated with the new comment ? Thank you.