As I'm new to Django so I'm going to ask a stupid question on how to use Django features of session , cookies without using default django admin , I mean deleting it and creating everything new.
Any help or suggestion will be appreciated!
Well in Django the admin panel is very customizable you can just read the documents about how to customize your Admin panel. you just need to import CustomUsers in the models
here is the link. And admin panel of Django is great so it is always recommendable but if you still don't want it then just remove in from the main URL.py
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('mainprocess.urls')),
]
just remove the admin path and add your self-made path.
Django admin is just a tool which is not required for any other features by any mean.
So you just need to search about topics you said you want to have in youtube and find videos about it and learn!
my suggestion is to not learn anything related to html and templates and forms in django because it will not be used in your job in company in feature and focusing on creating API and Authentication and writing models on django
Related
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 have a Django app that will serve diferent websites.
Each one will have it´s own domain
Each one will have it´s own sub app with templates and views
They all share the same backend, models and data
My aproach
As I already have the database with the segmentation info I need to show the desired products in each site and I will have different views for each sub app, I don´t need to add another field in the models.
I think that it would be easier just to detect the request domain in my main app urls.py and rout home url to the desired sub app.
Something like:
# urls.py
if "name1" in request.domain:
urlpatterns += [path('', include('app1.urls'))]
if "name2" in request.domain:
urlpatterns += [path('', include('app2.urls'))]
else:
urlpatterns += [path('', include('app3.urls'))]
Maybe I should make a middleware and set a global variable I can access in urls.py? Can I use this kind of if statements in urls.py?
Django sites
I checked the Django Sites Framework, but if I understand ir well, it´s more focused in segmenting the database in the models, not the templates and views. In any case I don´t really catch how the Sites framework detects the incomming URL and roots the request to each sub app.
Other intents
I searched for more info and this article can brief the different articles about the issue I found.
https://medium.com/crowdbotics/how-to-use-dynamic-subdomains-in-django-dc1cb2cac00b
But still I don´t get how can I achieve what I need. Sounds very logical just to use my aproach and don´t mess with my database. If it´s possible.
Any clues welcome. Thanks in advance!
I have a wagtail project being developed, essentially a blog with a forum. I chose django-machina as the forum I want to use because of how modular it is and how well it integrates into existing projects.
I followed the instructions in the documentation without issue, and the install was a success. I can access the app by going to /forum on my project.
However, the next step in the documentation refers to using the forum admin panel. My wagtail admin menu does not have a section for forum and I can't access the django admin panel as it is a wagtail project.
Where exactly can I access the django-machina forum admin panel in a wagtail project? Or would I have to recreate it somehow?
Jake, it's not so difficult. Let your project be named 'my_project'. So than we should go to my_project/my_project/urls.py. There we see something like this:
url(r'^django-admin/', admin.site.urls),
And what this string say to us? It show how to get the vanilla django-admin! Ok, now just go to your.site/django-admin and run your forum! ;)
Unless the documentation specifically mentions Wagtail, it's more likely that the admin panel shows up in the Django admin backend rather than the Wagtail one. On a standard Wagtail project this is found at the URL /django-admin/, but it depends on what you have specified in your project's urls.py file.
I would like to embed front end views in my django admin site at any possible specified locale, maybe in a class or site admin dashboard;anywhere I feel is the best option.. Tried out a few git projects but seems they are not compatible with current django versions..any one offering any idea?!
The Django Admin site is intentionally a separate site, with its own views.
In any app you can make functions that compute various values; but the Admin for that app will need to define its own views, using whatever functions you like.
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/