Skip to content

Conversation

aidando73
Copy link
Owner

Resolves #1

Introduction

The django-admin startapp command was throwing an error when the directory name had a trailing slash. This PR fixes the issue by modifying the validate_name method in the templates.py file to remove any trailing slashes from the directory name before checking if it's a valid identifier.

Changes Made

  • The templates.py file was viewed to understand the current implementation of the validate_name method.
  • The list_files function was used to list the files in the django/core/management directory.
  • The validate_name method was modified to use the rstrip method to remove any trailing slashes from the target variable.
  • The edit_file function was used to update the templates.py file with the modified validate_name method.

Solution

The validate_name method now correctly handles directory names with trailing slashes. The rstrip method is used to remove any trailing slashes from the target variable before checking if it's a valid identifier.

Tests and Example Uses

To test the changes, you can run the django-admin startapp command with a directory name that has a trailing slash. The command should now complete successfully without throwing an error.

django-admin startapp myapp /

This should create a new Django app called myapp in the current directory.

Conclusion

This PR fixes the issue with the django-admin startapp command throwing an error when the directory name has a trailing slash. The changes made ensure that the validate_name method correctly handles directory names with trailing slashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

django-admin startapp with trailing slash in directory name results in error

2 participants