Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Google docs created in Python DJANGO - Is it possible?
I'm working on a project using python Django and pycharm. I'm not super new to Django either. For my project, I'm hoping to create a kind of google docs/Microsoft access. Basically, I'm trying to create a spot on a website where people can type out something in kind of an essay form and export it. I've looked a little bit on the internet and haven't really found anything. I was wondering if anyone has done something like this or can answer with a link referring me to something. Thank You so much in advance. P.S. I want to stay away from just parsing the data they type to an actual google doc. I would rather do it all on my website separate from that. -
Filtering by method value - too many SQL variables error
One of my views needs to filter a queryset by a method value, example: invoices_ids = list(map(lambda inv: inv.id, filter(lambda inv: inv.status().lower() == request['status'], invoices))) invoices = invoices.filter(id__in = invoices_ids) The status method comes from something like this: class Invoice(models.Model): (...) def status(self): if self.canceled: return 'Canceled' elif self.passed_date: return 'Passed' elif self.req_date: return 'Requested' return 'Inserted' Problem is this kind of filtering gives me an OperationalError "too many SQL variables".. I guess there are too many invoices with a specific status, and the filter id__in gets a gigantic list. How can i overcome this? (To filter by status without having to save into another model variable) -
Add jupyter (classic) or jupyter lab as a page in my django or Flask app
I am building a small web app that is used to manage data science projects. I am currently using Django for the web app. I want a user to be able to open a jupyter notebook from inside my app. I know this sort of behavior is possible because I can use jupyter inside my PyCharm IDE. I don't wanna use Iframes (this will be the last resort.) I can't find any documentation on how to integrate with the server. Thanks for any help offered. -
Reverse ManyToMany lookup for model with filter
I am trying to use Django ManyToMany reverse lookup with filtering, values_list and order_by but can't figure it out. Here is my model (simplified): class Project(Model): users = ManyToManyField(User, verbose_name="Users", related_name="project_users", blank=True) files = ManyToManyField(FileInfo, verbose_name="Files", related_name="project_files",) class FilInfo(Model): # Name name = CharField(_("Name"), max_length=300, blank=False) # Description description = TextField( _("Description"), max_length=4096, validators=[MaxLengthValidator(4096)], ) # User model is a standard Django user model I am trying to get all distinct FileInfo.name for all Projects where self.request.user is a project_user Here is my obviously wrong attempt as a placeholder: // Doesn't even compile :( FileInfo.objects.values_list('name').filter(Q(pk = project__files__pk) & Q(project__users__pk=self.request.user.id)).distinct().order_by("-" + order_by) -
Django's ./manage.py always causes a skaffold rebuild: is there a way to prevent this?
I develop in local k8s cluster with minikube and skaffold. Using Django and DRF for the API. I'm working on a number of models.py and one thing that is starting to get annoying is anytime I run a ./manage.py command like (showmigrations, makemigrations, etc.) it triggers a skaffold rebuild of the API nodes. It takes less than 10 seconds, but getting annoying none the less. What should I exclude/include specifically from my skaffold.yaml to prevent this? apiVersion: skaffold/v2beta12 kind: Config build: artifacts: - image: postgres context: postgres sync: manual: - src: "**/*.sql" dest: . docker: dockerfile: Dockerfile.dev - image: api context: api sync: manual: - src: "**/*.py" dest: . docker: dockerfile: Dockerfile.dev local: push: false deploy: kubectl: manifests: - k8s/ingress/development.yaml - k8s/postgres/development.yaml - k8s/api/development.yaml defaultNamespace: development -
Django - send user object as argument to template tag
I need to send my user object as a argument to a template tag, how can this be accomplished given the following example: template.html {% load currency_transition %} ... <span>Price: {{ post.price_usd|floatformat:2|intcomma|currency_transition:user }}</span> templatetag.py register = template.Library() @register.filter def currency_transition(value, args): if args is None: return False user = get_user_model().objects.get(pk=args[0]) currency_transition = fiat_to_fiat(value=value, fiat=user.acc_fiat_currency) return currency_transition The function that does the actual math (if it matters): def fiat_to_fiat(value, fiat): conversion = value / FiatConversionRates.objects.get(base='USD', key=fiat).value return json.dumps(conversion, cls=DecimalEncoder) But im always failing with the following error: user = get_user_model().objects.get(pk=args[0]) <- Given line that fails with: TypeError: 'User' object is not subscriptable Can somebody help? Thanks in advance -
Sync multiple clients database in android
I'm new in Android programming and I'm trying to develop an online note app. In this app every user may have more than one device. For sync data between server and client I can implement insert and fetch operations but I have no idea how to implement update or remove records and sync these changes between all users devices. Anyone can help me to find an appropriate approach? even a link or something to give me a clue? And I'm sorry because of My grammar and vocab, This is the first time I'm trying to ask a question in English. -
Uploading a audio file to s3 with django-audiofield
File "/home/glc/glc_project/audiofield/fields.py", line 210, in _rename_audio Feb 20 21:58:47 glc-project gunicorn[36287]: filename = getattr(instance, self.name).path Feb 20 21:58:47 glc-project gunicorn[36287]: File "/home/glc/glc_project/glc_env/lib/python3.8/site-packages/django/db/models/fields/files.py", line 57, in path Feb 20 21:58:47 glc-project gunicorn[36287]: return self.storage.path(self.name) Feb 20 21:58:47 glc-project gunicorn[36287]: File "/home/glc/glc_project/glc_env/lib/python3.8/site-packages/django/core/files/storage.py", line 116, in path Feb 20 21:58:47 glc-project gunicorn[36287]: raise NotImplementedError("This backend doesn't support absolute paths.") Feb 20 21:58:47 glc-project gunicorn[36287]: NotImplementedError: This backend doesn't support absolute paths. -
Django TabularInline error in the admin.py file
Hey guys i have been trying to create an inline TabularInline view of the my model in the django admin.py file. I am facing an issue where i am getting the following error in the code below. Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/brian/Desktop/django react learning /site/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/home/brian/Desktop/django react learning /site/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "/home/brian/Desktop/django react learning /site/lib/python3.8/site-packages/django/core/management/base.py", line 442, in check raise SystemCheckError(msg) django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues: ERRORS: <class 'tweets.admin.TweetlikeAdmin'>: (admin.E202) 'tweets.Tweet' has no ForeignKey to 'tweets.Tweet'. So at first I thought I had missed something but when I tried changing it I got more errors which really don't make sense. so I made sure I share with you my models.py file and my admin.py file here is my models.py file class Tweetlike(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE) tweet = models.ForeignKey('Tweet',on_delete=models.CASCADE) timestamp = models.DateTimeField(auto_now_add=True) class Tweet(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE) #this means that one user can own tweets likes = models.ManyToManyField(User,related_name='tweet_user', blank=True, through=Tweetlike) content = models.TextField(blank=True,null=True) timestamp = models.DateTimeField(auto_now_add=True) image = models.FileField(upload_to='images/',blank=True,null=True) def __str__(self): return self.content and lastly here is … -
What should I focus on most while learning Django?
I have been learning django and right now I understand a few basic concepts. However, I am trying to dig deeper and I would like to know which concepts I should give my focus more to start building meaningful appliactions. I'd pick up on other things I wouldn't have learned as I work more and gain more experience and confidence in the framwework. Personally I was thinking of sidlining advanced concepts of the django admin. -
How to copy/clone a django model?
Actually what I am trying to do is verificating email during the registration. I know there are some ways like django-allauth but I just don't want to implement all that stuff to my app, I just want to send a code through email and activate the user after correcting the code. Creating object as is_active=False then turning it to True is a way but actually this is not working for me. I don't want to create User object before verificate the email because I usually make queries on all my users and don't want to show inactive users. (Making queries just for active users is a really long process, please don't suggest this :) ) Whatever, my solution is creating an TemporaryUser model which is a copy of django's User model. Than creating temporary users and using them for creating new User objects after verificating emails. Is there any way to do this, or another suggestions you can do for me? I really researched for copying a model but I couldn't find anything. I hope this can help other people who to copy a Django model. Thanks in advance... -
Cant display image in Django application from PostgreSQL database
I am facing the following issue: I am trying to deploy a Django website where some images are going to be displayed, but I am having some problems to make this work. I followed this totorial: https://www.etutorialspoint.com/index.php/356-how-to-display-image-from-database-in-django The thing is, when opening the Django application where the images are supposed to be shown (the app is called digitaltwin), this is what I get (every image id shows the same thing): Website screenshot I am storing my image in multiple folders (to try if one of them actually work). The folders are: C:\ C:\Users\marco\VS Code Repositories\rv_django C:\Users\marco\VS Code Repositories\rv_django\rv_django C:\Users\marco\VS Code Repositories\rv_django\rv_django\image C:\Users\marco\VS Code Repositories\rv_django\rv_django\image\media The image address is saved in a Postgres SQL Database. I can confirm the connection between django and the DB works since everytime I add a row, its displayed in the Django website. Here is how the address is saved in the database: id image 1 "media/1.png" 2 "C:\Users\marco\VS Code Repositories\rv_django\rv_django\image\1.png" 3 "C:\\Users\\marco\\VS Code Repositories\\rv_django\\rv_django\\image\\1.png" 4 "media//1.png" 5 "media\1.png" 6 "media\\1.png" 7 "C:/Users/marco/VS%20Code%20Repositories/rv_django/rv_django/image/1.png" 8 "C://Users//marco//VS%20Code%20Repositories//rv_django//rv_django//image//1.png" 10 "C:\Users\marco\VS%20Code%20Repositories\rv_django\rv_django\image\1.png" 12 "C:\\Users\\marco\\VS%20Code%20Repositories\\rv_django\\rv_django\\image\\1.png" 13 "media/1.png" 14 "C:\Users\marco\VS Code Repositories\rv_django\rv_django\image\media\1.png" 15 "C:\\Users\\marco\\VS Code Repositories\\rv_django\\rv_django\\image\\media\\1.png" 16 "C:/Users/marco/VS Code Repositories/rv_django/rv_django/image/media/1.png" 17 "C://Users//marco//VS Code Repositories//rv_django//rv_django//image//media//1.png" 18 "1.png" 19 "file:///C:/Users/marco/VS%20Code%20Repositories/rv_django/1.png" 20 "file:///C:/Users/marco/VS Code Repositories/rv_django/1.png" 21 … -
TypeError at /auth/users/ djoser
hi i am trying to make an app for when a user signs up they will get an email to verify their email address in django rest framework i found out from one of my previous questions that djoser would be a good fit and someone provided a playlist of how to implement it of which i am now following which is this: https://www.youtube.com/watch?v=CC3uxnYYdMM&list=PLJRGQoqpRwdfoa9591BcUS6NmMpZcvFsM&index=3 but in the next video you have to do a post request via postman and i did that and i got this error TypeError: create_user() missing 4 required positional arguments: 'latitude', 'longitude', 'country', and 'postcode' this may be because i have some extra fields and djoser only uses default fields like username and password and email. soo is it possible to add extra fields to the create user function or is there something i am missing? -
How to get time elapsed since creation date of an object(post) in django?
I tried looking through the documentation for a datetime formating that would allow me to show the time elapsed since a post was created e.g "created 15s ago" but I couldn't find one. I figured I had to create a custom filter but I don't have a clue on how to go about it. I am also new to the Django framework unfortunately. -
problem django get() returns two values postgresql
hello i have been this problem since i change sqlite to postgresql when it was empty i hit migrate and create tables when i create superuser it bugs but still creates admin users , and when its creates i cannt log in so its basic django admin and should not be something different how can i fix this? is it wrong migrate or? this is debug traceback MultipleObjectsReturned at /admin/login/ get() returned more than one Profile -- it returned 2! Request Method: POST Request URL: http://www.wokenmemes.com/admin/login/?next=/admin/ Django Version: 3.1.5 Exception Type: MultipleObjectsReturned Exception Value: get() returned more than one Profile -- it returned 2! Exception Location: /var/www/html/web/venv/lib/python3.8/site-packages/django/db/models/query.py, line 433, in get Python Executable: /var/www/html/web/venv/bin/python3 Python Version: 3.8.5 Python Path: ['/var/www/html/web', '/var/www/html/web/venv/bin', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/var/www/html/web/venv/lib/python3.8/site-packages'] Server time: Sat, 20 Feb 2021 20:19:07 +0000 and this is traceback when i create superuser Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/var/www/html/web/venv/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 79, in execute return super().execute(*args, **options) File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/var/www/html/web/venv/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 189, in handle … -
Trying to import models from an app throws an ImproperlyConfigured exception
I made a small web scraper to fill make all the db entries for my models but when I import my models I'm getting this ImproperlyConfigured exception and I'm not sure why. My import is as follows from ship_showroom.models import Ship, ShipExternals, ShipInternals, ShipOptionalInternals, ShipOptionalInternalsMilitary, Image The traceback is as follows Traceback (most recent call last): File "/home/mdacrim97/eliteDangerous/ship_scraper.py", line 5, in from ship_showroom.models import Ship, ShipExternals, ShipInternals, ShipOptionalInternals, ShipOptionalInternalsMilitary, Image File "/home/mdacrim97/eliteDangerous/ship_showroom/models.py", line 4, in class Ship(models.Model): File "/home/mdacrim97/anaconda3/lib/python3.7/site-packages/django/db/models/base.py", line 108, in new app_config = apps.get_containing_app_config(module) File "/home/mdacrim97/anaconda3/lib/python3.7/site-packages/django/apps/registry.py", line 253, in get_containing_app_config self.check_apps_ready() File "/home/mdacrim97/anaconda3/lib/python3.7/site-packages/django/apps/registry.py", line 135, in check_apps_ready settings.INSTALLED_APPS File "/home/mdacrim97/anaconda3/lib/python3.7/site-packages/django/conf/init.py", line 82, in getattr self._setup(name) File "/home/mdacrim97/anaconda3/lib/python3.7/site-packages/django/conf/init.py", line 67, in _setup % (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. I'm just starting my Django journey so I have no idea where something is wrong. It seems odd to me because I can do the exact same import just fine via python manage.py shell but in my web scarper file it does that which is in the same directory as manage.py I'm really lost any help is greatly appreciated. -
Django: How To Use Custom Path Converter To Pass A List Through URL
I am trying to pass a list from a form to view so that i can filter a queryset by that list. I am trying to do this with a custom path converter, but i have never made one before so can someone show how you would go about making a path converter that takes in a list and passes that into the view. If there is a better way to do this then please let me know converters.py class ListPathConverter: def to_python(self, value): return value def to_url(self, value): return value -
Creating a table using 2 models and populating the content of it using the third
I am wondering, whether there is a nice and simple way, how someone can populate the table that is made by 2 models. To be more specific, I have categories and sub-categories and what I want to do is to create a table of categories and sub-categories that will be populated with a link to the specific product. ---- | sub1 | sub2 | sub3 | ... cat1 | btn1 | btn2 | btn3 | ... cat2 | btn4 | btn5 | btn6 | ... ... ... ... ... My models: class Category(models.Model): name = models.CharField(max_length=120) class SubCategory(models.Model): name = models.CharField(max_length=120) class Whistle(models.Model): name = models.CharField(max_length=120) category = models.ForeignKey(Category, on_delete=models.CASCADE) sub_category = models.ForeignKey(SubCategory, on_delete=models.CASCADE) The way I am currently doing this is: def gemerate_dict_for_table(): all_rows = [] sub_categories = list(SubCategory.objects.all()) products = list(Product.objects.all()) categories = list(Category.objects.all()) for category in categories: custom_row = dict() custom_row["val"] = category.name one_row = [custom_row] for sub_category in sub_categories: product = list(filter(lambda x: x.category == category and x.sub_category == sub_category, products)) is_present = dict() if product: is_present["val"] = "X" is_present["product"] = product else: is_present["val"] = "-" one_row.append(is_present) all_rows.append(one_row) return all_rows Sadly, its very slow and it takes around 8 seconds to get the website loaded (having … -
DRF 3 - Creating Many-to-Many update/create serializer with though assoc table, when assoc table has additional fields in it
Expanding an old question DRF 3 - Creating Many-to-Many update/create serializer with though table [sorry this question may be little redundant, but i couldn't find the exact sol'n i needed anywhere. and all the solutions existing are years old] From OP- from django.db import models class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) persons = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Person) group = models.ForeignKey(Group) activity = models.CharField(max_length=80) joined_date = models.DateField() I added two more fields('activity' and 'joined_date') to 'Membership' assoc class. Let's sat we are POST'ing JSON data, and creating a new Group, using some appropriate api. old soln //we can create a new Group with related Person(s) using: { "name" : "Group 1", "memberships" : [ { "person" : 1 }, { "person" : 2 } ] } So how to add, the rest of the fields at the same time a new Group is created. -
Update a table that is in another html when submitting a form
I am new developing in django, I want is that when I submit the form, to be able to update a table dynamically without reloading the page that contain this table I have a view based on class ListView class TurnoCreateView(CreateView): model = Turno form_class = TurnForm template_name = 'turnos/form.html' success_url = reverse_lazy('turnero:pview') This is the form https://espolec-my.sharepoint.com/:i:/g/personal/emaalpar_espol_edu_ec/EebGrn_Lok5Jpk-FxV-XnuoBb9C9MJYt2O1e8f1IKg8yVA?e=TDQqrX The code of the view that renders the table is the following class AtencionTurnosListView(ListView): model = AtencionTurno template_name = 'atencion/atencionTv.html' And this the html of atencionTv.html https://espolec-my.sharepoint.com/:i:/g/personal/emaalpar_espol_edu_ec/Edxi-QT8IVtNu6D9-nVsLG4B_uunlI70GiGX9Y9i1P_3Cg?e=H7FDo5 -
Django urls.py file article detail path error
I want to be details of articles in my urls like this help/<category>/<article.slug> and here is urls.py code urlpatterns = [ path('help/', views.help), path('help/<slug:category>/<slug:slug>', views.article_detail) ] Here I am connecting the urls (I think here is the problem). class HelpArticle(models.Model): category = models.ForeignKey(HelpCategory, on_delete=models.CASCADE) title = models.CharField(max_length=300, unique=True) slug = models.SlugField(unique=True, blank=True) content = models.TextField(null=True) date = models.DateTimeField(auto_now_add=True) def __str__(self): return f'{self.title} ({self.category.title})' def save(self, *args, **kwargs): self.slug = slugify(self.title, allow_unicode=False) super().save(*args, **kwargs) def return_path(self): return f'{self.category.slug}/{self.slug}' And this is the HelpArticle model class. Terminal traceback says raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: URL route 'help/<slug:category.title>/<slug:slug>' uses parameter name 'category.title' which isn't a valid Python identifier. -
refresh parent template in django
Im coding for an e-commerce in django so im using sessions to update the shopping cart. everything is going right but i can't refresh the parent template to update the number of the cart svg which is up in the header of the template... So when i add a product to shopping cart, session is update but i can't update that number of the cart in parent template... When I add a product I execute a view that update the session and refresh the same page but it only refresh child template, not all the website. Some help? -
What are your popular django projects in Github?
I am an intermediate learner in Django. And I want to up my Django skills further by going through some great projects. It will be helpful for me if anybody suggests me some good projects. -
Django PyTest - Database access not allowed Error even with django_db and fixtures?
I am learning PyTest in django and I encountered problem that I cannot solve. I am getting this error: ____________________________________________________________________________________________________________ ERROR collecting prices_tool/tests/test_views.py ____________________________________________________________________________________________________________ prices_tool/tests/test_views.py:9: in <module> from prices_tool.views import results prices_tool/views.py:14: in <module> from prices_tool.forms import SearchForm, FreeSearchForm prices_tool/forms.py:7: in <module> class FreeSearchForm(forms.Form): prices_tool/forms.py:11: in FreeSearchForm for make in makes: ../prices_tool-env/lib/python3.8/site-packages/django/db/models/query.py:287: in __iter__ self._fetch_all() ../prices_tool-env/lib/python3.8/site-packages/django/db/models/query.py:1308: in _fetch_all self._result_cache = list(self._iterable_class(self)) ../prices_tool-env/lib/python3.8/site-packages/django/db/models/query.py:111: in __iter__ for row in compiler.results_iter(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size): ../prices_tool-env/lib/python3.8/site-packages/django/db/models/sql/compiler.py:1108: in results_iter results = self.execute_sql(MULTI, chunked_fetch=chunked_fetch, chunk_size=chunk_size) ../prices_tool-env/lib/python3.8/site-packages/django/db/models/sql/compiler.py:1154: in execute_sql cursor = self.connection.cursor() ../prices_tool-env/lib/python3.8/site-packages/django/utils/asyncio.py:26: in inner return func(*args, **kwargs) ../prices_tool-env/lib/python3.8/site-packages/django/db/backends/base/base.py:259: in cursor return self._cursor() ../prices_tool-env/lib/python3.8/site-packages/django/db/backends/base/base.py:235: in _cursor self.ensure_connection() E RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it. ========================================================================================================================== short test summary info =========================================================================================================================== ERROR prices_tool/tests/test_views.py - RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ============================================================================================================================== 1 error in 0.47s ============================================================================================================================== It seems that I cannot import any method from my views.py. Of course I tried adding @pytest.mark.django_db it did not work. I googled around and found some posts here and I added in my conftest.py this: @pytest.fixture(autouse=True) def enable_db_access_for_all_tests(db): pass And when that … -
Different shebang line of a python script depending on the system
I've a python script using the Django framework running from a virtualenv, and I'd like to use the same script on a different machine where the virtualenv is located in a different place. The script is like this: #!/home/lenovo/.virtualenvs/gjt/bin/python sys.path.append('/home/lenovo/prj/gjt/gjt') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'gjt.settings') import django django.setup() To use the same script on a different machine, I'd need to change the shebangline to something else. Either can I define the shebang line based on the /etc/hostname file or somehow use #!/usr/bin/python as the shebang, and still be able to use the virtualenv from the mentioned location? Of course i need to change the sys.path.append accordingly, but that's not an issue. Thanks.