python – The view insertemp.views.Insertrecord didn’t return an HttpResponse object. It returned None instead?

views.py
from django.shortcuts import render
from insertemp.models import Empinsert
from django.contrib import messages

def  Insertrecord(request):
    if request.method == 'POST':
        if request.POST.get('empname') and request.POST.get('email') and request.POST.get('country'):
            saverecord=Empinsert()
            saverecord.empname=request.POST.get('empname')
            saverecord.email=request.POST.get('email')
            saverecord.country=request.POST.get('country')
            saverecord.save()
            messages.SUCCESS(request,'your detail saved succeccfullt.......!')
            return render(request,"index.html")
    else:
            return render(request,"index.html")
urls.py
from django.contrib import admin
from django.urls import path
from . import views

urlpatterns = (
    
    path('', views.Insertrecord),

)
models.py
from django.db import models
class Empinsert(models.Model):

    empname=models.CharField(max_length=100)
    email=models.CharField(max_length=100)
    country=models.CharField(max_length=100)
    class meta:
        db_table="newemployeetable1"
settings.py
"""
Django settings for insertemp project.

Generated by 'django-admin startproject' using Django 3.1.7.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'n7#@rb50!g7yh9_aw@eud++4zv4ee9zgxvrbf0my34pxu=avmc'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ()


# Application definition

INSTALLED_APPS = (
    'insertemp',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

MIDDLEWARE = (
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',`enter code here`
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'insertemp.urls'
TEMPLATES = (
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS':(os.path.join(BASE_DIR, 'templates')),
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': (
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ),
        },
    },
)

WSGI_APPLICATION = 'insertemp.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME':'sampledb1',
        'USER':'root', 
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '3306',
        'OPTIONS':{
            'init_command':"SET sql_mode='STRICT_TRANS_TABLES'"
        }
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = (
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
)


# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True




STATIC_URL = '/static/'

sql server – sp_Blitz – RegOpenKeyEx() returned error 2

I’m running the latest sp_Blitz script on a SQL 2016 Std server on a Windows Server 2016 physical box. I’m getting the following error. What could be causing this and how do I troubleshoot it?

RegOpenKeyEx() returned error 2, ‘The system cannot find the file
specified.’ Msg 22001, Level 1, State 1 Warning: Null value is
eliminated by an aggregate or other SET operation. Msg 0, Level 11,
State 0, Line 0 A severe error occurred on the current command. The
results, if any, should be discarded.

The Windows Server Failover Clustering (WSFC) resource control API returned error code 19

What is root cause of this error. I couldn’t find any related information.
There are two nodes on Availability Group and if you reboot second node, database wont up.

dart – Error: A non-null value must be returned since the return type ‘int’ doesn’t allow null. int sum() { ^ Error: Compilation failed

estoy ejercitando con dart y resulta que cuando declaro una variable y le almaceno un objeto de tipo array de enteros para luego aplicar al objeto el metodo reduce este me retorna el siguiente error:

Error: A non-null value must be returned since the return type ‘int’ doesn’t allow null.
int sum() {
^
Error: Compilation failed.

Mi funcion deberia retornar un entero.

int sum() {
List<int> numbers = (1, 5, 8, 10);
numbers.reduce((a, b) => {
  return a + b;
});
}


void main() {
print(sum());
}

mojave – TextEdit can’t save RTF documents on 10.14.6: “The plug-in returned an error”

I wrote an RTF document in TextEdit and I get errors when I try to save.

the error, covering some js code I wrote, formatted via rtf

In fact, I can’t use TextEdit to save in any other format but TXT, all return the same, vague error. I think I pinpointed it to a broken alias in /System/Library/PrivateFrameworks named PDFKit.framework. It doesn’t show the intended path, so I assume it must’ve been corrupted somehow. Am I right to assume this? Is there a way to fix it? Tried googling to no avail.

Why I am getting "undelivered mail returned to sender" for emails that I never sent?

I am getting emails from my postmaster/mailer-deamon saying that the message can not be delivered. When I checked the original message it was sent from some (A) xyz@gmail.com(Tatyana Tanya) to (B) hueei@aol.com/hueei@live.de and it looks like dating spam. Can you tell me why I am getting this mail when it was sent from address A to address B?

windows – Unexpected IP address returned by Get-NetIPAddress

Suppose I have network adapter device2 with static IP 192.168.1.100/24. Get-NetIPAddress shows:

PS C:Windowssystem32> Get-NetIPAddress -InterfaceAlias device2 -AddressFamily IPv4


IPAddress         : 192.168.1.1
InterfaceIndex    : 19
InterfaceAlias    : device2
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Preferred
ValidLifetime     : Infinite ((TimeSpan)::MaxValue)
PreferredLifetime : Infinite ((TimeSpan)::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

Now I remove this address:

PS C:Windowssystem32> Remove-NetIPAddress -InterfaceIndex 19 -Confirm:$false
PS C:Windowssystem32> Remove-NetIPAddress -InterfaceIndex 19 -Confirm:$false
Remove-NetIPAddress : No MSFT_NetIPAddress objects found with property 'InterfaceIndex' equal to '19'.  Verify the value of the property and retry.

So, IP address list should be empty, which I can see in the Windows Properties dialog (device2 Properties, TCP/IPv4). Now Get-NetIPAddress shows:

PS C:Windowssystem32> Get-NetIPAddress -InterfaceAlias device2 -AddressFamily IPv4


IPAddress         : 169.254.149.125
InterfaceIndex    : 19
InterfaceAlias    : device2
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 16
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Preferred
ValidLifetime     : Infinite ((TimeSpan)::MaxValue)
PreferredLifetime : Infinite ((TimeSpan)::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

Such “fake” IP address sometimes appears in the Get-NetIPAddress output, when NIC is disconnected, in addition to real IP address of the NIC. So, in such case, Get-NetIPAddress may show, for example, two addresses: 192.168.1.1 and 169.254.149.125. This case is not 100% reproduced.

What does this unexpected IP address mean? Running PowerShell query from my program, I want to ignore it, to have the same results, as Windows IPv4 Properties dialog. May I filter it off by PrefixOrigin and SuffixOrigin values? In my tests, they are always equal to Manual for “real” IP address, and WellKnown and Link for “fake” IP address.

typescript – The data returned from a result is repeated several times – ReactJS

The getCourseAndModuleInfo function, returns some data from the database and stores it in states.

For some reason all the information is being repeated several times, as an example I used the course_id.

I realized that it has to do with the queries I make in the API and also with useEffect, however, I did not understand why this is happening.

import React, { useState, useCallback, useEffect } from 'react';
import api from '../../services/api';

interface CourseInfo {
  course_id: string;
  module_id: string;
}

interface HeaderInfoProps {
  course_info: CourseInfo;
}

const HeaderInfo: React.FC<HeaderInfoProps> = course_info => {
  const (isLoadingCourseName, setIsLoadingCourseName) = useState(false);
  const (isLoadingModuleName, setIsLoadingModuleName) = useState(false);
  const (courseName, setCourseName) = useState({ name: '' });
  const (moduleName, setModuleName) = useState({ name: '' });

  const { course_id, module_id } = course_info.course_info;

  // This is repeating several times
  console.log(course_id);

  const getCourseAndModuleInfo = useCallback(async () => {
    try {
      setIsLoadingCourseName(true);
      setIsLoadingModuleName(true);
      await api.get(`/course_name/${course_id}`).then(response => {
        const course_name = response.data;
        setCourseName(course_name);
      });

      await api.get(`/module_name/${module_id}`).then(response => {
        const module_name = response.data;
        setModuleName(module_name);
      });
      setIsLoadingCourseName(false);
      setIsLoadingModuleName(false);
    } catch (err) {
      console.log(err);
    }
  }, (course_id, module_id));

  useEffect(() => {
    getCourseAndModuleInfo();
  }, (getCourseAndModuleInfo));

  return (
    ...
  );
};

export default HeaderInfo;

development – The remote server returned an error (401) unauthorized

I have install a fresh version of SharePoint 2019 which is on domain A,then i added a second computer to A which will be hosting websites on IIS.

I have created a console application just for testing connection to SharePoint on the second computer using the code below and am getting unauthorized access.Is there anything wrong with the code below?. Note the credentials are correct.

        System.Net.NetworkCredential cred = new System.Net.NetworkCredential(@"DoaminNAmeadministrator","Password");

        using (ClientContext clientContext = new ClientContext("http://10.1.1.1/sharepoint2019/sites/test/"))
        {
            clientContext.AuthenticationMode = ClientAuthenticationMode.Default;

            clientContext.Credentials = cred;

            Microsoft.SharePoint.Client.ClientResult<System.IO.Stream> stream = null;

            KeywordQuery keywordQuery = new KeywordQuery(clientContext);

            keywordQuery.QueryText = "SharePoint";

            keywordQuery.EnablePhonetic = true;

            keywordQuery.EnableOrderingHitHighlightedProperty = true;
            //keywordQuery.SummaryLength = 500;


            SearchExecutor searchExecutor = new SearchExecutor(clientContext);

            ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);

            clientContext.ExecuteQuery();

9 – How can I display the values returned from an external API under a form?

I have created a custom module that pulls in data from an external API. Users select a few values on a form; submitting the form makes a call to the external API. The module then display the data, which has been filtered by the values entered from users.

I have been able to show the returned data with Drupal::messenger()->addMessage(), but this doesn’t seem the right method. I’ve found a few other suggestions, but I can’t get any of them to work. They are for older Drupal versions.

I’d like to be able to display the formatted results under the form, on the same page.

How can I achieve this in Drupal 9?