Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django best practice: Should I split non-app specific models into my project folder?
I am going to extend the django user models - is it best practice to create a new models.py in my project directory: I.e: project application migrations static models.py (all my application specific models) project forms.py urls.py views.py *** project models.py ? *** I want to add email confirmation to my user sign up. So basically just extend the user model. I am thinking this may not be best practice to do in my application models, but for this case it is only going to be one model so would not really matter. However if I want to extend more non-application specific models then it might be better to do this in a separate file? Does anyone do anything similar and have any tips? Thanks -
Django filter by date like "201803"
Srry for my english. I try create some filter list like ?date=201803 - its meen get all data 2018 years 03 month. This is my model: class TestModel(models.Model): id = models.UUIDField(primary_key=True, unique=True, default=uuid.uuid4, editable=False) date = models.DateTimeField(blank=False) text = models.TextField(max_length=256, blank=False) This is my view: class TestView(generics.ListCreateAPIView): permission_classes = (permissions.IsAuthenticated,) serializer_class = TestSerializer queryset = TestModel.objects.all() filter_backends = (DjangoFilterBackend,) filter_fields = ('date',) but if i can view some date if do like this: ?date=2005-03-12T21:48:00Z field date = models.DateTimeField(blank=False) must be DateTimeField How can do request like this: ?date=201803 ? -
How to run a python file from remote link by posting request from android application
I'm developing a mobile app that will use a python back-end for posting to MySql database.Normally I was using php link for the post purposes and tried it with python as well. protected void TrySignUp() { HttpURLConnection connection; OutputStreamWriter request = null; URL url = null; String response = null; String parameters = "username=" + mUserNameString + "&password=" + mPasswordString.hashCode()+"&email="+mEmailString+"$pic_link="+""; try { url = new URL("https://www.pythonanywhere.com/user/menimadim/files/home/menimadim/backend.py"); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestMethod("POST"); request = new OutputStreamWriter(connection.getOutputStream()); request.write(parameters); request.flush(); request.close(); String line = ""; InputStreamReader isr = new InputStreamReader(connection.getInputStream()); BufferedReader reader = new BufferedReader(isr); StringBuilder sb = new StringBuilder(); while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } // Response from server after login process will be stored in response variable. response = sb.toString(); // You can perform UI operations here Toast.makeText(this, "Message from Server: \n" + response, Toast.LENGTH_LONG).show(); isr.close(); reader.close(); } catch (IOException e) { // Error Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show(); } } My question is: How can I run the python script from remote link as an API with Android. Any suggestion would be welcomed such as free server for beneficial usage. Please consider that I'm new python developer... -
Django: Show existing data in ModelForm of another field
In my model CustomModel there is a field called file: file = models.OneToOneField('File', on_delete=models.PROTECT, editable=False, blank=True, null=True) The File model looks like this: class File(models.Model): file = models.FileField( upload_to=get_filepath, max_length=45, validators=[ FileExtensionValidator(allowed_extensions=['pdf', 'jpg', 'png']), file_size, ] ) original_name = models.CharField(max_length=45) extension = models.CharField(max_length=3) In my forms.py there is this: class CustomModelForm(forms.ModelForm): upload = forms.FileField(max_length=45, required=False, validators=[ FileExtensionValidator(allowed_extensions=['pdf', 'jpg', 'png']), file_size, ],) My problem: When people edit the CustomModel then they can find all existing data. Only for the upload field that is not possible. My goal is to show the people, when they edit CustomModel, the content of CustomModel.file. However, in my CustomModelForm there I cannot show this field, but only the upload field. I need to show for the upload field the contet of CustomModel.file if available. I just don't know how to do this. -
Innosetup Runhidden flag is not working
I have wrapped up my django project using pyinstaller and later used Innosetup to make installer. Since django command prompt running background looks ugly, I used runhidden flag in Innosetup.But when i click on desktop icon application starts running by hiding command prompt, and when i run once more time without closing previous opened app command prompt become visible. I want to make command prompt hidden always. For more details have a look on my ISS script: [Run] Filename: "{app}\{#MyAppExeName}"; Description: "Start Crumbs For Tableau"; Flags: waituntilidle postinstall runhidden skipifsilent -
django.db.utils.IntegrityError: UNIQUE constraint failed: ProgrammerProfile_posts.author_id
So I am trying to make this website and I get this error while I was making changes to my models django.db.utils.IntegrityError: UNIQUE constraint failed: ProgrammerProfile_posts.author_id models.py- from __future__ import unicode_literals from django.db import models from django.contrib.auth.models import User class Person(models.Model): id = models.IntegerField(primary_key=True) Name = models.CharField(max_length=255) age = models.IntegerField() Description = models.TextField() ProfilePic = models.FileField() def __str__(self): return self.Name class Posts(models.Model): id = models.IntegerField(primary_key=True) Name = models.CharField(max_length=255) post = models.TextField() author = models.ForeignKey('Person', on_delete=models.CASCADE) def __str__(self): return self.Name -
AWS Kubernetes RDS connection
I'm having some trouble with my AWS Kubernetes instance. I'm trying to get my django instances to connect to the RDS service via the DB endpoint. DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': os.environ['NAME'], 'USER': os.environ['USER'], 'PASSWORD': os.environ['PASSWORD'], 'HOST': os.environ['HOST'], 'PORT': os.environ['PORT'] } } The host string would resemble this service.key.region.rds.amazonaws.com and is being passed to the container via env in the deploy.yml containers: - name: service env: - name: HOST value: service.key.region.rds.amazonaws.com This set up works locally in kubernetes but not when I put it in the cluster I have on AWS. It returns the following error instead: django.db.utils.OperationalError: could not translate host name Any suggestions or am I missing something in how AWS likes handling things? -
Django TypeError, drop
I want to signed in user to be able to invite users to a 'team', where the teams they can select from are only those they are a part of. I keep getting the same error (init() missing 1 required positional argument: 'user') when I try and output a list of all teams in model UserTeams where the userID = current logged in user. My view: def invite(request): if request.method == 'POST': form = InvitePlayerForm(request.POST) if form.is_valid(): userteam = form.save(commit=False) userteam.save() else: form = InvitePlayerForm() query = UserTeams.objects.all() return render(request, 'teammanager/invite.html', { "invite": query, "form": form }) My Form: class InvitePlayerForm(forms.ModelForm): class Meta: model = UserTeams fields = ['userID','teamID'] def __init__(self,user,*args,**kwargs): super (InvitePlayerForm,self ).__init__(user,*args,**kwargs) self.fields['teamID'].queryset = Team.objects.filter(id__in = UserTeams.objects.filter(userID = user)) My UserTeams model: class UserTeams(models.Model): userID = models.ForeignKey(User,on_delete=models.CASCADE) teamID = models.ForeignKey(Team,on_delete=models.CASCADE) My HTML: <html> <body> <h4>Invite players to your team</h4> <form method="post"> {% csrf_token %} {{ form.as_p }} <input class="btn btn-success" type="submit" value="Add Player"></button> </form> -
Object list into chart labels not working
I have the next view, where I get three lists. 1-dates list 2-questions made by users in a time range. 3-answers of users in the same time range. views.py data_list_question = [] data_list_answer = [] timeline = [] for n in range(24,0,-4): t1 = timedelta(weeks=n) t2 = timedelta(weeks=n-4) c = today-t1 timeline.append(c) a = int(question.objects.filter(published_date__gt=(today-t1), published_date__lt=(today-t2)).count()) data_list_question.append(a) b = answer.objects.filter(published_date__gt=(today-t1), published_date__lt=(today-t2)).count() data_list_answer.append(b) Then I use this values in a scipt in the template like next: chart.html <script type="text/javascript"> $( document ).ready(function() { var ctx = document.getElementById("lineChartstats"); var lineChart = new Chart(ctx, { type: 'line', data: { labels: {{ timeline|date:"j b" }}, datasets: [{ label: "Questions", backgroundColor: "rgba(38, 185, 154, 0.31)", borderColor: "rgba(38, 185, 154, 0.7)", pointBorderColor: "rgba(38, 185, 154, 0.7)", pointBackgroundColor: "rgba(38, 185, 154, 0.7)", pointHoverBackgroundColor: "#fff", pointHoverBorderColor: "rgba(220,220,220,1)", pointBorderWidth: 1, data: {{ data_list_question}} }, { label: "Answers", backgroundColor: "rgba(3, 88, 106, 0.3)", borderColor: "rgba(3, 88, 106, 0.70)", pointBorderColor: "rgba(3, 88, 106, 0.70)", pointBackgroundColor: "rgba(3, 88, 106, 0.70)", pointHoverBackgroundColor: "#fff", pointHoverBorderColor: "rgba(151,187,205,1)", pointBorderWidth: 1, data: {{ data_list_answer }} }] }, }); }); </script> The problem is that the data for each dataset works, however the labels 'timeline' does not work. I do not know how to solve this problem. Thanks … -
Form displays error where there shouldn't be
I have a form which is actually built from 2 forms: UserForm and StudentForm which extends the User model. With the form actually there is no problem whatsoever, but when I try to handle it manually, then I get this error: "This field is required." I filled in all fields but it still appears. I think is related to the fact that I compare my student_ID field with the one from database, and if they don't match, an error like "Wrong student ID." should pop up. And indeed it pops up if values don't match but also the error from above in both cases. Here is my form: class StudentForm(forms.ModelForm): email = forms.EmailField(required=True, widget=forms.EmailInput(attrs={'placeholder': "E-mail Address", 'class': 'email'})) name = forms.CharField(max_length=50, required=True, widget=forms.TextInput(attrs={'placeholder': "Name", 'class': 'name'})) surname = forms.CharField(max_length=50, required=True, widget=forms.TextInput(attrs={'placeholder': "Surname", 'class': 'surname'})) student_ID = forms.CharField(required=True, max_length=14, min_length=14, widget=forms.PasswordInput(attrs={'placeholder': "Student ID", 'class': 'std_id'})) photo = forms.ImageField(required=True, widget=forms.FileInput(attrs={'class': 'profile_pic'})) phone = forms.CharField(max_length=15, required=True, validators=[RegexValidator(regex='^[0-9+]+$', message='Not a valid phone number.')], widget=forms.TextInput(attrs={'placeholder': "Phone Number", 'class': 'phone'})) def clean_student_ID(self): id = self.cleaned_data['student_ID'] try: StudentData.objects.get(student_ID=id) except: raise forms.ValidationError("Wrong student ID.") return id class Meta: model = Student fields = ('email', 'name', 'surname', 'phone', 'student_ID', 'photo') -
generate temporary URLs in Django 2 python 3
hi there is one same quetion in stackoverflow with this link: How to generate temporary URLs in Django but the accepted answer code is for python 2 and i converted it to python3 vertion: import hashlib, zlib import pickle as pickle import urllib.request, urllib.parse, urllib.error my_secret = "michnorts" def encode_data(data): """Turn `data` into a hash and an encoded string, suitable for use with `decode_data`.""" text = zlib.compress(pickle.dumps(data, 0)).encode('base64').replace('\n', '') m = hashlib.md5(my_secret + text).hexdigest()[:12] return m, text def decode_data(hash, enc): """The inverse of `encode_data`.""" text = urllib.parse.unquote(enc) m = hashlib.md5(my_secret + text).hexdigest()[:12] if m != hash: raise Exception("Bad hash!") data = pickle.loads(zlib.decompress(text.decode('base64'))) return data hash, enc = encode_data(['Hello', 'Goodbye']) print(hash, enc) print(decode_data(hash, enc)) but it have error : text = zlib.compress(pickle.dumps(data, 0)).encode('base64').replace('\n', '') AttributeError: 'bytes' object has no attribute 'encode' how should i fix this? -
Error while connecting to SQL server through Django
In settings file, I have given SQL SERVER Database connection values like this. DATABASES = { 'default': { 'NAME': 'AdventureWorks2014', 'ENGINE': 'sqlserver_ado', 'HOST': '127.0.0.1', 'USER': '', 'PASSWORD': '', } } Versions: Django v:1.11 Python v: 2.7 django-mssql v: 1.8 pip v:9.0 Development Platform: Visual Studio After the database connection values changes, I have used the command python manage.py makemigrations Here I got the error is , Executing manage.py makemigrations Traceback (most recent call last): File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\manage.py", line 17, in execute_from_command_line(sys.argv) File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\core\management__init__.py", line 364, in execute_from_command_line utility.execute() File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\core\management__init__.py", line 338, in execute django.setup() File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\apps\registry.py", line 108, in populate app_config.import_models() File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\apps\config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "C:\Python27\Lib\importlib__init__.py", line 37, in import_module import(name) File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\contrib\auth\models.py", line 4, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\contrib\auth\base_user.py", line 52, in class AbstractBaseUser(models.Model): File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\db\models\base.py", line 124, in new new_class.add_to_class('_meta', Options(meta, app_label)) File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\db\models\base.py", line 325, in add_to_class value.contribute_to_class(cls, name) File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\db__init__.py", line 33, in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File "E:\Django Projects\DjangoMSSQLDatabaseConn\DjangoMSSQLDatabaseConn\VirtualEnv\lib\site-packages\django\db\utils.py", line 212, in getitem conn = backend.DatabaseWrapper(db, alias) … -
Django Image Upload - Image file not saving
I'm writing a project where you can add photos to a website from a disk or other sites. In jquery I wrote a book marklet where I can add pictures from other site. But I have problem with uploading images from the disc. I wrote model, modelform, views and html file. When I choose a img file in the form all looks OK. I'm moved to image list web page, but there is not file what I whant to upload. Image file not saving. I don't know what I did wrong. Below is my code: models.py class Image(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='images_created') title = models.CharField(max_length=200) slug = models.SlugField(max_length=200, blank=True) url = models.URLField(blank=True) image = models.ImageField(upload_to='images/%Y/%m/%d') description = models.TextField(blank=True) created = models.DateField(auto_now_add=True, db_index=True) users_like = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='images_liked', blank=True) total_likes = models.PositiveIntegerField(db_index=True, default=0) def __str__(self): return self.title def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(self.title) super(Image, self).save(*args, **kwargs) def get_absolute_url(self): return reverse('images:detail', args=[self.id, self.slug]) class Meta: ordering = ["-image"] forms.py class ImageCreateForm(forms.ModelForm): class Meta: model = Image fields = ('title', 'url', 'description') widgets = { 'url': forms.HiddenInput, } def clean_url(self): url = self.cleaned_data['url'] valid_extensions = ['jpg', 'jpeg'] extension = url.rsplit('.', 1)[1].lower() if extension not in valid_extensions: raise forms.ValidationError('Podany adres URL … -
Whether Django urls.py unittest should be apart from DRF ModelViewSet?
I'm testing in my project some Django REST Framework ModelViewSet views and while I was reading Book - TDD web dev with Python, available at GitHub, I ran into a simple design question -I guess- that would be whether I should use django.urls.resolve or get the same info, for instance, calling: response = self.client.options(reverse_lazy('namespace:view_func_or_pattern_name') from DRF APITestCase and get results of resolver_match in response as I could get with django.urls.resolve. I imagine that it's just a matter of choosing to split tests of urls.py and views.py, as I have seen at this question. Or what else would it be? -
Create model instance out of Form and add it to other instance
In my models.py I have model called Bus. It contains multiple fields, including the field file below: class Bus(models.Model): file = models.OneToOneField('File', on_delete=models.PROTECT, editable=False) The File model consists of: class File(models.Model): file = models.FileField( upload_to=get_filepath, max_length=45, validators=[ FileExtensionValidator(allowed_extensions=['pdf', 'jpg', 'png']), file_size, ] ) original_name = models.CharField(max_length=45) extension = models.CharField(max_length=3) When you want to create a new Bus I need of course a form. That's defined in my forms.py: class BusForm(forms.ModelForm): upload = forms.FileField(max_length=45, required=False, validators=[ FileExtensionValidator(allowed_extensions=['pdf', 'jpg', 'png']), file_size, ],) My problem: In the save() method of BusForm I have to create a File instance and add it to the Bus instance (file field). For multiple hours I tried to achieve that. However, I don't get it. If someone could try to help me how the save() method has to look like, that would be great! -
Django autosetting user foriegnkey field to submitting user on form
What I'm trying to do is to auto set a field of a model to the user that is submitting the form. Models.py: class startcampaign(models.Model): title = models.CharField(max_length=30) description = models.TextField() user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) Forms.py: class StartCampaignsForm(forms.ModelForm): class Meta: model = startcampaign exclude =['user'] Views.py: def register(request): if request.method == 'POST': form = StartCampaignsForm(request.POST) if form.is_valid(): campaign_register = StartCampaignsForm.save(commit=False) campaign_register.user = self.objects.get(user=self.user) campaign_register.save(commit=True) return redirect('home') else: form = StartCampaignsForm() return render(request, 'Campaigns/register.html', {'form': form}) When I run this currently, I get save() is missing a positional argument 'self'. I' not dedicated to this method. I just need a working example that lets me autoset the user which is submitting the form to the foreign key field of 'user' in my model. -
Comparing DateField in Django, workd in 1.8.8 but throws error in 1.11.11
In the model... Event.date = models.DateField(default=datetime.date.today) In the view... import datetime future_events = Event.objects.filter(date__gte=datetime.date.today).order_by('date', 'start_time') The Error? expected string or buffer Request Method: GET Request URL: http://127.0.0.1:8000/event/ Django Version: 1.11.11 Exception Type: TypeError Exception Value: expected string or buffer Dont understand whats not working here worked okay before I upgraded Django but fails now. Any help is appreciated. -
Accessing list of dictionaries in template by index
I have a list of dictionaries in the django template. I wish to use its values in a form. [ { "movie_id": 1950, "title": "In the Heat of the Night (1967)" }, { "movie_id": 3741, "title": "Badlands (1973)" }, { "movie_id": 3959, "title": "Time Machine, The (1960)" }, { "movie_id": 4101, "title": "Dogs in Space (1987)" }, { "movie_id": 8572, "title": "Littlest Rebel, The (1935)" }, { "movie_id": 65230, "title": "Marley & Me (2008)" }, { "movie_id": 105954, "title": "All Is Lost (2013)" } ] In my template, I want to get values of each field by index. ie. for the list[0]['movieId'], I would like to get the value 1950. Is that possible? -
How to use external data in Django?
I have an existing Python module which encapsulate my Business Logic and itself is connected to a backend-database. import project-backend stations = project-backend.getStations() #returns a dict() stations['zurich'].getPipes() # etc. etc. As a Django-Newbie, how can I use this existing BL-module in a Django app? My Webapp does not need to store anything, because everything is handled by the existing BL. Do I need to import the existing BL-module within the representing model's definition an disable the managing (managed=False)? Or shall I implement a custom-manager which routes all queries to the BL-module? -
running django project in visual studio 2013 python exe opens but not running
I have installed VisualStudio2017 with python option enabled. I am trying to migrate my existing Django project (python 2.7) to python 3.6 . The solution build successfully in visual studio 2017 but when i am running the application (F5) , python exe opens but not executing & shows black screen and also Visual studio closes automatically. I have same issue in enter image description herevisual studio 2013 (python 2.7) , That's why i am trying to migrate to Visual Studio 2017. But the issue i had faced not solved. -
Django: save() got an unexpected keyword argument 'commit'
In my forms.py I have a custom ModelForm that contains a save() method: def save(self): bus = super().save(commit=False) datei = self.upload.name original_dateiname = datei.name extension = original_dateiname.split('.')[-1] a = Datei.objects.create(file=datei, original_dateiname=original_dateiname, extension=extension) self.datei = a bus.save() return bus However, now I get the error: save() got an unexpected keyword argument 'commit' What's wrong here? -
How to exclude some query from inline Django admin model?
Django 2.0.3, Python 3.6.1. I try to filter QuerySet of one field (ForeignKey) on inline model (Django Admin). # ./app/models.py class Product(models.Model): product_id = models.PositiveSmallIntegerField() class Price(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE) price = models.PositiveSmallIntegerField() # ./app/admin.py class PriceInlineAdmin(admin.TabularInline): model = Price @admin.register(Product) class ProductAdmin(admin.ModelAdmin): list_display = ('id',) inlines = [ PriceInlineAdmin ] How to exclude from PriceInlineAdmin QuerySet products with ID start with 1? -
Django paypal ngrok
It is so strange. I integrated paypal on my django project few months before. It worked, but currently it doesn't. But I haven't changed anything. I tested an old version and it is the same. I think do what I have to do: -firstly I run my server -secondly I run ngrok python3.6 mange.py runserver 8080 ./ngrok http 8080 My payment is accepted by Paypal, I have a notification too, but I don't receive any signal and any model is created. Nothing indicates an error. It's look like if I don't use ngrok, but I do ! I do everything whith ngrok url. I have : PAYPAL_RECEIVER_EMAIL="myemail-facilitator@gmail.com" PAYPAL_TEST = True valid_ipn_received.connect(myfonction) paypal_dict = { "business": "myemail-facilitator@gmail.com",# "amount": price, "item_name":"Achat XXX", "invoice": id, "currency_code": "EUR", "custom":request.user.id, "notify_url": request.build_absolute_uri(reverse('paypal-ipn')), "return_url": request.build_absolute_uri(reverse('payment:done', kwargs={'id': id})), "cancel_return": request.build_absolute_uri(reverse('payment:canceled',kwargs={'id': id})), } I use myemail-buyer@gmail.com to buy. I think that I don't do just a little thing but what ? If somebody can help me... I become crazy Thank you ! ̀ -
Django Responsive Form using class:'form-control'
I have a from and added class':'form-control' to every field of the form to make them responsive like this : companyname=forms.CharField( widget=forms.PasswordInput(attrs={'class':'form-control' ,'style': 'width:30%'}) ) but when i add form-control class , the label is showd at the upper row of the text box i dont know what to do to bring the label beside the text box when it has no class the code below is ok but its not responsive <div class="panel-body" style="text-align:right ; margin-left:auto;margin-right:auto;width:80%;"> <div style="width:85% ;margin-left:auto;margin-right:auto;"> <form enctype="multipart/form-data" method="post" > {% csrf_token %} {{ profile_form.as_p}} <input id="savepersonalinfo" type="submit" name="" value="ثبت"> </form> </div> </div> and also how can i put the textboxes arranged exactly in same column ? in the picutre iust companyname has form-control class and is responsive and other fields are not -
GIT: Moving all content of a parent/subfolder to parent/
I am new to Github. I have uploaded my Django app to Github that I will be using on Heroku. I successfully added files and folders on the web interface of Github but realized that I incorrectly uploaded folders. I cloned my github repo on my local machine. I have a sub-folder that I want to move to it's parent folder but the git mv is not working for me or I am doing something wrong I can't figure out what. parent folder: PH_Dorms sub folder: ph_dorms 1st try: cd PH_Dorms git mv ph_dorms ../ Result: fatal: '../' is outside repository 2nd try: cd PH_Dorms git mv ph_dorms ./ Result: "fatal: can not move directory into itself, source=ph_dorms, destination=ph_dorms 3rd try: cd PH_Dorms cd ph_dorms git mv ph_dorms ./ Result: fatal: can not move directory into itself, source=ph_dorms/ph_dorms, destination=ph_dorms/ph_dorms 4th try: cd PH_Dorms cd ph_dorms git mv ph_dorms ../ Result: fatal: cannot move directory over file, source=ph_dorms/ph_dorms, destination=ph_dorms 5th try: cd PH_Dorms cd ph_dorms git mv ph_dorms/* ../ Result: fatal: bad source, source=ph_dorms/ph_dorms/, destination= 6th try: cd PH_Dorms cd ph_dorms git mv * ../ Result: fatal: bad source, source=ph_dorms/, destination= 7th try: cd PH_Dorms cd ph_dorms git mv * ./ …