I am learning Django through Django official documentation on Cloud Studio,which can let people develop website online.However,a CSRF issue occurred when I tried to log in the Admin page Django carried originally.I didn't change anything in admin.py
enter image description here
enter image description here
Related
after I deployed my django app to cpanel it doesn't save pictures that I upload it from django adminstration page
Not: all data I enter it's save it and can return it to template but pictures not upload them
How I can solve this problem?
I think, in models you should use,
your_variable_name = models.ImageField(upload_to='photos/%Y/%m/%d', blank=True)
and if this solution doesn't work, try posting your code here.
I'm new to Django and I'm trying to learn it from Django for Professionals by William Vincent. After installing django-allauth and following the steps in the book, I managed to get the logging in and out the sign up functionality to work. However, when I go to 127.0.0.1:8000/admin, I don't see a Sites section. This section is later used in the book to change the site being referred to (example.com) in the registration confirmation email.
I've searched for django-allauth Site admin in here and in the docs but I couldn't find anything about making the Sites section show.
I suggest using the official docs
It should look probably something like -
admin.py
from django-allauth.models import Site
from django.contrib import admin
class DjangoAllAuthSiteAdmin(admin.ModelAdmin):
pass
admin.site.register(Site, DjangoAllAuthSiteAdmin)
I was able to solve this problem by adding 'django.contrib.sites' to the INSALLED_APPS list within settings.py.
I am a noob in Django and I am about to deploy my first site in Django. I have a Profile model in my models.py file which has profile_pic attribute which will store the profile pic of the user. It is working well when upload the image in the development mode,ie, when DEBUG=True. But what changes do I have to make in the urls.py so that users can easily upload their profile picture even after deploying my site. Any code snippetor examples or some link would be very helpful.
Following online tutorial, I create a very simple django blog. It seems all right, but after I log into 127.0.0.1:8000/admin/ , I can't find the place to add posts.
My django blog interface(I don't have enough reputation to add picture):
Django administration
Welcome,xxx change password / log out
Site administration
Authentication and Authorization
Groups Add Change
Users Add Change
Recent Actions
My Actions
None available.
Does anyone know why my administration interface don't have "add post"??? thanks in advance!! :)
I use:
Django 1.7
Operation: win 7 32
Seems like you haven't registered your posts model in the Django admin
https://docs.djangoproject.com/en/dev/intro/tutorial02/#make-the-poll-app-modifiable-in-the-admin
or your posts app isn't installed in your settings.py
https://docs.djangoproject.com/en/dev/intro/tutorial01/#activating-models
And the sites framework is no longer activated by default since Django 1.6
add admin.autodiscover() at urls.py. details here: https://docs.djangoproject.com/en/dev/ref/contrib/admin/
I am trying to work with django-allauth. I followed the instructions at github page and done following:
Added allauth urls into urls.py
urlpatterns += patterns ('',
url('^accounts/', include('allauth.urls')),
url('^accounts/profile/$', ProfileView.as_view(), name='ProfileView'),
url('^login/$', login, name='account_login'),
url('^logout/$', logout, name='account_logout'),
url('^login/cancelled/$', login_cancelled, name='socialaccount_login_cancelled'),
url('^login/error/$', login_error, name='socialaccount_login_error'),
)
Updated TEMPLATE_CONTEXT_DIRS, TEMPLATE_CONTEXT_PROCESSORS, AUTHENTICATION_BACKENDS and INSTALLED_APPS. Also added ACCOUNT_AUTHENTICATION_METHOD = "username_email"
Added Key and Secret for twitter in the Social apps table.
Copied django-allauth templates to my app's directory and modified it. I can see all the templates working fine like /accounts/signup/ and /accounts/social/connections/.
Now, from connections or signup when I click Twitter link /accounts/twitter/login/ I ended up with the following error:
Social Network Login Failure
An error occured while attempting to login via your social network
account.
Am I missing something? May be some stupid mistake (Twitter login url? No clues!). I also tried to find some tutorials based on the latest codebase but unable to find any. django-allauth example on github wasn't of any help. Please help. Also, please feel free to provide me any links or tutorials based on the latest codebase.
Thanks in advance.
I am a beginner so you can expect some stupid mistakes from people like me but I try to learn. I spent many hours trying to resolve this. Finally the issue turns out to be Twitter App Key Settings:
I get "Social Network Login Failure" error because my Twitter App settings are not configured for the localhost. Make sure you have the following settings configured in your Twitter App for your localhost (development machine):
Callback URL: http://127.0.0.1:8000/
NOTE: If you want to use it for production server then you need to set Callback to your domain name as follows:
Callback URL: http://Your_Domain_Name.com
OR better use another set of Keys specifically for production use only.
BONUS : If you are using django-social-auth and you don't have these settings configured then you may end up with 401 Unauthorized error.