之前做过一些Django 的模块开发,毕设会从头去做一个后端,所以记录一下最开始构建的坑
- 数据库连接
当你正常创建一个项目(即startproject
),那么wsgi.py 中将会把配置文件指向settings,讲其中的DATABASES
替换为你的配置,如果是mysql或者MariaDB,配置应该像下面这样
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'database',
'USER': 'root',
'PASSWORD': 'xxxxxx',
'HOST': 'xxx.xxx.xx.x',
'PORT': '3306',
},
}
如果是mysql或者MariaDB,这之后需要继续安装驱动mysqlclient ,如果是windows用户,出现了 无法打开包括文件: “mysql.h”
类似的问题,可以下载https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient 进行手动安装(pip install 文件名 即可)
如果是其他的数据库,参考https://docs.djangoproject.com/zh-hans/4.1/ref/databases
- 简易的登录
Django 自带一个用户验证系统。默认情况下已经安装,并在配置完数据库后第一次migrate后生成相关的数据库表。
如何使用?主要参考
使用 Django 的验证系统 | Django 文档 | Django (djangoproject.com)
- 前后端分离的登录
很显然上述的方法很难实现前后端分离,我们需要一些别的方案
Django在做前后端分离开发的时候有一个特别强大的第三方包Django REST framework
,用于构建Web API
再加上djangorestframework-jwt插件,就可以使用了
参考
django-rest-framework-jwt的使用 – Maple_feng – 博客园 (cnblogs.com)
这之后,通过View的子类APIView调用,并设置authentication_classes即可,全局见下文
- 层级关系
又上我们得到了一个简单的登录系统,可能由于用户表等原因,已经建立了一个相关的app,django的关系可以由简单的app概括
通过命令建立app(django startapp
),并在主目录将url.py引导过来即可
注意,此时该app的模型表并没有同步,需要makemigrations和migrate
migrate默认是所有的app,如果没有,可以通过后面指定app来应用修改
python manage.py makemigrations [appname]
python manage.py migrate [appname]
如果存在一个层级关系,例如在index路径下面的xxx路径需要到index的子app
合理的作法是
from django.urls import path
from django.conf.urls import url, include
from rest_framework_jwt.views import obtain_jwt_token
urlpatterns = [
url(r'^login/', obtain_jwt_token),
url(r'^', include('index.urls')),
]
django的include会引导这个app
此时再在index的urls.py中建立相关的引导即可
from django.urls import path
from . import views
urlpatterns = [
path('index/', views.Index.as_view(), name='index'),
url(r'^index/xxx/', include('index.xxx.urls')) #嵌套
]
- 全局的认证设置
根据第三节的教程,我们需要在每个view中设置认证,一个更好的解决方案是进行全局的设置,在setting.py中:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES':(
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
"rest_framework_jwt.authentication.JSONWebTokenAuthentication",
"index.jwtMiddleware.TokenAuth"
)
}
将需要的认证类”index.jwtMiddleware.TokenAuth”添加到下面即可
- 认证类的用户信息
根据之前的教程我们创建了认证类,对于request.user的返回教程没有做,添加user和token的返回即可
完整的文件如下:
from rest_framework.exceptions import AuthenticationFailed
from rest_framework_jwt.serializers import VerifyJSONWebTokenSerializer
class TokenAuth:
def authenticate(self, request):
token = {"token": request.META.get('HTTP_TOKEN')}
# print(request.META.get("HTTP_TOKEN"))
valid_data = VerifyJSONWebTokenSerializer().validate(token)
print(valid_data)
user = valid_data['user']
print(user)
if user:
return user, token
else:
raise AuthenticationFailed('认证失败')
评论
eNvOPHVXS
Vous l’aurez compris, surveiller votre taux de testostérone est absolument primordial.
Sans elle, chez les femmes comme chez les hommes, vos entraînements n’auront aucune efficacité.
Au-delà de votre construction musculaire, la testostérone vous
aidera à vous sentir mieux dans votre corps et dans votre esprit.
Seulement, une bonne hygiène de vie n’est pas toujours suffisant
pour réaliser pleinement vos objectifs.
Seul un professionnel de la santé qualifié peut évaluer votre situation physique, votre historique
médical et vos besoins spécifiques afin de vous
fournir des conseils sûrs et adaptés. En suivant leurs recommandations et en respectant les lois en vigueur, vous maximiserez vos probabilities de progresser en toute sécurité dans votre
pratique sportive. Corriger un déficit en testostérone implique une évaluation hormonale complète through une prise de sang.
L’auto-diagnostic, souvent motivé par une perte d’énergie ou un inconfort
sexuel, ne suffit pas à initier un traitement hormonal.
Si vous envisagez d’acheter de la testostérone, il est fortement recommandé de consulter
un professionnel de la santé, tel qu’un endocrinologue,
qui pourra évaluer vos besoins et vous prescrire un traitement approprié.
Il est essentiel de privilégier des moyens légaux et sécurisés pour acheter des hormones et de ne pas compromettre votre santé pour des résultats à court terme.
Opter pour un produit sans ordonnance à base
de testostérone vous permet d’avoir rapidement à disposition une resolution afin d’entamer votre programme de musculation plus rapidement.
D’autre part, la supplémentation en zinc était liée à l’augmentation de la
testostérone, ce qui a conduit à la conclusion que ce minéral joue un rôle essentiel dans la production de l’hormone.
Il est donc essentiel de privilégier des moyens légaux et sûrs pour maximiser
les résultats en musculation et en sport.
Cela implique de suivre des programmes d’entraînement spécifiques,
de maintenir une alimentation équilibrée et de se tourner vers des compléments alimentaires
légalement disponibles sur le marché. Ces compléments peuvent être bénéfiques pour la performance sportive
sans nuire à la santé. Même si cela n’est pas recommandé, il reste attainable d’acheter de la testostérone en magasin. Il est préférable de
bien se renseigner et de consulter un médecin avant de procéder à un acheter de testostérone.
La testostérone en vente libre sous forme de complément alimentaire est disponible dans de
nombreux magasins spécialisés de fitness et de sport ainsi que dans des grandes surfaces telles que Carrefour ou Auchan.
La testostérone est reconnue comme un puissant stéroïde
anabolisant, efficace pour favoriser la prise de masse et la
définition musculaire lorsqu’elle est associée à un programme d’entraînement
adapté. Consultez un professionnel de la santé pour obtenir des conseils
et des recommandations personnalisés, et restez concentré sur des strategies d’entraînement
naturelles et sûres pour atteindre vos objectifs. En résumé, acheter de
la testostérone en pharmacie sans ordonnance est illégal en France, sauf lorsqu’il s’agit de compléments sans hormone lively.
Toute démarche médicale doit passer par une consultation et un diagnostic de santé
précis. Lorsque l’on est sportif et/ou que l’on pratique la
musculation, on peut avoir besoin de recourir à certains
compléments alimentaires, comme la whey ou les BCAA.
Ces plateformes sont souvent recommandées par des experts et disposent de
nombreuses évaluations positives. Réponses aux questions
les plus fréquentes sur l’achat de testostérone en ligne, pour
vous aider à naviguer en toute sécurité et avec confiance.
Par exemple, Androtardyl est un produit couramment utilisé avec des effets prouvés.
Les témoignages d’utilisateurs indiquent une satisfaction élevée, en particulier
pour ceux souffrant d’hypogonadisme. Les consommateurs rapportent une
amélioration de la libido, de l’humeur et de la masse
musculaire. On n’a pas seulement des médicaments, mais aussi des
choix alimentaires et de vie qui aident.
Le site Dokteronline me permet d’obtenir simplement et rapidement des solutions
de santé. La régularité de la réponse au quotidien m’a permis de développer
une confiance nécessaire. Certains soupçonnent l’usage illégitime de testostérone chez des athlètes.
Cependant, il faut savoir qu’elle peut être responsable de plusieurs
troubles et présenter un danger pour la santé. Nous conseillons davantage
la prise d’un produit afin de stimuler le corps et l’inciter à fabriquer plus de testostérone naturellement.
TestoPrime apparait comme une évidence pour favoriser la focus de cette hormone.
Il permettra ainsi de gagner en muscles, de retrouver un corps plein de vie,
de brûler la graisse, d’augmenter la confiance en soi et
d’avoir une activité sexuelle plus épanouie.
Les prix peuvent paraitre élevés mais le service est de grande qualité et cela
se paie. Contactez votre médecin si vous ressentez des effets indésirables graves ou persistants.
Pour commencer un traitement, il faut remplir certains critères cliniques
et biologiques.
Conversely, BPC157’s prowess in gastrointestinal health and wound healing offers a broader spectrum of potential advantages. In animal research, TB500 has shown the ability to stimulate the regeneration of damaged cardiac muscle, a phenomenon critical within the recovery from heart-related issues. By enhancing blood move to muscles, TB500 promotes the efficient delivery of nutrients and oxygen, essential for muscle restore and progress.
It’s nonetheless in the early levels of analysis, with much of the proof coming from animal research. It’s also essential to mention that BPC 157 isn’t presently accredited by the FDA for any medical use, including most cancers prevention or treatment. While the peptide exhibits promise, it stays outdoors of approved medical protocols, that means its use continues to be experimental. It’s essential to method this peptide with an understanding of each its potential advantages and challenges. The secret is discovering the best stability, utilizing BPC 157 to help recovery without encouraging tumor development. As with any analysis chemical, it’s your responsibility to weigh the potential benefits in opposition to the unknown dangers. When in doubt, seek the assistance of a licensed medical supplier who is educated in peptide-based therapies.
Payment processing makes use of established and safe fee techniques together with main credit cards, PayPal, or other recognized monetary service suppliers. These payment methods typically provide fraud safety and dispute decision mechanisms for consumer protection. When inspecting the differences between TB-500 and BPC-157, it is imperative to investigate their structural variances and the resultant influence on their particular person talents to facilitate healing in muscle and joint accidents. These small molecules play a vital role in regulating the body’s defense mechanisms in opposition to pathogens and infections. So, if you’re interested by which peptide could be greatest for your wants, keep studying to study more concerning the battle of the healing peptides.
Before figuring out the advantages, let’s introduce BPC157 and TB500’s distinctive properties. This video is a follow-up to my latest dialogue on the peptides BPC-157 and TB-500, where I coated what they are, how they work, and what they could be helpful for. If you haven’t watched that video yet—which I extremely recommend—you can discover it [HERE]. Please notice that all merchandise featured on this website are intended completely for research and growth functions. It is considered an experimental peptide and is marketed as a research chemical.
Correct dosage administration of BPC-157 and TB-500 nasal spray holds vital significance, as inaccuracies in dosing can result in suboptimal outcomes or potential side effects. Patients are suggested to strictly adhere to the dosage guidelines outlined by their healthcare provider to make sure the specified therapeutic effects are achieved. The mechanism of motion of BPC-157 and TB-500 includes the promotion of cell migration, angiogenesis, and the manifestation of anti-inflammatory effects. BPC-157 is a synthetic peptide derivative of a protein found in human gastric juice, known as Physique Safety Compound (BPC).
When studied collectively in vitro, TB-500 and BPC-157 have been observed to overlap in some practical areas and complementary actions. Both peptides have the potential to contribute to the creation of a more permissive milieu via attenuation of pro-inflammatory signaling. Researchers have posited that exposure to TB-500 could facilitate mobile motility and structural group in research fashions. TB-500 is a lab-engineered peptide modeled after Thymosin Beta-4, a naturally occurring protein within the physique. It is widely regarded for its capacity to advertise cell migration and regeneration.
BPC157 operates by promoting angiogenesis, encouraging the formation of recent blood vessels, and stimulating cell migration to injured areas. By enhancing blood circulate and fostering tissue regeneration, BPC-157 could contribute to accelerated therapeutic processes. These findings highlight the potential of peptide blends in revolutionizing the sphere of wound healing and tissue regeneration. Its application extends past physical injuries, as TB-500 has demonstrated promising results in treating circumstances like chronic fatigue syndrome and muscle tears. Medical studies have highlighted the effectiveness of TB-500 in enhancing muscle growth and enhancing endurance.
We will delve into the mechanisms of motion, scientific studies, and potential advantages of using TB500 nasal spray. Originally derived from gastric proteins, BPC‑157 has strong gastroprotective effects, aiding within the restore of the intestinal lining, lowering irritation within the intestine, and accelerating the healing of ulcers. Following step-by-step injection instructions for TB500 ensures dosage accuracy, injection safety, and optimum well being outcomes for users. Before administering TB500, ensure all essential supplies are prepared, together with the vial, syringe, alcohol swab, and sharps disposal container.
Customers frequently highlight faster recovery, reduced inflammation, and improved general well-being. Neurological studies suggest that BPC-157 may shield neurons from oxidative stress and trauma, doubtlessly offering benefits for neurodegenerative ailments. In The Meantime, organ safety has also been documented; in animal models, the peptide lowered liver and kidney harm caused by toxins and drugs overuse.
References:
https://neurotrauma.world/tb-500-peptide-injections-benefits-dosage-and-risks