Search the Community
Showing results for tags 'django'.
-
Hello, I am building a Django app. I would like to create a global file where I will store all text and links on my website. For example: homeSiteTitle = 'My Title', homeButtonText = 'My Button', homeButtonUrl = 'https://example.com', Then I want to use these variables in my .html files. <a href="{{homeButtonUrl"}}><button>{{homeButtonText}}</button> Is there any way I can achieve this. I hope you understand me.
-
Hi, I am new to Django and react. I am following the guide below and I have run into an issue. I think my file structure is the issue. The Guide I am following The file structure in the guide is ├── manage.py ├── mysite │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── myapp <----- a normal Django app │ ├── __init__.py │ ├── models.py │ ├── urls.py │ └── views.py ├── assets <----- our front-end project source │ ├── javascript │ └── styles ├── static <----- our front-end project outputs (and other Django static files) │ ├── css │ ├── images │ └── js └── templates <----- our Django template files └── myapp and my file structure is: |myproject ├── manage.py ├── .gitignore ├── package-lock.json ├── package.json ├── webpack.config.js │ ├── node_modules │ ├── ..... ├── myproject │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── myapp │ ├── __init__.py │ ├── models.py │ ├── urls.py │ └── views.py ├── js │ ├── index.js ├── static │ ├── css │ ├── images │ ├── js | ├── index-bundle.js └── templates ├── myapp ├── hello_webpack.html I have followed the guide step by step until adding the hello_webpack.html file. The error I get when runserver is: TypeError("Invalid path type: %s" % type(value).name) TypeError: Invalid path type: list My /js/index.js function component() { const element = document.createElement('div'); element.innerHTML = 'Hello webpack'; return element; } document.body.appendChild(component()) webpack.config.js const path = require('path'); module.exports = { entry: './js/index.js', // path to our input file output: { filename: 'index-bundle.js', // output bundle file name path: path.resolve(__dirname, './static'), // path to our Django static directory }, }; myproject/settings.py import os STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [STATICFILES_DIRS,], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] myproject/urls.py from django.contrib import admin from django.urls import path from django.views.generic import TemplateView urlpatterns = [ path('admin/', admin.site.urls), path('hello-webpack/', TemplateView.as_view(template_name='hello_webpack.html')) ] templates/hello_webpack.html {% load static %} <!doctype html> <html> <head> <title>Getting Started with Django and Webpack</title> </head> <body> <script src="{% static 'index-bundle.js' %}"></script> </body> </html> I have tried changing the STATICFILES_DIRS in settings.py but I cannot get it working. I would really appreciate any help.
-
Hello and good day. I'm creating a website where users can commission artists. I wanted to check my work and see if the models I've made for this website lack anything or there might be a better way to do them. I'm relatively new to Django and since I don't personally know any senior Django developers I though I might ask here. all criticism is welcome. the website is divided into 4 apps. the main web app, the artist profile app, the digital art app and the physical art app. 1. Artist Profile App: where you can create an artist account, track your orders, score and reviews. from django.db import models class Artist(models.Model): user = models.CharField(max_length=50, verbose_name="Artist Username") fname = models.CharField(max_length=50, verbose_name=("First Name")) lname = models.CharField(max_length=50, verbose_name=("Last Name")) email = models.EmailField(max_length=100, verbose_name=("Email")) phone = models.BigIntegerField(verbose_name=("Phone Number")) UserAddress = models.ManyToManyField("artistProfileApp.UserAddress", verbose_name=("User Addresses")) overall_score = models.DecimalField(max_digits=3, decimal_places=1, default=0, verbose_name=("User Score")) def __str__(self): return self.user class Review(models.Model): artist = models.ForeignKey(Artist, on_delete=models.CASCADE, related_name='reviews') reviewer = models.ForeignKey(Artist, on_delete=models.CASCADE) score = models.PositiveIntegerField(choices=[(i, i) for i in range(1, 6)]) review_text = models.TextField() def __str__(self): return f"{self.reviewer}'s review of {self.artist}" #I realize UserAddress model can be done a lot better using lists and dropdowns, im going to do that later on and the charfields are just placeholders for now class UserAddress(models.Model): user = models.ForeignKey(Artist, on_delete=models.CASCADE) address_name = models.CharField(max_length=50) country = models.CharField(max_length=50) province = models.CharField(max_length=50) city = models.CharField(max_length=50) address = models.CharField(max_length=50) postal_code = models.CharField(max_length=50) 2. Digital Art App: a separate app to handle all digital art displays and orders from django.db import models from artistProfileApp import models as artistProfileModel class DigitalArtwork(models.Model): artist = models.ForeignKey(artistProfileModel.Artist, on_delete=models.CASCADE) title = models.CharField(max_length=255) description = models.TextField(max_length=500) image = models.ImageField(upload_to='artworks/', blank=True) plans = models.ManyToManyField("digitalArtApp.DigitalArtworkPlan", verbose_name=("Digital Artwork Plans")) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.title class DigitalArtworkPlan(models.Model): title = models.CharField(max_length=255) description = models.TextField(max_length=500) price = models.BigIntegerField() image = models.ImageField(upload_to='artworks/plans', blank=True) class DigitalArtworkOrder(models.Model): customer = models.ForeignKey(artistProfileModel.Artist, on_delete=models.CASCADE) artwork = models.ForeignKey(DigitalArtwork, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) payed_at = models.DateTimeField(auto_now_add=True) 3. Physical Art App: a separate app to handle physical arts, similar to digital art app with some changes from django.db import models from artistProfileApp import models as artistProfileModel class PhysicalArtwork(models.Model): artist = models.ForeignKey(artistProfileModel.Artist, on_delete=models.CASCADE) title = models.CharField(max_length=255) description = models.TextField() image = models.ImageField(upload_to='artworks/', blank=True) plans = models.ManyToManyField("physicalArtApp.PhysicalArtworkPlan", verbose_name=("Digital Artwork Plans")) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.title class PhysicalArtworkPlan(models.Model): title = models.CharField(max_length=255) description = models.TextField(max_length=500) price = models.BigIntegerField() image = models.ImageField(upload_to='artworks/plans', blank=True) class PhysicalArtworkOrder(models.Model): customer = models.ForeignKey(artistProfileModel.Artist, on_delete=models.CASCADE) artwork = models.ForeignKey(PhysicalArtwork, on_delete=models.CASCADE) address = models.TextField() created_at = models.DateTimeField(auto_now_add=True)
-
Hi Everyone, I'm looking to buy a Samsung 960 PRO 512GB to spice up my PC. Here are my specs right now: Processor: Intel 6600k Overclocked to 4ghz Motherboard: MSI M5 Gaming Cooler: Corsair H100i v2 GPU: Gigabyte 980ti Windforce Overclocked late 2015, early 2016 PSU: EVGA G2 750w Current Storage which WILL remain: WD Blue 1Tb and 4Tb So I was wondering if there were any drivers or software require to transfer and install this drive. This is my first time installing an SSD, . I am a Wan Show viewer, I have been subscribed since 2013 and watch every video across all channels, just if any LMG people see this. Thanks, Django
-
Good morning, afternoon, or evening, I have been teaching myself PHP for the last few years and have also delved into various other programming languages. Over the years I have seen a lot of people give PHP flack for various reasons. So I decided a few days ago to look into other languages that I can use to build backends and other services. I have considered Node and other JS frameworks but I also have heard about Python and specifically Django. I have used Python in the past for writing up quick scripts for little things because I thought that was what Python was best at, however, I realize now looking at Python again that it is actually a very strong language. Have any of you worked with Django and what are you thoughts on it? Alternatively, what other web languages have you looked at besides PHP and Django and what did you like or dislike about them? Thanks everyone for the input!
-
Hi, Im hosting a LAN-Party. That's why I need a seatmap and an ticket system. I found this CMS on GitHub that is perfect for my LAN-Party. The only thing is that I don't know how to use Django, CMS and python. Link to project: https://github.com/lancms/lancms2 Link to free Django/Python/CMS hosting website: https://www.pythonanywhere.com So I would be so happy if anyone could've helped me with this! If someone just could make a quick tutorial or something how to set up the website! Best regards, henriksen67
-
Hi, Im hosting a LAN-Party. That's why I need a seatmap and an ticket system. I found this CMS on GitHub that is perfect for my LAN-Party. The only thing is that I don't know how to use Django, CMS and python. Link to project: https://github.com/lancms/lancms2 Link to free Django/Python/CMS hosting website: https://www.pythonanywhere.com So I would be so happy if anyone could've helped me with this! If someone just could make a quick tutorial or something how to set up the website! Best regards, henriksen67
-
Hi guys, Does anyone know the best web-hosting service for a Django website? thanks.
-
I am wondering what my fellow coders think the best development environment or solution is for a project that will use Django with MySQL for the data. This will be my first notable project and I want to start with a solution that will make for the least hassle come time to deploy to the web server. My current idea is to Django and MySQL containers with Docker and Compose. Any suggestions are appreciated!
-
Hello everybody! I would like to know if django is good for web development? And if you could share some tips to get started with django.
-
Hello Everyone, So i'm fiddling around with learning some Django (1.6.5, and py 2.7.6), and have an issue with my templates(?) so in the views.py file for the site, classes which represent simple 'pages' work fine it seems; like a basic 'hello this page is working' set up. However things begin to get a bit strange when i try adding templates. So i created a new folder in the project directory called 'template', in which i've put my html file. so my urls.py currently looks like this: ##### from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'profit.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^hello/$', 'engine.views.hello'), #engine is the app name url(r'^hello_template/$', 'template.hello_template'), #template is dir. ) ##### MOST* of the time the /hello and /admin pages work. so i try to change my settings.py file to include a 'TEMPLATE_DIR' location, so it knows where to look for a template; but i notice in the tutorial i'm following (presumably Django 1.3) that TEMPLATE_DIR is a pre-existing variable which has been specified in the settings.py file, whereas it doesn't exist in my settings.py file (i guess there have been some changes with Django 1.6) so I added it myself. Now when i try test things; this is where everything goes to pot. Most often the 127.0.0.1:8000/hello page will work - 127.0.0.1:8000/admin or /hello_template/ will not work and present me the following error.. ######## ImportError at /admin/No module named template Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.6.5 Exception Type: ImportError Exception Value: No module named template Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 40 Python Executable: /usr/bin/python Python Version: 2.7.6 ######### I went and checked out the 'exception location' as described in the above error path, and found nothing that would indicate the problem lied therein... anyone have any ideas regarding this issue? Thanks in advance, H.
-
Hi fellows, I am a computer engineering student, and with other students, I am going to build/host a website. We are trying to do something with ~hopefully~ industry-like project management quality. We are going to use Trac for project management, with Mercurial as version control. We will also use Jenkins for CI. On a side note, I will also be running ownCloud for purposes unrelated to the project. I'm currently building a new PC on which I plan to host virtual machines. However, it is not completely dedicated to hosting VMs, it will also be my daily gaming rig. It will be on 24/7. PC Specs (only relevant parts listed): i7-4770k 16gb ram 256gb SSD 2x 1TB hard drives (not in RAID) (need more info?) Here is the software I wish to run in VMs: Django stack Trac Mercurial server Jenkins ownCloud Here is how I thought about splitting the software in the VMs and how much ressource to allocate to each. I would like your knowledgeable opinion on the setup, and/or improvement suggestions. Ex: Do I allocate enough/too much ressources to the VMs? Should I merge the 2nd VM in the first one? Should I split the first VM into smaller VMs? I think you catch my drift. Probably going to use VMWare Workstation. If you have other suggestions, like VirtualBox, please explain the pros/cons. VM1 - Linux server distro, 1 vCPU , 2vCore, 6gb RAM, fixed size vDisk, bridged network adapter Django stack Trac Mercurial Jenkins VM2 - Linux server distro, 1vCPU, 1vCore, 2gb RAM, , fixed size vDisk, bridged network adapter ownCloud I will forward some ports on my home router, setup a dynamic dns service, and grant access to these VMs to my collaborators (~6 other people). When the DEV is complete, I will move the Django stack somewhere else on its own for QA, then again for PROD. Thanks buddies. edit: formatting, tags, a bit more info
- 5 replies
-
- virtual machine
- vm
-
(and 8 more)
Tagged with: