Skip to main content

Blog #12

Its 6:50PM in the evening. I started Django yesterday, and as expected problem arrived while I'm in PowerShell for preparing Django. However, I solved it using commands like pip install Django & pip install Django --upgrade(tutorial by code with harry youtube videos), and after that error occurred: pip is not recognized and I again download python from its official website and the error was solved hopefully.
After that, I created a folder djangoproject and go to vs code terminal and run a command "django-admin startproject <newfoldername>",  but showed me "django-admin startproject hello django-admin : the term 'django-admin' is not recognized as the name of a cmdlet function script file or operable program. check the spelling of the name or if a path was included verify that the path is correct and try again."  
Reason of this error is because of the file path/directory in Powershell. Its needs to change. 
So my first approach was to go to admin powershell from  window option + right-click and PowerShell shows "PS C:\WINDOWS\system32>" and I copy the file path of djangoproject folder and paste it in admin powershell like this "PS C:\WINDOWS\system32>cd C:\Users\Shubrajit Acharjee\djangoproject" and it shows an error like this:

Set-Location : A positional parameter cannot be found that accepts argument 'Acharjee\djangoproject'.
At line:1 char:1
+ cd \C:\Users\Shubrajit Acharjee\djangoproject
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Location], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

after some changes and help of StackOverflow I got this:
cd "\C:\Users\Shubrajit Acharjee\djangoproject"
cd : Cannot find drive. A drive with the name '\C' does not exist.
At line:1 char:1
+ cd "\C:\Users\Shubrajit Acharjee\djangoproject"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (\C:String) [Set-Location], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
"if any space is there in your directory path do not forget to add double inverted commas " by stack overflow.
after that again some changes in file path I got this:
 cd ":\Users\Shubrajit Acharjee\djangoproject"
cd : Cannot find path 'C:\WINDOWS\system32\:\Users\Shubrajit Acharjee\djangoproject' because it does not exist.
At line:1 char:1
+ cd ":\Users\Shubrajit Acharjee\djangoproject"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\WINDOWS\syst...e\djangoproject:String) [Set-Location], ItemNotFoundE
   xception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
It happened because of ":".
again some changes and boom:
<default location when you opened it> + cd "\Users\Shubrajit Acharjee\djangoproject".
after that run command django-admin it will shows result like this:
Type 'django-admin help <subcommand>' for help on a specific subcommand.

Available subcommands:

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    runserver
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

Hence problem solved/>



Comments

Popular posts from this blog

Got an error while coding in django

 error is in an element name "price" in model.py. error:    return field.get_db_prep_save(self._effective_default(field), self.conne ction)   File "C:\Users\Shubrajit Acharjee\PycharmProjects\untitled\lib\site-packag es\django\db\models\fields\__init__.py", line 823, in get_db_prep_save     return self.get_db_prep_value(value, connection=connection, prepared=Fal se)   File "C:\Users\Shubrajit Acharjee\PycharmProjects\untitled\lib\site-packag es\django\db\models\fields\__init__.py", line 818, in get_db_prep_value     value = self.get_prep_value(value)   File "C:\Users\Shubrajit Acharjee\PycharmProjects\untitled\lib\site-packag es\django\db\models\fields\__init__.py", line 1776, in get_prep_value     raise e.__class__( ValueError: Field 'price' expected a number but got ''. solution:Go to migrations file and delete all the auto generated migration files related to element "price" and code correctly in models.py file and ru...