So, Im learning django from djangobook.com and a bit confused about the project skeleton created by the following command.
django-admin.py startproject mysite
This creates the following tree.
mysite
- manage.py
- mysite
- init
- settings
- urls
- views
But the book says it should create the tree below:
mysite/
init.py
manage.py
settings.py
urls.py
I'm using Python 2.7.3 on Windows 7 pro 64 bit. Django version is 1.4.
The book is teaching using Django ver 1.1. I suspect the difference in project skeleton is due to the newer version of django that Im using.
So is it because of the newer version? If so, why was this change made in django?
TIA.
Right, the project layout has changed since Django 1.4.
You will get more information about the reasons on this page:
https://docs.djangoproject.com/en/1.4/releases/1.4/#updated-default-project-layout-and-manage-py
I would also recommend to do at least the official tutorial from the website which is up to date:
https://docs.djangoproject.com/en/1.4/intro/tutorial01/
They explain the project layout.
Related
I want to have charts in the admin panel,
I installed the django-admin-charts package,
Which said add these to settings.py
INSTALLED_APPS = (
'admin_tools_stats', # this must be BEFORE 'admin_tools' and 'django.contrib.admin'
'django_nvd3',
)
But after adding it, it gives this error:
ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (E: \ test1 \ venv1 \ lib \ site-packages \ django \ utils \ encoding.py)
I searched but didn't find much about smart_text!
Maybe it has a problem with Django version 4 or Python version 3.10.3?
This is because django-admin-charts needs smart_text and in django 4 smart_text is removed from the utils/encoding so the better way to resolve this issue is to add this code in your settings.py file
import django
from django.utils.encoding import smart_str
django.utils.encoding.smart_text = smart_str
I digged around a little and the problem seems to be the Django version. smart_text function is not present in the django/utils/encoding.py file. I downgraded from 4.0.2 to 3.2.13, set PyMemcacheCache as the default cache in settings.py and it works. In my case downgrading is not acceptable as Django. 3.2.13 doesn't support redis cache, but it might help you. Let's hope that django-admin-charts will add suport for Django 4.0.
I got this error when we switched from Django 2.2 to Django 4 version.
There were a library which was not upgraded. I found this out by searching the usage of "django.utils.encoding import smart_text" statement under the project scope.
The issue resolved once I upgraded the django-wkhtmltopdf library from 3.3.0 to 3.4.0.
Check for any dependent libraries and upgrade as above to fix the issue.
I want to use scratch files as a console replacement for prototyping in my Rails apps. The simplest solution I've found is requiring environment manually like this:
require '/project/path/config/environment.rb'
But it does not use Spring and is terribly slow because of that.
I've found two ways to do it, depending on your workflow one might fit you better than another. Assuming you're using IDEA 14 (it might be different for earlier versions) and Rails 4.1+.
Custom runner
In top menu Run -> Edit Configurations...;
Configuration tab:
2.1. Ruby script: <Path to your bin/rails file>;
2.2. Script arguments: runner <Path to your script>;
2.3. Working directory: <Your project dir>;
2.4. Environment variables: RAILS_ENV=development;
2.5. Ruby arguments: -e '$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)';
2.6. Ruby SDK: <Your project SDK>.
Bundler tab:
3.1. Run the script in context of the bundle (bundle exec): <check>.
The problem with this approach is that you would have to manually change path to scratch file each time you want to run the different one (please comment if you know workaround).
External tool
Assuming you have Spring installed:
In top menu IntelliJ IDEA -> Preferences;
Tools -> External Tools;
Hit + in the bottom of the menu:
3.1. Name: Rails Runner;
3.2. Program: $ProjectFileDir$/bin/spring;
3.3. Parameters: rails runner $FilePath$;
3.4. Working directory: $ProjectFileDir$.
Keymap:
4.1. Search for Rails Runner;
4.2. Double-click and add custom shortcut (Alt + S is convenient and available).
The only problem with this approach is that you have to have custom shortcut to make it convenient.
Found in this tuto the cmd to deploy a grails app on Glassfish application server:
asadmin deploy --libraries $GRAILS_HOME/lib/glassfish-grails.jar helloworld-0.1.war
Browsing to $GRAILS_HOME/lib/ , don't find glassfish-grails.jar file .
From where can someone get this library ? i mean :glassfish-grails.jar
That stuff is badly dated and I don't think they've updated it in 4 years. For some reason it didn't even appear to be open source when I look at this a year or so ago.
There was plugin but it's almost as dated. The repo has seen some updates fairly recently, so if you wanted to get this thing to the finish line it seems very doable and I think it'd be a great addition.
I would be willing to help out some after the holidays It looks like just updating the glassfish-embedded-all dependency to 'org.glassfish.main.extras:glassfish-embedded-all:4.1' and ensuring that the plugin code compiles would be a chunk of the work, with ensuring that it functions being the remaining :) See http://mvnrepository.com/ for more info, dependencies, etc.
Feel free to email me if you get stuck or want to know anything about getting a new server to act like Tomcat and Jetty do in run-app - I've worked on both of those.
The tutorial was written for the Glassfish v3 Prelude version, a very early version of Glassfish 3, and seems to be invalid for current versions of Glassfish 3.
The file glassfish-grails.jar doesn't exist anymore in the GRAILS lib folder, but it isn't needed anyway.
To make a shared-war (a WAR without the lib files) work, you have to do the following:
Copy all the libs from $GRAILS_HOME/lib/ to $GLASSFISH_HOME/glassfish/lib/.
Deploy it via: asadmin deploy helloworld-0.1.war (or use the Glassfish Admin GUI)
Everything else should work as described in the tutorial.
See also:
Grails - trying to deploy a nojars application into glassfish 3.0.1
I have a symfony project. It's not mine. I wanna to understand the version in which the project is written. It do not seem to be a 2.0 version.
The project folder structure is this:
-test
-plugins
-nbprojects
-log
-lib
-data
-config
-cache
-apps
-.git
files
-test.txt
-symfony
-kill.sh
-index.html
-ftp.sh
-ftp_1.sh
-ftp_2.sh
data.txt
another
.readme_notes.swo
Any idea of which version of Symfony this is and how to do in order to start modify this project?
I'm not sure why You want to recognize symfony versions, but you can for e.g check:
for symfony 1.x - index.php file in web folder
symfony 2.x.x - app.php file in web folder
Looks like a symfony1 project.
To have a precise idea of the version, as #cpntk said, once in the project directory, just run:
php symfony --version
I m reading the tutorial of getting started with zend framework2, when I came to this :
I don't know how to excecute this :
here is the link of the page : http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html
How can I achieve this?
i have written a throughout article on how to install Zend Framework 2 on a windows environment. It is directed at Win7, but works very similar (if not identical) for XP, too.
Please read my Blog "Zend Framework 2 Installation on Xampp for Windows"
Well, the best way to get started with Zend Skeleton Application is:
$cd my/project/dir
$git clone git://github.com/zendframework/ZendSkeletonApplication.git --recursive
$cd ZendSkeletonApplication
In your project root you will find two files: composer.json and composer.phar. You can get more information about composer from the official Getting Started.
The composer.json file describes the project's dependencies:
{
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "~2.4"
}
}
In order to get the dependencies you need to execute from you project root:
$composer.phar self-update
$composer.phar update
Finally, you can start the internal PHP cli-server in the root directory:
$php -S 0.0.0.0:8080 -t public/ public/index.php
I hope this will help you to install and configure your app.
If you're using Windows, please check your php.exe directory. And execute it. Example:
C:\php\php.exe composer.phar self-update
If you're linux user, you already know the answer.
Zend Framework 2 has just been release and it is not a framework for newbies. There are a few different ways to install which you can find on http://framework.zend.com/downloads
or with XAMPP at Xampp In Windows
But I have the feeling that if you are having trouble at this point then ZF2 is not for you.
Per chance if you were on a Mac or Linux box, you would open the Terminal application. Navigate to the zend framework application (cd /path/to/app), and then run the commands.