1

I have an education website and a blog to it, the website is in php language, but the blog was written in django. i need to make the blog use the users information from the php .sql database, so the user should not need to register in the blog. I am using sqllite in the blog. here is the .sql file.

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `ID` int(11) NOT NULL,
  `username` varchar(25) NOT NULL,
  `fullname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `birth` date NOT NULL,
  `gender` varchar(22) NOT NULL,
  `role` varchar(22) NOT NULL DEFAULT 'Student',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`ID`, `username`, `fullname`, `email`, `password`, `birth`, `gender`, `role`, `created_at`) VALUES
(1, 'ahmedsobh', 'Ahmed Sobh', '[email protected]', '123123', '1995-03-25', 'Male', 'Doc', '2017-06-19 14:41:45'),
(2, 'koko', 'Kareem Sobh', 'koko@ay', '1212', '1212-12-12', 'Male', 'Student', '2017-06-19 14:41:45');
--
-- Indexes for dumped tables
--
--
--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`ID`),
  ADD UNIQUE KEY `username` (`username`);

--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

so how to edite the settings file to be able to read the table users in this .sql file so that any user in the table can just login in the blog without registration.

Here is the settings for the sqlite of the blog:

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }

Password validation

https://docs.djangoproject.com/en/1.10/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', }, ]

4
  • as i know about Django, you can create new database base on it but (you have to create model to access to data ~> conflict) So i suggest that you can: Create models and data struct... and use SQL code to insert data later on Commented Jun 28, 2017 at 4:39
  • @NamNguyễn no there is no model in my blog for login. the login is handled by a ready function. Commented Jun 28, 2017 at 6:50
  • Maybe like this : stackoverflow.com/questions/25697337/… Commented Jun 28, 2017 at 8:05
  • @mbieren i did not work. there error was that could not import Post module. Commented Jun 28, 2017 at 23:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.