django-apps

Check admin login on my django app

偶尔善良 提交于 2021-02-11 18:06:49
问题 I have created a django app and have linked to the admin index page by modifying base.html. However, the link of the app is accessible directly as well. Can I check on the page or in the views.py of my app if the user is logged in to the django admin or not? 回答1: Use the @staff_member_required decorator: from django.contrib.admin.views.decorators import staff_member_required @staff_member_required def my_view(request): ... 回答2: from django.contrib.auth.decorators import user_passes_test @user

Check admin login on my django app

时光毁灭记忆、已成空白 提交于 2021-02-11 18:04:09
问题 I have created a django app and have linked to the admin index page by modifying base.html. However, the link of the app is accessible directly as well. Can I check on the page or in the views.py of my app if the user is logged in to the django admin or not? 回答1: Use the @staff_member_required decorator: from django.contrib.admin.views.decorators import staff_member_required @staff_member_required def my_view(request): ... 回答2: from django.contrib.auth.decorators import user_passes_test @user

Getting an error when integrated django-private-chat in the django project? [closed]

假装没事ソ 提交于 2020-03-04 21:35:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last month . I am working on an application where I want to implement the django-private-chat in for one to one messaging feature after I did everything which is said in the documentation I ran the server and got to the link http://127.0.0.1:8000/dialogs/ I am getting this error please help me out I have included the error

Getting errors while trying to integrate django-private-chat in my application?

假如想象 提交于 2020-01-30 10:56:49
问题 I am working on an application where I want to implement the django-private-chat in for one to one messaging feature after I did everything which is said in the documentation I ran the server and got to the link http://127.0.0.1:8000/dialogs/ I am getting the blank page and when I see in console I am seeing this javascript error please help me out I have included the error traceback also My dialogs.html: {% extends "django_private_chat/base.html" %} {% load static %} {% load i18n %} {% block

How register Flask Blueprints from config like apps in Django?

和自甴很熟 提交于 2020-01-13 19:05:07
问题 How I can register Flask Blueprints from my config like apps in Django? I would like to define Blueprints in the configuration file, which will be automatically registered #config.py BLUEPRINTS = ( 'news', 'files', ) 回答1: I actually have been sketching out something like that in a project tentatively named Hip Pocket. It's basically the same answer as @HighCat has given you, except it uses Python's packaging system rather than a config.py file (although it could be extended to autoload from a

How can I run a local Django site with a separate app folder?

谁说我不能喝 提交于 2020-01-06 06:53:38
问题 I'm developing a new Django site. It uses some existing Django apps and I'm building some of my own. Current folder structure (truncated): projects/ - mysite/ - .git/ - conf/ - mysite/ - __init__.py - settings.py - myapp/ - __init__.py - admin.py - models.py - manage.py I'd like to make my site and apps available as separate Git repositories. In other words, someone may want to clone/contribute to the whole site, or they may want to clone/contribute to just an app. According to the Packaging

Django using model of one app into other app's model

此生再无相见时 提交于 2020-01-05 07:39:11
问题 Salam and hi, I am using django and breaking two parts of project in two apps. However there is a reference field of one table as foreign key of other in terms of db. So how can I use one app's model primary key as foreign key of another app's model? And if is not possible then should I just make single app of all such apps. I am actually thinking apps as different modules/components of project, may be I will be adding some apps in future. thanks 回答1: Either import the model from the other

Django - using different apps together in a project

怎甘沉沦 提交于 2020-01-05 06:52:16
问题 In the basic Django tutorials and documentations I have found so far, apps are treated as some standalone parts of the project. I haven't yet found, though, solutions of using them together in a complex project. We can sign up at some url domain/signup , and it is handled by users.views.signup . For a GET request signup renders signup.html . For a POST request, after evaluating the posted data, it either renders signup.html with some message or registers a new user, logs him/her in and

How to use django-subscription to create live notifications

自作多情 提交于 2019-12-25 02:13:37
问题 I have been working on this for some time now, and would like to create facebook-like notification system. My project has following features It has a blog interface where users can write their blogs, and people can post comments on it. I want to send notification to the author whenever somebody comments on it. Users can post their questions, just like on stackoverflow and whenever somebody answers the question I want to inform the user which posted it. Users can mark certain blogs/questions

Cannot import models from another app in Django

人走茶凉 提交于 2019-12-20 18:03:10
问题 so I have 2 apps running in the same project. My files are structured as follows: /project_codebase /project __init.py settings.py urls.py wsgi.py ... /app1 ... /app2 ... manage.py So, I for some weird reason have a different name for my base directory (that is, it ends with codebase). Hopefully, that is not an issue. In my settings.py , I have this: INSTALLED_APPS = [ ... 'app1', 'app2', ] Ok, so in my models.py (from app2) , I can easily import models from app1 with from app1.models import