django-1.8

Auto register Django auth models using custom admin site

允我心安 提交于 2019-12-03 01:43:36
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 would like to see all the other apps models in this new custom site including the auth's users and

Django app works fine, but getting a TEMPLATE_* warning message

不问归期 提交于 2019-12-02 19:58:05
When I use runserver, it gives this warning message: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG. Quoth the Django Documentation: "TEMPLATE_DEBUG Deprecated since version 1.8: Set the 'debug' option in the OPTIONS of a DjangoTemplates backend instead." Here is my settings.py with my futile attempts to fix it: DEBUG = True TEMPLATE_DEBUG = DEBUG TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates

auth_user error with Django 1.8 and syncdb / migrate

佐手、 提交于 2019-12-02 17:24:49
When upgrading to Django 1.8 (with zc.buildout) and running syncdb or migrate, I get this message: django.db.utils.ProgrammingError: relation "auth_user" does not exist One of my models contains django.contrib.auth.models.User: user = models.ForeignKey( User, related_name='%(app_label)s_%(class)s_user', blank=True, null=True, editable=False ) Downgrading to Django 1.7 removes the error. Do I have to include the User object differently in Django 1.8? I fix this by running auth first, then the rest of my migrations: python manage.py migrate auth python manage.py migrate On my environment, I fix

Not able to create super user with Django manage.py

馋奶兔 提交于 2019-12-02 15:49:46
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 Django If you run $ python manage.py createsuperuser Superuser creation skipped due to not running in a TTY

Disable choice list in Django admin, only for editing

吃可爱长大的小学妹 提交于 2019-12-02 09:51:38
I want to disable some fields when I am editing an object. I have managed to do this for text fields, but it's been impossible for a dropdown list (choice list). I am doing this action in the constructor of the form. class OrderModelForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(forms.ModelForm, self).__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance and instance.pk: self.fields['description'].widget.attrs['readonly'] = True self.fields['city_code'].widget.attrs['disabled'] = True Notice how I made it for both with different keywords , but I

Why Python requests library failing to get response?

北城余情 提交于 2019-12-02 05:26:42
问题 I have a view method: # This view method is to register a new user through api call def register(request): if request.method == 'GET': registrationForm = RegistrationForm(request.GET) if registrationForm.is_valid(): r = requests.get('http://localhost:8000/api/create-user/', timeout=10) print r.content return HttpResponseRedirect('/') else: registrationForm = RegistrationForm() return render(request, 'frontend/index.html', {'registrationForm': registrationForm}) Here in the above mentioned

Why Python requests library failing to get response?

安稳与你 提交于 2019-12-01 23:51:40
I have a view method: # This view method is to register a new user through api call def register(request): if request.method == 'GET': registrationForm = RegistrationForm(request.GET) if registrationForm.is_valid(): r = requests.get('http://localhost:8000/api/create-user/', timeout=10) print r.content return HttpResponseRedirect('/') else: registrationForm = RegistrationForm() return render(request, 'frontend/index.html', {'registrationForm': registrationForm}) Here in the above mentioned view method, the requests library just keeps on loading and just doesnt get the response and ultimately

Django 1.8 test issue: ProgrammingError: relation “auth_user” does not exist

狂风中的少年 提交于 2019-12-01 20:57:30
问题 I recently upgraded Django to 1.8 and set up a new development database for a fresh start. Migrations and dependencies went well, safe the usual errors you get and you end up solving. The app is working locally now just fine. However, I am getting an error when trying to run tests: python manage.py test This is the error I am getting: django.db.utils.ProgrammingError: relation "auth_user" does not exist Needless to say, Django's auth module is indeed installed and migrated in the app, so I am

Django 1.8 test issue: ProgrammingError: relation “auth_user” does not exist

旧巷老猫 提交于 2019-12-01 20:50:50
I recently upgraded Django to 1.8 and set up a new development database for a fresh start. Migrations and dependencies went well, safe the usual errors you get and you end up solving. The app is working locally now just fine. However, I am getting an error when trying to run tests: python manage.py test This is the error I am getting: django.db.utils.ProgrammingError: relation "auth_user" does not exist Needless to say, Django's auth module is indeed installed and migrated in the app, so I am not sure what is going on. Here is the full stacktrace in case you need to peek at it, but it does't

Django AttributeError 'tuple' object has no attribute 'regex'

风格不统一 提交于 2019-11-30 00:46:04
问题 I'm using django 1.8 and having trouble with it. I am trying to import tinymce in my project. When I render it caught AttributeError: tuple' object has no attribute 'regex' When I remove the url in url.py it is working. Here is my codes. url.py from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ # Examples: # url(r'^$', 'hizlinot.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), (r'^tinymce/',